38 #include <lifev/eta/fem/ETFESpace.hpp> 39 #include <lifev/eta/expression/Integrate.hpp> 51 using namespace LifeV;
81 ETA_VectorialADR2DTest::ETA_VectorialADR2DTest ()
85 M_comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
87 M_comm.reset (
new Epetra_SerialComm() );
97 ETA_VectorialADR2DTest::run()
99 bool verbose (M_comm->MyPID() == 0);
107 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
110 const UInt Nelements (10);
112 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
114 regularMesh2D ( *fullMeshPtr, 0, Nelements, Nelements,
false,
118 std::shared_ptr< mesh_Type > meshPtr;
120 MeshPartitioner<
mesh_Type > meshPart (fullMeshPtr, M_comm);
121 meshPtr = meshPart.meshPartition();
128 std::cout <<
" done ! " << std::endl;
143 std::cout <<
" -- Building FESpaces ... " << std::flush;
146 std::string uOrder (
"P1");
147 std::string bOrder (
"P1");
149 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
150 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 2, M_comm) );
152 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > betaSpace
153 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, bOrder, 2, M_comm) );
157 std::cout <<
" done ! " << std::endl;
161 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
166 std::cout <<
" -- Building ETFESpaces ... " << std::flush;
169 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 2, 2 > > ETuSpace
170 (
new ETFESpace< mesh_Type, MapEpetra, 2, 2 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), M_comm) );
172 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 2, 2 > > ETbetaSpace
173 (
new ETFESpace< mesh_Type, MapEpetra, 2, 2 > (meshPtr, & (betaSpace->refFE() ), & (betaSpace->fe().geoMap() ), M_comm) );
177 std::cout <<
" done ! " << std::endl;
181 std::cout <<
" ---> Dofs: " << ETuSpace->dof().numTotalDof() << std::endl;
192 std::cout <<
" -- Interpolating the advection field ... " << std::flush;
196 betaSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (betaFct), beta, 0.0);
200 std::cout <<
" done! " << std::endl;
212 std::cout <<
" -- Defining the matrices ... " << std::flush;
215 std::shared_ptr<matrix_Type> systemMatrix (
new matrix_Type ( uSpace->map() ) );
216 *systemMatrix *= 0.0;
218 std::shared_ptr<matrix_Type> ETsystemMatrix (
new matrix_Type ( ETuSpace->map() ) );
219 *ETsystemMatrix *= 0.0;
223 std::cout <<
" done! " << std::endl;
246 std::cout <<
" -- Classical assembly ... " << std::flush;
251 adrAssembler.setup (uSpace, betaSpace);
253 adrAssembler.addDiffusion (systemMatrix, 1.0);
255 adrAssembler.addAdvection (systemMatrix, beta);
257 adrAssembler.addMass (systemMatrix, 2.0);
263 std::cout <<
" done ! " << std::endl;
267 std::cout <<
" Time : " << StdChrono.diff() << std::endl;
284 std::cout <<
" -- ET assembly ... " << std::flush;
289 using namespace ExpressionAssembly;
291 integrate ( elements (ETuSpace->mesh() ),
296 dot ( grad (phi_i) , grad (phi_j) )
297 + dot ( grad (phi_j) * value (ETbetaSpace, beta), phi_i)
298 + 2.0 * dot (phi_i, phi_j)
309 std::cout <<
" done! " << std::endl;
313 std::cout <<
" Time : " << ETChrono.diff() << std::endl;
324 std::cout <<
" -- Closing the matrices ... " << std::flush;
327 systemMatrix->globalAssemble();
328 ETsystemMatrix->globalAssemble();
332 std::cout <<
" done ! " << std::endl;
343 std::cout <<
" -- Computing the error ... " << std::flush;
346 std::shared_ptr<matrix_Type> checkMatrix (
new matrix_Type ( ETuSpace->map() ) );
349 *checkMatrix += *systemMatrix;
350 *checkMatrix += (*ETsystemMatrix) * (-1);
352 checkMatrix->globalAssemble();
354 Real errorNorm ( checkMatrix->normInf() );
358 std::cout <<
" done ! " << std::endl;
370 std::cout <<
" Matrix Error : " << errorNorm << std::endl;
MatrixEpetra< Real > matrix_Type
double Real
Generic real data.
RegionMesh< LinearTriangle > mesh_Type
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.