10 #include <fei_macros.hpp>
12 #include <fei_FiniteElementData.hpp>
14 #include <fei_CommUtils.hpp>
15 #include <snl_fei_LinearSystem_FEData.hpp>
16 #include <fei_VectorSpace.hpp>
17 #include <fei_MatrixGraph.hpp>
18 #include <fei_Matrix_Impl.hpp>
19 #include <snl_fei_Constraint.hpp>
20 #include <snl_fei_Utils.hpp>
21 #include <fei_impl_utils.hpp>
23 #include <fei_DirichletBCRecord.hpp>
24 #include <fei_DirichletBCManager.hpp>
25 #include <fei_EqnBuffer.hpp>
26 #include <fei_FEDataFilter.hpp>
29 #define fei_file "snl_fei_LinearSystem_FEData.cpp"
30 #include <fei_ErrMacros.hpp>
35 : fei::LinearSystem(matrixGraph),
36 comm_(matrixGraph->getRowSpace()->getCommunicator()),
54 fei::console_out() <<
"LinearSystem_FEData::eqnIsEssentialBC NOT IMPLEMENTED!!"<<FEI_ENDL;
60 std::vector<double>& bcVals)
const
62 fei::console_out() <<
"LinearSystem_FEData::getEssentialBC_Eqns NOT IMPLEMENTED!!"<<FEI_ENDL;
68 matrixGraph_->getConstrainedIndices(crEqns);
75 if (dbcManager_ == NULL) {
76 dbcManager_ =
new fei::DirichletBCManager(matrixGraph_->getRowSpace());
80 if (matrix_.get() != NULL && globalAssemble) {
81 err = matrix_->gatherFromOverlap();
83 fei::console_out() <<
"snl_fei::LinearSystem_FEData::loadComplete, ERROR in matrix."
84 <<
"gatherFromOverlap(), data may be incorrect."<<FEI_ENDL;
90 if (rhs_.get() != NULL && globalAssemble) {
91 err = rhs_->gatherFromOverlap();
93 fei::console_out() <<
"snl_fei::LinearSystem_FEData::loadComplete, ERROR rhs."
94 <<
"gatherFromOverlap(), data may be incorrect."<<FEI_ENDL;
100 CHK_ERR( implementBCs(applyBCs) );
102 return(feData_->loadComplete());
112 int snl_fei::LinearSystem_FEData::implementBCs(
bool applyBCs)
114 std::vector<int> essEqns;
115 std::vector<double> essGamma;
120 bool zeroSharedRows =
false;
123 CHK_ERR( dbcManager_->finalizeBCEqns(bcEqns) );
125 std::map<int,fei::FillableMat*>& remotes = bcEqns.getRemotelyOwnedMatrices();
126 std::map<int,fei::FillableMat*>::iterator
127 it = remotes.begin(),
128 it_end = remotes.end();
129 for(; it!=it_end; ++it) {
130 fei::impl_utils::separate_BC_eqns( *(it->second), essEqns, essGamma);
133 CHK_ERR( bcEqns.gatherFromOverlap() );
135 fei::impl_utils::separate_BC_eqns( *(bcEqns.getMatrix()), essEqns, essGamma);
137 int len = essEqns.size();
138 essEqns.resize(len*3);
139 int* nodeNumbers = &essEqns[0]+len;
140 int* dof_ids = nodeNumbers+len;
143 int* essEqnsPtr = &essEqns[0];
144 double* gammaPtr = &essGamma[0];
146 for(
int i=0; i<len; ++i) {
147 int eqn = essEqnsPtr[i];
148 nodeNumbers[i] = lookup_->getAssociatedNodeNumber(eqn);
149 int fieldID = lookup_->getAssociatedFieldID(eqn);
150 int base_eqn = lookup_->getEqnNumber(nodeNumbers[i], fieldID);
151 dof_ids[i]=vecSpace->getFieldDofMap().get_dof_id(fieldID, eqn-base_eqn);
155 CHK_ERR( feData_->setDirichletBCs(len, nodeNumbers, dof_ids, gammaPtr) );
165 const double *weights,
174 const double *weights,
LinearSystem_FEData(fei::SharedPtr< FiniteElementData > &fedata, fei::SharedPtr< fei::MatrixGraph > &matrixGraph)
int setBCValuesOnVector(fei::Vector *vector)
virtual ~LinearSystem_FEData()
void getConstrainedEqns(std::vector< int > &crEqns) const
bool eqnIsEssentialBC(int globalEqnIndex) const
int loadPenaltyConstraint(int constraintID, const double *weights, double penaltyValue, double rhsValue)
int loadLagrangeConstraint(int constraintID, const double *weights, double rhsValue)
std::ostream & console_out()
int localProc(MPI_Comm comm)
void getEssentialBCs(std::vector< int > &bcEqns, std::vector< double > &bcVals) const
int loadComplete(bool applyBCs=true, bool globalAssemble=true)
int numProcs(MPI_Comm comm)
int getNumIndices_Owned() const