78 #include <boost/timer.hpp> 80 #include <Epetra_ConfigDefs.h> 83 #include <Epetra_MpiComm.h> 85 #include <Epetra_SerialComm.h> 90 #include <lifev/core/LifeV.hpp> 92 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 93 #include <lifev/core/algorithm/PreconditionerML.hpp> 95 #include <lifev/fsi/solver/FSISolver.hpp> 96 #include <lifev/structure/solver/StructuralOperator.hpp> 97 #include <lifev/fsi/solver/FSIMonolithicGI.hpp> 99 #include <lifev/core/filter/ExporterEnsight.hpp> 100 #include <lifev/core/filter/ExporterEmpty.hpp> 102 #include <lifev/core/filter/ExporterHDF5.hpp> 115 typedef LifeV::FSIOperator::data_Type data_Type;
116 typedef LifeV::FSIOperator::dataPtr_Type dataPtr_Type;
118 typedef LifeV::FSIOperator::vector_Type vector_Type;
119 typedef LifeV::FSIOperator::vectorPtr_Type vectorPtr_Type;
144 using namespace LifeV;
146 FSIOperator::solid_Type::material_Type::isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().registerProduct (
"linearVenantKirchhoff", &FSIOperator::createVenantKirchhoffLinear );
147 FSIOperator::solid_Type::material_Type::isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().registerProduct (
"exponential", &FSIOperator::createExponentialMaterialNonLinear );
148 FSIOperator::solid_Type::material_Type::isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().registerProduct (
"neoHookean", &FSIOperator::createNeoHookeanMaterialNonLinear );
149 FSIOperator::solid_Type::material_Type::isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().registerProduct (
"nonLinearVenantKirchhoff", &FSIOperator::createVenantKirchhoffNonLinear );
151 std::cout <<
"register MonolithicGE : " << FSIMonolithicGE::S_register << std::endl;
152 std::cout <<
"register MonolithicGI : " << FSIMonolithicGI::S_register << std::endl;
154 M_data = dataPtr_Type (
new data_Type() );
155 M_data->setup ( data_file );
159 M_fsi = fsi_solver_ptr (
new FSISolver( ) );
160 MPI_Barrier ( MPI_COMM_WORLD );
162 M_fsi->setData ( M_data );
163 M_fsi->FSIOper()->setDataFile ( data_file );
167 std::string fluidMeshPartitioned = data_file (
"problem/fluidMeshPartitioned",
"none" );
168 std::string solidMeshPartitioned = data_file (
"problem/solidMeshPartitioned",
"none" );
170 if ( fluidMeshPartitioned.compare (
"none" ) )
172 FSIOperator::meshFilter_Type fluidMeshFilter ( data_file, fluidMeshPartitioned );
173 fluidMeshFilter.setComm ( M_fsi->FSIOper()->worldComm() );
174 FSIOperator::meshFilter_Type solidMeshFilter ( data_file, solidMeshPartitioned );
175 solidMeshFilter.setComm ( M_fsi->FSIOper( )->worldComm( ) );
176 M_fsi->FSIOper( )->partitionMeshes ( fluidMeshFilter, solidMeshFilter );
177 M_fsi->FSIOper( )->setupFEspace( );
178 M_fsi->FSIOper( )->setupDOF ( fluidMeshFilter );
179 fluidMeshFilter.closeFile( );
180 solidMeshFilter.closeFile( );
185 M_fsi->FSIOper( )->partitionMeshes( );
186 M_fsi->FSIOper( )->setupFEspace( );
187 M_fsi->FSIOper( )->setupDOF( );
191 debugStream ( 10000 ) <<
"Setting up the FESpace and DOF \n";
193 MPI_Barrier ( MPI_COMM_WORLD );
196 debugStream ( 10000 ) <<
"Setting up the BC \n";
198 M_fsi->setFluidBC ( BCh_monolithicFlux (
true ) );
199 M_fsi->setSolidBC ( BCh_monolithicSolid ( *M_fsi->FSIOper( ) ) );
203 M_fsi->setFluidBC ( BCh_monolithicFluid ( *M_fsi->FSIOper( ),
true ) );
204 M_fsi->setHarmonicExtensionBC ( BCh_harmonicExtension ( *M_fsi->FSIOper( ) ) );
206 dynamic_cast<LifeV::FSIMonolithic*> (M_fsi->FSIOper().get() )->mergeBCHandlers();
209 debugStream ( 10000 ) <<
"BC set\n";
212 std::string
const exporterType = data_file (
"exporter/type",
"ensight" );
213 std::string
const fluidName = data_file (
"exporter/fluid/filename",
"fluid" );
214 std::string
const solidName = data_file (
"exporter/solid/filename",
"solid" );
217 if (exporterType.compare (
"hdf5") == 0)
219 M_exporterFluid.reset (
new hdf5Filter_Type ( data_file, fluidName) );
220 M_exporterSolid.reset (
new hdf5Filter_Type ( data_file, solidName) );
225 if (exporterType.compare (
"none") == 0)
227 M_exporterFluid.reset (
new ExporterEmpty<RegionMesh<LinearTetra> > ( data_file, M_fsi->FSIOper()->uFESpace().mesh(), fluidName, M_fsi->FSIOper()->uFESpace().map().comm().MyPID() ) );
228 M_exporterSolid.reset (
new ExporterEmpty<RegionMesh<LinearTetra> > ( data_file, M_fsi->FSIOper()->dFESpace().mesh(), solidName, M_fsi->FSIOper()->uFESpace().map().comm().MyPID() ) );
232 M_exporterFluid.reset (
new ensightFilter_Type ( data_file, fluidName) );
233 M_exporterSolid.reset (
new ensightFilter_Type ( data_file, solidName) );
239 M_saveEvery = data_file (
"exporter/saveEvery", 1);
242 std::string restartType (data_file (
"importer/restartFSI",
"false" ) );
243 std::cout <<
"The load state is: " << restartType << std::endl;
245 if ( !restartType.compare (
"true") )
253 M_velAndPressure.reset (
new vector_Type ( M_fsi->FSIOper()->fluid().getMap(), M_exporterFluid->mapType() ) );
255 M_fluidDisp.reset (
new vector_Type ( M_fsi->FSIOper()->mmFESpace().map(), M_exporterFluid->mapType() ) );
257 M_solidDisp.reset (
new vector_Type ( M_fsi->FSIOper()->dFESpace().map(), M_exporterSolid->mapType() ) );
261 M_exporterFluid->setMeshProcId (M_fsi->FSIOper()->uFESpace().mesh(), M_fsi->FSIOper()->uFESpace().map().comm().MyPID() );
262 M_exporterSolid->setMeshProcId (M_fsi->FSIOper()->dFESpace().mesh(), M_fsi->FSIOper()->dFESpace().map().comm().MyPID() );
263 M_exporterFluid->addVariable ( ExporterData<FSIOperator::mesh_Type>::VectorField,
"f-velocity",
264 M_fsi->FSIOper()->uFESpacePtr(), M_velAndPressure, UInt (0) );
265 M_exporterFluid->addVariable ( ExporterData<FSIOperator::mesh_Type>::ScalarField,
"f-pressure",
266 M_fsi->FSIOper()->pFESpacePtr(), M_velAndPressure,
267 UInt (3 * M_fsi->FSIOper()->uFESpace().dof().numTotalDof() ) );
269 M_exporterFluid->addVariable ( ExporterData<FSIOperator::mesh_Type>::VectorField,
"f-displacement",
270 M_fsi->FSIOper()->mmFESpacePtr(), M_fluidDisp, UInt (0) );
275 M_exporterSolid->addVariable ( ExporterData<FSIOperator::mesh_Type>::VectorField,
"s-displacement",
276 M_fsi->FSIOper()->dFESpacePtr(), M_solidDisp, UInt (0) );
280 FC0.initParameters ( *M_fsi->FSIOper(), 3);
282 M_data->dataFluid()->dataTime()->setInitialTime ( M_data->dataFluid()->dataTime()->initialTime() );
283 M_data->dataFluid()->dataTime()->setTime ( M_data->dataFluid()->dataTime()->initialTime() );
284 M_data->dataSolid()->dataTime()->setInitialTime ( M_data->dataFluid()->dataTime()->initialTime() );
285 M_data->dataSolid()->dataTime()->setTime ( M_data->dataFluid()->dataTime()->initialTime() );
286 M_data->timeDataALE()->setInitialTime ( M_data->dataFluid()->dataTime()->initialTime() );
287 M_data->timeDataALE()->setTime ( M_data->dataFluid()->dataTime()->initialTime() );
296 boost::timer _overall_timer;
298 LifeV::UInt iter = 1;
300 dynamic_cast<LifeV::FSIMonolithic*> (M_fsi->FSIOper().get() )->enableStressComputation (0);
302 vectorPtr_Type solution (
new vector_Type ( (*M_fsi->FSIOper()->couplingVariableMap() ) ) );
304 M_fsi->FSIOper()->extrapolation ( *solution );
307 M_fsi->FSIOper()->exportSolidDisplacement (*M_solidDisp);
308 M_fsi->FSIOper()->exportFluidVelocityAndPressure (*M_velAndPressure);
309 *M_fluidDisp = M_fsi->FSIOper()->meshDisp();
310 M_exporterFluid->postProcess ( M_data->dataFluid()->dataTime()->time() );
311 M_exporterSolid->postProcess ( M_data->dataFluid()->dataTime()->time() );
313 for ( ; M_data->dataFluid()->dataTime()->canAdvance(); ++iter)
315 M_returnValue = EXIT_FAILURE;
316 M_data->dataFluid()->dataTime()->updateTime();
317 M_data->dataSolid()->dataTime()->updateTime();
318 M_data->timeDataALE()->updateTime();
322 FC0.renewParameters ( *M_fsi, 3 );
324 M_fsi->FSIOper()->extrapolation ( *solution );
326 M_fsi->iterate ( solution );
329 M_fsi->FSIOper()->updateSolution ( *solution );
331 if (iter % M_saveEvery == 0)
333 M_fsi->FSIOper()->exportSolidDisplacement (*M_solidDisp);
334 M_fsi->FSIOper()->exportFluidVelocityAndPressure (*M_velAndPressure);
335 *M_fluidDisp = M_fsi->FSIOper()->meshDisp();
337 M_exporterSolid->postProcess ( M_data->dataFluid()->dataTime()->time() );
338 M_exporterFluid->postProcess ( M_data->dataFluid()->dataTime()->time() );
341 std::cout <<
"solution norm at time: " << M_data->dataFluid()->dataTime()->time() <<
"(iter" << iter <<
") : " 342 << M_fsi->displacement().norm2() <<
"\n";
345 if ( M_data->method().compare (
"monolithicGI") == 0 )
347 checkResultGI (M_data->dataFluid()->dataTime()->time() );
351 checkResultGCE (M_data->dataFluid()->dataTime()->time() );
357 std::cout <<
"Total computation time = " 358 << _overall_timer.elapsed() <<
"s" <<
"\n";
360 return M_returnValue;
378 filterPtr_Type M_importerSolid;
379 filterPtr_Type M_importerFluid;
380 vectorPtr_Type M_velAndPressure;
381 vectorPtr_Type M_fluidDisp;
382 vectorPtr_Type M_solidDisp;
384 std::vector<vectorPtr_Type> M_solidStencil;
385 std::vector<vectorPtr_Type> M_fluidStencil;
386 std::vector<vectorPtr_Type> M_ALEStencil;
391 LifeV::UInt M_saveEvery;
396 std::cout <<
"Result correct at time: " << time << std::endl;
397 M_returnValue = EXIT_SUCCESS;
410 std::shared_ptr<Problem> fsip;
412 returnVariable = EXIT_FAILURE;
415 fsip = std::shared_ptr<Problem> (
new Problem ( data_file ) );
416 returnVariable = fsip->run();
419 catch ( std::exception
const& _ex )
421 std::cout <<
"caught exception : " << _ex.what() <<
"\n";
424 return returnVariable;
443 int main (
int argc,
char** argv)
446 MPI_Init (&argc, &argv);
448 std::cout <<
"% using serial Version" << std::endl;
452 const std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
453 GetPot data_file (data_file_name);
454 FSIChecker _sp_check
( data_file
);
455 int returnValue = _sp_check
();
468 using namespace LifeV;
470 typedef FSIOperator::mesh_Type mesh_Type;
473 std::string
const importerType = data_file (
"importer/type",
"ensight");
474 std::string
const fluidName = data_file (
"importer/fluid/filename",
"fluid");
475 std::string
const solidName = data_file (
"importer/solid/filename",
"solid");
477 std::string
const loadInitSol = data_file (
"importer/initSol",
"00000");
478 std::string
const loadInitSolFD = data_file (
"importer/initSolFD",
"-1");
479 std::string iterationString;
481 M_Tstart = data_file (
"fluid/time_discretization/initialtime", 0.);
483 std::cout <<
"The file for fluid is : " << fluidName << std::endl;
484 std::cout <<
"The file for solid is : " << solidName << std::endl;
485 std::cout <<
"The importerType is : " << importerType << std::endl;
486 std::cout <<
"The iteration is : " << loadInitSol << std::endl;
487 std::cout <<
"For the fluid disp is : " << loadInitSolFD << std::endl;
488 std::cout <<
"Starting time : " << M_Tstart << std::endl;
493 std::string methodFluid = data_file (
"fluid/time_discretization/method",
"Newmark");
494 std::string methodSolid = data_file (
"solid/time_discretization/method",
"Newmark");
495 std::string methodALE = data_file (
"mesh_motion/time_discretization/method",
"Newmark");
498 if (importerType.compare (
"hdf5") == 0)
500 M_importerFluid.reset (
new hdf5Filter_Type ( data_file, fluidName) );
501 M_importerSolid.reset (
new hdf5Filter_Type ( data_file, solidName) );
506 if (importerType.compare (
"none") == 0)
508 M_importerFluid.reset (
new ExporterEmpty<mesh_Type > ( data_file, M_fsi->FSIOper()->uFESpace().mesh(),
"fluid", M_fsi->FSIOper()->uFESpace().map().comm().MyPID() ) );
509 M_importerSolid.reset (
new ExporterEmpty<mesh_Type > ( data_file, M_fsi->FSIOper()->dFESpace().mesh(),
"solid", M_fsi->FSIOper()->uFESpace().map().comm().MyPID() ) );
513 M_importerFluid.reset (
new ensightFilter_Type ( data_file, fluidName) );
514 M_importerSolid.reset (
new ensightFilter_Type ( data_file, solidName) );
518 M_importerFluid->setMeshProcId (M_fsi->FSIOper()->uFESpace().mesh(), M_fsi->FSIOper()->uFESpace().map().comm().MyPID() );
519 M_importerSolid->setMeshProcId (M_fsi->FSIOper()->dFESpace().mesh(), M_fsi->FSIOper()->dFESpace().map().comm().MyPID() );
526 iterationString = loadInitSol;
531 vectorPtr_Type pressure;
532 vectorPtr_Type solidDisp;
533 vectorPtr_Type fluidDisp;
535 for (iterInit = 0; iterInit < M_fsi->FSIOper()->fluidTimeAdvance()->size(); iterInit++ )
540 vel.reset (
new vector_Type (M_fsi->FSIOper()->uFESpace().map(), LifeV::Unique) );
541 pressure.reset (
new vector_Type (M_fsi->FSIOper()->pFESpace().map(), LifeV::Unique) );
542 solidDisp.reset (
new vector_Type (M_fsi->FSIOper()->dFESpace().map(), LifeV::Unique) );
547 LifeV::ExporterData<mesh_Type> initSolFluidVel (LifeV::ExporterData<mesh_Type>::VectorField, std::string (
"f-velocity." + iterationString), M_fsi->FSIOper()->uFESpacePtr(), vel, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
548 LifeV::ExporterData<mesh_Type> initSolFluidPress (LifeV::ExporterData<mesh_Type>::ScalarField, std::string (
"f-pressure." + iterationString), M_fsi->FSIOper()->pFESpacePtr(), pressure, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
551 LifeV::ExporterData<mesh_Type> initSolSolidDisp (LifeV::ExporterData<mesh_Type>::VectorField,
"s-displacement." + iterationString, M_fsi->FSIOper()->dFESpacePtr(), solidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
559 M_importerFluid->readVariable (initSolFluidVel);
560 M_importerFluid->readVariable (initSolFluidPress);
561 M_importerSolid->readVariable (initSolSolidDisp);
563 std::cout <<
"Norm of the vel " << vel->norm2() << std::endl;
564 std::cout <<
"Norm of the pressure " << pressure->norm2() << std::endl;
565 std::cout <<
"Norm of the solid " << solidDisp->norm2() << std::endl;
568 M_fsi->FSIOper()->setVectorInStencils (vel, pressure, solidDisp, iterInit )
571 int iterations = std::atoi (iterationString.c_str() );
574 std::ostringstream iter;
576 iter << std::setw (5) << ( iterations );
577 iterationString = iter.str();
580 readLastVectorSolidTimeAdvance ( solidDisp, iterInit, iterationString );
585 iterationString = loadInitSol;
586 int iterationStartALE = std::atoi (iterationString.c_str() );
589 std::ostringstream iter;
591 iter << std::setw (5) << ( iterationStartALE );
592 iterationString = iter.str();
594 std::cout <<
"The load init sol is: " << loadInitSol << std::endl;
595 std::cout <<
"The first read sol is: " << iterationString << std::endl;
597 for (iterInit = 0; iterInit < M_fsi->FSIOper()->ALETimeAdvance()->size(); iterInit++ )
600 fluidDisp.reset (
new vector_Type (M_fsi->FSIOper()->mmFESpace().map(), LifeV::Unique) );
603 LifeV::ExporterData<mesh_Type> initSolFluidDisp (LifeV::ExporterData<mesh_Type>::VectorField,
"f-displacement." + iterationString, M_fsi->FSIOper()->mmFESpacePtr(), fluidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
609 M_importerFluid->readVariable (initSolFluidDisp);
612 std::cout <<
"Norm of the df " << fluidDisp->norm2() << std::endl;
615 M_fsi->FSIOper()->setALEVectorInStencil ( fluidDisp, iterInit,
false );
618 int iterations = std::atoi (iterationString.c_str() );
621 std::ostringstream iter;
623 iter << std::setw (5) << ( iterations );
624 iterationString = iter.str();
628 M_fsi->FSIOper()->finalizeRestart();
631 readLastVectorALETimeAdvance ( fluidDisp, loadInitSol );
634 vel.reset (
new vector_Type (M_fsi->FSIOper()->uFESpace().map(), LifeV::Unique) );
635 pressure.reset (
new vector_Type (M_fsi->FSIOper()->pFESpace().map(), LifeV::Unique) );
636 fluidDisp.reset (
new vector_Type (M_fsi->FSIOper()->mmFESpace().map(), LifeV::Unique) );
637 M_velAndPressure.reset (
new vector_Type ( M_fsi->FSIOper()->fluid().getMap(), M_importerFluid->mapType() ) );
638 M_velAndPressure->subset (*pressure, pressure->map(), UInt (0), (UInt) 3 * M_fsi->FSIOper()->uFESpace().dof().numTotalDof() );
639 *M_velAndPressure += *vel;
641 M_fluidDisp.reset (
new vector_Type ( *fluidDisp, M_importerFluid->mapType() ) );
643 M_solidDisp.reset (
new vector_Type ( *solidDisp, M_importerSolid->mapType() ) );
648 void Problem::readLastVectorSolidTimeAdvance ( vectorPtr_Type solidDisp,
649 LifeV::UInt iterInit,
650 std::string iterationString)
652 using namespace LifeV;
654 typedef FSIOperator::mesh_Type mesh_Type;
660 solidDisp.reset (
new vector_Type (M_fsi->FSIOper()->dFESpace().map(), LifeV::Unique) );
662 LifeV::ExporterData<mesh_Type> initSolSolidDisp (LifeV::ExporterData<mesh_Type>::VectorField,
"s-displacement." + iterationString, M_fsi->FSIOper()->dFESpacePtr(), solidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
664 M_importerSolid->readVariable (initSolSolidDisp);
666 M_fsi->FSIOper()->setSolidVectorInStencil ( solidDisp, iterInit );
671 const std::string loadInitSol)
673 using namespace LifeV;
675 typedef FSIOperator::mesh_Type mesh_Type;
678 std::string iterationString = loadInitSol;
679 fluidDisp.reset (
new vector_Type (M_fsi->FSIOper()->mmFESpace().map(), LifeV::Unique) );
682 LifeV::ExporterData<mesh_Type> initSolFluidDisp (LifeV::ExporterData<mesh_Type>::VectorField,
"f-displacement." + iterationString, M_fsi->FSIOper()->mmFESpacePtr(), fluidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
688 M_importerFluid->readVariable (initSolFluidDisp);
691 std::cout <<
"Norm of the df " << fluidDisp->norm2() << std::endl;
694 if ( M_data->method().compare (
"monolithicGI") == 0 )
697 M_fsi->FSIOper()->setALEVectorInStencil ( fluidDisp, 10,
true );
701 M_fsi->FSIOper()->ALETimeAdvance()->shiftRight ( *fluidDisp );
708 LifeV::Real dispNorm = M_fsi->displacement().norm2();
709 if (time == 0.006 && ( (dispNorm - 104264) / dispNorm * (dispNorm - 104264) / dispNorm < 1e-5 ) )
711 resultCorrect (time);
713 else if (time == 0.007 && ( (dispNorm - 101014) / dispNorm * (dispNorm - 101014) / dispNorm < 1e-5 ) )
715 resultCorrect (time);
717 else if (time == 0.008 && ( (dispNorm - 98183.7) / dispNorm * (dispNorm - 98183.7) / dispNorm < 1e-5 ) )
719 resultCorrect (time);
727 LifeV::Real dispNorm = M_fsi->displacement().norm2();
728 if (time == 0.006 && (dispNorm - 89122.6) / dispNorm * (dispNorm - 89122.6) / dispNorm < 1e-5)
730 resultCorrect (time);
732 else if (time == 0.007 && (dispNorm - 83260.4) / dispNorm * (dispNorm - 83260.4) / dispNorm < 1e-5)
734 resultCorrect (time);
736 else if (time == 0.008 && (dispNorm - 79342.5) / dispNorm * (dispNorm - 79342.5) / dispNorm < 1e-5)
738 resultCorrect (time);
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
LifeV::UInt M_returnValue
LifeV::FactorySingleton< LifeV::Factory< LifeV::FSIOperator, std::string > > FSIFactory_Type
int main(int argc, char **argv)
filter_ptrtype M_exporterFluid
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
std::shared_ptr< FSISolver > fsi_solver_ptr
static const LifeV::UInt elm_nodes_num[]
void resultCorrect(LifeV::Real time)
FSIChecker(GetPot const &_data_file)
void readLastVectorALETimeAdvance(vectorPtr_Type fluidDisp, const std::string loadInitSol)
void readLastVectorSolidTimeAdvance(vectorPtr_Type fluidDisp, const LifeV::UInt iterInit, std::string iterationString)
filter_ptrtype M_exporterSolid
void checkResultGI(const LifeV::Real &time)
void restartFSI(GetPot const &data_file)
Problem(GetPot const &data_file)
void checkResultGCE(const LifeV::Real &time)
std::shared_ptr< ensightFilter_Type > ensightFilterPtr_Type
LifeV::ExporterEnsight< LifeV::FSIOperator::mesh_Type > ensightFilter_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
LifeV::FlowConditions FC0