38 #include <lifev/eta/fem/ETFESpace.hpp> 39 #include <lifev/eta/expression/Integrate.hpp> 51 using namespace LifeV;
80 ETA_InterpolateGradient2DTest::ETA_InterpolateGradient2DTest ()
84 M_comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
86 M_comm.reset (
new Epetra_SerialComm() );
96 ETA_InterpolateGradient2DTest::run()
98 bool verbose (M_comm->MyPID() == 0);
106 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
109 const UInt Nelements (10);
111 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
113 regularMesh2D ( *fullMeshPtr, 0, Nelements, Nelements,
false,
117 std::shared_ptr< mesh_Type > meshPtr;
119 MeshPartitioner<
mesh_Type > meshPart (fullMeshPtr, M_comm);
120 meshPtr = meshPart.meshPartition();
127 std::cout <<
" done ! " << std::endl;
138 std::cout <<
" -- Building FESpaces ... " << std::flush;
141 std::string uOrder (
"P1");
143 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
144 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 2, M_comm) );
148 std::cout <<
" done ! " << std::endl;
152 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
157 std::cout <<
" -- Building ETFESpaces ... " << std::flush;
160 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 2, 2 > > ETuSpace
161 (
new ETFESpace< mesh_Type, MapEpetra, 2, 2 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), M_comm) );
165 std::cout <<
" done ! " << std::endl;
169 std::cout <<
" ---> Dofs: " << ETuSpace->dof().numTotalDof() << std::endl;
180 std::cout <<
" -- Interpolating the function ... " << std::flush;
184 uSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uFct), uInterpolated, 0.0);
189 std::cout <<
" done! " << std::endl;
198 MatrixSmall<2, 2> identityMatrix;
199 identityMatrix (0, 0) = 1;
200 identityMatrix (0, 1) = 0;
201 identityMatrix (1, 0) = 0;
202 identityMatrix (1, 1) = 1;
208 std::cout <<
" done! " << std::endl;
221 std::cout <<
" -- ET assembly ... " << std::flush;
226 using namespace ExpressionAssembly;
228 integrate ( elements (ETuSpace->mesh() ),
231 dot ( grad (ETuSpace, uInterpolatedRepeated) , value (identityMatrix) )
242 std::cout <<
" done! " << std::endl;
246 std::cout <<
" Time : " << ETChrono.diff() << std::endl;
255 std::cout <<
" -- Broadcasting and summing integrals across processes ... " << std::flush;
258 Real globalIntegral (0.0);
261 M_comm->SumAll (&ETintegral, &globalIntegral, 1);
265 std::cout <<
" done ! " << std::endl;
275 std::cout <<
" -- Computing the error ... " << std::flush;
278 Real error = std::abs (globalIntegral - 12.0);
282 std::cout <<
"Error: " << error << std::endl;
287 std::cout <<
" done ! " << std::endl;
RegionMesh< LinearTriangle > mesh_Type
MatrixEpetra< Real > matrix_Type
Real uFct(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
Functions.
double Real
Generic real data.
uint32_type UInt
generic unsigned integer (used mainly for addressing)