38 #include <lifev/eta/fem/ETFESpace.hpp> 39 #include <lifev/eta/expression/Integrate.hpp> 51 using namespace LifeV;
87 ETA_ADR2DTest::ETA_ADR2DTest ()
91 M_comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
93 M_comm.reset (
new Epetra_SerialComm() );
105 bool verbose (M_comm->MyPID() == 0);
113 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
116 const UInt Nelements (10);
118 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
120 regularMesh2D ( *fullMeshPtr, 0, Nelements, Nelements,
false,
124 std::shared_ptr< mesh_Type > meshPtr;
126 MeshPartitioner<
mesh_Type > meshPart (fullMeshPtr, M_comm);
127 meshPtr = meshPart.meshPartition();
134 std::cout <<
" done ! " << std::endl;
149 std::cout <<
" -- Building FESpaces ... " << std::flush;
152 std::string uOrder (
"P1");
153 std::string bOrder (
"P1");
155 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
156 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 1, M_comm) );
158 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > betaSpace
159 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, bOrder, 2, M_comm) );
163 std::cout <<
" done ! " << std::endl;
167 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
172 std::cout <<
" -- Building ETFESpaces ... " << std::flush;
175 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 2, 1 > > ETuSpace
176 (
new ETFESpace< mesh_Type, MapEpetra, 2, 1 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), M_comm) );
178 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 2, 2 > > ETbetaSpace
179 (
new ETFESpace< mesh_Type, MapEpetra, 2, 2 > (meshPtr, & (betaSpace->refFE() ), & (betaSpace->fe().geoMap() ), M_comm) );
183 std::cout <<
" done ! " << std::endl;
187 std::cout <<
" ---> Dofs: " << ETuSpace->dof().numTotalDof() << std::endl;
198 std::cout <<
" -- Interpolating the advection field ... " << std::flush;
202 betaSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (betaFct), beta, 0.0);
206 std::cout <<
" done! " << std::endl;
218 std::cout <<
" -- Defining the matrices ... " << std::flush;
221 std::shared_ptr<matrix_Type> systemMatrix (
new matrix_Type ( uSpace->map() ) );
222 *systemMatrix *= 0.0;
224 std::shared_ptr<matrix_Type> ETsystemMatrix (
new matrix_Type ( ETuSpace->map() ) );
225 *ETsystemMatrix *= 0.0;
229 std::cout <<
" done! " << std::endl;
238 std::cout <<
" -- Defining and interpolating the RHS ... " << std::flush;
246 vector_Type fInterpolated (uSpace->map(), Repeated);
247 fInterpolated *= 0.0;
248 uSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (fRhs) , fInterpolated, 0.0 );
252 std::cout <<
" done! " << std::endl;
276 std::cout <<
" -- Classical assembly ... " << std::flush;
281 adrAssembler.setup (uSpace, betaSpace);
283 adrAssembler.addDiffusion (systemMatrix, 1.0);
285 adrAssembler.addAdvection (systemMatrix, beta);
287 adrAssembler.addMass (systemMatrix, 2.0);
289 adrAssembler.addMassRhs (rhs, fInterpolated);
295 std::cout <<
" done ! " << std::endl;
299 std::cout <<
" Time : " << StdChrono.diff() << std::endl;
316 std::cout <<
" -- ET assembly ... " << std::flush;
321 using namespace ExpressionAssembly;
323 integrate ( elements (ETuSpace->mesh() ),
328 dot ( grad (phi_i) , grad (phi_j) )
329 + dot ( grad (phi_j) , value (ETbetaSpace, beta) ) *phi_i
330 + 2.0 * phi_i * phi_j
335 integrate ( elements (ETuSpace->mesh() ),
339 value (ETuSpace, fInterpolated) *phi_i
350 std::cout <<
" done! " << std::endl;
354 std::cout <<
" Time : " << ETChrono.diff() << std::endl;
365 std::cout <<
" -- Closing the matrices and vectors... " << std::flush;
368 systemMatrix->globalAssemble();
369 ETsystemMatrix->globalAssemble();
371 rhs.globalAssemble();
372 ETrhs.globalAssemble();
376 std::cout <<
" done ! " << std::endl;
387 std::cout <<
" -- Computing the error ... " << std::flush;
390 std::shared_ptr<matrix_Type> checkMatrix (
new matrix_Type ( ETuSpace->map() ) );
393 *checkMatrix += *systemMatrix;
394 *checkMatrix += (*ETsystemMatrix) * (-1);
396 checkMatrix->globalAssemble();
398 Real errorNorm ( checkMatrix->normInf() );
413 checkRhs.globalAssemble();
417 Real errorRhsNorm ( checkRhsUnique.normInf() );
421 std::cout <<
" done ! " << std::endl;
426 std::cout <<
" Matrix Error : " << errorNorm << std::endl;
430 std::cout <<
" Rhs error : " << errorRhsNorm << std::endl;
439 return std::max (errorNorm, errorRhsNorm);
Real fRhs(const Real &, const Real &, const Real &, const Real &, const ID &i)
RegionMesh< LinearTriangle > mesh_Type
MatrixEpetra< Real > matrix_Type
double Real
Generic real data.
ADRAssembler - This class add into given matrices terms corresponding to the space discretization of ...
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Real betaFct(const Real &, const Real &, const Real &, const Real &, const ID &i)
Functions.