40 #error test_fsi cannot be compiled in 2D
43 #include <boost/timer.hpp> 49 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 50 #include <lifev/core/algorithm/PreconditionerML.hpp> 51 #include <lifev/core/LifeV.hpp> 52 #include <lifev/core/util/LifeChrono.hpp> 54 #include <lifev/fsi/solver/FSISolver.hpp> 55 #include <lifev/fsi/solver/FSIOperator.hpp> 56 #include <lifev/fsi/solver/FSIExactJacobian.hpp> 57 #include <lifev/fsi/solver/FSIFixedPoint.hpp> 58 #include <lifev/fsi/solver/FSIData.hpp> 59 #include <lifev/structure/solver/StructuralOperator.hpp> 60 #include <lifev/structure/solver/StructuralConstitutiveLaw.hpp> 61 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialNonLinear.hpp> 62 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialLinear.hpp> 64 #include <lifev/core/filter/ExporterHDF5.hpp> 65 #include <lifev/core/filter/ExporterEnsight.hpp> 68 #include <Epetra_ConfigDefs.h> 71 #include <Epetra_MpiComm.h> 73 #include <Epetra_SerialComm.h> 120 using namespace LifeV;
126 #define PI 3.141592653589793
137 UInt flag = M_oper.dataSolid()->vectorFlags() [0];
139 Real beta = M_oper.solid().thickness() * M_oper.solid().young ( flag ) /
140 (1 - M_oper.solid().poisson ( flag ) * M_oper.solid().poisson ( flag ) ) *
PI / area0;
142 Real qn = M_oper.fluid().flux (3);
144 M_outflow = std::pow (std::sqrt (M_oper.solid().rho() ) / (2 * std::sqrt (2.) ) * qn / area + std::sqrt (beta * std::sqrt (area0) ), 2) - beta * std::sqrt (area0);
146 std::cout <<
"--------------- Absorbing boundary condition ---------------" << std::endl;
147 std::cout <<
" Outflow BC : density = " << M_oper.solid().rho() << std::endl;
148 std::cout <<
" Outflow BC : thickness = " << M_oper.solid().thickness() << std::endl;
149 std::cout <<
" Outflow BC : young = " << M_oper.solid().young ( flag ) << std::endl;
150 std::cout <<
" Outflow BC : poisson = " << M_oper.solid().poisson ( flag ) << std::endl;
151 std::cout <<
" Outflow BC : area0 = " << area0 << std::endl;
152 std::cout <<
" Outflow BC : area = " << M_oper.fluid().area (3) << std::endl;
153 std::cout <<
" Outflow BC : radius = " << std::sqrt (area0 /
PI) << std::endl;
154 std::cout <<
" Outflow BC : beta = " << beta << std::endl;
155 std::cout <<
" Outflow BC : Flow rate = " << qn << std::endl;
156 std::cout <<
" Outflow BC : outflow = " << M_outflow << std::endl;
157 std::cout <<
"------------------------------------------------------------" << std::endl;
178 ERROR_MSG (
"This entrie is not allowed: disp_adatptor");
198 Real area0 = 0.147439938;
205 Real beta = ( std::sqrt (
PI) * M_oper.solid().thickness() * M_oper.solid().young ( flag ) ) / (1 - M_oper.solid().poisson ( flag ) * M_oper.solid().poisson ( flag ) );
206 Real R = ( std::sqrt (M_oper.solid().rho( ) * beta ) ) / ( std::sqrt (2.0) * std::pow (area0, exp) );
208 Real qn = M_oper.fluid().flux (3);
213 std::cout <<
"--------------- Absorbing boundary condition for Face-------" << std::endl;
214 std::cout <<
" Outflow BC : density = " << M_oper.solid().rho() << std::endl;
215 std::cout <<
" Outflow BC : thickness = " << M_oper.solid().thickness() << std::endl;
216 std::cout <<
" Outflow BC : young = " << M_oper.solid().young ( flag ) << std::endl;
217 std::cout <<
" Outflow BC : poisson = " << M_oper.solid().poisson ( flag ) << std::endl;
218 std::cout <<
" Outflow BC : area0 = " << area0 << std::endl;
219 std::cout <<
" Outflow BC : area = " << M_oper.fluid().area (3) << std::endl;
220 std::cout <<
" Outflow BC : radius = " << std::sqrt (area0 /
PI) << std::endl;
221 std::cout <<
" Outflow BC : beta = " << beta << std::endl;
222 std::cout <<
" Outflow BC : Flow rate = " << qn << std::endl;
223 std::cout <<
" Outflow BC : outflow = " << M_outflowFace << std::endl;
224 std::cout <<
"------------------------------------------------------------" << std::endl;
246 ERROR_MSG (
"This entrie is not allowed: disp_adatptor");
267 Real area0 = 0.191155176;
275 Real beta = ( std::sqrt (
PI) * M_oper.solid().thickness() * M_oper.solid().young ( flag ) ) / (1 - M_oper.solid().poisson ( flag ) * M_oper.solid().poisson ( flag ) );
276 Real R = ( std::sqrt (M_oper.solid().rho( ) * beta ) ) / ( std::sqrt (2.0) * std::pow (area0, exp) );
278 Real qn = M_oper.fluid().flux (4);
284 std::cout <<
"--------------- Absorbing boundary condition for Brain-------" << std::endl;
285 std::cout <<
" Outflow BC : density = " << M_oper.solid().rho() << std::endl;
286 std::cout <<
" Outflow BC : thickness = " << M_oper.solid().thickness() << std::endl;
287 std::cout <<
" Outflow BC : young = " << M_oper.solid().young ( flag ) << std::endl;
288 std::cout <<
" Outflow BC : poisson = " << M_oper.solid().poisson ( flag ) << std::endl;
289 std::cout <<
" Outflow BC : area0 = " << area0 << std::endl;
290 std::cout <<
" Outflow BC : area = " << M_oper.fluid().area (4) << std::endl;
291 std::cout <<
" Outflow BC : radius = " << std::sqrt (area0 /
PI) << std::endl;
292 std::cout <<
" Outflow BC : beta = " << beta << std::endl;
293 std::cout <<
" Outflow BC : Flow rate = " << qn << std::endl;
294 std::cout <<
" Outflow BC : outflow = " << M_outflowBrain << std::endl;
295 std::cout <<
"------------------------------------------------------------" << std::endl;
315 ERROR_MSG (
"This entrie is not allowed: disp_adatptor");
336 typedef FSIOperator::data_Type data_Type;
337 typedef FSIOperator::dataPtr_Type dataPtr_Type;
339 typedef FSIOperator::vector_Type vector_Type;
340 typedef FSIOperator::vectorPtr_Type vectorPtr_Type;
341 typedef FSIOperator::mesh_Type mesh_Type;
357 Problem (
const std::string& dataFileName, std::string method =
"" )
365 StructuralOperator< FSIOperator::mesh_Type>();
372 GetPot dataFile ( dataFileName );
373 M_data = dataPtr_Type (
new data_Type() );
374 M_data->setup ( dataFile );
375 M_data->dataSolid()->setTimeData ( M_data->dataFluid()->dataTime() );
378 MPI_Barrier ( MPI_COMM_WORLD );
380 debugStream ( 10000 ) <<
"creating FSISolver with operator : " << method <<
"\n";
381 M_fsi = fsi_solver_ptr (
new FSISolver( ) );
382 M_fsi->setData ( M_data );
383 M_fsi->FSIOper()->setDataFile ( dataFile );
384 MPI_Barrier ( MPI_COMM_WORLD );
387 debugStream ( 10000
) <<
"Setting up the FESpace and DOF \n";
388 M_fsi->FSIOper( )->partitionMeshes( );
389 M_fsi->FSIOper()->setupFEspace();
390 M_fsi->FSIOper()->setupDOF();
391 MPI_Barrier ( MPI_COMM_WORLD );
394 M_fsi->setFluidBC (BCh_fluid (*M_fsi->FSIOper() ) );
395 M_fsi->setHarmonicExtensionBC ( BCh_harmonicExtension (*M_fsi->FSIOper() ) );
396 M_fsi->setSolidBC (BCh_solid (*M_fsi->FSIOper() ) );
397 M_fsi->setLinFluidBC (BCh_fluidLin (*M_fsi->FSIOper() ) );
398 M_fsi->setLinSolidBC (BCh_solidLin (*M_fsi->FSIOper() ) );
401 std::cout <<
" absorbing BC = " << M_absorbingBC << std::endl;
403 MPI_Barrier ( MPI_COMM_WORLD );
410 MPI_Barrier ( MPI_COMM_WORLD );
412 std::string
const exporterType = dataFile (
"exporter/type",
"hdf5");
413 std::string
const exporterName = dataFile (
"exporter/name",
"fixedPt");
416 if ( M_fsi->isFluid() )
419 if (exporterType.compare (
"hdf5") == 0)
421 M_exporterFluid.reset (
new ExporterHDF5<mesh_Type > ( dataFile, exporterName +
"Fluid" ) );
425 M_exporterFluid.reset (
new ExporterEnsight<mesh_Type > ( dataFile, exporterName +
"Fluid" ) );
427 M_exporterFluid->setMeshProcId (M_fsi->FSIOper()->uFESpace().mesh(), M_fsi->FSIOper()->uFESpace().map().comm().MyPID() );
429 M_velAndPressure.reset (
new vector_Type ( M_fsi->FSIOper()->fluid().getMap(), M_exporterFluid->mapType() ) );
430 M_fluidDisp.reset (
new vector_Type ( M_fsi->FSIOper()->meshMotion().getMap(), M_exporterFluid->mapType() ) );
432 M_exporterFluid->addVariable ( ExporterData<mesh_Type>::VectorField,
"f-velocity",
433 M_fsi->FSIOper()->uFESpacePtr(), M_velAndPressure, UInt (0) );
435 M_exporterFluid->addVariable ( ExporterData<mesh_Type>::ScalarField,
"f-pressure",
436 M_fsi->FSIOper()->pFESpacePtr(), M_velAndPressure,
437 UInt (3 * M_fsi->FSIOper()->uFESpace().dof().numTotalDof() ) );
439 M_exporterFluid->addVariable ( ExporterData<mesh_Type>::VectorField,
"f-displacement",
440 M_fsi->FSIOper()->mmFESpacePtr(), M_fluidDisp, UInt (0) );
442 if ( M_fsi->isSolid() )
445 if (exporterType.compare (
"hdf5") == 0)
447 M_exporterSolid.reset (
new ExporterHDF5<mesh_Type > ( dataFile, exporterName +
"Solid" ) );
451 M_exporterSolid.reset (
new ExporterEnsight<mesh_Type > ( dataFile, exporterName +
"Solid" ) );
453 M_exporterSolid->setMeshProcId (M_fsi->FSIOper()->dFESpace().mesh(), M_fsi->FSIOper()->dFESpace().map().comm().MyPID() );
454 M_solidDisp.reset (
new vector_Type ( M_fsi->FSIOper()->solid().map(), M_exporterSolid->mapType() ) );
455 M_solidVel.reset (
new vector_Type ( M_fsi->FSIOper()->solid().map(), M_exporterSolid->mapType() ) );
457 M_exporterSolid->addVariable ( ExporterData<mesh_Type>::VectorField,
"s-displacement",
458 M_fsi->FSIOper()->dFESpacePtr(), M_solidDisp, UInt (0) );
459 M_exporterSolid->addVariable ( ExporterData<mesh_Type>::VectorField,
"s-velocity",
460 M_fsi->FSIOper()->dFESpacePtr(), M_solidVel, UInt (0) );
464 std::cout <<
"XXX10" << std::endl;
466 bool restart = dataFile
("problem/restart", false);
470 std::string velFName = dataFile (
"fluid/miscellaneous/velname" ,
"vel");
471 std::string pressName = dataFile (
"fluid/miscellaneous/pressname",
"press");
472 std::string velwName = dataFile (
"fluid/miscellaneous/velwname",
"velw");
473 std::string depName = dataFile (
"solid/miscellaneous/depname" ,
"dep");
474 std::string velSName = dataFile (
"solid/miscellaneous/velname" ,
"velw");
476 std::cout <<
"Starting time = " << M_Tstart << std::endl;
480 if ( M_fsi->isFluid() )
482 M_exporterFluid->import (M_Tstart, M_data->dataFluid()->dataTime()->timeStep() );
483 M_fsi->FSIOper()->initializeFluid ( *M_velAndPressure, *M_fluidDisp );
485 if ( M_fsi->isSolid() )
487 M_exporterSolid->import (M_Tstart, M_data->dataSolid()->dataTime()->timeStep() );
488 M_fsi->FSIOper()->initializeSolid ( M_solidDisp, M_solidVel );
495 std::cout <<
"XXX11" << std::endl;
496 M_data->dataFluid()->dataTime()->setInitialTime ( M_Tstart );
497 M_data->dataFluid()->dataTime()->setTime ( M_Tstart );
500 std::cout <<
"XXX12" << std::endl;
518 std::cout <<
"XXX15" << std::endl;
521 bool const isFluidLeader ( M_fsi->FSIOper()->isFluid() && M_fsi->FSIOper()->isLeader() );
524 ofile.open (
"fluxes.res" );
527 boost::timer _overall_timer;
531 std::cout <<
"XXX16" << std::endl;
533 for ( ; M_data->dataFluid()->dataTime()->canAdvance(); M_data->dataFluid()->dataTime()->updateTime(), ++_i )
537 if ( M_absorbingBC && M_fsi->isFluid() )
539 std::cout <<
"XXX17" << std::endl;
541 BCFunctionBase outFlow;
542 outFlow.setFunction (bc_adaptor (*M_fsi->FSIOper() ) );
543 std::cout <<
"XXX18" << std::endl;
545 std::cout <<
"XXX19" << std::endl;
561 std::cout <<
"XXX20" << std::endl;
563 if ( M_fsi->isFluid() )
567 ofile << M_data->dataFluid()->dataTime()->time() <<
" ";
570 flux = M_fsi->FSIOper()->fluid().flux (2);
573 ofile << flux <<
" ";
576 flux = M_fsi->FSIOper()->fluid().flux (3);
579 ofile << flux <<
" ";
582 flux = M_fsi->FSIOper()->fluid().pressure (2);
585 ofile << flux <<
" ";
588 flux = M_fsi->FSIOper()->fluid().pressure (3);
591 ofile << flux <<
" " << std::endl;
594 *M_velAndPressure = *M_fsi->FSIOper()->fluid().solution();
595 *M_fluidDisp = M_fsi->FSIOper()->meshMotion().disp();
596 M_exporterFluid->postProcess ( M_data->dataFluid()->dataTime()->time() );
599 if ( M_fsi->isSolid() )
601 *M_solidDisp = M_fsi->FSIOper()->solid().displacement();
603 *M_solidVel = M_fsi->FSIOper()->solidTimeAdvance()->firstDerivative();
605 M_exporterSolid->postProcess ( M_data->dataFluid()->dataTime()->time() );
608 std::cout <<
"[fsi_run] Iteration " << _i <<
" was done in : " << _timer.elapsed() <<
"\n";
611 checkResult ( M_data->dataFluid()->dataTime()->time() );
613 std::cout <<
"Total computation time = " << _overall_timer.elapsed() <<
"s" <<
"\n";
646 bool sameAs (
const LifeV::Real& a,
const LifeV::Real& b,
const LifeV::Real& relTol = 1e-6)
648 const LifeV::Real maxAbs (std::max (std::fabs (a), std::fabs (b) ) );
649 if (maxAbs < relTol * relTol)
654 return std::fabs (a - b) < relTol * maxAbs;
666 vectorPtr_Type M_velAndPressure;
667 vectorPtr_Type M_fluidDisp;
668 vectorPtr_Type M_solidDisp;
671 struct RESULT_CHANGED_EXCEPTION
676 std::cout <<
"Some modifications led to changes in the l2 norm of the solution at time " << time << std::endl;
692 GetPot dataFile ( dataFileName );
693 M_method = dataFile (
"problem/method",
"exactJacobian" );
697 const std::string& method ) :
704 std::shared_ptr<Problem> FSIproblem;
708 FSIproblem = std::shared_ptr<Problem> (
new Problem ( M_dataFileName, M_method ) );
709 std::cout <<
"XXX13" << std::endl;
711 std::cout <<
"XXX14" << std::endl;
713 catch (
const std::exception& _ex )
715 std::cout <<
"caught exception : " << _ex.what() <<
"\n";
723 int main (
int argc,
char** argv )
726 std::cout <<
"MPI Initialization" << std::endl;
727 MPI_Init ( &argc, &argv );
729 std::cout <<
"Serial Version" << std::endl;
736 std::string dataFileName = command_line.follow (
"data", 2,
"-f",
"--file" );
778 FSIChecker FSIProblem ( dataFileName );
779 std::cout <<
"XXX2" << std::endl;
781 std::cout <<
"XXX3" << std::endl;
783 std::cout <<
"Total sum up " << chrono.diffCumul() <<
" s." << std::endl;
786 std::cout <<
"MPI Finalization" << std::endl;
bc_adaptorBrain(FSIOperator &Operator)
vectorPtr_Type M_solidVel
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
double operator()(const char *VarName, const double &Default) const
LifeV::FactorySingleton< LifeV::Factory< LifeV::FSIOperator, std::string > > FSIFactory_Type
void start()
Start the timer.
FESpace - Short description here please!
int main(int argc, char **argv)
filter_ptrtype M_exporterFluid
RESULT_CHANGED_EXCEPTION(LifeV::Real time)
Real operator()(Real, Real, Real, Real, ID id)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Real operator()(Real, Real, Real, Real, ID id)
std::shared_ptr< FSISolver > fsi_solver_ptr
bc_adaptor(FSIOperator &Operator)
static const LifeV::UInt elm_nodes_num[]
FSIChecker(const std::string &dataFileName)
Epetra_Import const & importer()
Getter for the Epetra_Import.
Problem(const std::string &dataFileName, std::string method="")
Exporter< FSIOperator::mesh_Type > filter_type
void checkResult(const LifeV::Real &time)
std::string M_dataFileName
bc_adaptorFace(FSIOperator &Operator)
std::shared_ptr< filter_type > filter_ptrtype
filter_ptrtype M_exporterSolid
bool sameAs(const LifeV::Real &a, const LifeV::Real &b, const LifeV::Real &relTol=1e-6)
FESpace< FSIOperator::mesh_Type, MapEpetra > feSpace_Type
fsi_solver_ptr fsiSolver()
double Real
Generic real data.
Real operator()(Real, Real, Real, Real, ID id)
NdebugStream noDebugStream(int=0, NdebugStream::stprintf=&printf)
bool operator()(const char *VarName, bool Default) const
FSIChecker(const std::string &dataFileName, const std::string &method)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
std::shared_ptr< feSpace_Type > feSpacePtr_Type