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;
92 int main (
int argc,
char** argv )
96 MPI_Init (&argc, &argv);
97 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
99 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
102 const bool verbose (Comm->MyPID() == 0);
104 const UInt Nelements (10);
106 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
110 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
111 length, length, length,
114 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
115 std::shared_ptr< mesh_Type > meshPtr (meshPart.meshPartition() );
119 std::string uOrder (
"P2");
125 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
126 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 1, Comm) );
128 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > ETuSpace
129 (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPtr, & (uSpace->refFE() ), & (uSpace->fe().geoMap() ), Comm) );
131 vector_Type myFEvector (uSpace->map(), Unique);
132 uSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uFunction), myFEvector, 0.0);
133 vector_Type myFEvectorRepeated (myFEvector, Repeated);
135 vector_Type vectorOnes (uSpace->map(), Unique);
136 uSpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uOnes), vectorOnes, 0.0);
138 vector_Type integral (uSpace->map() );
141 using namespace ExpressionAssembly;
143 integrate ( elements (ETuSpace->mesh() ),
146 laplacian(ETuSpace, myFEvectorRepeated) * phi_i
151 integral.globalAssemble();
155 result = integral.dot(vectorOnes);
157 if ( Comm->MyPID() == 0 )
159 std::cout <<
"\n\nSCALAR CASE " << std::endl;
160 std::cout <<
"\nThe volume is = " << length*length*length << std::endl;
161 std::cout <<
"\nThe result is = " << result << std::endl;
162 std::cout <<
"\nThe error is = " << result-(length*length*length) << std::endl;
165 Real error_scalar = result-length*length*length;
171 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpaceVec
172 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 3, Comm) );
174 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 3 > > ETuSpaceVec
175 (
new ETFESpace< mesh_Type, MapEpetra, 3, 3 > (meshPtr, & (uSpaceVec->refFE() ), & (uSpaceVec->fe().geoMap() ), Comm) );
177 vector_Type myFEvectorVec (uSpaceVec->map(), Unique);
178 uSpaceVec->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uFunction), myFEvectorVec, 0.0);
179 vector_Type myFEvectorRepeatedVec (myFEvectorVec, Repeated);
181 vector_Type vectorOnesVec (uSpaceVec->map(), Unique);
182 uSpaceVec->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> (uOnes), vectorOnesVec, 0.0);
184 vector_Type integralVec (uSpaceVec->map() );
187 using namespace ExpressionAssembly;
189 integrate ( elements (ETuSpaceVec->mesh() ),
192 dot ( laplacian(ETuSpaceVec, myFEvectorVec), phi_i )
197 integralVec.globalAssemble();
201 result = integralVec.dot(vectorOnesVec);
203 if ( Comm->MyPID() == 0 )
205 std::cout <<
"\n\nVECTORIAL CASE " << std::endl;
206 std::cout <<
"\nThe volume is = " << 3*length*length*length << std::endl;
207 std::cout <<
"\nThe result is = " << result << std::endl;
208 std::cout <<
"\nThe error is = " << result-(3*(length*length*length)) <<
"\n\n";
211 Real error_vectorial = result-3*length*length*length;
217 if ( std::fabs(error_scalar) < 1e-9 && std::fabs(error_vectorial) < 1e-9 )
219 return ( EXIT_SUCCESS );
222 return ( EXIT_FAILURE );
int main(int argc, char **argv)
MatrixEpetra< Real > matrix_Type
double Real
Generic real data.
Real uOnes(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
RegionMesh< LinearTetra > mesh_Type
Real uFunction(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)