28 #include <lifev/core/LifeV.hpp> 30 #include <lifev/core/fem/BCManage.hpp> 32 #include <lifev/fsi/solver/MonolithicBlockComposedNN.hpp> 41 int MonolithicBlockComposedNN::solveSystem (
const vector_Type& rhs, vector_Type& step, solverPtr_Type& linearSolver )
43 M_firstCompPrec .reset (
new composed_prec (M_comm) );
44 M_secondCompPrec.reset (
new composed_prec (M_comm) );
48 if ( !M_blockPrecs.get() )
50 M_blockPrecs.reset (
new ComposedOperator< composed_prec > (M_comm) );
54 M_overlapLevel = M_list.get (
"overlap level", 2);
55 M_precType = M_list.get (
"prectype",
"Amesos");
58 M_matrixVector.push_back (*M_blocks[ (*M_blockReordering) [0]]);
59 M_matrixVector.push_back (*M_blocks[ (*M_blockReordering) [1]]);
60 M_matrixVector.push_back (*M_blocks[ (*M_blockReordering) [2]]);
61 M_matrixVector.push_back (*M_blocks[ (*M_blockReordering) [3]]);
64 for (ID k (0); k < M_blocks.size(); ++k)
66 M_blockPrecs->displayer().leaderPrint (
" M- Computing double prec. factorization ... ");
69 if (!M_recompute[ (*M_blockReordering) [k]])
71 M_prec[k].reset (M_factory.Create (M_precType, M_matrixVector[k].matrixPtr().get(), M_overlapLevel) );
77 M_prec[k].reset (M_factory.Create (M_precType, M_blocks[ (*M_blockReordering) [k]]->matrixPtr().get(), M_overlapLevel) );
79 if ( !M_prec[k].get() )
81 ERROR_MSG (
"Preconditioner not set, something went wrong in its computation\n" );
83 M_prec[k]->SetParameters (M_list);
84 M_prec[k]->Initialize();
87 M_blockPrecs->displayer().leaderPrintMax (
"done in ", chrono.diff() );
92 for (ID k (0); k < M_blocks.size(); ++k)
94 if (M_recompute[ (*M_blockReordering) [k]])
96 M_blockPrecs->displayer().leaderPrint (
" M- Computing double prec. factorization ... ");
98 M_prec[k].reset (M_factory.Create (M_precType, M_blocks[ (*M_blockReordering) [k]]->matrixPtr().get(), M_overlapLevel) );
99 if ( !M_prec[k].get() )
101 ERROR_MSG (
"Preconditioner not set, something went wrong in its computation\n" );
103 M_prec[k]->SetParameters (M_list);
104 M_prec[k]->Initialize();
105 M_prec[k]->Compute();
107 M_blockPrecs->displayer().leaderPrintMax (
"done in ", chrono.diff() );
111 M_blockPrecs->displayer().leaderPrint (
" M- Reusing double prec. factorization ... \n");
115 M_firstCompPrec->push_back (M_prec[0],
false,
false);
116 M_firstCompPrec->push_back (M_prec[1],
false,
false);
118 M_secondCompPrec->push_back (M_prec[2],
false,
false);
119 M_secondCompPrec->push_back (M_prec[3],
false,
false);
122 if (! (M_blockPrecs->number() ) )
124 M_blockPrecs->push_back (M_firstCompPrec,
false,
false,
false);
125 M_blockPrecs->push_back (M_secondCompPrec,
false,
false,
true );
129 M_blockPrecs->replace (M_firstCompPrec, (UInt) 0,
false,
false);
130 M_blockPrecs->replace (M_secondCompPrec, (UInt) 1,
false,
false);
133 return linearSolver->solveSystem (rhs, step, std::static_pointer_cast<Epetra_Operator> (M_blockPrecs) );
138 void MonolithicBlockComposedNN::setDataFromGetPot (
const GetPot& data,
const std::string& section)
140 PreconditionerIfpack::createIfpackList ( M_list, data, section,
"ifpack");
143 void MonolithicBlockComposedNN::coupler (mapPtr_Type& map,
144 const std::map<ID, ID>& locDofMap,
145 const vectorPtr_Type& numerationInterface,
146 const Real& timeStep,
147 const Real& coefficient,
148 const Real& rescaleFactor)
150 UInt totalDofs = map->map (Unique)->NumGlobalElements();
151 UInt fluidSolid = M_offset[0] + M_FESpace[0]->map().map (Unique)->NumGlobalElements();
153 for (
ID k = 0; k < 2; ++k)
155 M_blocks[k]->globalAssemble();
156 matrixPtr_Type block (
new matrix_Type (*M_blocks[k]) );
157 M_blocks.push_back (block);
158 M_bch.push_back (M_bch[k]);
159 M_FESpace.push_back (M_FESpace[k]);
160 M_offset.push_back (M_offset[k]);
161 M_recompute[2 + k] = (M_recompute[k]);
164 matrixPtr_Type coupling (
new matrix_Type (*map) );
166 coupling.reset (
new matrix_Type (*map, 0) );
167 coupling->insertValueDiagonal (1., M_offset[fluid], M_offset[solid] );
168 coupling->insertValueDiagonal (1., fluidSolid, totalDofs);
169 couplingMatrix (coupling, (*M_couplingFlags) [0], M_FESpace, M_offset, locDofMap, numerationInterface, timeStep, 2., coefficient, rescaleFactor);
170 M_coupling.push_back (coupling);
172 coupling.reset (
new matrix_Type (*map, 0) );
173 coupling->insertValueDiagonal ( 1., M_offset[0], fluidSolid );
174 coupling->insertValueDiagonal ( 1., fluidSolid , totalDofs);
175 couplingMatrix (coupling, (*M_couplingFlags) [1], M_FESpace, M_offset, locDofMap, numerationInterface, timeStep, 2., coefficient, rescaleFactor);
176 M_coupling.push_back (coupling);
178 coupling.reset (
new matrix_Type (*map, 0) );
179 coupling->insertValueDiagonal (1., M_offset[fluid], M_offset[solid] );
180 coupling->insertValueDiagonal (-1, fluidSolid, totalDofs);
181 couplingMatrix (coupling, (*M_couplingFlags) [2], M_FESpace, M_offset, locDofMap, numerationInterface, timeStep, 2., coefficient, rescaleFactor);
182 M_coupling.push_back (coupling);
184 coupling.reset (
new matrix_Type (*map, 0) );
185 coupling->insertValueDiagonal ( 1., M_offset[0], fluidSolid );
186 coupling->insertValueDiagonal ( 1., fluidSolid, totalDofs );
187 couplingMatrix (coupling, (*M_couplingFlags) [3], M_FESpace, M_offset, locDofMap, numerationInterface, timeStep, 2., coefficient, rescaleFactor);
188 M_coupling.push_back (coupling);
190 M_prec.resize (M_blocks.size() );
193 void MonolithicBlockComposedNN::applyBoundaryConditions (
const Real& time,
const UInt i)
195 M_blocks[i]->openCrsMatrix();
196 if ( !M_bch[i]->bcUpdateDone() )
198 M_bch[i]->bcUpdate ( *M_FESpace[i]->mesh(), M_FESpace[i]->feBd(), M_FESpace[i]->dof() );
199 M_bch[i]->setOffset (M_offset[i]);
201 bcManageMatrix ( *M_blocks[i] , *M_FESpace[i]->mesh(), M_FESpace[i]->dof(), *M_bch[i], M_FESpace[i]->feBd(), 2., time);
205 void MonolithicBlockComposedNN::push_back_matrix (
const matrixPtr_Type& Mat,
const bool recompute)
207 Mat->globalAssemble();
209 super_Type::push_back_matrix (Mat, recompute);
214 void MonolithicBlockComposedNN::replace_matrix (
const matrixPtr_Type& oper,
UInt position )
216 oper->globalAssemble();
218 M_blocks[position] = oper;
219 M_blocks[ (position + 2) % 4] = oper;
void updateInverseJacobian(const UInt &iQuadPt)
double Real
Generic real data.
uint32_type UInt
generic unsigned integer (used mainly for addressing)