35 #pragma GCC diagnostic ignored "-Wunused-variable" 36 #pragma GCC diagnostic ignored "-Wunused-parameter" 40 #include <Epetra_ConfigDefs.h> 43 #include <Epetra_MpiComm.h> 45 #include <Epetra_SerialComm.h> 48 #include <Epetra_FECrsGraph.h> 50 #pragma GCC diagnostic warning "-Wunused-variable" 51 #pragma GCC diagnostic warning "-Wunused-parameter" 53 #include <lifev/core/LifeV.hpp> 54 #include <lifev/core/util/WallClock.hpp> 55 #include <lifev/core/util/OpenMPParameters.hpp> 57 #include <lifev/core/mesh/MeshPartitioner.hpp> 58 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 59 #include <lifev/core/mesh/RegionMesh.hpp> 61 #include <lifev/core/array/MatrixEpetra.hpp> 63 #include <lifev/eta/fem/ETFESpace.hpp> 65 #include <lifev/eta/expression/Integrate.hpp> 66 #include <lifev/eta/expression/BuildGraph.hpp> 69 #include <boost/shared_ptr.hpp> 72 using namespace LifeV;
77 int main (
int argc,
char** argv )
81 MPI_Init (&argc, &argv);
82 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
84 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
87 const bool verbose (Comm->MyPID() == 0);
93 std::cout <<
"Please run program as " << argv[0]
94 <<
" " <<
"<num_elements> " <<
"<num_threads>" 95 <<
" " <<
"<scheduler> " <<
"<chunkSize>\n";
100 OpenMPParameters ompParams;
102 const UInt Nelements = std::atoi (argv[1]);
103 ompParams.numThreads = std::atoi (argv[2]);
105 ompParams.scheduler =
static_cast<omp_sched_t> (std::atoi (argv[3]) );
107 ompParams.chunkSize = std::atoi (argv[4]);
111 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
115 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type);
117 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
122 MeshPartitioner< mesh_Type > meshPart;
123 meshPart.setPartitionOverlap ( 1 );
124 meshPart.doPartition ( fullMeshPtr, Comm );
130 std::cout <<
" done ! " << std::endl;
136 std::cout <<
" -- Building ETFESpaces ... " << std::flush;
139 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > uSpace
140 (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPart, &feTetraP1, Comm) );
144 std::cout <<
" done ! " << std::endl;
148 std::cout <<
" ---> Dofs: " << uSpace->dof().numTotalDof() << std::endl;
151 std::shared_ptr<matrix_Type> closedSystemMatrix;
155 std::cout <<
" -- Precomputing matrix graph ... " << std::flush;
160 std::shared_ptr<Epetra_FECrsGraph> matrixGraph;
162 using namespace ExpressionAssembly;
165 matrixGraph.reset (
new Epetra_FECrsGraph (Copy, * (uSpace->map().map (Unique) ), 0,
true) );
167 buildGraph ( elements (uSpace->mesh() ),
171 dot ( grad (phi_i) , grad (phi_j) )
174 matrixGraph->GlobalAssemble();
179 std::cout <<
" done in " << timer.elapsedTime() <<
"s." << std::endl;
184 std::cout <<
" -- Assembling the Laplace matrix with a precomputed graph ... " << std::flush;
189 using namespace ExpressionAssembly;
192 closedSystemMatrix.reset (
new matrix_Type ( uSpace->map(), *matrixGraph ,
true) );
193 *closedSystemMatrix *= 0.0;
197 integrate ( elements (uSpace->mesh() ),
201 dot ( grad (phi_i) , grad (phi_j) ), ompParams
202 ) >> closedSystemMatrix;
204 closedSystemMatrix->globalAssemble();
210 std::cout <<
" done in " << timer.elapsedTime() <<
"s." << std::endl;
213 Real closedMatrixNorm ( closedSystemMatrix->normInf() );
217 std::cout <<
" Closed matrix norm : " << closedMatrixNorm << std::endl;
224 Real closedMatrixNormDiff (std::abs (closedMatrixNorm - 3.2) );
228 std::cout <<
" Error (closed): " << closedMatrixNormDiff << std::endl;
231 Real testTolerance (1e-10);
233 if ( closedMatrixNormDiff >= testTolerance )
235 return ( EXIT_FAILURE );
237 return ( EXIT_SUCCESS );
int main(int argc, char **argv)
MatrixEpetra< Real > matrix_Type
double Real
Generic real data.
RegionMesh< LinearTetra > mesh_Type