39 #error test_structure cannot be compiled in 2D
43 #include <Epetra_ConfigDefs.h> 46 #include <Epetra_MpiComm.h> 48 #include <Epetra_SerialComm.h> 52 #include <lifev/core/LifeV.hpp> 53 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 54 #include <lifev/core/algorithm/PreconditionerML.hpp> 56 #include <lifev/core/array/MapEpetra.hpp> 58 #include <lifev/core/fem/TimeAdvance.hpp> 59 #include <lifev/core/fem/TimeAdvanceNewmark.hpp> 60 #include <lifev/core/fem/TimeAdvanceBDF.hpp> 62 #include <lifev/core/mesh/MeshData.hpp> 63 #include <lifev/core/mesh/MeshPartitioner.hpp> 65 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp> 67 #include <lifev/structure/solver/StructuralConstitutiveLaw.hpp> 68 #include <lifev/structure/solver/StructuralOperator.hpp> 69 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialLinear.hpp> 70 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialNonLinear.hpp> 71 #include <lifev/structure/solver/isotropic/ExponentialMaterialNonLinear.hpp> 72 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialNonLinearPenalized.hpp> 73 #include <lifev/structure/solver/isotropic/SecondOrderExponentialMaterialNonLinear.hpp> 74 #include <lifev/structure/solver/isotropic/NeoHookeanMaterialNonLinear.hpp> 76 #include <lifev/core/filter/ExporterEnsight.hpp> 78 #include <lifev/core/filter/ExporterHDF5.hpp> 80 #include <lifev/core/filter/ExporterEmpty.hpp> 83 #include <lifev/eta/fem/ETFESpace.hpp> 88 using namespace LifeV;
102 std::string stringList = list;
103 std::set<UInt> setList;
109 while ( commaPos != std::string::npos )
111 commaPos = stringList.find (
"," );
112 setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
113 stringList = stringList.substr ( commaPos + 1 );
115 setList.insert ( atoi ( stringList.c_str() ) );
129 std::shared_ptr<Epetra_Comm> structComm );
203 return 0.088002 * ( x + 0.5 );
206 return - ( 0.02068 * 2.0 ) * ( y );
209 return - ( 0.02068 * 2.0 ) * ( z );
212 ERROR_MSG (
"This entry is not allowed: ud_functions.hpp");
225 std::shared_ptr<Epetra_Comm> structComm) :
229 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
230 GetPot dataFile ( data_file_name );
231 parameters->data_file_name = data_file_name;
233 parameters->rho = dataFile (
"solid/physics/density", 1. );
234 parameters->young = dataFile (
"solid/physics/young", 1. );
235 parameters->poisson = dataFile (
"solid/physics/poisson", 1. );
236 parameters->bulk = dataFile (
"solid/physics/bulk", 1. );
237 parameters->alpha = dataFile (
"solid/physics/alpha", 1. );
238 parameters->gamma = dataFile (
"solid/physics/gamma", 1. );
240 std::cout <<
"density = " << parameters->rho << std::endl
241 <<
"young = " << parameters->young << std::endl
242 <<
"poisson = " << parameters->poisson << std::endl
243 <<
"bulk = " << parameters->bulk << std::endl
244 <<
"alpha = " << parameters->alpha << std::endl
245 <<
"gamma = " << parameters->gamma << std::endl;
247 parameters->comm = structComm;
248 int ntasks = parameters->comm->NumProc();
250 if (!parameters->comm->MyPID() )
252 std::cout <<
"My PID = " << parameters->comm->MyPID() <<
" out of " << ntasks <<
" running." << std::endl;
261 std::cout <<
"2D cylinder test case is not available yet\n";
269 typedef StructuralOperator< RegionMesh<LinearTetra> >::vector_Type vector_Type;
270 typedef std::shared_ptr<vector_Type> vectorPtr_Type;
271 typedef std::shared_ptr< TimeAdvance< vector_Type > > timeAdvance_Type;
272 typedef FESpace< RegionMesh<LinearTetra>, MapEpetra > solidFESpace_Type;
273 typedef std::shared_ptr<solidFESpace_Type> solidFESpacePtr_Type;
275 typedef ETFESpace< RegionMesh<LinearTetra>, MapEpetra, 3, 3 > solidETFESpace_Type;
276 typedef std::shared_ptr<solidETFESpace_Type> solidETFESpacePtr_Type;
279 bool verbose = (parameters->comm->MyPID() == 0);
282 std::shared_ptr<BCHandler> BCh (
new BCHandler() );
285 GetPot dataFile ( parameters->data_file_name.c_str() );
287 std::shared_ptr<StructuralConstitutiveLawData> dataStructure (
new StructuralConstitutiveLawData( ) );
288 dataStructure->setup (dataFile);
291 meshData.setup (dataFile,
"solid/space_discretization");
294 std::shared_ptr<RegionMesh<LinearTetra> > fullMeshPtr (
new RegionMesh<LinearTetra> ( parameters->comm ) );
295 std::shared_ptr<RegionMesh<LinearTetra> > localMeshPtr (
new RegionMesh<LinearTetra> ( parameters->comm ) );
297 readMesh (*fullMeshPtr, meshData);
299 MeshPartitioner< RegionMesh<LinearTetra> > meshPart ( fullMeshPtr, parameters->comm );
300 localMeshPtr = meshPart.meshPartition();
302 std::string dOrder = dataFile (
"solid/space_discretization/order",
"P1");
305 solidFESpacePtr_Type dFESpace (
new solidFESpace_Type (localMeshPtr, dOrder, 3, parameters->comm) );
306 solidETFESpacePtr_Type dETFESpace (
new solidETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
310 std::cout << std::endl;
313 std::string timeAdvanceMethod = dataFile (
"solid/time_discretization/method",
"Newmark");
315 timeAdvance_Type timeAdvance ( TimeAdvanceFactory::instance().createObject ( timeAdvanceMethod ) );
320 if (timeAdvanceMethod ==
"Newmark")
322 timeAdvance->setup ( dataStructure->dataTimeAdvance()->coefficientsNewmark() , OrderDev);
325 if (timeAdvanceMethod ==
"BDF")
327 timeAdvance->setup (dataStructure->dataTimeAdvance()->orderBDF() , OrderDev);
330 timeAdvance->setTimeStep (dataStructure->dataTime()->timeStep() );
336 std::vector <ID> compx (1), compy (1), compz (1), compxy (2), compxz (2), compyz (2);
338 compy[0] = 1, compz[0] = 2;
346 BCFunctionBase zero (Private::bcZero);
347 BCFunctionBase nonZero;
349 if ( dataStructure->solidTypeIsotropic().compare (
"secondOrderExponential") )
351 nonZero.setFunction (Private::bcNonZero);
355 nonZero.setFunction (Private::bcNonZeroSecondOrderExponential);
362 BCh->addBC (
"EdgesIn", 20, Natural, Component, nonZero, compx);
363 BCh->addBC (
"EdgesIn", 40, Essential, Component, zero, compx);
367 StructuralOperator< RegionMesh<LinearTetra> > solid;
370 solid.setup (dataStructure,
377 solid.setDataFromGetPot (dataFile);
380 double timeAdvanceCoefficient = timeAdvance->coefficientSecondDerivative ( 0 ) / (dataStructure->dataTime()->timeStep() * dataStructure->dataTime()->timeStep() );
381 solid.buildSystem (timeAdvanceCoefficient);
390 Real dt = dataStructure->dataTime()->timeStep();
393 vectorPtr_Type rhs (
new vector_Type (solid.displacement(), Unique) );
394 vectorPtr_Type disp (
new vector_Type (solid.displacement(), Unique) );
395 vectorPtr_Type vel (
new vector_Type (solid.displacement(), Unique) );
396 vectorPtr_Type acc (
new vector_Type (solid.displacement(), Unique) );
400 std::cout <<
"S- initialization ... ";
403 std::vector<vectorPtr_Type> uv0;
405 if (timeAdvanceMethod ==
"Newmark")
407 uv0.push_back (disp);
412 vectorPtr_Type initialDisplacement (
new vector_Type (solid.displacement(), Unique) );
414 if ( !dataStructure->solidTypeIsotropic().compare (
"secondOrderExponential") )
416 dFESpace->interpolate (
static_cast<solidFESpace_Type::function_Type> ( Private::d0 ), *initialDisplacement, 0.0 );
419 if (timeAdvanceMethod ==
"BDF")
421 Real tZero = dataStructure->dataTime()->initialTime();
423 for ( UInt previousPass = 0; previousPass < timeAdvance->size() ; previousPass++)
425 Real previousTimeStep = tZero - previousPass * dt;
426 std::cout <<
"BDF " << previousTimeStep <<
"\n";
427 if ( !dataStructure->solidTypeIsotropic().compare (
"secondOrderExponential") )
429 uv0.push_back (initialDisplacement);
433 uv0.push_back (disp);
438 timeAdvance->setInitialCondition (uv0);
440 timeAdvance->setTimeStep ( dt );
442 timeAdvance->updateRHSContribution ( dt );
444 if ( !dataStructure->solidTypeIsotropic().compare (
"secondOrderExponential") )
446 solid.initialize ( initialDisplacement );
450 solid.initialize ( disp );
453 MPI_Barrier (MPI_COMM_WORLD);
457 std::cout <<
"ok." << std::endl;
460 std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporter;
462 std::string
const exporterType = dataFile (
"exporter/type",
"ensight");
464 if (exporterType.compare (
"hdf5") == 0)
466 exporter.reset (
new ExporterHDF5<RegionMesh<LinearTetra> > ( dataFile,
"structure" ) );
471 if (exporterType.compare (
"none") == 0)
473 exporter.reset (
new ExporterEmpty<RegionMesh<LinearTetra> > ( dataFile, meshPart.meshPartition(),
"structure", parameters->comm->MyPID() ) );
478 exporter.reset (
new ExporterEnsight<RegionMesh<LinearTetra> > ( dataFile, meshPart.meshPartition(),
"structure", parameters->comm->MyPID() ) );
482 exporter->setPostDir (
"./" );
483 exporter->setMeshProcId ( meshPart.meshPartition(), parameters->comm->MyPID() );
485 vectorPtr_Type solidDisp (
new vector_Type (solid.displacement(), exporter->mapType() ) );
486 vectorPtr_Type solidVel (
new vector_Type (solid.displacement(), exporter->mapType() ) );
487 vectorPtr_Type solidAcc (
new vector_Type (solid.displacement(), exporter->mapType() ) );
489 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"displacement", dFESpace, solidDisp, UInt (0) );
490 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"velocity", dFESpace, solidVel, UInt (0) );
491 exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"acceleration", dFESpace, solidAcc, UInt (0) );
493 exporter->postProcess ( 0 );
534 normVect = solid.displacement().norm2();
535 std::cout <<
"The norm 2 of the displacement field is: " << normVect << std::endl;
541 for (dataStructure->dataTime()->setTime ( dt ) ; dataStructure->dataTime()->canAdvance( ); dataStructure->dataTime()->updateTime( ) )
547 std::cout << std::endl;
548 std::cout <<
"S- Now we are at time " << dataStructure->dataTime()->time() <<
" s." << std::endl;
553 std::cout << std::endl;
554 std::cout <<
"S- Now we are at time " << dataStructure->dataTime()->time() <<
" s." << std::endl;
559 timeAdvance->updateRHSContribution ( dt );
560 *rhs += *solid.massMatrix() * timeAdvance->rhsContributionSecondDerivative() / timeAdvanceCoefficient;
561 solid.setRightHandSide ( *rhs );
564 solid.iterate ( BCh );
566 timeAdvance->shiftRight ( solid.displacement() );
568 *solidDisp = solid.displacement();
569 *solidVel = timeAdvance->firstDerivative();
570 *solidAcc = timeAdvance->secondDerivative();
572 exporter->postProcess ( dataStructure->dataTime()->time() );
592 normVect = solid.displacement().norm2();
593 std::cout <<
"The norm 2 of the displacement field is: " << normVect << std::endl;
596 if (!dataStructure->solidTypeIsotropic().compare (
"linearVenantKirchhoff") )
598 CheckResultLE (normVect, dataStructure->dataTime()->time() );
600 else if (!dataStructure->solidTypeIsotropic().compare (
"nonLinearVenantKirchhoff") )
602 CheckResultSVK (normVect, dataStructure->dataTime()->time() );
604 else if (!dataStructure->solidTypeIsotropic().compare (
"nonLinearVenantKirchhoffPenalized") )
606 CheckResultSVKPenalized (normVect, dataStructure->dataTime()->time() );
608 else if (!dataStructure->solidTypeIsotropic().compare (
"exponential") )
610 CheckResultEXP (normVect, dataStructure->dataTime()->time() );
612 else if (!dataStructure->solidTypeIsotropic().compare (
"secondOrderExponential") )
614 CheckResult2ndOrderExponential (normVect, dataStructure->dataTime()->time() );
618 CheckResultNH (normVect, dataStructure->dataTime()->time() );
626 MPI_Barrier (MPI_COMM_WORLD);
634 if ( time == 0.1 && std::fabs (dispNorm - 0.276527) <= 1e-5 )
638 if ( time == 0.2 && std::fabs (dispNorm - 0.276536) <= 1e-5 )
642 if ( time == 0.3 && std::fabs (dispNorm - 0.276529) <= 1e-5 )
646 if ( time == 0.4 && std::fabs (dispNorm - 0.276531) <= 1e-5 )
654 if ( time == 0.1 && std::fabs (dispNorm - 0.263348) <= 1e-5 )
658 if ( time == 0.2 && std::fabs (dispNorm - 0.263350) <= 1e-5 )
662 if ( time == 0.3 && std::fabs (dispNorm - 0.263350) <= 1e-5 )
666 if ( time == 0.4 && std::fabs (dispNorm - 0.263351) <= 1e-5 )
673 if ( time == 0.1 && std::fabs (dispNorm - 0.254316) <= 1e-5 )
677 if ( time == 0.2 && std::fabs (dispNorm - 0.254322) <= 1e-5 )
681 if ( time == 0.3 && std::fabs (dispNorm - 0.254317) <= 1e-5 )
685 if ( time == 0.4 && std::fabs (dispNorm - 0.254318) <= 1e-5 )
692 if ( time == 0.1 && std::fabs (dispNorm - 0.284844) <= 1e-5 )
696 if ( time == 0.2 && std::fabs (dispNorm - 0.284853) <= 1e-5 )
700 if ( time == 0.3 && std::fabs (dispNorm - 0.284846) <= 1e-5 )
704 if ( time == 0.4 && std::fabs (dispNorm - 0.284848) <= 1e-5 )
712 if ( time == 0.1 && std::fabs (dispNorm - 0.286120) <= 1e-5 )
716 if ( time == 0.2 && std::fabs (dispNorm - 0.286129) <= 1e-5 )
720 if ( time == 0.3 && std::fabs (dispNorm - 0.286122) <= 1e-5 )
724 if ( time == 0.4 && std::fabs (dispNorm - 0.286123) <= 1e-5 )
733 if ( time == 0.1 && std::fabs (dispNorm - 0.561523) <= 1e-5 )
737 if ( time == 0.2 && std::fabs (dispNorm - 0.561496) <= 1e-5 )
741 if ( time == 0.3 && std::fabs (dispNorm - 0.561517) <= 1e-5 )
745 if ( time == 0.4 && std::fabs (dispNorm - 0.561512) <= 1e-5 )
755 std::cout <<
"Correct value at time: " << time << std::endl;
766 MPI_Init (&argc, &argv);
767 std::shared_ptr<Epetra_MpiComm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
768 if ( Comm->MyPID() == 0 )
770 std::cout <<
"% using MPI" << std::endl;
773 std::shared_ptr<Epetra_SerialComm> Comm (
new Epetra_SerialComm() );
774 std::cout <<
"% using serial Version" << std::endl;
777 Structure structure ( argc, argv, Comm );
static Real bcNonZeroSecondOrderExponential(const Real &, const Real &, const Real &, const Real &, const ID &)
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)
void CheckResultLE(const Real &dispNorm, const Real &time)
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > fct_type
static const LifeV::UInt elm_nodes_num[]
std::shared_ptr< hdf5Filter_Type > hdf5FilterPtr_Type
void CheckResultEXP(const Real &dispNorm, const Real &time)
static Real bcZero(const Real &, const Real &, const Real &, const Real &, const ID &)
void CheckResultNH(const Real &dispNorm, const Real &time)
void run3d()
run the 3D driven cylinder simulation
void CheckResultSVKPenalized(const Real &dispNorm, const Real &time)
static Real d0(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
std::string data_file_name
void run2d()
run the 2D driven cylinder simulation
MeshData - class for handling spatial discretization.
std::shared_ptr< Private > parameters
void CheckResultSVK(const Real &dispNorm, const Real &time)
double Real
Generic real data.
static Real bcNonZero(const Real &, const Real &, const Real &, const Real &, const ID &)
void CheckResult2ndOrderExponential(const Real &dispNorm, const Real &time)
std::set< UInt > parseList(const std::string &list)
void resultChanged(Real time)
uint32_type UInt
generic unsigned integer (used mainly for addressing)