48 #include <Epetra_ConfigDefs.h> 51 #include <Epetra_MpiComm.h> 53 #include <Epetra_SerialComm.h> 58 #include <lifev/core/LifeV.hpp> 60 #include <lifev/core/mesh/MeshPartitioner.hpp> 61 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 62 #include <lifev/core/mesh/RegionMesh.hpp> 64 #include <lifev/core/array/MatrixEpetra.hpp> 65 #include <lifev/core/array/VectorEpetra.hpp> 67 #include <lifev/eta/fem/ETFESpace.hpp> 68 #include <lifev/eta/expression/Integrate.hpp> 70 #include <boost/shared_ptr.hpp> 72 #include <lifev/core/fem/FESpace.hpp> 73 #include <lifev/core/solver/ADRAssembler.hpp> 82 using namespace LifeV;
118 int main (
int argc,
char** argv )
122 MPI_Init (&argc, &argv);
123 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
125 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
128 const bool verbose (Comm->MyPID() == 0);
138 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
141 const UInt Nelements (10);
143 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type ( Comm ) );
145 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
149 std::shared_ptr< mesh_Type > meshPtr;
151 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
152 meshPtr = meshPart.meshPartition();
159 std::cout <<
" done ! " << std::endl;
170 std::cout <<
" -- Building the FESpace ... " << std::flush;
173 std::string uOrder (
"P1");
174 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 1, Comm) );
178 std::cout <<
" done ! " << std::endl;
182 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
187 std::cout <<
" -- Building the ETFESpace ... " << std::flush;
190 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > ETuSpace (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), Comm) );
194 std::cout <<
" done ! " << std::endl;
198 std::cout <<
" ---> Dofs: " << ETuSpace->dof().numTotalDof() << std::endl;
210 std::cout <<
" -- Classical way ... " << std::flush;
213 vector_Type fInterpolated (uSpace->map(), Repeated);
217 uSpace->interpolate (fRhs, fInterpolated, 0.0);
219 vector_Type rhs (uSpace->map(), Repeated);
223 ADRAssembler<mesh_Type, matrix_Type, vector_Type> adrAssembler;
225 adrAssembler.setup (uSpace, uSpace);
227 adrAssembler.addMassRhs (rhs, fInterpolated);
229 rhs.globalAssemble();
233 std::cout <<
" done ! " << std::endl;
256 std::cout <<
" -- ETA way ... " << std::flush;
259 vector_Type rhsET (ETuSpace->map(), Repeated);
263 using namespace ExpressionAssembly;
265 integrate ( elements (ETuSpace->mesh() ),
268 value (ETuSpace, fInterpolated) *phi_i
273 rhsET.globalAssemble();
277 std::cout <<
" done ! " << std::endl;
333 std::cout <<
" -- Integrating g ... " << std::flush;
336 vector_Type gInterpolated (uSpace->map(), Repeated);
340 uSpace->interpolate (g, gInterpolated, 0.0);
342 Real localIntegralg (0.0);
345 using namespace ExpressionAssembly;
347 integrate ( elements (ETuSpace->mesh() ),
349 value (ETuSpace, gInterpolated)
369 Real globalIntegralg (0.0);
372 Comm->SumAll (&localIntegralg, &globalIntegralg, 1);
376 std::cout <<
" done ! " << std::endl;
399 std::cout <<
" -- Computing the volume ... " << std::flush;
402 Real localVolume (0.0);
405 using namespace ExpressionAssembly;
417 integrate ( elements (ETuSpace->mesh() ),
424 Real globalVolume (0.0);
427 Comm->SumAll (&localVolume, &globalVolume, 1);
431 std::cout <<
" done ! " << std::endl;
441 vector_Type checkRhs (ETuSpace->map(), Repeated);
447 checkRhs.globalAssemble();
449 vector_Type checkRhsUnique (checkRhs, Unique);
451 Real errorRhsNorm ( checkRhsUnique.normInf() );
453 Real errorIntegralg (std::abs ( globalIntegralg - 0.0) );
455 Real errorVolume (std::abs ( globalVolume - 8.0) );
459 std::cout <<
" Rhs error : " << errorRhsNorm << std::endl;
463 std::cout <<
" Integral error : " << errorIntegralg << std::endl;
467 std::cout <<
" Volume error : " << errorVolume << std::endl;
484 Real testTolerance (1e-10);
486 if ( (errorRhsNorm < testTolerance)
487 && (errorIntegralg < testTolerance)
488 && (errorVolume < testTolerance) )
490 return ( EXIT_SUCCESS );
492 return ( EXIT_FAILURE );
int main(int argc, char **argv)
MatrixEpetra< Real > matrix_Type
Real gRaw(const Real &, const Real &x, const Real &, const Real &, const ID &)
Real fRhsRaw(const Real &, const Real &, const Real &, const Real &, const ID &)
double Real
Generic real data.
function_Type fRhs(fRhsRaw)
RegionMesh< LinearTetra > mesh_Type
FESpace< mesh_Type, MapEpetra >::function_Type function_Type