76 #include <boost/timer.hpp> 78 #include <Epetra_ConfigDefs.h> 81 #include <Epetra_MpiComm.h> 83 #include <Epetra_SerialComm.h> 88 #include <lifev/core/fem/BCHandler.hpp> 89 #include <lifev/core/LifeV.hpp> 91 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 92 #include <lifev/core/algorithm/PreconditionerML.hpp> 94 #include <lifev/fsi/solver/FSISolver.hpp> 95 #include <lifev/structure/solver/StructuralOperator.hpp> 96 #include <lifev/fsi/solver/FSIMonolithicGI.hpp> 98 #include <lifev/core/filter/ExporterEnsight.hpp> 99 #include <lifev/core/filter/ExporterEmpty.hpp> 101 #include <lifev/core/filter/ExporterHDF5.hpp> 116 typedef LifeV::FSIOperator::data_Type data_Type;
117 typedef LifeV::FSIOperator::dataPtr_Type dataPtr_Type;
119 typedef LifeV::FSIOperator::vector_Type vector_Type;
120 typedef LifeV::FSIOperator::vectorPtr_Type vectorPtr_Type;
146 using namespace LifeV;
148 FSIOperator::solid_Type::material_Type::isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().registerProduct (
"linearVenantKirchhoff", &FSIOperator::createVenantKirchhoffLinear );
149 FSIOperator::solid_Type::material_Type::isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().registerProduct (
"exponential", &FSIOperator::createExponentialMaterialNonLinear );
150 FSIOperator::solid_Type::material_Type::isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().registerProduct (
"neoHookean", &FSIOperator::createNeoHookeanMaterialNonLinear );
151 FSIOperator::solid_Type::material_Type::isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().registerProduct (
"nonLinearVenantKirchhoff", &FSIOperator::createVenantKirchhoffNonLinear );
153 std::cout <<
"register MonolithicGE : " << FSIMonolithicGE::S_register << std::endl;
154 std::cout <<
"register MonolithicGI : " << FSIMonolithicGI::S_register << std::endl;
156 M_data = dataPtr_Type (
new data_Type() );
157 M_data->setup ( data_file );
161 M_fsi = fsi_solver_ptr (
new FSISolver( ) );
162 MPI_Barrier ( MPI_COMM_WORLD );
164 M_fsi->setData ( M_data );
165 M_fsi->FSIOper()->setDataFile ( data_file );
169 std::string fluidMeshPartitioned = data_file (
"problem/fluidMeshPartitioned",
"none" );
170 std::string solidMeshPartitioned = data_file (
"problem/solidMeshPartitioned",
"none" );
172 if ( fluidMeshPartitioned.compare (
"none" ) )
174 FSIOperator::meshFilter_Type fluidMeshFilter ( data_file, fluidMeshPartitioned );
175 fluidMeshFilter.setComm ( M_fsi->FSIOper()->worldComm() );
176 FSIOperator::meshFilter_Type solidMeshFilter ( data_file, solidMeshPartitioned );
177 solidMeshFilter.setComm ( M_fsi->FSIOper( )->worldComm( ) );
178 M_fsi->FSIOper( )->partitionMeshes ( fluidMeshFilter, solidMeshFilter );
179 M_fsi->FSIOper( )->setupFEspace( );
180 M_fsi->FSIOper( )->setupDOF ( fluidMeshFilter );
181 fluidMeshFilter.closeFile( );
182 solidMeshFilter.closeFile( );
187 M_fsi->FSIOper( )->partitionMeshes( );
188 M_fsi->FSIOper( )->setupFEspace( );
189 M_fsi->FSIOper( )->setupDOF( );
192 debugStream ( 10000
) <<
"Setting up the FESpace and DOF \n";
194 MPI_Barrier ( MPI_COMM_WORLD );
197 debugStream ( 10000 ) <<
"Setting up the BC \n";
199 M_fsi->setFluidBC ( BCh_monolithicFlux (
true ) );
200 M_fsi->setSolidBC ( BCh_monolithicSolid ( *M_fsi->FSIOper( ) ) );
204 M_fsi->setFluidBC ( BCh_monolithicFluid ( *M_fsi->FSIOper( ),
true ) );
205 M_fsi->setHarmonicExtensionBC ( BCh_harmonicExtension ( *M_fsi->FSIOper( ) ) );
207 dynamic_cast<LifeV::FSIMonolithic*> (M_fsi->FSIOper().get() )->mergeBCHandlers();
210 debugStream ( 10000 ) <<
"BC set\n";
213 std::string
const exporterType = data_file (
"exporter/type",
"ensight" );
214 std::string
const fluidName = data_file (
"exporter/fluid/filename",
"fluid" );
215 std::string
const solidName = data_file (
"exporter/solid/filename",
"solid" );
218 if (exporterType.compare (
"hdf5") == 0)
220 M_exporterFluid.reset (
new hdf5Filter_Type ( data_file, fluidName) );
221 M_exporterSolid.reset (
new hdf5Filter_Type ( data_file, solidName) );
226 if (exporterType.compare (
"none") == 0)
228 M_exporterFluid.reset (
new ExporterEmpty<RegionMesh<LinearTetra> > ( data_file, M_fsi->FSIOper()->uFESpace().mesh(), fluidName, M_fsi->FSIOper()->uFESpace().map().comm().MyPID() ) );
229 M_exporterSolid.reset (
new ExporterEmpty<RegionMesh<LinearTetra> > ( data_file, M_fsi->FSIOper()->dFESpace().mesh(), solidName, M_fsi->FSIOper()->uFESpace().map().comm().MyPID() ) );
233 M_exporterFluid.reset (
new ensightFilter_Type ( data_file, fluidName) );
234 M_exporterSolid.reset (
new ensightFilter_Type ( data_file, solidName) );
240 M_saveEvery = data_file (
"exporter/saveEvery", 1);
242 M_fsi->initializeMonolithicOperator();
244 M_velAndPressure.reset (
new vector_Type ( M_fsi->FSIOper()->fluid().getMap(), M_exporterFluid->mapType() ) );
246 M_fluidDisp.reset (
new vector_Type ( M_fsi->FSIOper()->mmFESpace().map(), M_exporterFluid->mapType() ) );
248 M_solidDisp.reset (
new vector_Type ( M_fsi->FSIOper()->dFESpace().map(), M_exporterSolid->mapType() ) );
250 M_exporterFluid->setMeshProcId (M_fsi->FSIOper()->uFESpace().mesh(), M_fsi->FSIOper()->uFESpace().map().comm().MyPID() );
251 M_exporterSolid->setMeshProcId (M_fsi->FSIOper()->dFESpace().mesh(), M_fsi->FSIOper()->dFESpace().map().comm().MyPID() );
252 M_exporterFluid->addVariable ( ExporterData<FSIOperator::mesh_Type>::VectorField,
"f-velocity",
253 M_fsi->FSIOper()->uFESpacePtr(), M_velAndPressure, UInt (0) );
254 M_exporterFluid->addVariable ( ExporterData<FSIOperator::mesh_Type>::ScalarField,
"f-pressure",
255 M_fsi->FSIOper()->pFESpacePtr(), M_velAndPressure,
256 UInt (3 * M_fsi->FSIOper()->uFESpace().dof().numTotalDof() ) );
258 M_exporterFluid->addVariable ( ExporterData<FSIOperator::mesh_Type>::VectorField,
"f-displacement",
259 M_fsi->FSIOper()->mmFESpacePtr(), M_fluidDisp, UInt (0) );
264 M_exporterSolid->addVariable ( ExporterData<FSIOperator::mesh_Type>::VectorField,
"s-displacement",
265 M_fsi->FSIOper()->dFESpacePtr(), M_solidDisp, UInt (0) );
269 FC0.initParameters ( *M_fsi->FSIOper(), 3);
270 LH.initParameters ( *M_fsi->FSIOper(),
"dataHM");
272 M_data->dataFluid()->dataTime()->setInitialTime ( M_Tstart );
273 M_data->dataFluid()->dataTime()->setTime ( M_data->dataFluid()->dataTime()->initialTime() );
274 M_data->dataSolid()->dataTime()->setInitialTime ( M_Tstart );
275 M_data->dataSolid()->dataTime()->setTime ( M_data->dataFluid()->dataTime()->initialTime() );
276 M_data->timeDataALE()->setInitialTime ( M_Tstart );
277 M_data->timeDataALE()->setTime ( M_data->dataFluid()->dataTime()->initialTime() );
286 boost::timer _overall_timer;
288 LifeV::UInt iter = 1;
291 dynamic_cast<LifeV::FSIMonolithic*> (M_fsi->FSIOper().get() )->enableStressComputation (1);
293 bool valveIsOpen =
true;
295 vectorPtr_Type solution (
new vector_Type ( (*M_fsi->FSIOper()->couplingVariableMap() ) ) );
297 M_fsi->FSIOper()->extrapolation ( *solution );
299 for ( ; M_data->dataFluid()->dataTime()->canAdvance(); M_data->dataFluid()->dataTime()->updateTime(), M_data->dataSolid()->dataTime()->updateTime(), ++iter)
302 M_returnValue = EXIT_FAILURE;
304 LifeV::Real flux = M_fsi->FSIOper()->fluid().flux (2, M_fsi->displacement() );
310 M_fsi->setFluidBC (BCh_monolithicFluid (*M_fsi->FSIOper(), valveIsOpen) );
317 if (
false && M_fsi->FSIOper()->fluid().pressure (2, M_fsi->displacement() ) < LifeV::LumpedHeart::M_pressure )
320 M_fsi->setFluidBC (BCh_monolithicFluid (*M_fsi->FSIOper(), valveIsOpen) );
326 FC0.renewParameters ( *M_fsi, 3 );
327 LH.renewParameters ( *M_fsi->FSIOper(), flag, M_data->dataFluid()->dataTime()->time(), flux );
331 if (iter % M_saveEvery == 0)
333 M_fsi->FSIOper()->exportSolidDisplacement (*M_solidDisp);
335 M_fsi->FSIOper()->exportFluidVelocityAndPressure (*M_velAndPressure);
336 M_exporterSolid->postProcess ( M_data->dataFluid()->dataTime()->time() );
338 *M_fluidDisp = M_fsi->FSIOper()->meshDisp();
339 M_exporterFluid->postProcess ( M_data->dataFluid()->dataTime()->time() );
343 M_fsi->FSIOper()->extrapolation ( *solution );
345 M_fsi->iterate ( solution );
348 M_fsi->FSIOper()->updateSolution ( *solution );
350 M_fsi->FSIOper()->displayer().leaderPrintMax (
"[fsi_run] Iteration ", iter);
351 M_fsi->FSIOper()->displayer().leaderPrintMax (
" was done in : ", _timer.elapsed() );
353 std::cout <<
"solution norm " << iter <<
" : " 354 << M_fsi->displacement().norm2() <<
"\n";
357 if (!M_data->method().compare (
"monolithicGI") )
359 checkCEResult (M_data->dataFluid()->dataTime()->time() );
363 checkGCEResult (M_data->dataFluid()->dataTime()->time() );
368 std::cout <<
"Total computation time = " 369 << _overall_timer.elapsed() <<
"s" <<
"\n";
371 return M_returnValue;
385 filterPtr_Type M_importerSolid;
386 filterPtr_Type M_importerFluid;
387 vectorPtr_Type M_velAndPressure;
388 vectorPtr_Type M_fluidDisp;
389 vectorPtr_Type M_solidDisp;
391 std::vector<vectorPtr_Type> M_solidStencil;
392 std::vector<vectorPtr_Type> M_fluidStencil;
393 std::vector<vectorPtr_Type> M_ALEStencil;
400 LifeV::UInt M_saveEvery;
407 std::cout <<
"Result correct at time: " << time << std::endl;
408 M_returnValue = EXIT_SUCCESS;
421 std::shared_ptr<Problem> fsip;
425 fsip = std::shared_ptr<Problem> (
new Problem ( data_file ) );
428 catch ( std::exception
const& _ex )
430 std::cout <<
"caught exception : " << _ex.what() <<
"\n";
452 int main (
int argc,
char** argv)
455 MPI_Init (&argc, &argv);
457 std::cout <<
"% using serial Version" << std::endl;
462 const std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
463 GetPot data_file (data_file_name);
464 FSIChecker _sp_check
( data_file
);
465 int returnValue = _sp_check
();
477 LifeV::Real dispNorm = M_fsi->displacement().norm2();
478 if (time == 0.000 && (dispNorm - 106344) / dispNorm * (dispNorm - 106344) / dispNorm < 1e-3)
480 Problem::resultCorrect (time);
482 else if (time == 0.001 && (dispNorm - 147532) / dispNorm * (dispNorm - 147532) / dispNorm < 1e-3)
484 Problem::resultCorrect (time);
486 else if (time == 0.002 && (dispNorm - 108216) / dispNorm * (dispNorm - 108216) / dispNorm < 1e-3)
488 Problem::resultCorrect (time);
490 else if (time == 0.003 && (dispNorm - 105437) / dispNorm * (dispNorm - 105437) / dispNorm < 1e-3)
492 Problem::resultCorrect (time);
494 else if (time == 0.004 && (dispNorm - 104585) / dispNorm * (dispNorm - 104585) / dispNorm < 1e-3)
496 Problem::resultCorrect (time);
504 LifeV::Real dispNorm = M_fsi->displacement().norm2();
505 if (time == 0.000 && (dispNorm - 110316) / dispNorm * (dispNorm - 110316) / dispNorm < 1e-5)
507 Problem::resultCorrect (time);
509 else if (time == 0.001 && (dispNorm - 99468.8) / dispNorm * (dispNorm - 99468.8) / dispNorm < 1e-5)
511 Problem::resultCorrect (time);
513 else if (time == 0.002 && (dispNorm - 91003.1) / dispNorm * (dispNorm - 91003.1) / dispNorm < 1e-5)
515 Problem::resultCorrect (time);
517 else if (time == 0.003 && (dispNorm - 90179.9) / dispNorm * (dispNorm - 90179.9) / dispNorm < 1e-5)
519 Problem::resultCorrect (time);
521 else if (time == 0.004 && (dispNorm - 88319.3) / dispNorm * (dispNorm - 88319.3) / dispNorm < 1e-5)
523 Problem::resultCorrect (time);
void checkCEResult(const LifeV::Real &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)
filter_ptrtype M_exporterSolid
NdebugStream noDebugStream(int=0, NdebugStream::stprintf=&printf)
Problem(GetPot const &data_file)
std::shared_ptr< ensightFilter_Type > ensightFilterPtr_Type
LifeV::ExporterEnsight< LifeV::FSIOperator::mesh_Type > ensightFilter_Type
void checkGCEResult(const LifeV::Real &time)
LifeV::FlowConditions FC0