37 #error test_structure cannot be compiled in 2D
41 #pragma GCC diagnostic ignored "-Wunused-variable" 42 #pragma GCC diagnostic ignored "-Wunused-parameter" 44 #include <Epetra_ConfigDefs.h> 47 #include <Epetra_MpiComm.h> 49 #include <Epetra_SerialComm.h> 53 #pragma GCC diagnostic warning "-Wunused-variable" 54 #pragma GCC diagnostic warning "-Wunused-parameter" 56 #include <lifev/core/LifeV.hpp> 57 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 58 #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/TimeAdvanceNewmark.hpp> 66 #include <lifev/core/fem/TimeAdvanceBDF.hpp> 68 #include <lifev/core/mesh/MeshData.hpp> 69 #include <lifev/core/mesh/MeshPartitioner.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/VenantKirchhoffMaterialLinear.hpp> 76 #include <lifev/structure/solver/VenantKirchhoffMaterialNonLinear.hpp> 77 #include <lifev/structure/solver/NeoHookeanMaterialNonLinear.hpp> 78 #include <lifev/structure/solver/ExponentialMaterialNonLinear.hpp> 80 #include <lifev/core/filter/Exporter.hpp> 81 #include <lifev/core/filter/ExporterEnsight.hpp> 83 #include <lifev/core/filter/ExporterHDF5.hpp> 85 #include <lifev/core/filter/ExporterEmpty.hpp> 86 #include <lifev/core/filter/ExporterVTK.hpp> 91 using namespace LifeV;
104 std::string stringList = list;
105 std::set<UInt> setList;
111 while ( commaPos != std::string::npos )
113 commaPos = stringList.find (
"," );
114 setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
115 stringList = stringList.substr ( commaPos + 1 );
117 setList.insert ( atoi ( stringList.c_str() ) );
165 std::shared_ptr<Epetra_Comm> structComm );
245 Real pressure = 5000;
250 return pressure * std::fabs ( ( x / radius ) );
253 return pressure * std::fabs ( ( y / radius ) );
281 std::shared_ptr<Epetra_Comm> structComm) :
288 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
289 GetPot dataFile ( data_file_name );
290 parameters->data_file_name = data_file_name;
292 parameters->rho = dataFile (
"solid/physics/density", 1. );
293 parameters->young = dataFile (
"solid/physics/young", 1. );
294 parameters->poisson = dataFile (
"solid/physics/poisson", 1. );
295 parameters->bulk = dataFile (
"solid/physics/bulk", 1. );
296 parameters->alpha = dataFile (
"solid/physics/alpha", 1. );
297 parameters->gamma = dataFile (
"solid/physics/gamma", 1. );
299 std::cout <<
"density = " << parameters->rho << std::endl
300 <<
"young = " << parameters->young << std::endl
301 <<
"poisson = " << parameters->poisson << std::endl
302 <<
"bulk = " << parameters->bulk << std::endl
303 <<
"alpha = " << parameters->alpha << std::endl
304 <<
"gamma = " << parameters->gamma << std::endl;
306 parameters->comm = structComm;
307 int ntasks = parameters->comm->NumProc();
309 if (!parameters->comm->MyPID() )
311 std::cout <<
"My PID = " << parameters->comm->MyPID() <<
" out of " << ntasks <<
" running." << std::endl;
320 std::cout <<
"2D cylinder test case is not available yet\n";
329 bool verbose = (parameters->comm->MyPID() == 0);
332 std::shared_ptr<BCHandler> BCh (
new BCHandler() );
335 GetPot dataFile ( parameters->data_file_name.c_str() );
337 std::shared_ptr<StructuralConstitutiveLawData> dataStructure (
new StructuralConstitutiveLawData( ) );
338 dataStructure->setup (dataFile);
341 meshData.setup (dataFile,
"solid/space_discretization");
343 std::shared_ptr<RegionMesh<LinearTetra> > fullMeshPtr (
new RegionMesh<LinearTetra> ( ( parameters->comm ) ) );
344 readMesh (*fullMeshPtr, meshData);
348 MeshPartitioner< RegionMesh<LinearTetra> > meshPart ( fullMeshPtr, parameters->comm );
350 std::string dOrder = dataFile (
"solid/space_discretization/order",
"P1");
352 dFESpace.reset (
new solidFESpace_Type (meshPart, dOrder, 3, parameters->comm) );
353 dETFESpace.reset (
new solidETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
360 std::cout << std::endl;
363 std::string timeAdvanceMethod = dataFile (
"solid/time_discretization/method",
"Newmark");
365 timeAdvance_type timeAdvance ( TimeAdvanceFactory::instance().createObject ( timeAdvanceMethod ) );
370 if (timeAdvanceMethod ==
"Newmark")
372 timeAdvance->setup ( dataStructure->dataTimeAdvance()->coefficientsNewmark() , OrderDev);
375 if (timeAdvanceMethod ==
"BDF")
377 timeAdvance->setup (dataStructure->dataTimeAdvance()->orderBDF() , OrderDev);
380 timeAdvance->setTimeStep (dataStructure->dataTime()->timeStep() );
386 std::vector <ID> compx (1), compy (1), compz (1), compxy (2), compxz (2), compyz (2);
388 compy[0] = 1, compz[0] = 2;
396 BCFunctionBase zero (Private::bcZero);
397 BCFunctionBase nonZero (Private::bcNonZero);
398 BCFunctionBase pressure (Private::bcPressure);
399 BCFunctionBase pressureNormal (Private::pressureUsingNormal);
408 BCh->addBC (
"EdgesIn", 40, Essential, Full, zero, 3);
409 BCh->addBC (
"EdgesIn", 60, Natural, Full, zero, 3);
410 BCh->addBC (
"EdgesIn", 20, Natural, Full, zero, 3);
411 BCh->addBC (
"EdgesIn", 70, Natural, Full, zero, 3);
412 BCh->addBC (
"EdgesIn", 30, Natural, Full, zero, 3);
413 BCh->addBC (
"EdgesIn", 50, Natural, Full, nonZero, 3);
421 StructuralOperator< RegionMesh<LinearTetra> > solid;
424 solid.setup (dataStructure,
431 solid.setDataFromGetPot (dataFile);
434 double timeAdvanceCoefficient = timeAdvance->coefficientSecondDerivative ( 0 ) / (dataStructure->dataTime()->timeStep() * dataStructure->dataTime()->timeStep() );
435 solid.buildSystem (timeAdvanceCoefficient);
439 std::cout <<
"S- initialization ... ";
443 std::string
const restart = dataFile (
"importer/restart",
"none");
444 std::vector<vectorPtr_Type> solutionStencil;
446 if ( restart.compare (
"none" ) )
449 std::string
const importerType = dataFile (
"importer/type",
"ensight");
450 std::string
const fileName = dataFile (
"importer/filename",
"structure");
451 std::string
const initialLoaded = dataFile (
"importer/initialSol",
"NO_DEFAULT_VALUE");
463 if ( !importerType.compare (
"hdf5") )
465 importerSolid.reset (
new hdf5Filter_Type ( dataFile, fileName) );
470 if ( !importerType.compare (
"none") )
472 importerSolid.reset (
new emptyExporter_Type ( dataFile, dFESpace->mesh(),
"solid", dFESpace->map().comm().MyPID() ) );
476 importerSolid.reset (
new ensightFilter_Type ( dataFile, fileName) );
479 importerSolid->setMeshProcId (dFESpace->mesh(), dFESpace->map().comm().MyPID() );
493 solidDisp.reset (
new vector_Type (dFESpace->map(), Unique ) );
495 std::string iterationString;
497 std::cout <<
"size TimeAdvance:" << timeAdvance->size() << std::endl;
501 iterationString = initialLoaded;
502 for (UInt iterInit = 0; iterInit < timeAdvance->size(); iterInit++ )
506 solidDataReader.reset (
new exporterData_Type (exporterData_Type::VectorField, std::string (
"displacement." + iterationString), dFESpace, solidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime) );
508 importerSolid->readVariable ( *solidDataReader );
510 std::cout <<
"Norm of the " << iterInit + 1 <<
"-th solution : " << solidDisp->norm2() << std::endl;
517 solutionStencil.push_back ( solidDisp );
523 solid.initialize ( solidDisp );
527 int iterations = std::atoi (iterationString.c_str() );
530 std::ostringstream iter;
532 iter << std::setw (5) << ( iterations );
533 iterationString = iter.str();
537 importerSolid->closeFile();
540 timeAdvance->setInitialCondition (solutionStencil);
545 std::cout <<
"Starting from scratch" << std::endl;
546 vectorPtr_Type disp (
new vector_Type (solid.displacement(), Unique) );
548 if (timeAdvanceMethod ==
"Newmark")
550 solutionStencil.push_back (disp);
551 solutionStencil.push_back (disp);
552 solutionStencil.push_back (disp);
555 if (timeAdvanceMethod ==
"BDF")
557 for ( UInt previousPass = 0; previousPass < dataStructure->dataTimeAdvance()->orderBDF() ; previousPass++)
559 solutionStencil.push_back (disp);
563 timeAdvance->setInitialCondition (solutionStencil);
573 timeAdvance->setTimeStep (dataStructure->dataTime()->timeStep() );
575 timeAdvance->updateRHSContribution (dataStructure->dataTime()->timeStep() );
577 MPI_Barrier (MPI_COMM_WORLD);
581 std::cout <<
"ok." << std::endl;
584 std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporterSolid;
588 std::string
const exporterType = dataFile (
"exporter/type",
"ensight");
589 std::string
const exportFileName = dataFile (
"exporter/nameFile",
"structure");
590 std::string
const exportCheckName =
"checkExporter";
600 if (exporterType.compare (
"hdf5") == 0)
602 exporterSolid.reset (
new hdf5Filter_Type ( dataFile, exportFileName ) );
608 if (exporterType.compare (
"none") == 0)
610 exporterSolid.reset (
new emptyExporter_Type ( dataFile, meshPart.meshPartition(), exportFileName, parameters->comm->MyPID() ) );
614 exporterSolid.reset (
new ensightFilter_Type ( dataFile, meshPart.meshPartition(), exportFileName, parameters->comm->MyPID() ) );
618 exporterSolid->setPostDir (
"./" );
619 exporterSolid->setMeshProcId ( meshPart.meshPartition(), parameters->comm->MyPID() );
633 vectorPtr_Type solidDisp (
new vector_Type (solid.displacement(), Unique ) );
634 vectorPtr_Type solidVel (
new vector_Type (solid.displacement(), Unique ) );
635 vectorPtr_Type solidAcc (
new vector_Type (solid.displacement(), Unique ) );
657 exporterSolid->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"displacement", dFESpace, solidDisp, UInt (0) );
658 exporterSolid->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"velocity", dFESpace, solidVel, UInt (0) );
659 exporterSolid->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField,
"acceleration", dFESpace, solidAcc, UInt (0) );
663 exporterSolid->postProcess ( 0 );
671 vectorPtr_Type rhs (
new vector_Type (solid.displacement(), Unique) );
674 Real initialTime = dataStructure->dataTime()->initialTime();
675 Real dt = dataStructure->dataTime()->timeStep();
676 Real T = dataStructure->dataTime()->endTime();
681 for (
Real time = initialTime + dt; time <= T; time += dt)
683 dataStructure->dataTime()->setTime (time);
687 std::cout << std::endl;
688 std::cout <<
"S- Now we are at time " << dataStructure->dataTime()->time() <<
" s." << std::endl;
693 timeAdvance->updateRHSContribution ( dt );
694 *rhs += *solid.massMatrix() * timeAdvance->rhsContributionSecondDerivative() / timeAdvanceCoefficient;
696 std::cout <<
"Norm of the rhsNoBC: " << (*rhs).norm2() << std::endl;
697 solid.setRightHandSide ( *rhs );
700 solid.iterate ( BCh );
702 timeAdvance->shiftRight ( solid.displacement() );
704 *solidDisp = solid.displacement();
705 *solidVel = timeAdvance->firstDerivative();
706 *solidAcc = timeAdvance->secondDerivative();
719 exporterSolid->postProcess ( time );
724 normVect = solid.displacement().norm2();
725 std::cout <<
"The norm 2 of the displacement field is: " << normVect << std::endl;
730 MPI_Barrier (MPI_COMM_WORLD);
733 exporterSolid->closeFile();
742 MPI_Init (&argc, &argv);
743 std::shared_ptr<Epetra_MpiComm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
744 if ( Comm->MyPID() == 0 )
746 std::cout <<
"% using MPI" << std::endl;
749 std::shared_ptr<Epetra_SerialComm> Comm (
new Epetra_SerialComm() );
750 std::cout <<
"% using serial Version" << std::endl;
753 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::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 exporterCheck
filterPtr_Type importerSolid
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 &)
LifeV::ExporterVTK< mesh_Type > exporterVTK_Type
void run3d()
run the 3D driven cylinder simulation
ETFESpace< RegionMesh< LinearTetra >, MapEpetra, 3, 3 > solidETFESpace_Type
LifeV::RegionMesh< LinearTetra > mesh_Type
std::shared_ptr< exporterVTK_Type > exporterVTKPtr_Type
LifeV::ExporterData< mesh_Type > exporterData_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 &)
solidFESpacePtr_Type dFESpace
solidFESpacePtr_Type exporterFESpace
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)
std::shared_ptr< solidETFESpace_Type > solidETFESpacePtr_Type
std::shared_ptr< LifeV::Exporter< mesh_Type > > filterPtr_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< TimeAdvance< vector_Type > > timeAdvance_type
std::shared_ptr< exporterData_Type > exporterDataPtr_Type
solidETFESpacePtr_Type dETFESpace