39 #error test_structure cannot be compiled in 2D
43 #pragma GCC diagnostic ignored "-Wunused-variable" 44 #pragma GCC diagnostic ignored "-Wunused-parameter" 46 #include <Epetra_ConfigDefs.h> 49 #include <Epetra_MpiComm.h> 51 #include <Epetra_SerialComm.h> 55 #pragma GCC diagnostic warning "-Wunused-variable" 56 #pragma GCC diagnostic warning "-Wunused-parameter" 58 #include <lifev/core/LifeV.hpp> 59 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 60 #include <lifev/core/algorithm/PreconditionerML.hpp> 62 #include <lifev/core/array/MapEpetra.hpp> 64 #include <lifev/core/fem/TimeAdvance.hpp> 65 #include <lifev/core/fem/TimeAdvanceBDF.hpp> 67 #include <lifev/core/mesh/MeshData.hpp> 68 #include <lifev/core/mesh/MeshPartitioner.hpp> 70 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp> 72 #include <lifev/structure/solver/StructuralConstitutiveLaw.hpp> 73 #include <lifev/structure/solver/StructuralOperator.hpp> 74 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialLinear.hpp> 75 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialNonLinear.hpp> 76 #include <lifev/structure/solver/isotropic/ExponentialMaterialNonLinear.hpp> 77 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialNonLinearPenalized.hpp> 78 #include <lifev/structure/solver/isotropic/SecondOrderExponentialMaterialNonLinear.hpp> 79 #include <lifev/structure/solver/isotropic/NeoHookeanMaterialNonLinear.hpp> 82 #include <lifev/structure/solver/anisotropic/StructuralAnisotropicConstitutiveLaw.hpp> 83 #include <lifev/structure/solver/anisotropic/HolzapfelMaterialNonLinear.hpp> 84 #include <lifev/structure/solver/anisotropic/DistributedHolzapfelMaterialNonLinear.hpp> 87 #include <lifev/core/filter/ExporterEnsight.hpp> 89 #include <lifev/core/filter/ExporterHDF5.hpp> 91 #include <lifev/core/filter/ExporterEmpty.hpp> 94 #include <lifev/eta/fem/ETFESpace.hpp> 102 using namespace LifeV;
116 std::string stringList = list;
117 std::set<UInt> setList;
123 while ( commaPos != std::string::npos )
125 commaPos = stringList.find (
"," );
126 setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
127 stringList = stringList.substr ( commaPos + 1 );
129 setList.insert ( atoi ( stringList.c_str() ) );
163 std::shared_ptr<Epetra_Comm> structComm );
216 std::shared_ptr<Epetra_Comm> structComm) :
220 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
221 GetPot dataFile ( data_file_name );
222 parameters->data_file_name = data_file_name;
224 parameters->comm = structComm;
225 int ntasks = parameters->comm->NumProc();
227 if (!parameters->comm->MyPID() )
229 std::cout <<
"My PID = " << parameters->comm->MyPID() <<
" out of " << ntasks <<
" running." << std::endl;
238 std::cout <<
"2D cylinder test case is not available yet\n";
246 bool verbose = (parameters->comm->MyPID() == 0);
249 std::shared_ptr<BCHandler> BCh (
new BCHandler() );
252 GetPot dataFile ( parameters->data_file_name.c_str() );
254 std::shared_ptr<StructuralConstitutiveLawData> dataStructure (
new StructuralConstitutiveLawData( ) );
255 dataStructure->setup (dataFile);
257 dataStructure->showMe();
260 meshData.setup (dataFile,
"solid/space_discretization");
262 std::shared_ptr<RegionMesh<LinearTetra> > fullMeshPtr (
new RegionMesh<LinearTetra> ( parameters->comm ) );
263 std::shared_ptr<RegionMesh<LinearTetra> > localMeshPtr (
new RegionMesh<LinearTetra> ( parameters->comm ) );
264 readMesh (*fullMeshPtr, meshData);
266 MeshPartitioner< RegionMesh<LinearTetra> > meshPart ( fullMeshPtr, parameters->comm );
267 localMeshPtr = meshPart.meshPartition();
269 std::string dOrder = dataFile (
"solid/space_discretization/order",
"P1");
272 solidFESpacePtr_Type dFESpace (
new solidFESpace_Type (localMeshPtr, dOrder, 3, parameters->comm) );
273 solidETFESpacePtr_Type dETFESpace (
new solidETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
277 (*pointerToVectorOfFamilies).resize( dataStructure->numberFibersFamilies( ) );
280 fiberDirections.resize( dataStructure->numberFibersFamilies( ) );
282 std::cout <<
"Size of the number of families: " << (*pointerToVectorOfFamilies).size() << std::endl;
285 setOfFiberFunctions.setupFiberDefinitions( dataStructure->numberFibersFamilies( ) );
289 std::cout << std::endl;
292 std::string timeAdvanceMethod = dataFile (
"solid/time_discretization/method",
"BDF");
294 timeAdvance_Type timeAdvance ( TimeAdvanceFactory::instance().createObject ( timeAdvanceMethod ) );
298 timeAdvance->setup (dataStructure->dataTimeAdvance()->orderBDF() , OrderDev);
300 timeAdvance->setTimeStep (dataStructure->dataTime()->timeStep() );
306 std::vector <ID> compx (1), compy (1), compz (1), compxy (2), compxz (2), compyz (2);
308 compy[0] = 1, compz[0] = 2;
316 BCFunctionBase zero (bcZero);
317 BCFunctionBase nonZero;
319 nonZero.setFunction (bcNonZero);
324 BCh->addBC (
"EdgesIn", 20, Natural, Component, nonZero, compy);
325 BCh->addBC (
"EdgesIn", 40, Essential, Component, zero, compy);
328 BCh->addBC (
"EdgesIn", 50, EssentialVertices, Component, zero, compxy);
329 BCh->addBC (
"EdgesIn", 30, EssentialVertices, Component, zero, compyz);
330 BCh->addBC (
"EdgesIn", 80, EssentialVertices, Component, zero, compxz);
331 BCh->addBC (
"EdgesIn", 100, EssentialVertices, Full, zero, 3);
333 BCh->addBC (
"EdgesIn", 7, Essential, Component , zero, compx);
334 BCh->addBC (
"EdgesIn", 3, Essential, Component , zero, compz);
338 StructuralOperator< RegionMesh<LinearTetra> > solid;
341 solid.setup (dataStructure,
348 solid.setDataFromGetPot (dataFile);
351 for( UInt k(1); k <= pointerToVectorOfFamilies->size( ); k++ )
354 std::string family=
"Family";
356 std::string familyNumber;
357 std::ostringstream number;
359 familyNumber = number.str();
362 std::string creationString = family + familyNumber;
363 (*pointerToVectorOfFamilies)[ k-1 ].reset(
new fiberFunction_Type() );
364 (*pointerToVectorOfFamilies)[ k-1 ] = setOfFiberFunctions.fiberDefinition( creationString );
366 fiberDirections[ k-1 ].reset(
new vector_Type(solid.displacement(), Unique) );
370 solid.material()->anisotropicLaw()->setupFiberDirections( pointerToVectorOfFamilies );
373 double timeAdvanceCoefficient = timeAdvance->coefficientSecondDerivative ( 0 ) / (dataStructure->dataTime()->timeStep() * dataStructure->dataTime()->timeStep() );
374 solid.buildSystem (timeAdvanceCoefficient);
383 Real dt = dataStructure->dataTime()->timeStep();
385 vectorPtr_Type rhs (
new vector_Type (solid.displacement(), Unique) );
386 vectorPtr_Type disp (
new vector_Type (solid.displacement(), Unique) );
387 vectorPtr_Type vel (
new vector_Type (solid.displacement(), Unique) );
388 vectorPtr_Type acc (
new vector_Type (solid.displacement(), Unique) );
392 std::cout <<
"S- initialization ... ";
395 std::vector<vectorPtr_Type> uv0;
397 if (timeAdvanceMethod ==
"Newmark")
399 uv0.push_back (disp);
404 vectorPtr_Type initialDisplacement (
new vector_Type (solid.displacement(), Unique) );
406 if ( !dataStructure->solidTypeIsotropic().compare (
"secondOrderExponential") )
408 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type> ( d0 ), *initialDisplacement, 0.0 );
411 if (timeAdvanceMethod ==
"BDF")
413 Real tZero = dataStructure->dataTime()->initialTime();
415 for ( UInt previousPass = 0; previousPass < timeAdvance->size() ; previousPass++)
417 Real previousTimeStep = tZero - previousPass * dt;
418 std::cout <<
"BDF " << previousTimeStep <<
"\n";
419 if ( !dataStructure->solidTypeIsotropic().compare (
"secondOrderExponential") )
421 uv0.push_back (initialDisplacement);
425 uv0.push_back (disp);
430 timeAdvance->setInitialCondition (uv0);
432 timeAdvance->setTimeStep ( dt );
434 timeAdvance->updateRHSContribution ( dt );
436 if ( !dataStructure->solidTypeIsotropic().compare (
"secondOrderExponential") )
438 solid.initialize ( initialDisplacement );
442 solid.initialize ( disp );
445 MPI_Barrier (MPI_COMM_WORLD);
449 std::cout <<
"ok." << std::endl;
452 std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporter;
454 std::string
const exporterType = dataFile (
"exporter/type",
"ensight");
456 if (exporterType.compare (
"hdf5") == 0)
458 exporter.reset (
new ExporterHDF5<RegionMesh<LinearTetra> > ( dataFile,
"structure" ) );
463 if (exporterType.compare (
"none") == 0)
465 exporter.reset (
new ExporterEmpty<RegionMesh<LinearTetra> > ( dataFile, meshPart.meshPartition(),
"structure", parameters->comm->MyPID() ) );
470 exporter.reset (
new ExporterEnsight<RegionMesh<LinearTetra> > ( dataFile, meshPart.meshPartition(),
"structure", parameters->comm->MyPID() ) );
474 exporter->setPostDir (
"./" );
475 exporter->setMeshProcId ( meshPart.meshPartition(), parameters->comm->MyPID() );
477 vectorPtr_Type solidDisp (
new vector_Type (solid.displacement(), exporter->mapType() ) );
478 vectorPtr_Type solidVel (
new vector_Type (solid.displacement(), exporter->mapType() ) );
479 vectorPtr_Type solidAcc (
new vector_Type (solid.displacement(), exporter->mapType() ) );
482 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"displacement", dFESpace, solidDisp, UInt (0) );
483 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"velocity", dFESpace, solidVel, UInt (0) );
484 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"acceleration", dFESpace, solidAcc, UInt (0) );
489 for( UInt k(1); k <= pointerToVectorOfFamilies->size( ); k++ )
492 std::string family=
"Family-";
494 std::string familyNumber;
495 std::ostringstream number;
497 familyNumber = number.str();
500 std::string creationString = family + familyNumber;
501 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationString, dFESpace, fiberDirections[ k-1 ], UInt (0) );
504 *(fiberDirections[ k-1 ]) = solid.material()->anisotropicLaw()->ithFiberVector( k );
508 exporter->postProcess ( 0 );
509 std::cout.precision(16);
553 normVect = solid.displacement().norm2();
557 std::cout <<
"The norm 2 of the displacement field is: " << normVect << std::endl;
564 for (dataStructure->dataTime()->setTime ( dt ) ; dataStructure->dataTime()->canAdvance( ); dataStructure->dataTime()->updateTime( ) )
566 returnValue = EXIT_FAILURE;
570 std::cout << std::endl;
571 std::cout <<
"S- Now we are at time " << dataStructure->dataTime()->time() <<
" s." << std::endl;
576 timeAdvance->updateRHSContribution ( dt );
577 *rhs += *solid.massMatrix() * timeAdvance->rhsContributionSecondDerivative() / timeAdvanceCoefficient;
578 solid.setRightHandSide ( *rhs );
581 solid.iterate ( BCh );
583 timeAdvance->shiftRight ( solid.displacement() );
585 *solidDisp = solid.displacement();
586 *solidVel = timeAdvance->firstDerivative();
587 *solidAcc = timeAdvance->secondDerivative();
592 exporter->postProcess ( dataStructure->dataTime()->time() );
617 normVect = solid.displacement().norm2();
618 std::cout <<
"The norm 2 of the displacement field is: " << normVect << std::endl;
621 if ( !dataStructure->solidTypeAnisotropic().compare (
"holzapfel") )
622 CheckResultHolzapfelModel (normVect, dataStructure->dataTime()->time() );
624 CheckResultDistributedModel (normVect, dataStructure->dataTime()->time() );
628 MPI_Barrier (MPI_COMM_WORLD);
635 if ( time == 0.05 && std::fabs (dispNorm - 0.84960668) <= 1e-7 )
639 if ( time == 0.1 && std::fabs (dispNorm - 0.84981715) <= 1e-7 )
647 if ( time == 0.05 && std::fabs (dispNorm - 1.7747561302) <= 1e-7 )
651 if ( time == 0.1 && std::fabs (dispNorm - 1.7757263996) <= 1e-7 )
659 std::cout <<
"Correct value at time: " << time << std::endl;
670 MPI_Init (&argc, &argv);
671 std::shared_ptr<Epetra_MpiComm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
672 if ( Comm->MyPID() == 0 )
674 std::cout <<
"% using MPI" << std::endl;
677 std::shared_ptr<Epetra_SerialComm> Comm (
new Epetra_SerialComm() );
678 std::cout <<
"% using serial Version" << std::endl;
681 Structure structure ( argc, argv, Comm );
std::shared_ptr< Epetra_Comm > comm
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
Structure(int argc, char **argv, std::shared_ptr< Epetra_Comm > structComm)
int main(int argc, char **argv)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
std::shared_ptr< fiberFunction_Type > fiberFunctionPtr_Type
static const LifeV::UInt elm_nodes_num[]
std::shared_ptr< hdf5Filter_Type > hdf5FilterPtr_Type
FESpace< RegionMesh< LinearTetra >, MapEpetra > solidFESpace_Type
void run3d()
run the 3D driven cylinder simulation
ETFESpace< RegionMesh< LinearTetra >, MapEpetra, 3, 3 > solidETFESpace_Type
std::string data_file_name
void run2d()
run the 2D driven cylinder simulation
MeshData - class for handling spatial discretization.
void CheckResultDistributedModel(const Real &dispNorm, const Real &time)
std::shared_ptr< Private > parameters
std::shared_ptr< vector_Type > vectorPtr_Type
double Real
Generic real data.
std::set< UInt > parseList(const std::string &list)
std::shared_ptr< solidETFESpace_Type > solidETFESpacePtr_Type
std::shared_ptr< TimeAdvance< vector_Type > > timeAdvance_Type
std::vector< vectorPtr_Type > listOfFiberDirections_Type
void resultChanged(Real time)
StructuralOperator< RegionMesh< LinearTetra > >::vector_Type vector_Type
void CheckResultHolzapfelModel(const Real &dispNorm, const Real &time)
std::shared_ptr< solidFESpace_Type > solidFESpacePtr_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
std::shared_ptr< vectorFiberFunction_Type > vectorFiberFunctionPtr_Type
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > fiberFunction_Type
std::vector< fiberFunctionPtr_Type > vectorFiberFunction_Type