54 #include <Epetra_ConfigDefs.h> 57 #include <Epetra_MpiComm.h> 59 #include <Epetra_SerialComm.h> 63 #include <lifev/core/LifeV.hpp> 65 #include <lifev/core/mesh/MeshPartitioner.hpp> 66 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 67 #include <lifev/core/mesh/RegionMesh.hpp> 69 #include <lifev/core/array/MatrixEpetra.hpp> 70 #include <lifev/core/array/VectorEpetra.hpp> 72 #include <lifev/core/array/MatrixEpetraStructured.hpp> 73 #include <lifev/core/array/VectorEpetraStructured.hpp> 75 #include <lifev/eta/fem/ETFESpace.hpp> 76 #include <lifev/eta/expression/Integrate.hpp> 78 #include <lifev/core/fem/FESpace.hpp> 80 #include <boost/shared_ptr.hpp> 88 using namespace LifeV;
113 int main (
int argc,
char** argv )
117 MPI_Init (&argc, &argv);
118 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
120 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
123 const bool verbose (Comm->MyPID() == 0);
128 std::cout <<
" -- Building and partitioning the mesh ... " << std::flush;
131 const UInt Nelements (10);
133 std::shared_ptr< mesh_Type > fullMeshPtr (
new mesh_Type ( Comm ) );
135 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
139 std::shared_ptr< mesh_Type > meshPtr;
141 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
142 meshPtr = meshPart.meshPartition();
149 std::cout <<
" done ! " << std::endl;
163 std::cout <<
" -- Building the spaces ... " << std::flush;
166 std::string uOrder (
"P2");
167 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uSpace
168 (
new FESpace< mesh_Type, MapEpetra > (meshPtr, uOrder, 1, Comm) );
170 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 3 > > ETuSpace
171 (
new ETFESpace< mesh_Type, MapEpetra, 3, 3 > (meshPtr, &feTetraP2, & (uSpace->fe().geoMap() ), Comm) );
173 std::shared_ptr<ETFESpace< mesh_Type, MapEpetra, 3, 1 > > ETpSpace
174 (
new ETFESpace< mesh_Type, MapEpetra, 3, 1 > (meshPtr, &feTetraP1, & (uSpace->fe().geoMap() ), Comm) );
178 std::cout <<
" done ! " << std::endl;
182 std::cout <<
" ---> Velocity dofs: " << ETuSpace->dof().numTotalDof() << std::endl;
186 std::cout <<
" ---> Pressure dofs: " << ETpSpace->dof().numTotalDof() << std::endl;
199 std::cout <<
" -- Assembly of the Stokes matrix ... " << std::flush;
202 std::shared_ptr<blockMatrix_Type> ETsystemMatrix (
new blockMatrix_Type ( ETuSpace->map() | ETpSpace->map() ) );
203 *ETsystemMatrix *= 0.0;
216 using namespace ExpressionAssembly;
218 integrate ( elements (ETuSpace->mesh() ),
223 dot ( grad (phi_i) , grad (phi_j) )
226 >> ETsystemMatrix->block (0, 0);
228 integrate ( elements (ETuSpace->mesh() ),
236 >> ETsystemMatrix->block (0, 1);
238 integrate ( elements (ETuSpace->mesh() ),
246 >> ETsystemMatrix->block (1, 0);
249 ETsystemMatrix->globalAssemble();
253 std::cout <<
" done! " << std::endl;
261 Real matrixNorm (ETsystemMatrix->normInf() );
265 std::cout <<
" Matrix norm " << matrixNorm << std::endl;
277 std::cout <<
" -- Building the rhs ... " << std::flush;
280 vector_Type fInterpolated (ETuSpace->map(), Repeated);
282 fInterpolated *= 0.0;
284 uSpace->interpolate (forceFct, fInterpolated, 0.0);
286 blockVector_Type ETrhs (ETuSpace->map() | ETpSpace->map() , Repeated);
290 using namespace ExpressionAssembly;
292 integrate ( elements (ETuSpace->mesh() ),
295 dot (value (ETuSpace, fInterpolated), phi_i)
300 ETrhs.globalAssemble();
304 std::cout <<
" done! " << std::endl;
314 blockVector_Type ETrhsUnique (ETrhs, Unique);
316 Real rhsNorm (ETrhsUnique.normInf() );
320 std::cout <<
" Rhs norm " << rhsNorm << std::endl;
339 ( std::abs (matrixNorm - 3.856 ) < 1e-2) &&
340 ( std::abs (rhsNorm - 0.00187384) < 1e-5)
343 return ( EXIT_SUCCESS );
345 return ( EXIT_FAILURE );
int main(int argc, char **argv)
MatrixEpetra< Real > matrix_Type
function_Type forceFct(forceFctRaw)
Real forceFctRaw(const Real &, const Real &, const Real &, const Real &z, const ID &)
MatrixEpetraStructured< Real > blockMatrix_Type
double Real
Generic real data.
RegionMesh< LinearTetra > mesh_Type
VectorEpetraStructured blockVector_Type
FESpace< mesh_Type, MapEpetra >::function_Type function_Type