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> 65 #include <lifev/core/mesh/MeshData.hpp> 67 #include <lifev/core/array/MatrixEpetra.hpp> 68 #include <lifev/core/array/VectorEpetra.hpp> 70 #include <lifev/eta/fem/ETFESpace.hpp> 71 #include <lifev/eta/expression/Integrate.hpp> 73 #include <lifev/core/fem/FESpace.hpp> 75 #include <lifev/core/util/LifeChrono.hpp> 77 using namespace LifeV;
98 int main (
int argc,
char** argv )
102 MPI_Init (&argc, &argv);
103 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
105 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
108 const bool verbose (Comm->MyPID() == 0);
110 const UInt Nelements (10);
112 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
116 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
117 length, length, length,
120 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
121 std::shared_ptr< mesh_Type > meshPtr (meshPart.meshPartition() );
125 std::string uOrder (
"P2");
131 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 1, Comm) );
133 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > ETuSpace (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), Comm) );
135 vector_Type vectorTestFunctions (uSpace->map(), Unique);
136 uSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uTestFunctions), vectorTestFunctions, 0.0);
137 vector_Type vectorTestFunctionsRepeated (vectorTestFunctions, Repeated);
139 vector_Type vectorOnes (uSpace->map(), Repeated);
143 vector_Type integral (uSpace->map() );
146 using namespace ExpressionAssembly;
148 integrate ( elements (ETuSpace->mesh() ),
151 value(ETuSpace,vectorOnes) * laplacian(phi_i)
156 integral.globalAssemble();
160 result = integral.dot(vectorTestFunctions);
162 if ( Comm->MyPID() == 0 )
164 std::cout <<
"\n\nSCALAR CASE " << std::endl;
165 std::cout <<
"\nThe volume is = " << length*length*length << std::endl;
166 std::cout <<
"\nThe result is = " << result << std::endl;
167 std::cout <<
"\nThe error is = " << result-(length*length*length) << std::endl;
170 Real error_scalar = result-length*length*length;
176 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpaceVec
177 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 3, Comm) );
179 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 3 > > ETuSpaceVec
180 (
new ETFESpace< mesh_Type, MapEpetra, 3, 3 > (meshPtr, & (uSpaceVec->refFE() ), & (uSpaceVec->fe().geoMap() ), Comm) );
182 vector_Type vectorTestFunctionsVec (uSpaceVec->map(), Unique);
183 uSpaceVec->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uTestFunctions), vectorTestFunctionsVec, 0.0);
184 vector_Type vectorTestFunctionsRepeatedVec (vectorTestFunctionsVec, Repeated);
186 vector_Type vectorOnesVec (uSpaceVec->map(), Repeated );
187 vectorOnesVec.zero();
190 vector_Type integralVec (uSpaceVec->map() );
193 using namespace ExpressionAssembly;
195 integrate ( elements (ETuSpaceVec->mesh() ),
198 dot ( value(ETuSpaceVec,vectorOnesVec), laplacian(phi_i) )
203 integralVec.globalAssemble();
206 result = integralVec.dot(vectorTestFunctionsVec);
208 if ( Comm->MyPID() == 0 )
210 std::cout <<
"\n\nVECTORIAL CASE " << std::endl;
211 std::cout <<
"\nThe volume is = " << (length*length*length)*3 << std::endl;
212 std::cout <<
"\nThe result is = " << result << std::endl;
213 std::cout <<
"\nThe error is = " << result-((length*length*length)*3) <<
"\n\n";
216 Real error_vectorial = result-3*length*length*length;
222 if ( std::fabs(error_scalar) < 1e-9 && std::fabs(error_vectorial) < 1e-9 )
224 return ( EXIT_SUCCESS );
227 return ( EXIT_FAILURE );
int main(int argc, char **argv)
MatrixEpetra< Real > matrix_Type
Real uOne(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
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