40 #include <lifev/core/LifeV.hpp> 41 #include <lifev/core/util/LifeChrono.hpp> 42 #include <lifev/core/array/GhostHandler.hpp> 43 #include <lifev/core/array/VectorEpetra.hpp> 44 #include <lifev/core/mesh/MeshData.hpp> 45 #include <lifev/core/mesh/MeshPartitioner.hpp> 46 #include <lifev/core/mesh/NeighborMarker.hpp> 47 #include <lifev/core/filter/GetPot.hpp> 48 #include <lifev/core/fem/FESpace.hpp> 50 #include <lifev/core/filter/Exporter.hpp> 52 #include <lifev/core/filter/ExporterHDF5.hpp> 54 #include <lifev/core/filter/ExporterEmpty.hpp> 55 #include <lifev/core/filter/ExporterEnsight.hpp> 61 using namespace LifeV;
63 int main (
int argc,
char* argv[] )
67 MPI_Init (&argc, &argv);
68 std::cout <<
"MPI Initialization" << std::endl;
76 typedef std::shared_ptr< feSpace_Type > feSpacePtr_Type;
86 const std::string data_file_name = command_line
.follow ("data_ghosthandler", 2
, "-f", "--file");
90 std::cout <<
"Epetra Initialization" << std::endl;
91 std::shared_ptr<Epetra_Comm> comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
93 std::shared_ptr<Epetra_Comm> comm (
new Epetra_SerialComm() );
97 bool isLeader = ( comm->MyPID() == 0 );
99 #ifdef HAVE_LIFEV_DEBUG 101 std::ofstream fileOut ( (
"gh." + std::to_string ( comm->MyPID() ) +
".out" ).c_str() );
104 std::ofstream fileOut (
"/dev/null" );
109 std::cout <<
"GhostHendler test" << std::endl;
119 meshData.setup ( dataFile,
"space_discretization" );
122 std::shared_ptr<mesh_Type> fullMeshPtr (
new mesh_Type ( comm ) );
125 readMesh ( *fullMeshPtr, meshData );
128 std::shared_ptr<mesh_Type> meshPtr (
new mesh_Type ( comm ) );
131 meshPtr = meshPart.meshPartition();
140 std::cout <<
" C- Time for mesh " << chronoMesh.diff() << std::endl;
146 feSpacePtr_Type feSpaceP1 (
new feSpace_Type ( meshPtr,
153 fileOut <<
"=================== P1" << std::endl;
154 fileOut <<
"9---8---7---6---5" << std::endl;
155 fileOut <<
"| /| /| /| /|" << std::endl;
156 fileOut <<
"| / | / | / | / |" << std::endl;
157 fileOut <<
"|/ |/ |/ |/ |" << std::endl;
158 fileOut <<
"0---1---2---3---4" << std::endl;
160 GhostHandler<mesh_Type> ghostP1 ( fullMeshPtr, meshPtr, feSpaceP1->mapPtr(), comm );
162 ghostP1.setUpNeighbors();
165 MapEpetra mapP1Overlap ( ghostP1.ghostMapOnPoints ( dataFile (
"ghost/overlap", 2 ) ) );
167 fileOut <<
"=================== mapP1 Unique" << std::endl;
168 fileOut <<
"9---8---7---+---+ +---+---+---6---5" << std::endl;
169 fileOut <<
"| /| /| /| /| | /| /| /| /|" << std::endl;
170 fileOut <<
"| / | / | / | / | | / | / | / | / |" << std::endl;
171 fileOut <<
"|/ |/ |/ |/ | |/ |/ |/ |/ |" << std::endl;
172 fileOut <<
"0---1---2---+---+ +---+---+---3---4" << std::endl;
173 fileOut << *mapP1.map ( Unique );
175 fileOut <<
"=================== mapP1 Repeated" << std::endl;
176 fileOut <<
"9---8---7---+---+ +---+---7---6---5" << std::endl;
177 fileOut <<
"| /| /| /| /| | /| /| /| /|" << std::endl;
178 fileOut <<
"| / | / | / | / | | / | / | / | / |" << std::endl;
179 fileOut <<
"|/ |/ |/ |/ | |/ |/ |/ |/ |" << std::endl;
180 fileOut <<
"0---1---2---+---+ +---+---2---3---4" << std::endl;
181 fileOut << *mapP1.map ( Repeated );
183 fileOut <<
"=================== mapP1 Repeated overlap 2" << std::endl;
184 fileOut <<
"9---8---7---6---5 9---8---7---6---5" << std::endl;
185 fileOut <<
"| /| /| /| /| | /| /| /| /|" << std::endl;
186 fileOut <<
"| / | / | / | / | | / | / | / | / |" << std::endl;
187 fileOut <<
"|/ |/ |/ |/ | |/ |/ |/ |/ |" << std::endl;
188 fileOut <<
"0---1---2---3---4 0---1---2---3---4" << std::endl;
189 fileOut << *mapP1Overlap.map ( Repeated );
193 ghostP1.exportToHDF5();
195 ghostP1.importFromHDF5();
201 std::shared_ptr<VectorEpetra> vP1 (
new VectorEpetra ( mapP1Overlap, Unique ) );
204 Int* pointer ( mapP1Overlap.map ( Repeated )->MyGlobalElements() );
205 for ( Int ii = 0; ii < mapP1Overlap.map ( Repeated )->NumMyElements(); ++ii, ++pointer )
207 vP1->sumIntoGlobalValues ( *pointer, 1 );
210 vP1->globalAssemble();
213 if ( mapP1Overlap.map ( Repeated )->NumMyElements() != 10 )
218 feSpacePtr_Type feSpaceP0 (
new feSpace_Type ( meshPtr,
225 fileOut <<
"=================== P0" << std::endl;
226 fileOut <<
"+---+---+---+---+" << std::endl;
227 fileOut <<
"|1 /|3 /|5 /|7 /|" << std::endl;
228 fileOut <<
"| / | / | / | / |" << std::endl;
229 fileOut <<
"|/ 0|/ 2|/ 4|/ 6|" << std::endl;
230 fileOut <<
"+---+---+---+---+" << std::endl;
232 GhostHandler<mesh_Type> ghostP0 ( fullMeshPtr, meshPtr, feSpaceP0->mapPtr(), comm );
234 ghostP0.setUpNeighbors();
237 MapEpetra mapP0P0 ( ghostP0.ghostMapOnElementsFV() );
238 MapEpetra mapP0P1 ( ghostP0.ghostMapOnElementsFE ( dataFile (
"ghost/overlap", 2 ) ) );
240 fileOut <<
"=================== mapP0 Unique" << std::endl;
241 fileOut <<
"+---+---+---+---+ +---+---+---+---+" << std::endl;
242 fileOut <<
"|1 /|3 /| /| /| | /| /|5 /|7 /|" << std::endl;
243 fileOut <<
"| / | / | / | / | | / | / | / | / |" << std::endl;
244 fileOut <<
"|/ 0|/ 2|/ |/ | |/ |/ |/ 4|/ 6|" << std::endl;
245 fileOut <<
"+---+---+---+---+ +---+---+---+---+" << std::endl;
246 fileOut << *mapP0.map ( Unique );
248 fileOut <<
"=================== mapP0 Repeated" << std::endl;
249 fileOut <<
"+---+---+---+---+ +---+---+---+---+" << std::endl;
250 fileOut <<
"|1 /|3 /| /| /| | /| /|5 /|7 /|" << std::endl;
251 fileOut <<
"| / | / | / | / | | / | / | / | / |" << std::endl;
252 fileOut <<
"|/ 0|/ 2|/ |/ | |/ |/ |/ 4|/ 6|" << std::endl;
253 fileOut <<
"+---+---+---+---+ +---+---+---+---+" << std::endl;
254 fileOut << *mapP0.map ( Repeated );
256 fileOut <<
"=================== mapP0 Repeated face neighbors" << std::endl;
257 fileOut <<
"+---+---+---+---+ +---+---+---+---+" << std::endl;
258 fileOut <<
"|1 /|3 /|5 /| /| | /| /|5 /|7 /|" << std::endl;
259 fileOut <<
"| / | / | / | / | | / | / | / | / |" << std::endl;
260 fileOut <<
"|/ 0|/ 2|/ |/ | |/ |/ 2|/ 4|/ 6|" << std::endl;
261 fileOut <<
"+---+---+---+---+ +---+---+---+---+" << std::endl;
262 fileOut << *mapP0P0.map ( Repeated );
264 fileOut <<
"=================== mapP0 Repeated point neighbors overlap 2" << std::endl;
265 fileOut <<
"+---+---+---+---+ +---+---+---+---+" << std::endl;
266 fileOut <<
"|1 /|3 /|5 /|7 /| |1 /|3 /|5 /|7 /|" << std::endl;
267 fileOut <<
"| / | / | / | / | | / | / | / | / |" << std::endl;
268 fileOut <<
"|/ 0|/ 2|/ 4|/ 6| |/ 0|/ 2|/ 4|/ 6|" << std::endl;
269 fileOut <<
"+---+---+---+---+ +---+---+---+---+" << std::endl;
270 fileOut << *mapP0P1.map ( Repeated );
272 ghostP0.showMe (
true, fileOut );
276 std::shared_ptr<VectorEpetra> vP0 (
new VectorEpetra ( mapP0P0, Unique ) );
279 pointer = mapP0P1.map ( Repeated )->MyGlobalElements();
281 for ( Int ii = 0; ii < mapP0P1.map ( Repeated )->NumMyElements(); ++ii, ++pointer )
283 vP0->sumIntoGlobalValues ( *pointer, 1 );
286 vP0->globalAssemble();
288 fileOut <<
"=================== vector" << std::endl;
289 fileOut << vP0->epetraVector();
292 if ( mapP0P1.map ( Repeated )->NumMyElements() != 8 )
303 std::cout <<
" C- Time for ghost " << chronoGhost.diff() << std::endl;
306 std::shared_ptr< Exporter< mesh_Type > > exporter;
309 std::string
const exporterType = dataFile
( "exporter/type", "ensight" );
313 if ( exporterType.compare (
"hdf5" ) == 0 )
315 exporter.reset (
new ExporterHDF5< mesh_Type > ( dataFile, dataFile (
"exporter/file_name",
"GH" ) ) );
320 if ( exporterType.compare (
"none") == 0 )
322 exporter.reset (
new ExporterEmpty< mesh_Type > ( dataFile, dataFile (
"exporter/file_name",
"GH" ) ) );
326 exporter.reset (
new ExporterEnsight< mesh_Type > ( dataFile, dataFile (
"exporter/file_name",
"GH" ) ) );
331 exporter->setPostDir ( dataFile (
"exporter/folder",
"./" ) );
332 exporter->setMeshProcId ( meshPtr, comm->MyPID() );
335 exporter->exportPID ( meshPtr, comm );
338 exporter->addVariable ( ExporterData<mesh_Type>::ScalarField,
341 static_cast<UInt> ( 0 ),
342 ExporterData<mesh_Type>::SteadyRegime,
343 ExporterData<mesh_Type>::Node );
346 exporter->addVariable ( ExporterData<mesh_Type>::ScalarField,
349 static_cast<UInt> ( 0 ),
350 ExporterData<mesh_Type>::SteadyRegime,
351 ExporterData<mesh_Type>::Cell );
354 exporter->postProcess ( 0 );
362 std::cout <<
" C- Time total " << chronoTotal.diff() << std::endl;
369 std::cout <<
"MPI Finalization" << std::endl;
void start()
Start the timer.
FESpace - Short description here please!
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
int32_type Int
Generic integer data.
Epetra_Import const & importer()
Getter for the Epetra_Import.
NeighborMarkerCommon< MarkerIDStandardPolicy > neighborMarkerCommon_Type
The NeighborMarkerCommon: uses all defaults except for Points.
Class for 3D, 2D and 1D Mesh.
std::shared_ptr< std::vector< Int > > M_isOnProc
MeshData - class for handling spatial discretization.
const std::string operator()(const char *VarName, const char *Default) const
void stop()
Stop the timer.
GetPot(const STRING_VECTOR &FileNameList)
const std::string follow(const char *Default, unsigned No, const char *Option,...)
int main(int argc, char **argv)
void importFromHDF5(std::string const &fileName="ghostmap")
Import neighbor lists to an hdf5 file.