51 #include <Epetra_ConfigDefs.h> 54 #include <Epetra_MpiComm.h> 56 #include <Epetra_SerialComm.h> 60 #include <lifev/core/LifeV.hpp> 62 #include <lifev/core/mesh/MeshPartitioner.hpp> 63 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 64 #include <lifev/core/mesh/RegionMesh.hpp> 66 #include <lifev/core/array/MatrixEpetra.hpp> 67 #include <lifev/core/array/VectorEpetra.hpp> 69 #include <lifev/eta/fem/ETFESpace.hpp> 70 #include <lifev/eta/expression/Integrate.hpp> 72 #include <lifev/core/fem/FESpace.hpp> 74 #include <lifev/core/util/LifeChrono.hpp> 76 #include <boost/shared_ptr.hpp> 84 using namespace LifeV;
120 int main (
int argc,
char** argv )
124 MPI_Init (&argc, &argv);
125 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
127 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
130 const bool verbose (Comm->MyPID() == 0);
135 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
138 const UInt Nelements (10);
140 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
142 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
146 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
147 std::shared_ptr< mesh_Type > meshPtr (meshPart.meshPartition() );
153 std::cout <<
" done ! " << std::endl;
165 std::cout <<
" -- Building FESpaces ... " << std::flush;
168 std::string uOrder (
"P1");
170 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
171 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 3, Comm) );
175 std::cout <<
" done ! " << std::endl;
179 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
184 std::cout <<
" -- Building ETFESpaces ... " << std::flush;
187 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 3 > > ETuSpace
188 (
new ETFESpace< mesh_Type, MapEpetra, 3, 3 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), Comm) );
192 std::cout <<
" done ! " << std::endl;
196 std::cout <<
" ---> Dofs: " << ETuSpace->dof().numTotalDof() << std::endl;
206 std::cout <<
" -- Interpolating the function ... " << std::flush;
209 vector_Type uInterpolated (uSpace->map(), Unique);
210 uSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uFct), uInterpolated, 0.0);
211 vector_Type uInterpolatedRepeated (uInterpolated, Repeated);
215 std::cout <<
" done! " << std::endl;
226 MatrixSmall<3, 3> identityMatrix;
227 identityMatrix (0, 0) = 1;
228 identityMatrix (1, 1) = 1;
229 identityMatrix (2, 2) = 1;
235 std::cout <<
" done! " << std::endl;
248 std::cout <<
" -- ET assembly ... " << std::flush;
253 using namespace ExpressionAssembly;
255 integrate ( elements (ETuSpace->mesh() ),
258 dot ( grad (ETuSpace, uInterpolatedRepeated) , value (identityMatrix) )
269 std::cout <<
" done! " << std::endl;
273 std::cout <<
" Time : " << ETChrono.diff() << std::endl;
282 std::cout <<
" -- Broadcasting and summing integrals across processes ... " << std::flush;
285 Real globalIntegral (0.0);
288 Comm->SumAll (&ETintegral, &globalIntegral, 1);
292 std::cout <<
" done ! " << std::endl;
302 std::cout <<
" -- Computing the error ... " << std::flush;
305 Real error = std::abs (globalIntegral - 64.0);
309 std::cout <<
"Error: " << error << std::endl;
314 std::cout <<
" done ! " << std::endl;
322 Real tolerance (1e-10);
324 if (error < tolerance)
326 return ( EXIT_SUCCESS );
328 return ( EXIT_FAILURE );
int main(int argc, char **argv)
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.
RegionMesh< LinearTetra > mesh_Type