33 #error test_structure cannot be compiled in 2D
37 #pragma GCC diagnostic ignored "-Wunused-variable" 38 #pragma GCC diagnostic ignored "-Wunused-parameter" 40 #include <Epetra_ConfigDefs.h> 43 #include <Epetra_MpiComm.h> 45 #include <Epetra_SerialComm.h> 49 #pragma GCC diagnostic warning "-Wunused-variable" 50 #pragma GCC diagnostic warning "-Wunused-parameter" 52 #include <lifev/core/LifeV.hpp> 54 #include <lifev/core/array/MapEpetra.hpp> 56 #include <lifev/core/mesh/MeshData.hpp> 57 #include <lifev/core/mesh/MeshPartitioner.hpp> 59 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp> 60 #include <lifev/structure/solver/StructuralOperator.hpp> 62 #include <lifev/structure/solver/WallTensionEstimator.hpp> 63 #include <lifev/structure/solver/WallTensionEstimatorData.hpp> 65 #include <lifev/core/filter/ExporterEnsight.hpp> 67 #include <lifev/core/filter/ExporterHDF5.hpp> 69 #include <lifev/core/filter/ExporterEmpty.hpp> 74 using namespace LifeV;
80 std::string stringList = list;
81 std::set<UInt> setList;
87 while ( commaPos != std::string::npos )
89 commaPos = stringList.find (
"," );
90 setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
91 stringList = stringList.substr ( commaPos + 1 );
93 setList.insert ( atoi ( stringList.c_str() ) );
129 std::shared_ptr<Epetra_Comm> structComm );
193 return - 0.018374999999251 * ( x - 0.5 );
196 return 0.074999999996944 / 2.0 * ( y );
199 return - 0.018374999999251 * ( z + 0.5 );
202 ERROR_MSG (
"This entry is not allowed: ud_functions.hpp");
214 return - 0.0179039 * ( x - 0.5 );
217 return 0.07115742 / 2.0 * ( y );
220 return - 0.0179039 * ( z + 0.5 );
223 ERROR_MSG (
"This entry is not allowed: ud_functions.hpp");
234 return - 0.01649141 * ( x - 0.5 );
237 return 0.069238236 / 2.0 * ( y );
240 return - 0.01649141 * ( z + 0.5 );
243 ERROR_MSG (
"This entry is not allowed: ud_functions.hpp");
254 return - 0.018542821 * ( x - 0.5 );
257 return 0.077904116 / 2.0 * ( y );
260 return - 0.018542821 * ( z + 0.5 );
263 ERROR_MSG (
"This entry is not allowed: ud_functions.hpp");
274 return - 0.055120902 * ( x - 0.5 );
277 return 0.240591303 / 2.0 * ( y );
280 return - 0.055120902 * ( z + 0.5 );
283 ERROR_MSG (
"This entry is not allowed: ud_functions.hpp");
299 std::shared_ptr<Epetra_Comm> structComm) :
303 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
304 GetPot dataFile ( data_file_name );
305 parameters->data_file_name = data_file_name;
307 parameters->comm = structComm;
308 int ntasks = parameters->comm->NumProc();
310 if (!parameters->comm->MyPID() )
312 std::cout <<
"My PID = " << parameters->comm->MyPID() <<
" out of " << ntasks <<
" running." << std::endl;
321 std::cout <<
"2D cylinder test case is not available yet\n";
330 typedef WallTensionEstimator< mesh_Type >::solutionVect_Type vector_Type;
331 typedef std::shared_ptr<vector_Type> vectorPtr_Type;
333 typedef std::shared_ptr<solidFESpace_Type> solidFESpacePtr_Type;
335 typedef ETFESpace< RegionMesh<LinearTetra>, MapEpetra, 3, 3 > solidETFESpace_Type;
336 typedef std::shared_ptr<solidETFESpace_Type> solidETFESpacePtr_Type;
340 std::shared_ptr<BCHandler> BCh (
new BCHandler() );
343 bool verbose = (parameters->comm->MyPID() == 0);
346 GetPot dataFile ( parameters->data_file_name.c_str() );
348 std::shared_ptr<StructuralConstitutiveLawData> dataStructure (
new StructuralConstitutiveLawData( ) );
349 dataStructure->setup (dataFile);
352 std::shared_ptr<WallTensionEstimatorData> tensionData (
new WallTensionEstimatorData( ) );
353 tensionData->setup (dataFile);
355 tensionData->showMe();
358 meshData.setup (dataFile,
"solid/space_discretization");
361 std::shared_ptr<mesh_Type > fullMeshPtr (
new RegionMesh<LinearTetra> ( ( parameters->comm ) ) );
362 std::shared_ptr<mesh_Type > localMeshPtr (
new RegionMesh<LinearTetra> ( ( parameters->comm ) ) );
364 readMesh (*fullMeshPtr, meshData);
367 localMeshPtr = meshPart.meshPartition();
370 std::string dOrder = dataFile (
"solid/space_discretization/order",
"P1");
371 solidFESpacePtr_Type dFESpace (
new solidFESpace_Type (localMeshPtr, dOrder, 3, parameters->comm) );
372 solidETFESpacePtr_Type dETFESpace (
new solidETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
378 Real refElemArea (0);
380 for (UInt iq = 0; iq < dFESpace->qr().nbQuadPt(); iq++)
382 refElemArea += dFESpace->qr().weight (iq);
385 Real wQuad (refElemArea / dFESpace->refFE().nbDof() );
388 std::vector<GeoVector> coords = dFESpace->refFE().refCoor();
389 std::vector<Real> weights (dFESpace->fe().nbFEDof(), wQuad);
390 fakeQuadratureRule.setDimensionShape ( shapeDimension (dFESpace->refFE().shape() ), dFESpace->refFE().shape() );
391 fakeQuadratureRule.setPoints (coords, weights);
396 std::cout << std::endl;
401 UInt marker = dataFile
( "solid/physics/material_flag", 1
);
404 std::shared_ptr<WallTensionEstimator< mesh_Type > > solid (
new WallTensionEstimator< mesh_Type >() );
407 StructuralOperator< RegionMesh<LinearTetra> > solidOperator;
410 solid->setup (dataStructure,
418 solidOperator.setup (dataStructure,
425 std::string
const filename = tensionData->nameFile();
426 std::string
const importerType = tensionData->typeFile();
428 std::string iterationString;
432 std::cout <<
"The filename is : " << filename << std::endl;
433 std::cout <<
"The importerType is: " << importerType << std::endl;
437 if (importerType.compare (
"hdf5") == 0)
439 M_importer.reset (
new hdf5Filter_Type (dataFile, filename) );
444 if (importerType.compare (
"none") == 0)
446 M_importer.reset (
new emptyFilter_Type ( dataFile, solid->dFESpace().mesh(),
"solid", solid->dFESpace().map().comm().MyPID() ) );
450 M_importer.reset (
new ensightFilter_Type ( dataFile, filename ) );
453 M_importer->setMeshProcId (solid->dFESpace().mesh(), solid->dFESpace().map().comm().MyPID() );
456 vectorPtr_Type solidDisp (
new vector_Type (solid->dFESpace().map(), M_importer->mapType() ) );
460 std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporter;
462 std::string
const exporterType = dataFile (
"exporter/type",
"hdf5");
463 std::string
const nameExporter = dataFile (
"exporter/name",
"tensions");
466 if (exporterType.compare (
"hdf5") == 0)
468 M_exporter.reset (
new hdf5Filter_Type ( dataFile, nameExporter ) );
473 if (exporterType.compare (
"none") == 0)
475 M_exporter.reset (
new emptyFilter_Type ( dataFile, meshPart.meshPartition(), nameExporter, parameters->comm->MyPID() ) ) ;
480 M_exporter.reset (
new ensightFilter_Type ( dataFile, meshPart.meshPartition(), nameExporter, parameters->comm->MyPID() ) ) ;
484 M_exporter->setMeshProcId (solid->dFESpace().mesh(), solid->dFESpace().map().comm().MyPID() );
486 vectorPtr_Type solidTensions (
new vector_Type (solid->principalStresses(), M_exporter->mapType() ) );
488 vectorPtr_Type sigma_1;
489 vectorPtr_Type sigma_2;
490 vectorPtr_Type sigma_3;
497 vectorPtr_Type patchAreaVector;
498 vectorPtr_Type vectorEigenvalues;
501 sigma_1.reset(
new vector_Type( dFESpace->map() ) );
502 sigma_2.reset(
new vector_Type( dFESpace->map() ) );
503 sigma_3.reset(
new vector_Type( dFESpace->map() ) );
509 patchAreaVector.reset (
new vector_Type ( dETFESpace->map() ) );
510 vectorEigenvalues.reset(
new vector_Type( dFESpace->map() ) );
516 evaluateNode( elements ( dETFESpace->mesh() ),
520 ) >> patchAreaVector;
521 patchAreaVector->globalAssemble();
532 M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"eigenvalues", dFESpace, vectorEigenvalues, UInt (0) );
533 M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"vonMises", dFESpace, solidTensions, UInt (0) );
534 M_exporter->postProcess ( 0.0 );
573 MPI_Barrier (MPI_COMM_WORLD);
576 LifeV::Real dt = dataFile (
"solid/time_discretization/timestep", 0.0);
577 std::string
const nameField = dataFile (
"solid/analysis/nameField",
"NO_DEFAULT_VALUE");
579 if ( !tensionData->analysisType().compare (
"istant") )
582 iterationString = tensionData->iterStart (0);
583 LifeV::Real startTime = tensionData->initialTime (0);
586 if( !dataStructure->solidTypeIsotropic().compare(
"exponential") )
589 LifeV::ExporterData<
mesh_Type> solutionDispl (LifeV::ExporterData<mesh_Type>::VectorField, nameField +
"." + iterationString, dFESpace, solidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
592 M_importer->readVariable (solutionDispl);
593 M_importer->closeFile();
595 else if ( !dataStructure->solidTypeIsotropic().compare(
"linearVenantKirchhoff") )
597 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type> ( Private::displacementLinearElastic ),
600 else if ( !dataStructure->solidTypeIsotropic().compare(
"nonLinearVenantKirchhoff") )
602 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type> ( Private::displacementVenantKirchhoff ),
605 else if ( !dataStructure->solidTypeIsotropic().compare(
"nonLinearVenantKirchhoffPenalized") )
607 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type> ( Private::displacementVenantKirchhoffPenalized ),
610 else if ( !dataStructure->solidTypeIsotropic().compare(
"neoHookean") )
612 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type> ( Private::displacementNeoHookean ),
617 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type> ( Private::displacementSecondOrderExponential ),
621 solidOperator.computeCauchyStressTensor( solidDisp, fakeQuadratureRule, sigma_1, sigma_2, sigma_3 );
623 *sigma_1 = *sigma_1 / *patchAreaVector;
624 *sigma_2 = *sigma_2 / *patchAreaVector;
625 *sigma_3 = *sigma_3 / *patchAreaVector;
628 solidOperator.computePrincipalTensions( sigma_1, sigma_2, sigma_3, vectorEigenvalues );
643 solid->setDisplacement (*solidDisp);
645 std::cout <<
"The norm of the set displacement, at time " << startTime <<
", is: " << solid->displacement().norm2() << std::endl;
648 solid->analyzeTensions();
660 std::cout << std::endl;
661 std::cout <<
"Norm of the tension vector: " << solid->principalStresses().norm2() << std::endl;
662 std::cout <<
"Norm of the vector eigenvalues: " << vectorEigenvalues->norm2() << std::endl;
669 M_exporter->postProcess ( startTime );
673 std::cout <<
"Analysis Completed!" << std::endl;
678 if( !dataStructure->solidTypeIsotropic().compare(
"exponential") )
681 if ( !tensionData->recoveryVariable().compare (
"displacement") )
683 CheckResultDisplacement ( solid->principalStresses().norm2() );
685 else if ( !tensionData->recoveryVariable().compare (
"eigenvalues") )
687 CheckResultEigenvalues ( solid->principalStresses().norm2() );
691 CheckResultTensions ( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
695 else if ( !dataStructure->solidTypeIsotropic().compare(
"linearVenantKirchhoff") )
697 checkLinearElastic( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
699 else if ( !dataStructure->solidTypeIsotropic().compare(
"nonLinearVenantKirchhoff") )
701 checkVenantKirchhoff( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
703 else if ( !dataStructure->solidTypeIsotropic().compare(
"nonLinearVenantKirchhoffPenalized") )
705 checkVenantKirchhoffPenalized( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
707 else if ( !dataStructure->solidTypeIsotropic().compare(
"neoHookean") )
709 checkNeoHookean( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
713 check2ndOrderExponential( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
718 M_exporter->closeFile();
728 std::cout <<
"Work in progress! " << std::endl;
733 std::cout <<
"finished" << std::endl;
736 MPI_Barrier (MPI_COMM_WORLD);
742 if ( ( (std::fabs (tensNorm - 4.67086e6) / 4.67086e6) <= 1e-5 ) )
750 if ( ( (std::fabs (tensNorm - 4.67086e6) / 4.67086e6) <= 1e-5 ) )
758 if ( ( ( std::fabs (tensNorm - 4.67086e6) / 4.67086e6) <= 1e-5 ) &&
759 ( std::fabs ( testETA - 4.67086e6) / 4.67086e6) <= 1e-5 )
767 if ( ( ( std::fabs (tensNorm - 4.5e+6) / 4.5e+6) <= 1e-5 ) && ( ( std::fabs (testETA - 4.5e+6) / 4.5e+6) <= 1e-5 ) )
775 if ( ( ( std::fabs (tensNorm - 4.66588e+6) / 4.66588e+6) <= 1e-5 ) &&
776 ( ( std::fabs (testETA - 4.66588e+6) / 4.66588e+6) <= 1e-5 ) )
784 if ( ( ( std::fabs (tensNorm - 4.65222e+6) / 4.65222e+6) <= 1e-5 ) &&
785 ( ( std::fabs (testETA - 4.65222e+6) / 4.65222e+6) <= 1e-5 ) )
793 if ( ( ( std::fabs (tensNorm - 4.67165e+6) / 4.67165e+6) <= 1e-5 ) &&
794 ( ( std::fabs (testETA - 4.67165e+6) / 4.67165e+6) <= 1e-5 ) )
802 if ( ( ( std::fabs (testETA - 1.17608e+6) / 1.17608e+6) <= 1e-5 ) &&
803 ( ( std::fabs (tensNorm - 1.17608e+6) / 1.17608e+6) <= 1e-5 ) )
811 std::cout <<
"Correct Result after the Analysis" << std::endl;
821 MPI_Init (&argc, &argv);
822 std::shared_ptr<Epetra_MpiComm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
823 if ( Comm->MyPID() == 0 )
825 std::cout <<
"% using MPI" << std::endl;
828 std::shared_ptr<Epetra_SerialComm> Comm (
new Epetra_SerialComm() );
829 std::cout <<
"% using serial Version" << std::endl;
832 Structure structure ( argc, argv, Comm );
void checkVenantKirchhoffPenalized(const Real tensNorm, const Real testETA)
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)
class ExpressionEmult Class for representing the transpose operation of an expression ...
void checkNeoHookean(const Real tensNorm, const Real testETA)
std::shared_ptr< emptyFilter_Type > emptyFilterPtr_Type
FESpace - Short description here please!
void checkVenantKirchhoff(const Real tensNorm, const Real testETA)
int main(int argc, char **argv)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
void CheckResultDisplacement(const Real tensNorm)
static Real displacementLinearElastic(const Real &, const Real &x, const Real &y, const Real &z, 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
void check2ndOrderExponential(const Real tensNorm, const Real testETA)
void CheckResultEigenvalues(const Real tensNorm)
std::shared_ptr< hdf5Filter_Type > hdf5FilterPtr_Type
static Real displacementSecondOrderExponential(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
filterPtr_Type M_importer
LifeV::ExporterEmpty< mesh_Type > emptyFilter_Type
Epetra_Import const & importer()
Getter for the Epetra_Import.
static Real displacementNeoHookean(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
static Real displacementVenantKirchhoff(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
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
std::shared_ptr< std::vector< Int > > M_isOnProc
void run2d()
run the 2D driven cylinder simulation
void checkLinearElastic(const Real tensNorm, const Real testETA)
std::shared_ptr< ensightFilter_Type > ensightFilterPtr_Type
MeshData - class for handling spatial discretization.
std::shared_ptr< Private > parameters
ExpressionMeas - Expression for the measure of the element.
double Real
Generic real data.
std::set< UInt > parseList(const std::string &list)
filterPtr_Type M_exporter
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 displacementVenantKirchhoffPenalized(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
QuadratureRule - The basis class for storing and accessing quadrature rules.
void CheckResultTensions(const Real tensNorm, const Real testETA)
uint32_type UInt
generic unsigned integer (used mainly for addressing)