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> 69 #include <lifev/core/filter/PartitionIO.hpp> 71 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp> 73 #include <lifev/structure/solver/StructuralConstitutiveLaw.hpp> 74 #include <lifev/structure/solver/StructuralOperator.hpp> 75 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialLinear.hpp> 76 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialNonLinearPenalized.hpp> 77 #include <lifev/structure/solver/isotropic/ExponentialMaterialNonLinear.hpp> 78 #include <lifev/structure/solver/isotropic/NeoHookeanMaterialNonLinear.hpp> 79 #include <lifev/structure/solver/isotropic/SecondOrderExponentialMaterialNonLinear.hpp> 81 #include <lifev/structure/solver/anisotropic/StructuralAnisotropicConstitutiveLaw.hpp> 82 #include <lifev/structure/solver/anisotropic/HolzapfelMaterialNonLinear.hpp> 83 #include <lifev/structure/solver/anisotropic/HolzapfelGeneralizedMaterialNonLinear.hpp> 86 #include <lifev/core/filter/ExporterEnsight.hpp> 88 #include <lifev/core/filter/ExporterHDF5.hpp> 90 #include <lifev/core/filter/ExporterEmpty.hpp> 93 #include <lifev/eta/fem/ETFESpace.hpp> 101 using namespace LifeV;
115 std::string stringList = list;
116 std::set<UInt> setList;
122 while ( commaPos != std::string::npos )
124 commaPos = stringList.find (
"," );
125 setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
126 stringList = stringList.substr ( commaPos + 1 );
128 setList.insert ( atoi ( stringList.c_str() ) );
181 std::shared_ptr<Epetra_Comm> structComm );
244 Real pressure = 20000;
251 return pressure * ( y / radius );
254 return pressure * ( x / radius );
268 Real radius = std::sqrt ( x * x + y * y );
270 Real highestPressure ( 199950 );
271 Real totalTime = 4.5;
272 Real halfTime = totalTime / 2.0;
274 Real a = ( highestPressure / 2 ) * ( 1 / ( halfTime * halfTime ) );
278 pressure = a * t * t;
283 pressure = - a * (t - totalTime) * (t - totalTime) + highestPressure;
289 return pressure * ( x / radius ) ;
292 return pressure * ( y / radius ) ;
305 Real radius = std::sqrt ( x * x + y * y );
308 Real highestPressure ( 199950 );
310 Real totalTime = 9.0;
311 Real halfTime = totalTime / 2.0;
312 Real quarterTime = halfTime / 2.0;
314 Real aA = ( highestPressure / 2 ) * ( 1 / ( quarterTime * quarterTime ) );
315 Real aD = ( 2 * highestPressure ) * ( 1 / ( halfTime * halfTime ) );
317 if ( t <= quarterTime )
319 pressure = aA * t * t;
322 if ( t > quarterTime && t <= halfTime )
324 pressure = - aA * (t - halfTime) * (t - halfTime) + highestPressure;
327 if ( t > halfTime && t <= 3 * quarterTime )
329 pressure = - aD * (t - halfTime) * (t - halfTime) + highestPressure;
332 if ( t > 3 * quarterTime && t <= 4 * quarterTime )
334 pressure = aD * (t - totalTime) * (t - totalTime);
340 return pressure * ( x / radius ) ;
343 return pressure * ( y / radius ) ;
370 std::shared_ptr<Epetra_Comm> structComm) :
374 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
375 GetPot dataFile ( data_file_name );
376 parameters->data_file_name = data_file_name;
378 parameters->comm = structComm;
379 int ntasks = parameters->comm->NumProc();
381 if (!parameters->comm->MyPID() )
383 std::cout <<
"My PID = " << parameters->comm->MyPID() <<
" out of " << ntasks <<
" running." << std::endl;
392 std::cout <<
"2D cylinder test case is not available yet\n";
400 bool verbose = (parameters->comm->MyPID() == 0);
403 std::shared_ptr<BCHandler> BCh (
new BCHandler() );
406 GetPot dataFile ( parameters->data_file_name.c_str() );
408 std::shared_ptr<StructuralConstitutiveLawData> dataStructure (
new StructuralConstitutiveLawData( ) );
409 dataStructure->setup (dataFile);
414 const std::string partitioningMesh = dataFile (
"partitioningOffline/loadMesh",
"no");
417 std::shared_ptr<MeshPartitioner<mesh_Type> > meshPart;
418 std::shared_ptr<mesh_Type> pointerToMesh;
420 if ( ! (partitioningMesh.compare (
"no") ) )
422 std::shared_ptr<mesh_Type > fullMeshPtr (
new mesh_Type ( ( parameters->comm ) ) );
425 meshData.setup (dataFile,
"solid/space_discretization");
426 readMesh (*fullMeshPtr, meshData);
428 meshPart.reset (
new MeshPartitioner<mesh_Type> (fullMeshPtr, parameters->comm ) );
430 pointerToMesh = meshPart->meshPartition();
435 const std::string partsFileName (dataFile (
"partitioningOffline/hdf5_file_name",
"NO_DEFAULT_VALUE.h5") );
438 std::shared_ptr<Epetra_MpiComm> mpiComm =
439 std::dynamic_pointer_cast<Epetra_MpiComm> (parameters->comm);
441 PartitionIO<mesh_Type> partitionIO (partsFileName, mpiComm);
444 partitionIO.read (pointerToMesh);
448 std::string dOrder = dataFile (
"solid/space_discretization/order",
"P1");
451 solidFESpacePtr_Type dFESpace (
new solidFESpace_Type (pointerToMesh, dOrder, 3, parameters->comm) );
452 solidFESpacePtr_Type dScalarFESpace (
new solidFESpace_Type (pointerToMesh, dOrder, 1, parameters->comm) );
453 solidETFESpacePtr_Type dETFESpace (
new solidETFESpace_Type (pointerToMesh, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
457 (*pointerToVectorOfFamilies).resize( dataStructure->numberFibersFamilies( ) );
460 fiberDirections.resize( dataStructure->numberFibersFamilies( ) );
463 std::cout <<
"Size of the number of families: " << (*pointerToVectorOfFamilies).size() << std::endl;
466 setOfFiberFunctions.setupFiberDefinitions( dataStructure->numberFibersFamilies( ) );
470 std::cout << std::endl;
473 std::string timeAdvanceMethod = dataFile (
"solid/time_discretization/method",
"BDF");
475 timeAdvance_Type timeAdvance ( TimeAdvanceFactory::instance().createObject ( timeAdvanceMethod ) );
479 timeAdvance->setup (dataStructure->dataTimeAdvance()->orderBDF() , OrderDev);
481 timeAdvance->setTimeStep (dataStructure->dataTime()->timeStep() );
487 std::vector <ID> compx (1), compy (1), compz (1), compxy (2), compxz (2), compyz (2);
489 compy[0] = 1, compz[0] = 2;
497 BCFunctionBase zero (bcZero);
498 BCFunctionBase nonZero;
499 BCFunctionBase pressure;
501 nonZero.setFunction (bcNonZero);
502 pressure.setFunction (smoothPressure);
507 BCh->addBC (
"EdgesIn", 20, Natural, Component, nonZero, compy);
508 BCh->addBC (
"EdgesIn", 40, Essential, Component, zero, compy);
511 BCh->addBC (
"EdgesIn", 50, EssentialVertices, Component, zero, compxy);
512 BCh->addBC (
"EdgesIn", 30, EssentialVertices, Component, zero, compyz);
513 BCh->addBC (
"EdgesIn", 80, EssentialVertices, Component, zero, compxz);
514 BCh->addBC (
"EdgesIn", 100, EssentialVertices, Full, zero, 3);
516 BCh->addBC (
"EdgesIn", 7, Essential, Component , zero, compx);
517 BCh->addBC (
"EdgesIn", 3, Essential, Component , zero, compz);
543 StructuralOperator< RegionMesh<LinearTetra> > solid;
546 solid.setup (dataStructure,
553 solid.setDataFromGetPot (dataFile);
556 for( UInt k(1); k <= pointerToVectorOfFamilies->size( ); k++ )
559 std::string family=
"Family";
561 std::string familyNumber;
562 std::ostringstream number;
564 familyNumber = number.str();
567 std::string creationString = family + familyNumber;
568 (*pointerToVectorOfFamilies)[ k-1 ].reset(
new fiberFunction_Type() );
569 (*pointerToVectorOfFamilies)[ k-1 ] = setOfFiberFunctions.fiberDefinition( creationString );
571 fiberDirections[ k-1 ].reset(
new vector_Type(solid.displacement(), Unique) );
574 thetaSection.reset(
new vector_Type( dScalarFESpace->map() ) );
576 thetaRotation.reset(
new vector_Type( dScalarFESpace->map() ) );
579 positionCenterVector.reset(
new vector_Type( dFESpace->map() ) );
582 localPositionVector.reset(
new vector_Type( dFESpace->map() ) );
585 if( !dataStructure->constitutiveLaw().compare(
"anisotropic") )
586 solid.material()->anisotropicLaw()->setupFiberDirections( pointerToVectorOfFamilies );
589 double timeAdvanceCoefficient = timeAdvance->coefficientSecondDerivative ( 0 ) / (dataStructure->dataTime()->timeStep() * dataStructure->dataTime()->timeStep() );
590 solid.buildSystem (timeAdvanceCoefficient);
598 vectorPtr_Type rhs (
new vector_Type (solid.displacement(), Unique) );
599 vectorPtr_Type disp (
new vector_Type (solid.displacement(), Unique) );
600 vectorPtr_Type vel (
new vector_Type (solid.displacement(), Unique) );
601 vectorPtr_Type acc (
new vector_Type (solid.displacement(), Unique) );
605 std::cout <<
"S- initialization ... ";
610 std::string
const restart = dataFile (
"importer/restart",
"none");
611 std::vector<vectorPtr_Type> solutionStencil;
612 solutionStencil.resize ( timeAdvance->size() );
614 std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > importerSolid;
616 if ( restart.compare (
"none" ) )
619 std::string
const importerType = dataFile (
"importer/type",
"ensight");
620 std::string
const fileName = dataFile (
"importer/filename",
"structure");
621 std::string
const initialLoaded = dataFile (
"importer/initialSol",
"NO_DEFAULT_VALUE");
626 if ( !importerType.compare (
"hdf5") )
628 importerSolid.reset (
new hdf5Filter_Type ( dataFile, fileName) );
633 if ( !importerType.compare (
"none") )
635 importerSolid.reset (
new emptyExporter_Type ( dataFile, dFESpace->mesh(),
"solid", dFESpace->map().comm().MyPID() ) );
639 importerSolid.reset (
new ensightFilter_Type ( dataFile, fileName) );
643 importerSolid->setMeshProcId (dFESpace->mesh(), dFESpace->map().comm().MyPID() );
655 vectorPtr_Type solidDisp (
new vector_Type (dFESpace->map(), importerSolid->mapType() ) );
657 std::string iterationString;
663 iterationString = initialLoaded;
664 for (UInt iterInit = 0; iterInit < timeAdvance->size(); iterInit++ )
669 solidDisp.reset (
new vector_Type (solid.displacement(), Unique ) );
672 LifeV::ExporterData<mesh_Type> solidDataReader (LifeV::ExporterData<mesh_Type>::VectorField, std::string (
"displacement." + iterationString), dFESpace, solidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
674 importerSolid->readVariable (solidDataReader);
684 solutionStencil[ iterInit ] = solidDisp;
689 solid.initialize ( solidDisp );
693 int iterations = std::atoi (iterationString.c_str() );
696 std::ostringstream iter;
698 iter << std::setw (5) << ( iterations );
699 iterationString = iter.str();
703 importerSolid->closeFile();
706 timeAdvance->setInitialCondition (solutionStencil);
715 vectorPtr_Type disp (
new vector_Type (solid.displacement(), Unique) );
717 for ( UInt previousPass = 0; previousPass < timeAdvance->size() ; previousPass++)
719 solutionStencil[ previousPass ] = disp;
722 timeAdvance->setInitialCondition (solutionStencil);
725 solid.initialize ( disp );
729 timeAdvance->setTimeStep ( dataStructure->dataTime()->timeStep() );
731 timeAdvance->updateRHSContribution ( dataStructure->dataTime()->timeStep() );
733 MPI_Barrier (MPI_COMM_WORLD);
737 std::cout <<
"ok." << std::endl;
740 std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporterSolid;
742 std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporterCheck;
745 std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporter;
747 std::string
const exporterType = dataFile (
"exporter/type",
"ensight");
748 std::string
const exportFileName = dataFile (
"exporter/nameFile",
"structure");
750 if (exporterType.compare (
"hdf5") == 0)
752 exporter.reset (
new ExporterHDF5<RegionMesh<LinearTetra> > ( dataFile, exportFileName ) );
757 if (exporterType.compare (
"none") == 0)
759 exporter.reset (
new ExporterEmpty<RegionMesh<LinearTetra> > ( dataFile, pointerToMesh, exportFileName, parameters->comm->MyPID() ) );
764 exporter.reset (
new ExporterEnsight<RegionMesh<LinearTetra> > ( dataFile, pointerToMesh, exportFileName, parameters->comm->MyPID() ) );
768 exporter->setPostDir (
"./" );
769 exporter->setMeshProcId ( pointerToMesh, parameters->comm->MyPID() );
771 vectorPtr_Type solidDisp (
new vector_Type (solid.displacement(), exporter->mapType() ) );
772 vectorPtr_Type solidVel (
new vector_Type (solid.displacement(), exporter->mapType() ) );
773 vectorPtr_Type solidAcc (
new vector_Type (solid.displacement(), exporter->mapType() ) );
774 vectorPtr_Type rhsVector (
new vector_Type (solid.displacement(), exporter->mapType() ) );
776 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"displacement", dFESpace, solidDisp, UInt (0) );
777 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"velocity", dFESpace, solidVel, UInt (0) );
778 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"acceleration", dFESpace, solidAcc, UInt (0) );
779 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"forcingTerm", dFESpace, rhsVector, UInt (0) );
781 if( !dataStructure->constitutiveLaw().compare(
"anisotropic") )
785 for( UInt k(1); k <= pointerToVectorOfFamilies->size( ); k++ )
788 std::string family=
"Family-";
790 std::string familyNumber;
791 std::ostringstream number;
793 familyNumber = number.str();
796 std::string creationString = family + familyNumber;
797 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationString, dFESpace, fiberDirections[ k-1 ], UInt (0) );
800 *(fiberDirections[ k-1 ]) = solid.material()->anisotropicLaw()->ithFiberVector( k );
804 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField,
"thetaSection", dScalarFESpace, thetaSection, UInt (0) );
805 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField,
"thetaRotation", dScalarFESpace, thetaRotation, UInt (0) );
806 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"positionCenter", dFESpace, positionCenterVector, UInt (0) );
807 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"localPosition", dFESpace, localPositionVector, UInt (0) );
809 dScalarFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type>( thetaFunction ),
813 dScalarFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type>( thetaRotationFunction ),
817 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type>( positionCenter ),
818 *positionCenterVector,
821 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type>( localPosition ),
822 *localPositionVector,
825 exporter->postProcess ( dataStructure->dataTime()->initialTime() );
826 std::cout.precision(16);
831 Real initialTime = dataStructure->dataTime()->initialTime();
832 Real dt = dataStructure->dataTime()->timeStep();
833 Real T = dataStructure->dataTime()->endTime();
836 UInt tol = dataStructure->dataTimeAdvance()->orderBDF() + 1;
837 UInt saveEvery = dataFile
( "exporter/saveEvery", 1
);
846 for (
Real time = initialTime + dt; time <= T; time += dt)
848 dataStructure->dataTime()->setTime( time );
852 std::cout << std::endl;
853 std::cout <<
"S- Now we are at time " << dataStructure->dataTime()->time() <<
" s." << std::endl;
858 timeAdvance->updateRHSContribution ( dt );
859 *rhs += *solid.massMatrix() * timeAdvance->rhsContributionSecondDerivative() / timeAdvanceCoefficient;
860 solid.setRightHandSide ( *rhs );
863 solid.iterate ( BCh );
865 timeAdvance->shiftRight ( solid.displacement() );
867 *solidDisp = solid.displacement();
868 *solidVel = timeAdvance->firstDerivative();
869 *solidAcc = timeAdvance->secondDerivative();
872 *rhsVector = solid.rhsCopy();
876 r = iter % saveEvery;
879 std::cout <<
"First component displacement at ID = "<< IDPoint <<
": " << solid.displacement()[ IDPoint - 1 ] << std::endl;
880 std::cout <<
"Second component displacement at ID = "<< IDPoint <<
": " <<
881 solid.displacement()[ IDPoint - 1 + dFESpace->dof().numTotalDof() ] << std::endl;
882 std::cout <<
"Third component displacement at ID = "<< IDPoint <<
": " <<
883 solid.displacement()[ IDPoint - 1 + 2 * dFESpace->dof().numTotalDof() ] << std::endl;
886 if ( (iter - d) <= tol || ( (std::floor(d/saveEvery) + 1)*saveEvery - iter ) <= tol )
888 exporter->postProcess( time );
894 MPI_Barrier (MPI_COMM_WORLD);
903 MPI_Init (&argc, &argv);
904 std::shared_ptr<Epetra_MpiComm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
905 if ( Comm->MyPID() == 0 )
907 std::cout <<
"% using MPI" << std::endl;
910 std::shared_ptr<Epetra_SerialComm> Comm (
new Epetra_SerialComm() );
911 std::cout <<
"% using serial Version" << std::endl;
914 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)
static Real mergingPressures(const Real &t, const Real &x, const Real &y, const Real &, const ID &i)
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > fct_type
LifeV::ExporterEnsight< mesh_Type > ensightFilter_Type
LifeV::Exporter< mesh_Type > filter_Type
filterPtr_Type importerSolid
std::shared_ptr< fiberFunction_Type > fiberFunctionPtr_Type
static const LifeV::UInt elm_nodes_num[]
filterPtr_Type exporterSolid
std::shared_ptr< hdf5Filter_Type > hdf5FilterPtr_Type
FESpace< RegionMesh< LinearTetra >, MapEpetra > solidFESpace_Type
static Real bcZero(const Real &, const Real &, const Real &, const Real &, const ID &)
void run3d()
run the 3D driven cylinder simulation
ETFESpace< RegionMesh< LinearTetra >, MapEpetra, 3, 3 > solidETFESpace_Type
LifeV::RegionMesh< LinearTetra > mesh_Type
std::string data_file_name
void run2d()
run the 2D driven cylinder simulation
std::shared_ptr< ensightFilter_Type > ensightFilterPtr_Type
MeshData - class for handling spatial discretization.
LifeV::ExporterEmpty< mesh_Type > emptyExporter_Type
std::shared_ptr< Private > parameters
std::shared_ptr< vector_Type > vectorPtr_Type
double Real
Generic real data.
static Real bcNonZero(const Real &, const Real &, const Real &, const Real &, const ID &)
std::shared_ptr< emptyExporter_Type > emptyExporterPtr_Type
static Real pressureUsingNormal(const Real &, const Real &, const Real &, const Real &, const ID &)
std::set< UInt > parseList(const std::string &list)
static Real bcPressure(const Real &, const Real &x, const Real &y, const Real &, const ID &i)
int operator()(const char *VarName, int Default) const
std::shared_ptr< solidETFESpace_Type > solidETFESpacePtr_Type
std::shared_ptr< LifeV::Exporter< mesh_Type > > filterPtr_Type
static Real smoothPressure(const Real &t, const Real &x, const Real &y, const Real &, const ID &i)
std::shared_ptr< TimeAdvance< vector_Type > > timeAdvance_Type
std::vector< vectorPtr_Type > listOfFiberDirections_Type
StructuralOperator< RegionMesh< LinearTetra > >::vector_Type vector_Type
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