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> 58 #include <lifev/core/array/MapEpetra.hpp> 60 #include <lifev/core/mesh/MeshData.hpp> 61 #include <lifev/core/mesh/MeshPartitioner.hpp> 62 #include <lifev/core/filter/PartitionIO.hpp> 63 #include <lifev/core/mesh/RegionMesh.hpp> 65 #include <lifev/core/fem/FESpace.hpp> 67 #include <lifev/core/filter/Exporter.hpp> 68 #include <lifev/core/filter/ExporterEnsight.hpp> 70 #include <lifev/core/filter/ExporterHDF5.hpp> 72 #include <lifev/core/filter/ExporterEmpty.hpp> 78 using namespace LifeV;
84 std::string stringList = list;
85 std::set<UInt> setList;
91 while ( commaPos != std::string::npos )
93 commaPos = stringList.find (
"," );
94 setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
95 stringList = stringList.substr ( commaPos + 1 );
97 setList.insert ( atoi ( stringList.c_str() ) );
134 std::shared_ptr<Epetra_Comm> structComm );
163 std::shared_ptr<Private> parameters;
173 rho (1), poisson (1), young (1), bulk (1), alpha (1), gamma (1)
175 double rho, poisson, young, bulk, alpha, gamma;
177 std::string data_file_name;
179 std::shared_ptr<Epetra_Comm> comm;
186 Real mu = E / ( 2 * ( 1 + poi ) );
187 Real lambda = ( E * poi ) / ( ( 1 + poi ) * ( 1 - 2 * poi ) );
195 Real radius = std::sqrt ( X * X + Y * Y );
196 Real theta = std::atan ( Y / X );
202 return std::cos (theta) * ( ( ( radius / (2.0 * (mu + lambda) ) ) * ( ( Rin * Rin * Pin - Rout * Rout * Pout ) / ( Rout * Rout - Rin * Rin ) ) )
203 + ( ( (Rin * Rin * Rout * Rout ) / ( 2 * mu * radius) ) * ( ( Pin - Pout ) / ( Rout * Rout - Rin * Rin ) ) ) );
208 return std::sin (theta) * ( ( ( radius / (2.0 * (mu + lambda) ) ) * ( ( Rin * Rin * Pin - Rout * Rout * Pout ) / ( Rout * Rout - Rin * Rin ) ) )
209 + ( ( (Rin * Rin * Rout * Rout ) / ( 2 * mu * radius) ) * ( ( Pin - Pout ) / ( Rout * Rout - Rin * Rin ) ) ) );
216 ERROR_MSG (
"This entry is not allowed!!");
230 std::shared_ptr<Epetra_Comm> structComm) :
234 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
235 GetPot dataFile ( data_file_name );
236 parameters->data_file_name = data_file_name;
252 parameters->comm = structComm;
253 int ntasks = parameters->comm->NumProc();
255 if (!parameters->comm->MyPID() )
257 std::cout <<
"My PID = " << parameters->comm->MyPID() <<
" out of " << ntasks <<
" running." << std::endl;
266 std::cout <<
"2D cylinder test case is not available yet\n";
275 bool verbose = (parameters->comm->MyPID() == 0);
278 std::shared_ptr<BCHandler> BCh (
new BCHandler() );
281 GetPot dataFile ( parameters->data_file_name.c_str() );
284 const std::string partitioningMesh = dataFile (
"partitioningOffline/loadMesh",
"no");
287 std::shared_ptr<MeshPartitioner<mesh_Type> > meshPart;
288 std::shared_ptr<mesh_Type> pointerToMesh;
290 #ifdef LIFEV_HAS_HDF5 291 if ( ! (partitioningMesh.compare (
"no") ) )
294 std::shared_ptr<mesh_Type > fullMeshPtr (
new mesh_Type ( ( parameters->comm ) ) );
297 meshData.setup (dataFile,
"solid/space_discretization");
298 readMesh (*fullMeshPtr, meshData);
300 meshPart.reset (
new MeshPartitioner<mesh_Type> (fullMeshPtr, parameters->comm ) );
302 pointerToMesh = meshPart->meshPartition();
304 #ifdef LIFEV_HAS_HDF5 308 const std::string partsFileName (dataFile (
"partitioningOffline/hdf5_file_name",
"NO_DEFAULT_VALUE.h5") );
310 std::shared_ptr<Epetra_MpiComm> mpiComm =
311 std::dynamic_pointer_cast<Epetra_MpiComm> (parameters->comm);
312 PartitionIO<mesh_Type> partitionIO (partsFileName, mpiComm);
314 partitionIO.read (pointerToMesh);
319 std::string dOrder = dataFile (
"solid/space_discretization/order",
"P1");
321 solidFESpacePtr_Type dFESpace (
new solidFESpace_Type (pointerToMesh, dOrder, 3, parameters->comm) );
327 dFESpace->setQuadRule ( fineQuadRule );
328 dFESpace->setBdQuadRule ( fineBdQuadRule );
329 dFESpace->qr().showMe();
333 std::cout << std::endl;
338 std::cout <<
"Setting up the reader and the iterations!! " << std::endl;
342 std::string
const importerType = dataFile (
"importer/type",
"ensight");
343 std::string
const fileName = dataFile (
"importer/filename",
"structure");
344 std::string
const initialLoaded = dataFile (
"importer/initialSol",
"NO_DEFAULT_VALUE");
345 LifeV::Real initialTime = dataFile (
"importer/initialTime", 0.0);
349 if ( !importerType.compare (
"hdf5") )
351 importerSolid.reset (
new hdf5Filter_Type ( dataFile, fileName) );
356 if ( !importerType.compare (
"none") )
358 importerSolid.reset (
new emptyExporter_Type ( dataFile, dFESpace->mesh(),
"solid", dFESpace->map().comm().MyPID() ) );
362 importerSolid.reset (
new ensightFilter_Type ( dataFile, fileName) );
366 importerSolid->setMeshProcId (dFESpace->mesh(), dFESpace->map().comm().MyPID() );
378 vectorPtr_Type solidDisp (
new vector_Type (dFESpace->map(), importerSolid->mapType() ) );
381 std::string iterationString;
384 iterationString = initialLoaded;
387 LifeV::ExporterData<
mesh_Type> solidDataReader (LifeV::ExporterData<mesh_Type>::VectorField, std::string (
"displacement." + iterationString), dFESpace, solidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
389 importerSolid->readVariable (solidDataReader);
397 importerSolid->closeFile();
400 Real L2_Error, L2_RelError;
419 L2_Error = dFESpace->l2Error (Private::uexact, solution, initialTime , &L2_RelError);
421 std::ofstream out_norm;
425 out_norm.open (
"norm.txt", std::ios::app);
426 out_norm << L2_Error <<
" " 427 << L2_RelError <<
"\n";
432 MPI_Barrier (MPI_COMM_WORLD);
434 std::cout <<
"Relative error L2: " << L2_RelError << std::endl;
442 MPI_Init (&argc, &argv);
443 std::shared_ptr<Epetra_MpiComm> Comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
444 if ( Comm->MyPID() == 0 )
446 std::cout <<
"% using MPI" << std::endl;
449 std::shared_ptr<Epetra_SerialComm> Comm (
new Epetra_SerialComm() );
450 std::cout <<
"% using serial Version" << std::endl;
453 Structure structure ( argc, argv, Comm );
Structure(int argc, char **argv, std::shared_ptr< Epetra_Comm > structComm)
ExporterEnsight data exporter.
const QuadratureRule quadRuleTetra15pt(pt_tetra_15pt, 5, "Quadrature rule 15 points on a tetraedra", TETRA, 15, 5)
const QuadratureRule quadRuleTria4pt(pt_tria_4pt, 3, "Quadrature rule 4 points on a triangle", TRIANGLE, 4, 3)
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
std::shared_ptr< hdf5Filter_Type > hdf5FilterPtr_Type
FESpace< RegionMesh< LinearTetra >, MapEpetra > solidFESpace_Type
std::set< UInt > parseList(const std::string &list)
void run3d()
run the 3D driven cylinder simulation
LifeV::RegionMesh< LinearTetra > mesh_Type
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< vector_Type > vectorPtr_Type
double Real
Generic real data.
std::shared_ptr< emptyExporter_Type > emptyExporterPtr_Type
std::shared_ptr< LifeV::Exporter< mesh_Type > > filterPtr_Type
QuadratureRule - The basis class for storing and accessing quadrature rules.
static Real uexact(const Real &, const Real &X, const Real &Y, const Real &, const ID &i)
int main(int argc, char **argv)
std::shared_ptr< solidFESpace_Type > solidFESpacePtr_Type