37 #include <Epetra_ConfigDefs.h> 40 #include <Epetra_MpiComm.h> 42 #include <Epetra_SerialComm.h> 46 #include <lifev/core/LifeV.hpp> 48 #include <lifev/core/algorithm/PreconditionerIfpack.hpp> 49 #include <lifev/core/algorithm/PreconditionerML.hpp> 51 #include <lifev/core/filter/ExporterEnsight.hpp> 52 #include <lifev/core/filter/ExporterHDF5.hpp> 54 #include <lifev/core/fem/BCManage.hpp> 56 #include <lifev/core/mesh/MeshPartitioner.hpp> 57 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 58 #include <lifev/core/mesh/RegionMesh.hpp> 60 #include <lifev/core/mesh/MeshData.hpp> 62 #include <lifev/level_set/solver/LevelSetSolver.hpp> 64 using namespace LifeV;
84 return sqrt ( (x + 0.7) * (x + 0.7) + y * y + z * z ) - 0.3;
89 return sqrt ( (x + 0.7 - t) * (x + 0.7 - t) + y * y + z * z ) - 0.3;
98 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);
114 std::cout <<
" -- Reading the data ... " << std::flush;
116 GetPot dataFile (
"data" );
119 std::cout <<
" done ! " << std::endl;
122 const UInt Nelements (dataFile (
"mesh/nelements", 20) );
125 std::cout <<
" ---> Number of elements : " << Nelements << std::endl;
132 std::cout <<
" -- Building the mesh ... " << std::flush;
134 std::shared_ptr< mesh_Type > fullMeshPtr (
new RegionMesh<LinearTetra> ( Comm ) );
135 regularMesh3D ( *fullMeshPtr, 1, Nelements, Nelements, Nelements,
false,
140 std::cout <<
" done ! " << std::endl;
145 std::cout <<
" -- Partitioning the mesh ... " << std::flush;
147 std::shared_ptr< mesh_Type > localMeshPtr;
149 MeshPartitioner< mesh_Type > meshPart (fullMeshPtr, Comm);
150 localMeshPtr = meshPart.meshPartition();
154 std::cout <<
" done ! " << std::endl;
159 std::cout <<
" -- Freeing the global mesh ... " << std::flush;
164 std::cout <<
" done ! " << std::endl;
171 std::cout <<
" -- Building FESpaces ... " << std::flush;
173 std::string uOrder (
"P1");
174 std::string bOrder (
"P1");
175 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > uFESpace (
new FESpace< mesh_Type, MapEpetra > (localMeshPtr, uOrder, 1, Comm) );
176 std::shared_ptr<FESpace< mesh_Type, MapEpetra > > betaFESpace (
new FESpace< mesh_Type, MapEpetra > (localMeshPtr, bOrder, 3, Comm) );
179 std::cout <<
" done ! " << std::endl;
183 std::cout <<
" ---> Dofs: " << uFESpace->dof().numTotalDof() << std::endl;
188 std::shared_ptr<DataLevelSet> data_level_set (
new DataLevelSet);
189 data_level_set->setup (dataFile,
"level-set");
193 LevelSetSolver<mesh_Type> level_set (uFESpace, betaFESpace);
194 level_set.setup (data_level_set);
196 vector_Type initLS (level_set.map() );
197 uFESpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> ( initLSFct ), initLS, 0.0 );
198 level_set.initialize (initLS);
200 level_set.setupLinearSolver (dataFile,
"");
202 vector_Type beta (betaFESpace->map() );
203 betaFESpace->interpolate (
static_cast<FESpace< mesh_Type, MapEpetra >::function_Type> ( betaFct ), beta, 0.0);
206 BCFunctionBase BCu ( exactSolution );
207 bchandler.addBC (
"Dirichlet", 1, Essential, Full, BCu, 1);
208 for (UInt i (2); i <= 6; ++i)
210 bchandler.addBC (
"Dirichlet", i, Essential, Full, BCu, 1);
214 ExporterHDF5<mesh_Type> exporter ( dataFile, localMeshPtr,
"solution", Comm->MyPID() );
215 exporter.setMultimesh (
false);
216 std::shared_ptr<vector_Type> solutionPtr (
new vector_Type (level_set.solution(), Repeated) );
217 exporter.addVariable ( ExporterData<mesh_Type>::ScalarField,
"level-set", uFESpace, solutionPtr, UInt (0) );
218 exporter.postProcess (0);
221 Real current_time ( data_level_set->dataTime()->initialTime() );
222 Real dt ( data_level_set->dataTime()->timeStep() );
223 Real final_time ( data_level_set->dataTime()->endTime() );
225 while ( current_time < final_time)
228 data_level_set->dataTime()->updateTime();
231 std::cout <<
" We are now at time " << current_time << std::endl;
236 std::cout <<
"[LS] Building system ... " << std::flush;
238 level_set.updateSystem (beta, bchandler, current_time);
241 std::cout <<
" done " << std::endl;
245 std::cout <<
"[LS] Solving system ... " << std::flush;
253 std::cout <<
" Iterate done in " << c.diff() << std::endl;
257 std::cout <<
"[LS] Reinitizialization ... " << std::flush;
259 level_set.reinitializationDirect();
262 std::cout <<
" done " << std::endl;
266 std::cout <<
"[LS] Exporting ... " << std::flush;
269 *solutionPtr = level_set.solution();
270 exporter.postProcess (current_time);
274 std::cout <<
" done " << std::endl;
278 Real N (level_set.solution().norm1() );
281 std::cout <<
"Final norm of the solution : " << N << std::endl;
284 if ( (N < 6900) || (N > 7100) )
286 return (EXIT_FAILURE);
290 exporter.closeFile();
295 std::cout <<
"End Result: TEST PASSED" << std::endl;
302 return ( EXIT_SUCCESS );
VectorEpetra - The Epetra Vector format Wrapper.
Real exactSolution(const Real &t, const Real &x, const Real &y, const Real &z, const ID &)
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
MatrixEpetra< Real > matrix_Type
static const LifeV::UInt elm_nodes_num[]
Real betaFct(const Real &, const Real &, const Real &, const Real &, const ID &i)
RegionMesh< LinearTetra > mesh_Type
Real initLSFct(const Real &, const Real &x, const Real &y, const Real &z, const ID &)
double Real
Generic real data.
int main(int argc, char **argv)