45 #include <Epetra_ConfigDefs.h> 48 #include <Epetra_MpiComm.h> 50 #include <Epetra_SerialComm.h> 54 #include <lifev/core/LifeV.hpp> 56 #include <lifev/core/mesh/MeshPartitioner.hpp> 57 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 58 #include <lifev/core/mesh/RegionMesh.hpp> 59 #include <lifev/core/mesh/MeshData.hpp> 61 #include <lifev/core/array/MatrixEpetra.hpp> 62 #include <lifev/core/array/VectorEpetra.hpp> 64 #include <lifev/eta/fem/ETFESpace.hpp> 65 #include <lifev/eta/expression/Integrate.hpp> 67 #include <lifev/core/fem/FESpace.hpp> 69 #include <lifev/core/util/LifeChrono.hpp> 71 using namespace LifeV;
87 int main (
int argc,
char** argv )
91 MPI_Init (&argc, &argv);
92 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
94 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
97 const bool verbose (Comm->MyPID() == 0);
99 const UInt Nelements (10);
101 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
106 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
107 length, length, length,
110 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
111 std::shared_ptr< mesh_Type > meshPtr (meshPart.meshPartition() );
115 std::string uOrder (
"P2");
121 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
122 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 1, Comm) );
124 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > ETuSpace
125 (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), Comm) );
127 vector_Type vectorTestFunctions (uSpace->map(), Unique);
128 uSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uTestFunctions), vectorTestFunctions, 0.0);
130 matrix_Type integral (uSpace->map() );
133 using namespace ExpressionAssembly;
135 integrate ( elements (ETuSpace->mesh() ),
139 laplacian(phi_i) * laplacian(phi_j)
144 integral.globalAssemble();
148 vector_Type first(uSpace->map());
149 first = integral * vectorTestFunctions;
150 result = vectorTestFunctions.dot(first);
152 if ( Comm->MyPID() == 0 )
154 std::cout <<
"\n\nSCALAR CASE " << std::endl;
155 std::cout <<
"\nThe volume is = " << 27 << std::endl;
156 std::cout <<
"\nThe result is = " << result << std::endl;
157 std::cout <<
"\nThe error is = " << result-27 << std::endl;
160 Real error_scalar = result-27.0;
166 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpaceVec
167 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 3, Comm) );
169 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 3 > > ETuSpaceVec
170 (
new ETFESpace< mesh_Type, MapEpetra, 3, 3 > (meshPtr, & (uSpaceVec->refFE() ), & (uSpaceVec->fe().geoMap() ), Comm) );
172 vector_Type vectorTestFunctionsVec (uSpaceVec->map(), Unique);
173 uSpaceVec->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uTestFunctions), vectorTestFunctionsVec, 0.0);
175 matrix_Type integralVec (uSpaceVec->map() );
178 using namespace ExpressionAssembly;
180 integrate ( elements (ETuSpaceVec->mesh() ),
184 dot ( laplacian(phi_i), laplacian(phi_j) )
189 integralVec.globalAssemble();
193 vector_Type firstVec(uSpaceVec->map());
194 firstVec = integralVec * vectorTestFunctionsVec;
195 result = vectorTestFunctionsVec.dot(firstVec);
197 if ( Comm->MyPID() == 0 )
199 std::cout <<
"\n\nVECTORIAL CASE " << std::endl;
200 std::cout <<
"\nThe volume is = " << 81 << std::endl;
201 std::cout <<
"\nThe result is = " << result << std::endl;
202 std::cout <<
"\nThe error is = " << result-81 <<
"\n\n";
205 Real error_vectorial = result-81.0;
211 if ( std::fabs(error_scalar) < 1e-9 && std::fabs(error_vectorial) < 1e-9 )
213 return ( EXIT_SUCCESS );
216 return ( EXIT_FAILURE );
int main(int argc, char **argv)
MatrixEpetra< Real > matrix_Type
Real uTestFunctions(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
double Real
Generic real data.
RegionMesh< LinearTetra > mesh_Type