39 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 40 #include <lifev/core/algorithm/PreconditionerML.hpp> 42 #include <lifev/core/util/LifeChrono.hpp> 43 #include <lifev/core/array/MatrixEpetraStructured.hpp> 44 #include <lifev/core/array/MatrixEpetraStructuredView.hpp> 45 #include <lifev/core/array/MatrixEpetraStructuredUtility.hpp> 70 const std::string& section,
71 const std::string& subsection )
73 const bool verbose ( M_comm->MyPID() == 0 );
75 bool displayList = dataFile ( ( section +
"/displayList" ).data(),
false);
77 std::string precType = dataFile ( ( section +
"/prectype" ).data(),
"Yosida" );
78 list.set (
"prectype", precType );
80 std::string fluidPrec = dataFile ( ( section +
"/" + subsection +
"/subprecs/fluid_prec" ).data(),
"ML" );
81 list.set (
"subprecs: fluid prec", fluidPrec );
82 std::string fluidPrecDataSection = dataFile ( ( section +
"/" + subsection +
"/subprecs/fluid_prec_data_section" ).data(),
"" );
83 list.set (
"subprecs: fluid prec data section", ( fluidPrecDataSection ).data() );
85 std::string schurPrec = dataFile ( ( section +
"/" + subsection +
"/subprecs/schur_prec" ).data(),
"ML" );
86 list.set (
"subprecs: Schur prec", schurPrec );
87 std::string schurPrecDataSection = dataFile ( ( section +
"/" + subsection +
"/subprecs/schur_prec_data_section" ).data(),
"" );
88 list.set (
"subprecs: Schur prec data section", ( schurPrecDataSection ).data() );
90 if ( displayList && verbose )
92 std::cout <<
"Yosida parameters list:" << std::endl;
93 std::cout <<
"-----------------------------" << std::endl;
94 list.print ( std::cout );
95 std::cout <<
"-----------------------------" << std::endl;
110 std::cout <<
"You must specified manually the pointers to the FESpaces" << std::endl;
114 const bool verbose ( M_comm->MyPID() == 0 );
117 this->resetPreconditioner();
119 std::vector<UInt> blockNumRows ( 2, 0 );
120 blockNumRows[0] = M_velocityBlockSize;
121 blockNumRows[1] = M_pressureBlockSize;
122 std::vector<UInt> blockNumColumns ( blockNumRows );
124 const bool inversed (
true );
125 const bool notInversed (
false );
126 const bool notTransposed (
false );
139 std::cout <<
" >Getting the structure of A... ";
144 F.setup ( 0, 0, blockNumRows[0], blockNumColumns[0], oper.get() );
147 Bt.setup ( 0, blockNumColumns[0], blockNumRows[0], blockNumColumns[1], oper.get() );
150 B.setup ( blockNumRows[0], 0, blockNumRows[1], blockNumColumns[0], oper.get() );
153 C.setup ( blockNumRows[0], blockNumColumns[0], blockNumRows[1], blockNumColumns[1], oper.get() );
157 std::cout <<
" done in " << timer.diff() <<
" s." << std::endl;
180 std::cout <<
" Block 1 ( F )" << std::endl;
183 std::shared_ptr<matrixBlock_Type> P1a (
new matrixBlock_Type ( map ) );
184 P1a->setBlockStructure ( blockNumRows, blockNumColumns );
185 P1a->blockView ( 0, 0, B11 );
186 P1a->blockView ( 1, 1, B22 );
187 MatrixEpetraStructuredUtility::copyBlock ( F, B11 );
188 MatrixEpetraStructuredUtility::createIdentityBlock ( B22 );
189 P1a->globalAssemble();
190 std::shared_ptr<matrix_Type> p1a = P1a;
191 superPtr_Type precForBlock1 ( PRECFactory::instance().createObject ( M_fluidPrec ) );
192 precForBlock1->setDataFromGetPot ( M_dataFile, M_fluidDataSection );
198 this->pushBack ( p1a, precForBlock1, notInversed, notTransposed );
201 std::cout <<
" done in " << timer.diff() <<
" s." << std::endl;
210 std::cout <<
" Block 1 ( B )" << std::endl;
213 std::shared_ptr<matrixBlock_Type> P1b (
new matrixBlock_Type ( map ) );
214 P1b->setBlockStructure ( blockNumRows, blockNumColumns );
215 P1b->blockView ( 0, 0, B11 );
216 P1b->blockView ( 1, 0, B21 );
217 P1b->blockView ( 1, 1, B22 );
218 MatrixEpetraStructuredUtility::copyBlock ( B, B21 );
220 MatrixEpetraStructuredUtility::createIdentityBlock ( B11 );
221 MatrixEpetraStructuredUtility::createIdentityBlock ( B22 );
222 P1b->globalAssemble();
223 std::shared_ptr<matrix_Type> p1b = P1b;
224 this->pushBack ( p1b, inversed, notTransposed );
227 std::cout <<
" done in " << timer.diff() <<
" s." << std::endl;
236 std::cout <<
" Block 1 ( Schur )" << std::endl;
240 std::shared_ptr<matrixBlock_Type> massMat (
new matrixBlock_Type ( map ) );
241 massMat->setBlockStructure ( blockNumRows, blockNumColumns );
242 massMat->blockView ( 0, 0, M );
243 M_adrVelocityAssembler.addMass ( massMat, 1.0 / M_timestep, M.firstRowIndex(), M.firstColumnIndex() );
244 massMat->globalAssemble();
246 std::shared_ptr<matrixBlock_Type> P1c (
new matrixBlock_Type ( map ) );
248 std::shared_ptr<matrixBlock_Type> BBlockMat (
new matrixBlock_Type ( map ) );
249 BBlockMat->setBlockStructure ( blockNumRows, blockNumColumns );
250 BBlockMat->blockView ( 1, 0, B21 );
251 MatrixEpetraStructuredUtility::copyBlock ( B, B21 );
252 BBlockMat->globalAssemble();
253 std::shared_ptr<matrixBlock_Type> invLumpedMassBlockMat (
new matrixBlock_Type ( map ) );
254 invLumpedMassBlockMat->setBlockStructure ( blockNumRows, blockNumColumns );
255 invLumpedMassBlockMat->blockView ( 0, 0, B11 );
256 MatrixEpetraStructuredUtility::createInvDiagBlock ( M, B11 );
258 *invLumpedMassBlockMat *= -1.0;
259 invLumpedMassBlockMat->globalAssemble();
260 std::shared_ptr<matrixBlock_Type> tmpResultMat (
new matrixBlock_Type ( map ) );
261 BBlockMat->multiply (
false,
262 *invLumpedMassBlockMat,
false,
263 *tmpResultMat,
true );
265 invLumpedMassBlockMat.reset();
266 std::shared_ptr<matrixBlock_Type> BtBlockMat (
new matrixBlock_Type ( map ) );
267 BtBlockMat->setBlockStructure ( blockNumRows, blockNumColumns );
268 BtBlockMat->blockView ( 0, 1, B12 );
269 MatrixEpetraStructuredUtility::copyBlock ( Bt, B12 );
270 BtBlockMat->globalAssemble();
271 tmpResultMat->multiply (
false,
275 tmpResultMat.reset();
277 P1c->setBlockStructure ( blockNumRows, blockNumColumns );
278 P1c->blockView ( 0, 0, B11 );
279 MatrixEpetraStructuredUtility::createIdentityBlock ( B11 );
280 P1c->globalAssemble();
281 std::shared_ptr<matrix_Type> p1c = P1c;
282 superPtr_Type precForBlock2 ( PRECFactory::instance().createObject ( M_schurPrec ) );
283 precForBlock2->setDataFromGetPot ( M_dataFile, M_schurDataSection );
284 this->pushBack ( p1c, precForBlock2, notInversed, notTransposed );
287 std::cout <<
" done in " << timer.diff() <<
" s." << std::endl;
297 std::cout <<
" Block 2 ( F^-1, I )" << std::endl;
300 std::shared_ptr<matrixBlock_Type> P2a (
new matrixBlock_Type ( map ) );
302 P2a->setBlockStructure ( blockNumRows, blockNumColumns );
303 P2a->blockView ( 0, 0, B11 );
304 P2a->blockView ( 1, 1, B22 );
305 MatrixEpetraStructuredUtility::copyBlock ( F, B11 );
306 MatrixEpetraStructuredUtility::createIdentityBlock ( B22 );
307 P2a->globalAssemble();
308 std::shared_ptr<matrix_Type> p2a = P2a;
309 this->pushBack ( p2a, inversed, notTransposed );
312 std::cout <<
" done in " << timer.diff() <<
" s." << std::endl;
321 std::cout <<
" Block 2 ( Bt )" << std::endl;
324 std::shared_ptr<matrixBlock_Type> P2b (
new matrixBlock_Type ( map ) );
325 P2b->setBlockStructure ( blockNumRows, blockNumColumns );
326 P2b->blockView ( 0, 0, B11 );
327 P2b->blockView ( 0, 1, B12 );
328 P2b->blockView ( 1, 1, B22 );
329 MatrixEpetraStructuredUtility::copyBlock ( Bt, B12 );
331 MatrixEpetraStructuredUtility::createIdentityBlock ( B11 );
332 MatrixEpetraStructuredUtility::createIdentityBlock ( B22 );
333 P2b->globalAssemble();
334 std::shared_ptr<matrix_Type> p2b = P2b;
335 this->pushBack ( p2b, inversed, notTransposed );
338 std::cout <<
" done in " << timer.diff() <<
" s." << std::endl;
347 std::cout <<
" Block2 ( F )" << std::endl;
351 this->pushBack ( p1a, precForBlock1, notInversed, notTransposed );
354 std::cout <<
" done in " << timer.diff() <<
" s." << std::endl;
359 if ( verbose ) std::cout <<
" >All the blocks are built" << std::endl
361 return ( EXIT_SUCCESS );
378 const std::string& section )
380 M_dataFile = dataFile;
381 this->createParametersList ( M_list, dataFile, section,
"Yosida" );
382 this->setParameters ( M_list );
388 M_precType = list.get (
"prectype",
"Yosida" );
390 M_fluidPrec = list.get (
"subprecs: fluid prec",
"ML" );
391 M_fluidDataSection = list.get (
"subprecs: fluid prec data section",
"" );
393 M_schurPrec = list.get (
"subprecs: Schur prec",
"ML" );
394 M_schurDataSection = list.get (
"subprecs: Schur prec data section",
"" );
401 M_velocityBlockSize = uFESpace->fieldDim() * uFESpace->dof().numTotalDof();
402 M_pressureBlockSize = pFESpace->dof().numTotalDof();
406 M_adrVelocityAssembler.setup ( uFESpace, uFESpace );
void start()
Start the timer.
int numBlocksRows() const
bool M_preconditionerCreated
std::shared_ptr< matrix_Type > matrixPtr_Type
FESpacePtr_Type M_uFESpace
virtual ~PreconditionerYosida()
constructor from matrix A.
std::shared_ptr< FESpace< mesh_Type, map_Type > > FESpacePtr_Type
void createParametersList(list_Type &list, const GetPot &dataFile, const std::string §ion, const std::string &subsection="Yosida")
Create the list of parameters of the preconditioner.
void updateInverseJacobian(const UInt &iQuadPt)
void setTimestep(const Real ×tep)
Setter for the timestep.
void setFESpace(FESpacePtr_Type uFESpace, FESpacePtr_Type pFESpace)
Setter for the FESpace.
double condest()
Return an estimation of the conditionement number of the preconditioner.
void setDataFromGetPot(const GetPot &dataFile, const std::string §ion)
Setter using GetPot.
int numBlocksColumns() const
double Real
Generic real data.
Teuchos::ParameterList list_Type
virtual void setParameters(Teuchos::ParameterList &list)
Method to setup the solver using Teuchos::ParameterList.
MatrixEpetraStructuredView< Real > matrixBlockView_Type
PreconditionerYosida(const std::shared_ptr< PreconditionerYosida > &)
FESpacePtr_Type M_pFESpace
std::shared_ptr< super_Type > superPtr_Type
int buildPreconditioner(matrixPtr_Type &A)
Build the preconditioner.