28 #include <lifev/core/LifeV.hpp> 30 #include <lifev/fsi/solver/MonolithicBlock.hpp> 40 void MonolithicBlock::couplingMatrix (matrixPtr_Type& bigMatrix,
42 const std::vector<fespacePtr_Type>& problem,
43 const std::vector<UInt>& offset,
44 const std::map<ID, ID>& locDofMap,
45 const vectorPtr_Type& numerationInterface,
48 const Real& coefficient,
49 const Real& rescaleFactor)
56 std::vector<fespacePtr_Type> newProblem (problem.begin() + 3, problem.end() );
57 std::vector<UInt> newOffset (offset.begin() + 3, offset.end() );
59 couplingMatrix ( bigMatrix, subFlag, newProblem, newOffset, locDofMap, numerationInterface, rescaleFactor, value, coefficient, rescaleFactor);
61 std::map<ID, ID>::const_iterator ITrow;
62 UInt interface (numerationInterface->map().map (Unique)->NumGlobalElements() );
63 UInt totalSize (offset[0] + problem[0]->map().map (Unique)->NumGlobalElements() );
68 UInt solidFluidInterface ( offset[2] );
69 std::map<ID, ID>::const_iterator ITrow;
72 for ( ITrow = locDofMap.begin(); ITrow != locDofMap.end() ; ++ITrow )
74 if ( numerationInterface->map().map (Unique)->LID (
static_cast<EpetraInt_Type> (ITrow->second ) ) >= 0 )
76 bigMatrix->addToCoefficient (solidFluidInterface + ITrow->first + dim * problem[2]->dof().numTotalDof(), offset[0] + ITrow->second + dim * problem[0]->dof().numTotalDof(), (-value) *rescaleFactor);
87 for ( ITrow = locDofMap.begin(); ITrow != locDofMap.end() ; ++ITrow, newFlag = flag )
89 if (numerationInterface->map().map (Unique)->LID (
static_cast<EpetraInt_Type> (ITrow->second ) ) >= 0 )
93 bigMatrix->addToCoefficient ( offset[0] + ITrow->second + dim * problem[0]->dof().numTotalDof(), (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize, value );
98 bigMatrix->addToCoefficient ( offset[1] + ITrow->first + dim * problem[1]->dof().numTotalDof(), (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize, -value );
101 if (newFlag - 2 >= 0)
103 bigMatrix->addToCoefficient ( (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize, (ITrow->first) + dim * problem[1]->dof().numTotalDof(), value);
106 if (newFlag - 1 >= 0)
108 bigMatrix->addToCoefficient ( (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize, (offset[0] + ITrow->second) + dim * problem[0]->dof().numTotalDof(), -value / timeStep * rescaleFactor * coefficient);
111 bigMatrix->addToCoefficient ( (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize , (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize, 0.0);
117 void MonolithicBlock::applyBoundaryConditions (
const Real& time)
119 ASSERT ( M_bch.size() == M_blocks.size(),
"The number of BChandlers must correspond to the number of blocks" )
120 for (ID i = 0; i < M_bch.size(); ++i)
122 applyBoundaryConditions (time, i);
127 void MonolithicBlock::applyBoundaryConditions (
const Real& time,
const UInt i)
129 M_blocks[i]->openCrsMatrix();
130 if ( !M_bch[i]->bcUpdateDone() )
132 M_bch[i]->bcUpdate ( *M_FESpace[i]->mesh(), M_FESpace[i]->feBd(), M_FESpace[i]->dof() );
133 M_bch[i]->setOffset (M_offset[i]);
136 bcManageMatrix ( *M_blocks[i] , *M_FESpace[i]->mesh(), M_FESpace[i]->dof(), *M_bch[i], M_FESpace[i]->feBd(), 1., time);
139 void MonolithicBlock::setConditions ( std::vector<bchandlerPtr_Type>& vec )
145 MonolithicBlock::setSpaces (std::vector<fespacePtr_Type>& vec )
151 MonolithicBlock::setOffsets (
UInt blocks, ...)
155 va_start (arguments, blocks);
158 for (ID i = 0; i < M_blocks.size(); ++i)
160 M_offset.push_back (va_arg (arguments, UInt) );
167 MonolithicBlock::robinCoupling ( matrixPtr_Type& matrix,
171 const MonolithicBlock::fespacePtr_Type& FESpace1,
173 const MonolithicBlock::fespacePtr_Type& FESpace2,
175 const std::map<ID, ID>& locDofMap,
176 const MonolithicBlock::vectorPtr_Type& numerationInterface )
179 UInt interface (numerationInterface->map().map (Unique)->NumGlobalElements() );
180 std::map<ID, ID>::const_iterator ITrow;
181 UInt totalSize (offset2 + FESpace2->map().map (Unique)->NumGlobalElements() );
184 if ( ( (
Int) coupling) - 4 >= 0)
186 for ( ITrow = locDofMap.begin(); ITrow != locDofMap.end() ; ++ITrow)
188 if (numerationInterface->map().map (Unique)->LID (
static_cast<EpetraInt_Type> (ITrow->second ) ) >= 0 )
190 for (UInt dim = 0; dim < nDimensions; ++dim)
192 matrix->addToCoefficient ( (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize, (offset2 + ITrow->second) + dim * FESpace2->dof().numTotalDof(), alphas);
198 if ( ( (
Int) coupling - 2) >= 0)
200 for ( ITrow = locDofMap.begin(); ITrow != locDofMap.end() ; ++ITrow)
202 if (numerationInterface->map().map (Unique)->LID (
static_cast<EpetraInt_Type> (ITrow->second ) ) >= 0 )
204 for (UInt dim = 0; dim < nDimensions; ++dim)
206 matrix->addToCoefficient ( ITrow->first + dim * FESpace1->dof().numTotalDof(), (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize, alphaf );
212 if ( ( (
Int) coupling) - 1 >= 0)
214 for ( ITrow = locDofMap.begin(); ITrow != locDofMap.end() ; ++ITrow)
216 if (numerationInterface->map().map (Unique)->LID (
static_cast<EpetraInt_Type> (ITrow->second ) ) >= 0 )
218 for (UInt dim = 0; dim < nDimensions; ++dim)
220 matrix->addToCoefficient ( (
int) (*numerationInterface) [ITrow->second ] + dim * interface + totalSize, (ITrow->first) + dim * FESpace1->dof().numTotalDof(), alphas);
227 void MonolithicBlock::addToBlock (
const matrixPtr_Type& Mat,
UInt position)
229 *Mat += *M_blocks[position];
230 M_blocks[position] = Mat;
233 void MonolithicBlock::push_back_oper ( MonolithicBlock& Oper)
240 M_blocks.insert (M_blocks.end(), Oper.blockVector().begin(), Oper.blockVector().end() );
241 M_bch.insert (M_bch.end(), Oper.BChVector().begin(), Oper.BChVector().end() );
242 M_FESpace.insert (M_FESpace.end(), Oper.FESpaceVector().begin(), Oper.FESpaceVector().end() );
243 M_offset.insert (M_offset.end(), Oper.offsetVector().begin(), Oper.offsetVector().end() );
int32_type Int
Generic integer data.
void updateInverseJacobian(const UInt &iQuadPt)
double Real
Generic real data.
const UInt nDimensions(NDIM)
uint32_type UInt
generic unsigned integer (used mainly for addressing)