44 #include <Epetra_ConfigDefs.h> 47 #include <Epetra_MpiComm.h> 49 #include <Epetra_SerialComm.h> 54 #include <lifev/core/LifeV.hpp> 55 #include <lifev/core/util/LifeChrono.hpp> 56 #include <lifev/core/filter/GetPot.hpp> 57 #include <lifev/core/array/MapEpetra.hpp> 60 #include <lifev/one_d_fsi/fem/OneDFSIBCHandler.hpp> 61 #include <lifev/one_d_fsi/solver/OneDFSISolver.hpp> 62 #include <lifev/multiscale/models/MultiscaleModelFSI1D.hpp> 66 using namespace LifeV;
71 Real norm = abs (val - test);
75 std::cout <<
"value = " << val <<
" computed value = " << test <<
" diff = " << norm << std::endl;
84 std::shared_ptr<Epetra_Comm> comm;
87 std::cout <<
"MPI Initialization" << std::endl;
88 MPI_Init ( &argc, &argv );
96 MPI_Comm_size ( MPI_COMM_WORLD, &nprocs );
97 MPI_Comm_rank ( MPI_COMM_WORLD, &rank );
101 std::cout <<
"MPI Processes: " << nprocs << std::endl;
102 std::cout <<
"MPI Epetra Initialization ... " << std::endl;
104 comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
108 std::cout <<
"MPI SERIAL Epetra Initialization ... " << std::endl;
109 comm.reset (
new Epetra_SerialComm() );
117 typedef bc_Type::bcFunction_Type bcFunction_Type;
125 const bool check = command_line
.search (2
, "-c", "--check");
127 std::string fileName = command_line
.follow ("data", 2
, "-f", "--file");
134 oneDModel.setCommunicator ( comm );
137 std::array< Real,
NDIM > geometryScale;
138 std::array< Real,
NDIM > geometryRotate;
139 std::array< Real,
NDIM > geometryTranslate;
141 geometryScale[0] = dataFile (
"1D_Model/space_discretization/transform", 1., 0);
142 geometryScale[1] = dataFile (
"1D_Model/space_discretization/transform", 1., 1);
143 geometryScale[2] = dataFile (
"1D_Model/space_discretization/transform", 1., 2);
145 geometryRotate[0] = dataFile (
"1D_Model/space_discretization/transform", 0., 3) *
M_PI / 180;
146 geometryRotate[1] = dataFile (
"1D_Model/space_discretization/transform", 0., 4) *
M_PI / 180;
147 geometryRotate[2] = dataFile (
"1D_Model/space_discretization/transform", 0., 5) *
M_PI / 180;
149 geometryTranslate[0] = dataFile (
"1D_Model/space_discretization/transform", 0., 6);
150 geometryTranslate[1] = dataFile (
"1D_Model/space_discretization/transform", 0., 7);
151 geometryTranslate[2] = dataFile (
"1D_Model/space_discretization/transform", 0., 8);
153 oneDModel.setGeometry ( geometryScale, geometryRotate, geometryTranslate );
155 oneDModel.setupData ( fileName );
166 bcFunction_Type sinusoidalFunction ( std::bind ( &Sin::operator(), &sinus, std::placeholders::_1 ) );
169 bc_Type::bcFunctionSolverDefinedPtr_Type absorbing (
new OneDFSIFunctionSolverDefinedAbsorbing ( OneDFSI::right, OneDFSI::W2 ) );
170 bcFunction_Type absorbingFunction ( std::bind ( &OneDFSIFunctionSolverDefinedAbsorbing::operator(),
171 dynamic_cast<OneDFSIFunctionSolverDefinedAbsorbing*> ( & ( *absorbing ) ), std::placeholders::_1, std::placeholders::_2 ) );
188 absorbing->setSolution ( oneDModel.solution() );
189 absorbing->setFluxSource ( oneDModel.flux(), oneDModel.source() );
194 std::cout <<
"\nTemporal loop:" << std::endl;
202 for ( ; oneDModel.data().dataTime()->canAdvance() ; oneDModel.data().dataTime()->updateTime(), ++count )
204 std::cout << std::endl <<
"--------- Iteration " << count <<
" time = " << oneDModel.data().dataTime()->time() << std::endl;
206 chronoIteration.start();
208 if ( oneDModel.data().dataTime()->isFirstTimeStep() )
210 oneDModel.buildModel();
214 oneDModel.updateModel();
217 chronoSystem.start();
219 oneDModel.solveModel();
223 oneDModel.updateSolution();
226 if ( count % 50 == 0 || oneDModel.data().dataTime()->isLastTimeStep() )
228 oneDModel.saveSolution();
231 chronoIteration.stop();
233 std::cout <<
" System solved in " << chronoSystem.diff() <<
" s, (total time " << chronoIteration.diff() <<
" s)." << std::endl;
237 std::cout << std::endl <<
" Simulation ended successfully in " << chronoTotal.diff() <<
" s" << std::endl;
240 std::cout <<
"MPI Finalization" << std::endl;
247 Int rightNodeID = oneDModel.solver()->boundaryDOF ( OneDFSI::right );
249 ok = ok && checkValue ( 0.999998 , (*oneDModel.solution (
"A") ) [rightNodeID]);
250 ok = ok && checkValue (-0.00138076, (*oneDModel.solution (
"Q") ) [rightNodeID]);
251 ok = ok && checkValue (-0.00276153, (*oneDModel.solution (
"W1") ) [rightNodeID]);
252 ok = ok && checkValue ( 0.00000000, (*oneDModel.solution (
"W2") ) [rightNodeID]);
254 ok = ok && checkValue ( 0.999999 , (*oneDModel.solution (
"A") ) [rightNodeID - 1]);
255 ok = ok && checkValue (-0.00040393, (*oneDModel.solution (
"Q") ) [rightNodeID - 1]);
256 ok = ok && checkValue (-0.00080833, (*oneDModel.solution (
"W1") ) [rightNodeID - 1]);
257 ok = ok && checkValue ( 0.00000045, (*oneDModel.solution (
"W2") ) [rightNodeID - 1]);
261 std::cout <<
"Test successful" << std::endl;
266 std::cout <<
"Test unsuccessful" << std::endl;
bc_Type & bc() const
Get the BC handler container of the boundary conditions of the model.
void start()
Start the timer.
solutionPtr_Type M_exporterSolution
void setBC(const bcSide_Type &bcSide, const bcLine_Type &bcLine, const bcType_Type &bcType, const bcFunction_Type &bcFunction)
Set a boundary condition.
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Sin(const Real mean=0, const Real scale=10, const Real period=.01, const Real phase=0.)
The constructor.
int32_type Int
Generic integer data.
void updateInverseJacobian(const UInt &iQuadPt)
int main(int argc, char **argv)
double Real
Generic real data.
bool checkValue(const Real val, const Real test, const Real tol=1.e-5, const bool verbose=true)
bool search(unsigned No, const char *P,...)
void stop()
Stop the timer.
GetPot(const STRING_VECTOR &FileNameList)
const std::string follow(const char *Default, unsigned No, const char *Option,...)
void setupModel()
Setup the model.