45 #include <Epetra_ConfigDefs.h> 48 #include <Epetra_MpiComm.h> 50 #include <Epetra_SerialComm.h> 54 #include <lifev/core/filter/GetPot.hpp> 56 #include <lifev/core/mesh/MarkerDefinitions.hpp> 58 #include <lifev/core/mesh/RegionMesh.hpp> 59 #include <lifev/core/mesh/BareMesh.hpp> 61 #include <lifev/core/filter/ParserINRIAMesh.hpp> 62 #include <lifev/core/mesh/ConvertBareMesh.hpp> 63 #include <lifev/core/array/MapEpetra.hpp> 79 return LifeV::Repeated;
83 template<
typename meshEntity>
89 m.replaceFlag (LifeV::EntityFlags::DEFAULT);
94 using namespace LifeV;
96 int main (
int argc,
char** argv)
99 MPI_Init (&argc, &argv);
100 std::cout <<
"MPI Initialization" << std::endl;
101 std::shared_ptr<Epetra_Comm> comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
103 std::shared_ptr<Epetra_Comm> comm (
new Epetra_SerialComm );
106 GetPot datafile (
"data_baremesh" );
107 std::string dirname = datafile (
"mesh_dir",
"." );
108 std::string fname = dirname + datafile (
"mesh_file",
109 "cartesian_cube8.mesh" );
110 std::string outfile =
"testBuilders_baremesh.dat";
111 std::ofstream ofile ( outfile.c_str() );
114 std::cerr <<
" Error: Cannot creat output file " << std::endl;
118 typedef BareMesh<LinearTetra> bareMesh_Type;
119 typedef RegionMesh<LinearTetra> mesh_Type;
123 bareMesh_Type bareMesh;
124 MeshIO::ReadINRIAMeshFile ( bareMesh, fname, m );
126 mesh_Type aMesh ( comm );
127 convertBareMesh ( bareMesh, aMesh );
129 std::cout <<
" **********************************************************" << std::endl;
131 std::cout <<
" ****************** CHECKING MESH WITH INTERNAL CHECKER" << std::endl;
133 aMesh.check ( 0,
true,
true );
136 std::cout <<
" **********************************************************" << std::endl;
138 std::cout <<
" ****************** CLEANING edges and faces " << std::endl;
140 aMesh.edgeList.clear();
141 aMesh.faceList.clear();
143 checkMesh3D (aMesh, sw,
145 std::cerr, std::cout, ofile);
151 std::cout <<
" Now building local Edges/faces Stuff" << std::endl << std::endl;
152 aMesh.updateElementEdges();
153 aMesh.updateElementFaces();
155 std::cout <<
" Now cleaning local Edges/faces Stuff" << std::endl << std::endl;
156 aMesh.cleanElementRidges();
157 aMesh.cleanElementFaces();
159 std::cout <<
" **********************************************************" << std::endl;
161 std::cout <<
" ****************** BUILDING ALL EDGES" << std::endl;
162 UInt bedges_found, iedges_found;
163 MeshUtility::buildEdges ( aMesh, ofile, std::cerr, bedges_found,
164 iedges_found,
true,
true,
true );
165 std::cout <<
" **********************************************************" << std::endl;
167 std::cout <<
" ****************** BUILDING ALL FACES" << std::endl;
168 UInt bfaces_found, ifaces_found;
169 MeshUtility::buildFaces ( aMesh, ofile, std::cerr, bfaces_found,
170 ifaces_found,
true,
true,
true );
174 std::cout <<
" Now building again local Edges/faces Stuff" << std::endl << std::endl;
175 aMesh.updateElementEdges();
176 aMesh.updateElementFaces();
178 checkMesh3D (aMesh, sw,
180 std::cerr, std::cout, ofile);
184 std::cerr <<
"Fixing bpoints" << std::endl;
186 MeshUtility::fixBoundaryPoints ( aMesh, ofile, std::cerr,
true );
187 std::cerr <<
"Fixing edge markers" << std::endl;
188 MeshUtility::setBoundaryEdgesMarker ( aMesh, ofile, std::cerr,
true );
189 std::cerr <<
"Fixing faces marker" << std::endl;
190 MeshUtility::setBoundaryFacesMarker ( aMesh, ofile, std::cerr,
true );
191 std::cerr <<
"Fixing points marker" << std::endl;
192 MeshUtility::setBoundaryPointsMarker ( aMesh, ofile, std::cerr,
true );
193 std::cerr << std::endl;
194 dummyVect disp ( 3 * aMesh.numPoints() );
195 MeshUtility::MeshTransformer<mesh_Type > transformer ( aMesh );
196 transformer.moveMesh ( disp, 3 );
197 MeshUtility::MeshStatistics::meshSize sizes = MeshUtility::MeshStatistics::computeSize ( aMesh );
198 std::cerr <<
"Hmin =" << sizes.minH <<
" Hmax=" << sizes.maxH << std::endl;
199 mesh_Type::points_Type newPointList = aMesh.pointList;
200 mesh_Type::faces_Type newFaceList = aMesh.faceList;
201 Utilities::fixAfterShallowCopy ( newFaceList, newPointList );
202 for ( mesh_Type::faces_Type::iterator i = newFaceList.begin(); i < newFaceList.end(); ++i )
204 ID theId = i->point (0).id();
205 if ( & (i->point (0) ) != & ( newPointList[ theId ] ) )
207 std::cerr <<
"ERROR: Error after renumbering Faces" << std::endl;
211 aMesh.faceList[2].replaceFlag ( EntityFlags::CUTTED );
212 aMesh.faceList.reorderAccordingToFlag ( EntityFlags::CUTTED, Flag::testOneSet );
213 if ( aMesh.faceList[0].flag() != EntityFlags::CUTTED )
215 std::cerr <<
"ERROR: Reordering is not working" << std::endl;
217 std::cout <<
"Number of cutted faces (should be 1) " <<
218 aMesh.faceList.countElementsWithFlag ( EntityFlags::CUTTED, Flag::testOneSet ) << std::endl;
220 aMesh.edgeList.changeAccordingToFunctor ( ResetFlag<mesh_Type::edge_Type>() );
221 aMesh.edge ( 0 ).setMarkerID ( 10 );
222 aMesh.edge ( 5 ).setMarkerID ( 10 );
223 aMesh.edge ( 10 ).setMarkerID ( 15 );
224 std::vector<ID> watermarks ( 2 );
225 watermarks[ 0 ] = 10;
226 watermarks[ 1 ] = 15;
228 SetFlagAccordingToWatermarks changeFlags ( EntityFlags::CUTTED, watermarks );
229 aMesh.edgeList.changeAccordingToFunctor ( changeFlags );
230 std::cout <<
"Number of cutted edges (should be 3) " <<
231 aMesh.edgeList.countElementsWithFlag (EntityFlags::CUTTED, Flag::testOneSet) << std::endl;
232 aMesh.edgeList.changeAccordingToFunctor ( ResetFlag<mesh_Type::edge_Type>() );
233 aMesh.edge ( 0 ).setMarkerID ( 10 );
234 aMesh.edge ( 5 ).setMarkerID ( 12 );
235 aMesh.edge ( 10 ).setMarkerID ( 15 );
236 SetFlagAccordingToMarkerRanges changer ( Flag::turnOn );
237 changer.insert ( std::make_pair ( 10, 12 ), EntityFlags::INTERNAL_INTERFACE );
238 changer.insert ( std::make_pair ( 15, 18 ), EntityFlags::CUTTED );
239 aMesh.edgeList.changeAccordingToFunctor ( changer );
240 std::cout <<
"Number of cutted edges (should be 1) " <<
241 aMesh.edgeList.countElementsWithFlag ( EntityFlags::CUTTED, Flag::testOneSet ) << std::endl;
242 std::cout <<
"Number of internal interface edges (should be 2) " <<
243 aMesh.edgeList.countElementsWithFlag ( EntityFlags::INTERNAL_INTERFACE, Flag::testOneSet ) << std::endl;
249 return ( EXIT_SUCCESS );
bool isGlobalIDPresent(int) const
void operator()(meshEntity &m)
LifeV::MapEpetraType mapType() const
dummyVect(dummyVect v, LifeV::MapEpetraType)
dummyVect(unsigned const int &n)
int main(int argc, char **argv)