49 #include <Epetra_ConfigDefs.h> 52 #include <Epetra_MpiComm.h> 54 #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> 79 #include <lifev/core/fem/FESpace.hpp> 80 #include <lifev/core/solver/ADRAssembler.hpp> 82 #include <lifev/core/util/LifeChrono.hpp> 90 using namespace LifeV;
121 int main (
int argc,
char** argv )
125 MPI_Init (&argc, &argv);
126 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
128 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
131 const bool verbose (Comm->MyPID() == 0);
141 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
144 const UInt Nelements (10);
146 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type ( Comm ) );
148 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
152 std::shared_ptr< mesh_Type > meshPtr;
154 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
155 meshPtr = meshPart.meshPartition();
162 std::cout <<
" done ! " << std::endl;
209 std::cout <<
" -- Building FESpaces ... " << std::flush;
212 std::string uOrder (
"P1");
213 std::string bOrder (
"P1");
215 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
216 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 1, Comm) );
218 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > betaSpace
219 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, bOrder, 3, Comm) );
223 std::cout <<
" done ! " << std::endl;
227 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
232 std::cout <<
" -- Building ETFESpaces ... " << std::flush;
235 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > ETuSpace
236 (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), Comm) );
238 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 3 > > ETbetaSpace
239 (
new ETFESpace< mesh_Type, MapEpetra, 3, 3 > (meshPtr, & (betaSpace->refFE() ), & (betaSpace->fe().geoMap() ), Comm) );
243 std::cout <<
" done ! " << std::endl;
247 std::cout <<
" ---> Dofs: " << ETuSpace->dof().numTotalDof() << std::endl;
278 std::cout <<
" -- Interpolating the advection field ... " << std::flush;
281 vector_Type beta (betaSpace->map(), Repeated);
282 betaSpace->interpolate (betaFct, beta, 0.0);
286 std::cout <<
" done! " << std::endl;
298 std::cout <<
" -- Defining the matrices ... " << std::flush;
301 std::shared_ptr<matrix_Type> systemMatrix (
new matrix_Type ( uSpace->map() ) );
302 *systemMatrix *= 0.0;
304 std::shared_ptr<matrix_Type> ETsystemMatrix (
new matrix_Type ( ETuSpace->map() ) );
305 *ETsystemMatrix *= 0.0;
309 std::cout <<
" done! " << std::endl;
327 LifeChrono StdChrono;
332 std::cout <<
" -- Classical assembly ... " << std::flush;
335 ADRAssembler<mesh_Type, matrix_Type, vector_Type> adrAssembler;
337 adrAssembler.setup (uSpace, betaSpace);
339 adrAssembler.addDiffusion (systemMatrix, 1.0);
341 adrAssembler.addAdvection (systemMatrix, beta);
343 adrAssembler.addMass (systemMatrix, 2.0);
349 std::cout <<
" done ! " << std::endl;
353 std::cout <<
" Time : " << StdChrono.diff() << std::endl;
386 std::cout <<
" -- ET assembly ... " << std::flush;
391 using namespace ExpressionAssembly;
393 integrate ( elements (ETuSpace->mesh() ),
398 dot ( grad (phi_i) , grad (phi_j) )
399 + dot ( grad (phi_j) , value (ETbetaSpace, beta) ) *phi_i
400 + 2.0 * phi_i * phi_j
410 std::cout <<
" done! " << std::endl;
414 std::cout <<
" Time : " << ETChrono.diff() << std::endl;
436 std::cout <<
" -- Closing the matrices ... " << std::flush;
439 systemMatrix->globalAssemble();
440 ETsystemMatrix->globalAssemble();
444 std::cout <<
" done ! " << std::endl;
456 std::cout <<
" -- Computing the error ... " << std::flush;
459 std::shared_ptr<matrix_Type> checkMatrix (
new matrix_Type ( ETuSpace->map() ) );
462 *checkMatrix += *systemMatrix;
463 *checkMatrix += (*ETsystemMatrix) * (-1);
465 checkMatrix->globalAssemble();
467 Real errorNorm ( checkMatrix->normInf() );
471 std::cout <<
" done ! " << std::endl;
491 std::cout <<
" Matrix Error : " << errorNorm << std::endl;
494 Real testTolerance (1e-10);
496 if (errorNorm < testTolerance)
498 return ( EXIT_SUCCESS );
500 return ( EXIT_FAILURE );
int main(int argc, char **argv)
Real betaFctRaw(const Real &, const Real &, const Real &, const Real &, const ID &i)
MatrixEpetra< Real > matrix_Type
function_Type betaFct(betaFctRaw)
double Real
Generic real data.
RegionMesh< LinearTetra > mesh_Type
FESpace< mesh_Type, MapEpetra >::function_Type function_Type