36 #include <Epetra_ConfigDefs.h> 39 #include <Epetra_MpiComm.h> 41 #include <Epetra_SerialComm.h> 45 #include <lifev/core/array/MatrixEpetra.hpp> 46 #include <lifev/core/array/MapEpetra.hpp> 47 #include <lifev/core/mesh/MeshData.hpp> 48 #include <lifev/core/mesh/MeshPartitioner.hpp> 49 #include <lifev/core/fem/FESpace.hpp> 50 #include <lifev/core/filter/ExporterEnsight.hpp> 51 #include <lifev/core/filter/ExporterHDF5.hpp> 52 #include <lifev/core/fem/ReferenceFE.hpp> 53 #include <lifev/core/fem/QuadratureRule.hpp> 54 #include <lifev/navier_stokes/fem/TimeAdvanceBDFNavierStokes.hpp> 55 #include <lifev/navier_stokes/solver/OseenSolver.hpp> 56 #include <lifev/navier_stokes/solver/OseenData.hpp> 63 using namespace LifeV;
94 std::string data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
95 GetPot dataFile ( data_file_name );
97 d->data_file_name = data_file_name;
100 std::cout <<
"mpi initialization ... " << std::endl;
103 d->comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
106 d->comm.reset (
new Epetra_SerialComm() );
109 if (!d->comm->MyPID() )
111 std::cout <<
"My PID = " << d->comm->MyPID() <<
" out of " << d->comm->NumProc () <<
" running." << std::endl;
120 GetPot dataFile ( d->data_file_name.c_str() );
122 bool verbose = (d->comm->MyPID() == 0);
125 std::shared_ptr<OseenData> oseenData (
new OseenData() );
126 oseenData->setup ( dataFile );
129 meshData.setup (dataFile,
"fluid/space_discretization");
131 std::shared_ptr<mesh_Type > fullMeshPtr (
new mesh_Type ( d->comm ) );
132 readMesh (*fullMeshPtr, meshData);
136 std::array< Real,
NDIM > geometryScale;
137 std::array< Real,
NDIM > geometryRotate;
138 std::array< Real,
NDIM > geometryTranslate;
140 geometryScale[0] = dataFile (
"fluid/space_discretization/transform", 1., 0);
141 geometryScale[1] = dataFile (
"fluid/space_discretization/transform", 1., 1);
142 geometryScale[2] = dataFile (
"fluid/space_discretization/transform", 1., 2);
144 geometryRotate[0] = dataFile (
"fluid/space_discretization/transform", 0., 3) *
M_PI / 180;
145 geometryRotate[1] = dataFile (
"fluid/space_discretization/transform", 0., 4) *
M_PI / 180;
146 geometryRotate[2] = dataFile (
"fluid/space_discretization/transform", 0., 5) *
M_PI / 180;
148 geometryTranslate[0] = dataFile (
"fluid/space_discretization/transform", 0., 6);
149 geometryTranslate[1] = dataFile (
"fluid/space_discretization/transform", 0., 7);
150 geometryTranslate[2] = dataFile (
"fluid/space_discretization/transform", 0., 8);
152 MeshUtility::MeshTransformer<mesh_Type, mesh_Type::markerCommon_Type > _transformMesh (*fullMeshPtr);
153 _transformMesh.transformMesh ( geometryScale, geometryRotate, geometryTranslate );
155 std::shared_ptr<mesh_Type > meshPtr;
158 meshPtr = meshPart.meshPartition();
161 std::string uOrder = dataFile (
"fluid/space_discretization/vel_order",
"P1");
162 std::string pOrder = dataFile (
"fluid/space_discretization/press_order",
"P1");
168 std::cout <<
"Building the velocity FE space ... " << std::flush;
171 feSpacePtr_Type uFESpacePtr (
new feSpace_Type (meshPtr, uOrder, 3, d->comm) );
175 std::cout <<
"ok." << std::endl;
180 std::cout <<
"Building the pressure FE space ... " << std::flush;
183 feSpacePtr_Type pFESpacePtr (
new feSpace_Type ( meshPtr, pOrder, 1, d->comm ) );
187 std::cout <<
"ok." << std::endl;
192 std::cout <<
"Building the P0 pressure FE space ... " << std::flush;
195 feSpacePtr_Type p0FESpacePtr (
new feSpace_Type ( meshPtr, feTetraP0, quadRuleTetra1pt,
196 quadRuleTria1pt, 1, d->comm ) );
200 std::cout <<
"ok." << std::endl;
205 UInt totalVelDof = uFESpacePtr->map().map (Unique)->NumGlobalElements();
206 UInt totalPressDof = pFESpacePtr->map().map (Unique)->NumGlobalElements();
207 UInt totalP0PresDof = p0FESpacePtr->map().map (Unique)->NumGlobalElements();
211 std::cout <<
"Total Velocity DOF = " << totalVelDof << std::endl;
215 std::cout <<
"Total Pressure DOF = " << totalPressDof << std::endl;
219 std::cout <<
"Total P0Press DOF = " << totalP0PresDof << std::endl;
224 std::cout <<
"Calling the fluid constructor ... ";
227 OseenSolver< mesh_Type > fluid (oseenData,
235 std::cout <<
"ok." << std::endl;
238 fluid.setUp (dataFile);
241 Real dt = oseenData->dataTime()->timeStep();
242 Real t0 = oseenData->dataTime()->initialTime();
243 Real tFinal = oseenData->dataTime()->endTime();
245 std::shared_ptr< Exporter<mesh_Type > > exporter;
246 std::shared_ptr< Exporter<mesh_Type > > importer;
248 std::string
const exporterType = dataFile (
"exporter/type",
"hdf5");
249 std::string
const exporterName = dataFile (
"exporter/filename",
"ethiersteinman");
250 std::string
const exportDir = dataFile (
"exporter/exportDir",
"./");
252 std::string
const importerType = dataFile (
"importer/type",
"ensight");
253 std::string
const importerName = dataFile (
"importer/filename",
"ethiersteinman");
254 std::string
const importDir = dataFile (
"importer/importDir",
"importDir/");
257 if (exporterType.compare (
"hdf5") == 0)
259 exporter.reset (
new ExporterHDF5<mesh_Type > ( dataFile, exporterName ) );
263 exporter.reset (
new ExporterEnsight<mesh_Type > ( dataFile, exporterName ) );
265 exporter->setPostDir ( exportDir );
266 exporter->setMeshProcId ( meshPtr, d->comm->MyPID() );
269 if (importerType.compare (
"hdf5") == 0)
271 importer.reset (
new ExporterHDF5<mesh_Type > ( dataFile, importerName ) );
275 importer.reset (
new ExporterEnsight<mesh_Type > ( dataFile, importerName ) );
278 importer->setPostDir ( importDir );
279 importer->setMeshProcId ( meshPtr, d->comm->MyPID() );
281 vectorPtr_Type velAndPressureExport (
new vector_Type (*fluid.solution(), exporter->mapType() ) );
282 vectorPtr_Type velAndPressureImport (
new vector_Type (*fluid.solution(), importer->mapType() ) );
284 if ( exporter->mapType() == Unique )
286 velAndPressureExport->setCombineMode (Zero);
289 importer->addVariable ( ExporterData<mesh_Type>::VectorField,
"velocity", uFESpacePtr,
290 velAndPressureImport, UInt (0) );
291 importer->addVariable ( ExporterData<mesh_Type>::ScalarField,
"pressure", pFESpacePtr,
292 velAndPressureImport, UInt (3 * uFESpacePtr->dof().numTotalDof() ) );
293 importer->import ( t0 );
295 *velAndPressureExport = *velAndPressureImport;
299 MPI_Barrier (MPI_COMM_WORLD);
300 computeP0pressure (pFESpacePtr, p0FESpacePtr, uFESpacePtr, *velAndPressureImport, *P0pres, t0);
302 exporter->addVariable ( ExporterData<mesh_Type>::VectorField,
"velocity", uFESpacePtr,
303 velAndPressureExport, UInt (0) );
305 exporter->addVariable ( ExporterData<mesh_Type>::ScalarField,
"pressure", pFESpacePtr,
306 velAndPressureExport, UInt (3 * uFESpacePtr->dof().numTotalDof() ) );
308 exporter->addVariable (ExporterData<mesh_Type>::ScalarField,
"P0pressure", p0FESpacePtr,
310 ExporterData<mesh_Type>::SteadyRegime, ExporterData<mesh_Type>::Cell );
311 exporter->postProcess ( t0 );
317 for (
Real time = t0 + dt ; time <= tFinal + dt / 2.; time += dt, iter++)
320 importer->import ( time );
322 *velAndPressureExport = *velAndPressureImport;
323 MPI_Barrier (MPI_COMM_WORLD);
324 computeP0pressure (pFESpacePtr, p0FESpacePtr, uFESpacePtr, *velAndPressureImport, *P0pres, time);
326 exporter->postProcess ( time );
331 std::cout <<
"Total iteration time " << chrono.diff() <<
" s." << std::endl;
347 MPI_Comm_rank (MPI_COMM_WORLD, &MyPID);
348 UInt offset = 3 * uFESpacePtr->dof().numTotalDof();
350 std::vector<
int> gid0Vec (0);
351 gid0Vec.reserve (p0FESpacePtr->mesh()->numVolumes() );
352 std::vector<Real> val0Vec (0);
353 val0Vec.reserve (p0FESpacePtr->mesh()->numVolumes() );
355 for (UInt ivol = 0; ivol < pFESpacePtr->mesh()->numVolumes(); ++ivol)
358 pFESpacePtr->fe().update ( pFESpacePtr->mesh()->volumeList ( ivol ), UPDATE_DPHI );
359 p0FESpacePtr->fe().update ( p0FESpacePtr->mesh()->volumeList ( ivol ) );
361 UInt eleID = pFESpacePtr->fe().currentLocalId();
364 for (UInt iNode = 0; iNode < (UInt) pFESpacePtr->fe().nbFEDof(); iNode++)
366 int ig = pFESpacePtr->dof().localToGlobalMap ( eleID, iNode );
367 tmpsum += velAndPressure (ig + offset);
368 gid0Vec.push_back ( p0FESpacePtr->fe().currentId() );
369 val0Vec.push_back ( tmpsum / (
double) pFESpacePtr->fe().nbFEDof() );
372 P0pres.setCoefficients (gid0Vec, val0Vec);
373 P0pres.globalAssemble();
374 MPI_Barrier (MPI_COMM_WORLD);
std::shared_ptr< Epetra_Comm > comm
FESpace - Short description here please!
std::shared_ptr< feSpace_Type > feSpacePtr_Type
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
OseenSolver< mesh_Type >::vectorPtr_Type vectorPtr_Type
OseenSolver< mesh_Type >::vector_Type vector_Type
RegionMesh< LinearTetra > mesh_Type
Epetra_Import const & importer()
Getter for the Epetra_Import.
void computeP0pressure(const feSpacePtr_Type &pFESpacePtr, const feSpacePtr_Type &p0FESpacePtr, const feSpacePtr_Type &uFESpacePtr, const vector_Type &velAndPressureExport, vector_Type &P0pres, Real)
std::shared_ptr< std::vector< Int > > M_isOnProc
MeshData - class for handling spatial discretization.
std::string data_file_name
double Real
Generic real data.
EnsightToHdf5(int argc, char **argv)
FESpace< mesh_Type, MapEpetra > feSpace_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)