37 #include <Epetra_ConfigDefs.h> 40 #include <Epetra_MpiComm.h> 42 #include <Epetra_SerialComm.h> 45 #include <Epetra_FECrsGraph.h> 47 #include <lifev/core/LifeV.hpp> 48 #include <lifev/core/util/LifeChrono.hpp> 50 #include <lifev/core/mesh/MeshPartitioner.hpp> 51 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 52 #include <lifev/core/mesh/RegionMesh.hpp> 54 #include <lifev/core/array/MatrixEpetra.hpp> 56 #include <lifev/eta/fem/ETFESpace.hpp> 58 #include <lifev/eta/expression/Integrate.hpp> 59 #include <lifev/eta/expression/BuildGraph.hpp> 62 #include <boost/shared_ptr.hpp> 65 using namespace LifeV;
70 int main (
int argc,
char** argv )
74 MPI_Init (&argc, &argv);
75 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
77 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
80 const bool verbose (Comm->MyPID() == 0);
86 std::cout <<
"Please run program as " << argv[0]
87 <<
" " <<
"<num_elements>\n";
92 const UInt Nelements = std::atoi (argv[1]);
96 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
99 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
101 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
105 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
111 std::cout <<
" done ! " << std::endl;
117 std::cout <<
" -- Building ETFESpaces ... " << std::flush;
120 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > uSpace
121 (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPart, &feTetraP1, Comm) );
125 std::cout <<
" done ! " << std::endl;
129 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
132 std::shared_ptr<matrix_Type> closedSystemMatrix;
133 std::shared_ptr<matrix_Type> openSystemMatrix;
137 std::cout <<
" -- Precomputing matrix graph ... " << std::flush;
140 LifeChrono feLoopTimer;
142 std::shared_ptr<Epetra_FECrsGraph> matrixGraph;
144 using namespace ExpressionAssembly;
147 matrixGraph.reset (
new Epetra_FECrsGraph (Copy, * (uSpace->map().map (Unique) ), 0) );
149 buildGraph ( elements (uSpace->mesh() ),
153 dot ( grad (phi_i) , grad (phi_j) )
156 matrixGraph->GlobalAssemble();
161 std::cout <<
" done in " << feLoopTimer.diff() <<
"s." << std::endl;
166 std::cout <<
" -- Assembling the Laplace matrix with a precomputed graph ... " << std::flush;
171 using namespace ExpressionAssembly;
174 closedSystemMatrix.reset (
new matrix_Type ( uSpace->map(), *matrixGraph ) );
175 *closedSystemMatrix *= 0.0;
179 integrate ( elements (uSpace->mesh() ),
183 dot ( grad (phi_i) , grad (phi_j) )
184 ) >> closedSystemMatrix;
186 closedSystemMatrix->globalAssemble();
192 std::cout <<
" done in " << feLoopTimer.diff() <<
"s." << std::endl;
197 std::cout <<
" -- Assembling the Laplace matrix without graph ... " << std::flush;
202 using namespace ExpressionAssembly;
204 openSystemMatrix.reset (
new matrix_Type ( uSpace->map() ) );
205 *openSystemMatrix *= 0.0;
209 integrate ( elements (uSpace->mesh() ),
213 dot ( grad (phi_i) , grad (phi_j) )
214 ) >> openSystemMatrix;
216 openSystemMatrix->globalAssemble();
222 std::cout <<
" done in " << feLoopTimer.diff() <<
"s." << std::endl;
225 Real closedMatrixNorm ( closedSystemMatrix->normInf() );
226 Real openMatrixNorm ( openSystemMatrix->normInf() );
230 std::cout <<
" Closed matrix norm : " << closedMatrixNorm << std::endl;
231 std::cout <<
" Open matrix norm : " << openMatrixNorm << std::endl;
238 Real closedMatrixNormDiff (std::abs (closedMatrixNorm - 3.2) );
239 Real openMatrixNormDiff (std::abs (openMatrixNorm - 3.2) );
243 std::cout <<
" Error (closed): " << closedMatrixNormDiff << std::endl;
244 std::cout <<
" Error (open): " << openMatrixNormDiff << std::endl;
247 Real testTolerance (1e-10);
249 if ( closedMatrixNormDiff >= testTolerance )
251 return ( EXIT_FAILURE );
253 if ( openMatrixNormDiff >= testTolerance )
255 return ( EXIT_FAILURE );
257 return ( EXIT_SUCCESS );
int main(int argc, char **argv)
MatrixEpetra< Real > matrix_Type
double Real
Generic real data.
RegionMesh< LinearTetra > mesh_Type