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> 57 #include <lifev/core/filter/ImporterMesh3D.hpp> 58 #include <lifev/core/mesh/RegionMesh.hpp> 59 #include <lifev/core/mesh/MeshElementBare.hpp> 60 #include <lifev/core/array/EnumMapEpetra.hpp> 76 return LifeV::Repeated;
80 template<
typename meshEntity>
86 m.replaceFlag (LifeV::EntityFlags::DEFAULT);
91 int main (
int argc,
char** argv)
94 MPI_Init (&argc, &argv);
95 std::cout <<
"MPI Initialization" << std::endl;
96 std::shared_ptr<Epetra_Comm> comm (
new Epetra_MpiComm ( MPI_COMM_WORLD ) );
98 std::shared_ptr<Epetra_Comm> comm (
new Epetra_SerialComm );
102 using namespace LifeV;
103 using namespace LifeV::MeshUtility;
105 GetPot datafile (
"data" );
106 std::string dirname = datafile (
"mesh_dir",
"." );
107 if (*dirname.rbegin() !=
'/');
109 std::string fname = dirname + datafile (
"mesh_file",
"cube_47785.m++" );
110 std::string outfile =
"testBuilders.dat";
111 std::ofstream ofile (outfile.c_str() );
114 std::cerr <<
" Error: Cannot creat output file" << std::endl;
118 RegionMesh<LinearTetra> aMesh ( comm );
119 typedef RegionMesh<LinearTetra> mesh_Type;
123 readMppFile (aMesh, fname, m);
125 std::cout <<
" **********************************************************" << std::endl;
127 std::cout <<
" ****************** CHECKING MESH WITH INTERNAL CHECKER" << std::endl;
129 aMesh.check (0,
true,
true);
133 std::cout <<
" **********************************************************" << std::endl;
135 std::cout <<
" ****************** CLEANING edges and faces " << std::endl;
137 aMesh.edgeList.clear();
138 aMesh.faceList.clear();
140 checkMesh3D (aMesh, sw,
142 std::cerr, std::cout, ofile);
148 std::cout <<
" Now building local Edges/faces Stuff" << std::endl << std::endl;
149 aMesh.updateElementEdges();
150 aMesh.updateElementFaces();
152 std::cout <<
" Now cleaning local Edges/faces Stuff" << std::endl << std::endl;
153 aMesh.cleanElementRidges();
154 aMesh.cleanElementFacets();
156 std::cout <<
" **********************************************************" << std::endl;
158 std::cout <<
" ****************** BUILDING ALL EDGES" << std::endl;
159 UInt bedges_found, iedges_found;
160 buildEdges (aMesh, ofile, std::cerr, bedges_found,
161 iedges_found,
true,
true,
true);
162 std::cout <<
" **********************************************************" << std::endl;
164 std::cout <<
" ****************** BUILDING ALL FACES" << std::endl;
165 UInt bfaces_found, ifaces_found;
166 buildFaces (aMesh, ofile, std::cerr, bfaces_found,
167 ifaces_found,
true,
true,
true);
171 std::cout <<
" Now building again local Edges/faces Stuff" << std::endl << std::endl;
172 aMesh.updateElementEdges();
173 aMesh.updateElementFaces();
175 checkMesh3D (aMesh, sw,
177 std::cerr, std::cout, ofile);
181 std::cerr <<
"Fixing bpoints" << std::endl;
183 fixBoundaryPoints (aMesh, ofile, std::cerr,
true);
184 std::cerr <<
"Fixing edge markers" << std::endl;
185 setBoundaryEdgesMarker (aMesh, ofile, std::cerr,
true);
186 std::cerr <<
"Fixing faces marker" << std::endl;
187 setBoundaryFacesMarker (aMesh, ofile, std::cerr,
true);
188 std::cerr <<
"Fixing points marker" << std::endl;
189 setBoundaryPointsMarker (aMesh, ofile, std::cerr,
true);
190 std::cerr << std::endl;
191 dummyVect disp (3 * aMesh.numPoints() );
192 MeshUtility::MeshTransformer<mesh_Type> transformer (aMesh);
193 transformer.moveMesh (disp, 3);
194 MeshUtility::MeshStatistics::meshSize sizes = MeshUtility::MeshStatistics::computeSize (aMesh);
195 std::cerr <<
"Hmin =" << sizes.minH <<
" Hmax=" << sizes.maxH << std::endl;
196 mesh_Type::points_Type newPointList = aMesh.pointList;
197 mesh_Type::faces_Type newFaceList = aMesh.faceList;
198 Utilities::fixAfterShallowCopy (newFaceList, newPointList);
199 for (mesh_Type::faces_Type::iterator i = newFaceList.begin(); i < newFaceList.end(); ++i)
201 ID theId = i->point (0).id();
202 if (& (i->point (0) ) != & (newPointList[theId]) )
204 std::cerr <<
"ERROR: Error after renumbering Faces" << std::endl;
208 aMesh.faceList[2].replaceFlag (EntityFlags::CUTTED);
209 aMesh.faceList.reorderAccordingToFlag (EntityFlags::CUTTED, &Flag::testOneSet);
210 if (aMesh.faceList[0].flag() != EntityFlags::CUTTED)
212 std::cerr <<
"ERROR: Reordering is not working" << std::endl;
214 std::cout <<
"Number of cutted faces (should be 1) " <<
215 aMesh.faceList.countElementsWithFlag (EntityFlags::CUTTED, &Flag::testOneSet) << std::endl;
217 aMesh.edgeList.changeAccordingToFunctor (ResetFlag<mesh_Type::edge_Type>() );
218 aMesh.edge (0).setMarkerID (10);
219 aMesh.edge (5).setMarkerID (10);
220 aMesh.edge (10).setMarkerID (15);
221 std::vector<ID> watermarks (2);
225 SetFlagAccordingToWatermarks changeFlags (EntityFlags::CUTTED, watermarks);
226 aMesh.edgeList.changeAccordingToFunctor (changeFlags);
227 std::cout <<
"Number of cutted edges (should be 3) " 228 << aMesh.edgeList.countElementsWithFlag (EntityFlags::CUTTED, &Flag::testOneSet) << std::endl;
229 aMesh.edgeList.changeAccordingToFunctor ( ResetFlag<mesh_Type::edge_Type>() );
230 aMesh.edge (0).setMarkerID (10);
231 aMesh.edge (5).setMarkerID (12);
232 aMesh.edge (10).setMarkerID (15);
233 SetFlagAccordingToMarkerRanges changer ( &Flag::turnOn );
234 changer.insert (std::make_pair (10, 12), EntityFlags::INTERNAL_INTERFACE);
235 changer.insert (std::make_pair (15, 18), EntityFlags::CUTTED);
236 aMesh.edgeList.changeAccordingToFunctor (changer);
237 std::cout <<
"Number of cutted edges (should be 1) " <<
238 aMesh.edgeList.countElementsWithFlag (EntityFlags::CUTTED, &Flag::testOneSet) << std::endl;
239 std::cout <<
"Number of internal interface edges (should be 2) " <<
240 aMesh.edgeList.countElementsWithFlag (EntityFlags::INTERNAL_INTERFACE, &Flag::testOneSet) << std::endl;
242 SetFlagAccordingToWatermark<std::equal_to<markerID_Type> > changer2 (EntityFlags::INTERNAL_INTERFACE, 12000, Flag::turnOn);
243 aMesh.faceList.changeAccordingToFunctor (changer2);
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)