43 using namespace LifeV;
82 f = std::bind ( &UOne, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
89 f = std::bind ( &dataProblem::analyticalSolution, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
96 f = std::bind ( &dataProblem::analyticalFlux, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5 );
109 GetPot command_line (argc, argv);
110 Members->data_file_name = command_line.follow (
"data", 2,
"-f",
"--file");
111 Members->xml_file_name = command_line.follow (
"parameterList.xml",
"--xml");
113 GetPot dataFile ( Members->data_file_name );
115 Members->discretization_section =
"darcy";
118 Members->comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
120 Members->comm.reset (
new Epetra_SerialComm() );
135 LifeChrono chronoTotal;
136 LifeChrono chronoReadAndPartitionMesh;
137 LifeChrono chronoBoundaryCondition;
138 LifeChrono chronoFiniteElementSpace;
139 LifeChrono chronoProblem;
140 LifeChrono chronoProcess;
141 LifeChrono chronoError;
144 std::shared_ptr < Displayer > displayer (
new Displayer ( Members->comm ) );
150 GetPot dataFile ( Members->data_file_name.c_str() );
156 displayer->leaderPrint (
"The Darcy solver\n" );
159 chronoReadAndPartitionMesh.start();
165 darcyData->setup ( dataFile );
168 darcyData_Type::paramListPtr_Type linearAlgebraList = Teuchos::rcp (
new darcyData_Type::paramList_Type );
169 linearAlgebraList = Teuchos::getParametersFromXmlFile ( Members->xml_file_name );
172 darcyData->setLinearAlgebraList ( linearAlgebraList );
178 meshData.setup ( dataFile, Members->discretization_section +
"/space_discretization");
181 regionMeshPtr_Type fullMeshPtr (
new regionMesh_Type ( Members->comm ) );
184 if ( meshData.meshType() !=
"structured" )
187 readMesh ( *fullMeshPtr, meshData );
192 const std::string structuredSection = Members->discretization_section +
"/space_discretization/";
195 regularMesh3D ( *fullMeshPtr, 0,
196 dataFile ( ( structuredSection +
"nx" ).data(), 4 ),
197 dataFile ( ( structuredSection +
"ny" ).data(), 4 ),
198 dataFile ( ( structuredSection +
"nz" ).data(), 4 ),
199 dataFile ( ( structuredSection +
"verbose" ).data(),
false ),
200 dataFile ( ( structuredSection +
"lx" ).data(), 1. ),
201 dataFile ( ( structuredSection +
"ly" ).data(), 1. ),
202 dataFile ( ( structuredSection +
"lz" ).data(), 1. ) );
206 regionMeshPtr_Type meshPtr;
209 MeshPartitioner< regionMesh_Type > meshPart;
212 meshPart.doPartition ( fullMeshPtr, Members->comm );
215 meshPtr = meshPart.meshPartition();
219 chronoReadAndPartitionMesh.stop();
222 displayer->leaderPrint (
"Time for read and partition the mesh ",
223 chronoReadAndPartitionMesh.diff(),
"\n" );
228 chronoBoundaryCondition.start();
230 bcHandlerPtr_Type bcDarcy (
new bcHandler_Type );
232 setBoundaryConditions ( bcDarcy );
235 chronoBoundaryCondition.stop();
238 displayer->leaderPrint (
"Time for create the boundary conditions handler ",
239 chronoBoundaryCondition.diff(),
"\n" );
244 chronoFiniteElementSpace.start();
247 const ReferenceFE* refFE_primal (
static_cast<ReferenceFE*> (NULL) );
248 const QuadratureRule* qR_primal (
static_cast<QuadratureRule*> (NULL) );
249 const QuadratureRule* bdQr_primal (
static_cast<QuadratureRule*> (NULL) );
251 refFE_primal = &feTetraP0;
252 qR_primal = &quadRuleTetra15pt;
253 bdQr_primal = &quadRuleTria4pt;
256 const ReferenceFE* refFE_dual (
static_cast<ReferenceFE*> (NULL) );
257 const QuadratureRule* qR_dual (
static_cast<QuadratureRule*> (NULL) );
258 const QuadratureRule* bdQr_dual (
static_cast<QuadratureRule*> (NULL) );
260 refFE_dual = &feTetraRT0;
261 qR_dual = &quadRuleTetra15pt;
262 bdQr_dual = &quadRuleTria4pt;
265 const ReferenceFE* refFE_dualInterpolate (
static_cast<ReferenceFE*> (NULL) );
266 const QuadratureRule* qR_dualInterpolate (
static_cast<QuadratureRule*> (NULL) );
267 const QuadratureRule* bdQr_dualInterpolate (
static_cast<QuadratureRule*> (NULL) );
269 refFE_dualInterpolate = &feTetraP0;
270 qR_dualInterpolate = &quadRuleTetra15pt;
271 bdQr_dualInterpolate = &quadRuleTria4pt;
275 const ReferenceFE* refFE_hybrid (
static_cast<ReferenceFE*> (NULL) );
276 const QuadratureRule* qR_hybrid (
static_cast<QuadratureRule*> (NULL) );
277 const QuadratureRule* bdQr_hybrid (
static_cast<QuadratureRule*> (NULL) );
279 refFE_hybrid = &feTetraRT0Hyb;
280 qR_hybrid = &quadRuleTetra15pt;
281 bdQr_hybrid = &quadRuleTria4pt;
285 fESpacePtr_Type p_FESpacePtr (
new fESpace_Type ( meshPtr, *refFE_primal, *qR_primal,
286 *bdQr_primal, 1, Members->comm ) );
289 fESpacePtr_Type u_FESpacePtr (
new fESpace_Type ( meshPtr, *refFE_dual, *qR_dual,
290 *bdQr_dual, 1, Members->comm ) );
293 fESpacePtr_Type hybrid_FESpacePtr (
new fESpace_Type ( meshPtr, *refFE_hybrid, *qR_hybrid,
294 *bdQr_hybrid, 1, Members->comm ) );
297 fESpacePtr_Type uInterpolate_FESpacePtr (
new fESpace_Type ( meshPtr, *refFE_dualInterpolate, *qR_dualInterpolate,
298 *bdQr_dualInterpolate, 3, Members->comm ) );
301 chronoFiniteElementSpace.stop();
304 displayer->leaderPrint (
"Time for create the finite element spaces ",
305 chronoFiniteElementSpace.diff(),
"\n" );
308 chronoProblem.start();
311 darcySolver_Type darcySolver;
314 chronoProblem.stop();
317 displayer->leaderPrint (
"Time for create the problem ", chronoProblem.diff(),
"\n" );
322 chronoProcess.start ();
325 darcySolver.setData ( darcyData );
328 darcySolver.setDisplayer ( displayer );
331 darcySolver.setup ();
336 scalarFieldPtr_Type primalField (
new scalarField_Type ( p_FESpacePtr ) );
339 scalarFieldPtr_Type dualField (
new scalarField_Type ( u_FESpacePtr ) );
342 scalarFieldPtr_Type hybridField (
new scalarField_Type ( hybrid_FESpacePtr ) );
345 vectorFieldPtr_Type dualInterpolated (
new vectorField_Type ( uInterpolate_FESpacePtr, Repeated ) );
350 darcySolver.setHybridField ( hybridField );
353 darcySolver.setPrimalField ( primalField );
356 darcySolver.setDualField ( dualField );
359 scalarFctPtr_Type scalarSourceFct (
new scalarSource );
360 darcySolver.setScalarSource ( scalarSourceFct );
363 vectorFctPtr_Type vectorSourceFct (
new vectorSource );
364 darcySolver.setVectorSource ( vectorSourceFct );
367 scalarFctPtr_Type reactionTermFct (
new reactionTerm );
368 darcySolver.setReactionTerm ( reactionTermFct );
371 matrixFctPtr_Type inversePermeabilityFct (
new inversePermeability );
372 darcySolver.setInversePermeability ( inversePermeabilityFct );
375 darcySolver.setBoundaryConditions ( bcDarcy );
378 std::shared_ptr< Exporter< regionMesh_Type > > exporter;
381 vectorPtr_Type primalExporter;
384 vectorPtr_Type primalErrorExporter;
387 vectorPtr_Type primalExact;
390 vectorPtr_Type dualExporter;
393 vectorPtr_Type dualErrorExporter;
396 vectorPtr_Type dualExact;
399 std::string
const exporterType = dataFile (
"exporter/type",
"none" );
402 const std::string exporterFileName = dataFile (
"exporter/file_name",
"PressureVelocity" );
406 if ( exporterType.compare (
"hdf5") == 0 )
408 exporter.reset (
new ExporterHDF5 < regionMesh_Type > ( dataFile, exporterFileName ) );
413 exporter.reset (
new ExporterEmpty < regionMesh_Type > ( dataFile, exporterFileName ) );
417 exporter->setPostDir ( dataFile (
"exporter/folder",
"./" ) );
419 exporter->setMeshProcId ( meshPtr, Members->comm->MyPID() );
422 primalExporter.reset (
new vector_Type ( primalField->getVector(), exporter->mapType() ) );
425 exporter->addVariable ( ExporterData < regionMesh_Type >::ScalarField,
426 dataFile (
"exporter/name_primal",
"Pressure" ),
429 static_cast<UInt> ( 0 ),
430 ExporterData < regionMesh_Type >::SteadyRegime,
431 ExporterData < regionMesh_Type >::Cell );
434 dualExporter.reset (
new vector_Type ( dualInterpolated->getVector(), exporter->mapType() ) );
437 exporter->addVariable ( ExporterData < regionMesh_Type >::VectorField,
438 dataFile (
"exporter/name_dual",
"Velocity" ),
439 uInterpolate_FESpacePtr,
441 static_cast<UInt> ( 0 ),
442 ExporterData < regionMesh_Type >::SteadyRegime,
443 ExporterData < regionMesh_Type >::Cell );
446 primalErrorExporter.reset (
new vector_Type ( primalField->getVector(), exporter->mapType() ) );
449 primalExact.reset (
new vector_Type ( primalField->getVector(), exporter->mapType() ) );
452 exporter->addVariable ( ExporterData < regionMesh_Type >::ScalarField,
453 dataFile (
"exporter/name_primal",
"Pressure" ) + std::string (
"Error"),
456 static_cast<UInt> ( 0 ),
457 ExporterData < regionMesh_Type >::SteadyRegime,
458 ExporterData < regionMesh_Type >::Cell );
461 dualErrorExporter.reset (
new vector_Type ( dualInterpolated->getVector(), exporter->mapType() ) );
464 dualExact.reset (
new vector_Type ( dualInterpolated->getVector(), exporter->mapType() ) );
467 exporter->addVariable ( ExporterData < regionMesh_Type >::VectorField,
468 dataFile (
"exporter/name_dual",
"Velocity" ) + std::string (
"Error"),
469 uInterpolate_FESpacePtr,
471 static_cast<UInt> ( 0 ),
472 ExporterData < regionMesh_Type >::SteadyRegime,
473 ExporterData < regionMesh_Type >::Cell );
476 displayer->leaderPrint (
"Number of unknowns : ",
477 hybrid_FESpacePtr->map().map ( Unique )->NumGlobalElements(),
"\n" );
480 exporter->exportPID ( meshPtr, Members->comm );
483 darcySolver.solve ();
488 *primalExporter = primalField->getVector ();
491 dualInterpolated->getVector() = uInterpolate_FESpacePtr->feToFEInterpolate ( *u_FESpacePtr, dualField->getVector() );
494 *dualExporter = dualInterpolated->getVector();
497 p_FESpacePtr->interpolate ( Members->getAnalyticalSolution(), *primalExact );
500 *primalErrorExporter = *primalExact - primalField->getVector ();
503 uInterpolate_FESpacePtr->interpolate ( Members->getAnalyticalFlux(), *dualExact );
506 *dualErrorExporter = *dualExact - *dualExporter;
509 exporter->postProcess (
static_cast<Real> (0) );
512 chronoProcess.stop();
515 displayer->leaderPrint (
"Time for process ", chronoProcess.diff(),
"\n" );
525 Real primalL2Norm (0), exactPrimalL2Norm (0), primalL2Error (0), primalL2RelativeError (0);
526 Real dualL2Norm (0), exactDualL2Norm (0), dualL2Error (0), dualL2RelativeError (0);
529 displayer->leaderPrint (
"\nPRESSURE ERROR\n" );
532 primalL2Norm = p_FESpacePtr->l2Norm ( primalField->getVector () );
535 displayer->leaderPrint (
" L2 norm of primal unknown: ", primalL2Norm,
"\n" );
538 exactPrimalL2Norm = p_FESpacePtr->l2NormFunction ( Members->getAnalyticalSolution(),
539 darcyData->dataTimePtr()->endTime() );
542 displayer->leaderPrint (
" L2 norm of primal exact: ", exactPrimalL2Norm,
"\n" );
545 primalL2Error = p_FESpacePtr->l2ErrorWeighted ( Members->getAnalyticalSolution(),
546 primalField->getVector(),
548 darcyData->dataTimePtr()->endTime() );
551 displayer->leaderPrint (
" L2 error of primal unknown: ", primalL2Error,
"\n" );
554 primalL2RelativeError = primalL2Error / exactPrimalL2Norm;
557 displayer->leaderPrint (
" L2 relative error of primal unknown: ", primalL2RelativeError,
"\n" );
560 displayer->leaderPrint (
"\nINTERPOLATED DARCY VELOCITY ERROR\n" );
563 dualL2Norm = uInterpolate_FESpacePtr->l2Norm ( dualInterpolated->getVector() );
566 displayer->leaderPrint (
" L2 norm of dual unknown: ", dualL2Norm,
"\n" );
569 exactDualL2Norm = uInterpolate_FESpacePtr->l2NormFunction ( Members->getAnalyticalFlux(),
570 darcyData->dataTimePtr()->endTime() );
573 displayer->leaderPrint (
" L2 norm of dual exact: ", exactDualL2Norm,
"\n" );
576 dualL2Error = uInterpolate_FESpacePtr->l2Error ( Members->getAnalyticalFlux(),
577 dualInterpolated->getVector(),
578 darcyData->dataTimePtr()->endTime(),
582 displayer->leaderPrint (
" L2 error of dual unknown: ", dualL2Error,
"\n" );
585 dualL2RelativeError = dualL2Error / exactDualL2Norm;
588 displayer->leaderPrint (
" L2 relative error of Dual unknown: ", dualL2RelativeError,
"\n" );
594 displayer->leaderPrint (
"Time for compute errors ", chronoError.diff(),
"\n" );
600 displayer->leaderPrint (
"Total time for the computation ", chronoTotal.diff(),
"\n" );
603 return primalL2Error;
Real UOne(const Real &, const Real &, const Real &, const Real &, const ID &)
Standard functions.
LifeV::Real run()
To lunch the simulation.
darcySolver_Type::dataPtr_Type darcyDataPtr_Type
std::string discretization_section
std::string xml_file_name
fct_type getAnalyticalFlux()
fct_type getAnalyticalSolution()
std::string data_file_name
darcy_linear(int argc, char **argv)
Constructor.
double Real
Generic real data.
std::shared_ptr< Epetra_Comm > comm
std::function< Real(const Real &, const Real &, const Real &, const Real &, const ID &) > fct_type