38 #include <lifev/eta/fem/ETFESpace.hpp> 39 #include <lifev/eta/expression/Integrate.hpp> 51 using namespace LifeV;
83 ETA_ADR1DTest::ETA_ADR1DTest ()
87 M_comm.reset (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
89 M_comm.reset (
new Epetra_SerialComm() );
101 bool verbose (M_comm->MyPID() == 0);
109 std::cout <<
" -- Building the mesh ... " << std::flush;
112 const UInt Nelements (10);
114 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
116 regularMesh1D ( *fullMeshPtr, 0, Nelements,
false,
127 std::cout <<
" done ! " << std::endl;
142 std::cout <<
" -- Building FESpaces ... " << std::flush;
145 std::string uOrder (
"P1");
146 std::string bOrder (
"P1");
148 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
149 (
new FESpace< mesh_Type, MapEpetra > (fullMeshPtr, uOrder, 1, M_comm) );
151 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > betaSpace
152 (
new FESpace< mesh_Type, MapEpetra > (fullMeshPtr, bOrder, 1, M_comm) );
156 std::cout <<
" done ! " << std::endl;
160 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
165 std::cout <<
" -- Building ETFESpaces ... " << std::flush;
168 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 1, 1 > > ETuSpace
169 (
new ETFESpace< mesh_Type, MapEpetra, 1, 1 > (fullMeshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), M_comm) );
171 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 1, 1 > > ETbetaSpace
172 (
new ETFESpace< mesh_Type, MapEpetra, 1, 1 > (fullMeshPtr, & (betaSpace->refFE() ), & (betaSpace->fe().geoMap() ), M_comm) );
176 std::cout <<
" done ! " << std::endl;
180 std::cout <<
" ---> Dofs: " << ETuSpace->dof().numTotalDof() << std::endl;
191 std::cout <<
" -- Interpolating the advection field ... " << std::flush;
195 betaSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (betaFct), beta, 0.0);
199 std::cout <<
" done! " << std::endl;
211 std::cout <<
" -- Defining the matrices ... " << std::flush;
214 std::shared_ptr<matrix_Type> systemMatrix (
new matrix_Type ( uSpace->map() ) );
215 *systemMatrix *= 0.0;
217 std::shared_ptr<matrix_Type> ETsystemMatrix (
new matrix_Type ( ETuSpace->map() ) );
218 *ETsystemMatrix *= 0.0;
222 std::cout <<
" done! " << std::endl;
231 std::cout <<
" -- Defining and interpolating the RHS ... " << std::flush;
239 vector_Type fInterpolated (uSpace->map(), Repeated);
240 fInterpolated *= 0.0;
241 uSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (fRhs) , fInterpolated, 0.0 );
245 std::cout <<
" done! " << std::endl;
269 std::cout <<
" -- Classical assembly ... " << std::flush;
274 adrAssembler.setup (uSpace, betaSpace);
276 adrAssembler.addDiffusion (systemMatrix, 1.0);
278 adrAssembler.addAdvection (systemMatrix, beta);
280 adrAssembler.addMass (systemMatrix, 2.0);
282 adrAssembler.addMassRhs (rhs, fInterpolated);
288 std::cout <<
" done ! " << std::endl;
292 std::cout <<
" Time : " << StdChrono.diff() << std::endl;
309 std::cout <<
" -- ET assembly ... " << std::flush;
320 using namespace ExpressionAssembly;
322 integrate ( elements (ETuSpace->mesh() ),
327 dot ( grad (phi_i) , grad (phi_j) )
328 + dot ( grad (phi_j) , value (oneVector) ) * value (ETbetaSpace, beta) *phi_i
329 + 2.0 * phi_i * phi_j
334 integrate ( elements (ETuSpace->mesh() ),
338 value (ETuSpace, fInterpolated) *phi_i
349 std::cout <<
" done! " << std::endl;
353 std::cout <<
" Time : " << ETChrono.diff() << std::endl;
364 std::cout <<
" -- Closing the matrices and vectors... " << std::flush;
367 systemMatrix->globalAssemble();
368 ETsystemMatrix->globalAssemble();
370 rhs.globalAssemble();
371 ETrhs.globalAssemble();
375 std::cout <<
" done ! " << std::endl;
386 std::cout <<
" -- Computing the error ... " << std::flush;
389 std::shared_ptr<matrix_Type> checkMatrix (
new matrix_Type ( ETuSpace->map() ) );
392 *checkMatrix += *systemMatrix;
393 *checkMatrix += (*ETsystemMatrix) * (-1);
395 checkMatrix->globalAssemble();
397 Real errorNorm ( checkMatrix->normInf() );
412 checkRhs.globalAssemble();
420 std::cout <<
" done ! " << std::endl;
425 std::cout <<
" Matrix Error : " << errorNorm << std::endl;
429 std::cout <<
" Rhs error : " << errorRhsNorm << std::endl;
438 return std::max (errorNorm, errorRhsNorm);
VectorEpetra - The Epetra Vector format Wrapper.
RegionMesh< LinearLine > mesh_Type
VectorEpetra(const VectorEpetra &vector, const MapEpetraType &mapType)
Copy constructor.
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
Real betaFct(const Real &, const Real &, const Real &, const Real &, const ID &)
Functions.
Real normInf() const
Compute and return the norm inf.
MatrixEpetra< Real > matrix_Type
double Real
Generic real data.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Real fRhs(const Real &, const Real &, const Real &, const Real &, const ID &)