54 using namespace LifeV;
80 const std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
81 GetPot dataFile ( data_file_name );
83 Members->data_file_name = data_file_name;
84 Members->discretization_section =
"fefct";
87 std::cout <<
"Epetra Initialization" << std::endl;
88 Members->comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
90 MPI_Comm_size (MPI_COMM_WORLD, &ntasks);
92 Members->comm.reset (
new Epetra_SerialComm() );
106 LifeChrono chronoTotal;
107 LifeChrono chronoReadAndPartitionMesh;
108 LifeChrono chronoFiniteElementSpace;
109 LifeChrono chronoFEFieldAndFEFct;
110 LifeChrono chronoAddFields;
111 LifeChrono chronoProblem;
112 LifeChrono chronoProcess;
113 LifeChrono chronoError;
119 GetPot dataFile ( Members->data_file_name.c_str() );
124 displayer.leaderPrint (
"The FEField and FEFunction test\n" );
127 chronoReadAndPartitionMesh.start();
133 meshData.setup ( dataFile, Members->discretization_section +
"/space_discretization");
139 readMesh ( *fullMeshPtr, meshData );
146 meshPtr = meshPart.meshPartition();
150 chronoReadAndPartitionMesh.stop();
153 displayer.leaderPrintMax (
"Time for read and partition the mesh ",
154 chronoReadAndPartitionMesh.diff() );
159 chronoFiniteElementSpace.start();
162 FESpacePtr_Type scalarField1_FESpace (
new FESpace_Type ( meshPtr, feTetraP0, quadRuleTetra15pt,
163 quadRuleTria4pt, 1, Members->comm ) );
166 FESpacePtr_Type scalarField2_FESpace (
new FESpace_Type ( meshPtr, feTetraP1, quadRuleTetra15pt,
167 quadRuleTria4pt, 1, Members->comm ) );
170 FESpacePtr_Type vectorField_FESpace (
new FESpace_Type ( meshPtr, feTetraP0, quadRuleTetra15pt,
171 quadRuleTria4pt, 3, Members->comm ) );
174 FESpacePtr_Type function_FESpace (
new FESpace_Type ( meshPtr, feTetraP0, quadRuleTetra15pt,
175 quadRuleTria4pt, 1, Members->comm ) );
178 chronoFiniteElementSpace.stop();
181 displayer.leaderPrintMax (
"Time for create the finite element spaces ",
182 chronoFiniteElementSpace.diff() );
185 chronoFEFieldAndFEFct.start();
189 scalarField1->getVector() = 1. ;
193 scalarField2->getVector() = 2.;
197 vectorField->getVector() = 3.;
206 chronoFEFieldAndFEFct.stop();
209 displayer.leaderPrintMax (
"Time for create the fields and the function ",
210 chronoFEFieldAndFEFct.diff() );
215 chronoAddFields.start();
218 function.addScalarField ( scalarField1 );
221 function.addScalarField ( scalarField2 );
224 function.addVectorField ( vectorField );
227 chronoAddFields.stop();
230 displayer.leaderPrintMax (
"Time for create the add the fields to the function ",
231 chronoAddFields.diff() );
239 error = std::fabs ( ( std::sin (1.) + 4. ) / 3. - function.eval ( iElem, point, 0. ) );
242 function.interpolate ( *scalarFieldFunction );
248 std::string
const exporterType = dataFile (
"exporter/type",
"hdf5");
252 if ( exporterType.compare (
"hdf5") == 0 )
254 exporter.reset (
new ExporterHDF5< regionMesh_Type > ( dataFile, dataFile (
"exporter/file_name",
"FieldFunction" ) ) );
257 exporter->setPostDir ( dataFile (
"exporter/folder",
"./" ) );
259 exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
264 if ( exporterType.compare (
"none") == 0 )
266 exporter.reset (
new ExporterEmpty< regionMesh_Type > ( dataFile, dataFile (
"exporter/file_name",
"FieldFunction" ) ) );
269 exporter->setPostDir ( dataFile (
"exporter/folder",
"./" ) );
271 exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
275 exporter.reset (
new ExporterEnsight< regionMesh_Type > ( dataFile, dataFile (
"exporter/file_name",
"FieldFunction" ) ) );
278 exporter->setPostDir ( dataFile (
"exporter/folder",
"./" ) );
280 exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
284 const std::string fieldName = dataFile (
"exporter/name_field",
"Field" );
287 exporter->addVariable ( ExporterData< regionMesh_Type >::ScalarField,
289 scalarField1_FESpace,
290 scalarField1->getVectorPtr(),
291 static_cast<UInt> ( 0 ),
292 ExporterData< regionMesh_Type >::UnsteadyRegime,
293 ExporterData< regionMesh_Type >::Cell );
296 exporter->addVariable ( ExporterData< regionMesh_Type >::ScalarField,
298 scalarField2_FESpace,
299 scalarField2->getVectorPtr(),
300 static_cast<UInt> ( 0 ),
301 ExporterData< regionMesh_Type >::UnsteadyRegime );
304 exporter->addVariable ( ExporterData< regionMesh_Type >::VectorField,
307 vectorField->getVectorPtr(),
308 static_cast<UInt> ( 0 ),
309 ExporterData< regionMesh_Type >::UnsteadyRegime,
310 ExporterData< regionMesh_Type >::Cell );
312 const std::string fctName = dataFile (
"exporter/name_fct",
"Function" );
315 exporter->addVariable ( ExporterData< regionMesh_Type >::ScalarField,
318 scalarFieldFunction->getVectorPtr(),
319 static_cast<UInt> ( 0 ),
320 ExporterData< regionMesh_Type >::UnsteadyRegime,
321 ExporterData< regionMesh_Type >::Cell );
324 exporter->postProcess (0);
std::shared_ptr< FEVectorField_Type > FEVectorFieldPtr_Type
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
std::shared_ptr< FESpace_Type > FESpacePtr_Type
RegionMesh< geoElement_Type > regionMesh_Type
std::shared_ptr< FEScalarField_Type > FEScalarFieldPtr_Type
std::string data_file_name
std::shared_ptr< std::vector< Int > > M_isOnProc
MeshData - class for handling spatial discretization.
LifeV::Real run()
Methods.
std::string discretization_section
std::shared_ptr< regionMesh_Type > regionMeshPtr_Type
double Real
Generic real data.
VectorSmall< 3 > Vector3D
std::shared_ptr< exporter_Type > exporterPtr_Type
std::shared_ptr< Epetra_Comm > comm
fefct(int argc, char **argv)
Constructors.
Displayer - This class is used to display messages in parallel simulations.
uint32_type UInt
generic unsigned integer (used mainly for addressing)