28 #ifndef CONVERT_BARE_MESH_HPP__ 29 #define CONVERT_BARE_MESH_HPP__ 31 #include <lifev/core/LifeV.hpp> 32 #include <lifev/core/mesh/MeshElementBare.hpp> 33 #include <lifev/core/mesh/MeshChecks.hpp> 34 #include <lifev/core/mesh/BareMesh.hpp> 35 #include <lifev/core/mesh/RegionMesh.hpp> 43 template <
int dim>
struct convert_spec;
45 template <
class S,
class MC>
60 if ( !baremesh.isPartitioned )
62 if ( baremesh.pointIDs.size() == 0 )
64 baremesh.pointIDs.resize ( baremesh.points.numberOfColumns() );
65 for (
UInt i = 0; i < baremesh.points.numberOfColumns(); ++i )
67 baremesh.pointIDs[i] = i;
70 if ( baremesh.ridgeIDs.size() == 0 )
72 baremesh.ridgeIDs.resize ( baremesh.ridges.numberOfColumns() );
73 for (
UInt i = 0; i < baremesh.ridges.numberOfColumns(); ++i )
75 baremesh.ridgeIDs[i] = i;
78 if ( baremesh.facetIDs.size() == 0 )
80 baremesh.facetIDs.resize ( baremesh.facets.numberOfColumns() );
81 for (
UInt i = 0; i < baremesh.facets.numberOfColumns(); ++i )
83 baremesh.facetIDs[i] = i;
86 if ( baremesh.elementIDs.size() == 0 )
88 baremesh.elementIDs.resize ( baremesh.elements.numberOfColumns() );
89 for (
UInt i = 0; i < baremesh.elements.numberOfColumns(); ++i )
91 baremesh.elementIDs[i] = i;
100 UInt numberPoints = baremesh.points.numberOfColumns();
102 mesh.setIsPartitioned (baremesh.isPartitioned);
104 mesh.setMaxNumPoints (numberPoints,
true);
105 mesh.setMaxNumGlobalPoints (numberPoints);
106 mesh.setNumVertices ( baremesh.numVertices );
107 mesh.setNumGlobalVertices ( baremesh.numVertices );
108 mesh.setNumBPoints ( baremesh.numBoundaryPoints );
109 mesh.setNumBVertices ( baremesh.numBoundaryVertices );
111 for (
UInt i = 0; i < numberPoints; ++i)
114 point_t& p = mesh.addPoint (
false,
false);
116 p.x() = baremesh.points (0, i);
117 p.y() = baremesh.points (1, i);
118 p.z() = baremesh.points (2, i);
120 p.setId (baremesh.pointIDs[i]);
122 p.setMarkerID (baremesh.pointMarkers[i]);
126 std::cout <<
"[INFO:convertBareMesh] Added " 127 << mesh.numPoints() <<
" marked points." << std::endl;
134 UInt numberElements = baremesh.elements.numberOfColumns();
135 mesh.setMaxNumGlobalElements (numberElements);
136 mesh.setMaxNumElements (numberElements,
true);
137 mesh.setNumElements (numberElements);
138 for (
UInt i = 0; i < numberElements; ++i)
142 e.setId (baremesh.elementIDs[i]);
143 e.setMarkerID (baremesh.elementMarkers[i]);
147 UInt pid = baremesh.elements (j, i);
148 e.setPoint (j, mesh.point (pid) );
152 mesh.pointList (pid).setFlag (LifeV::EntityFlags::VERTEX);
157 UInt numVertices = mesh.pointList.countElementsWithFlag (
158 LifeV::EntityFlags::VERTEX,
159 &LifeV::Flag::testAllSet);
160 mesh.setNumVertices (numVertices);
163 std::cout <<
"[INFO:convertBareMesh] Added " 164 << mesh.numElements() <<
" marked elements." <<
"\n" 165 <<
"[INFO:convertBareMesh] Found " 166 << mesh.numVertices() <<
" vertices." << std::endl;
169 mesh.setMarkerID (baremesh.regionMarkerID);
170 mesh.setId (baremesh.regionMarkerID);
173 convert_spec<S::S_nDimensions>::add_facets (baremesh, mesh, verbose);
174 convert_spec<S::S_nDimensions>::add_ridges (baremesh, mesh, verbose);
179 return convert_spec<S::S_nDimensions>::check (mesh, verbose);
190 template <
class S,
class MC>
197 typedef typename mesh_t::facet_Type facet_t;
199 std::cout <<
"[INFO:convertBareMesh] Updating facets" 202 UInt numberFacets = baremesh.facets.numberOfColumns();
203 mesh.setMaxNumFacets (numberFacets);
204 mesh.setMaxNumGlobalFacets (numberFacets);
205 mesh.setNumFacets (numberFacets);
206 mesh.setNumBoundaryFacets (0);
207 for (
UInt i = 0; i < numberFacets; ++i)
210 facet_t& f = mesh.addFacet (
false);
211 f.setId (baremesh.facetIDs[i]);
212 f.setMarkerID (baremesh.facetMarkers[i]);
214 for (
UInt j = 0; j < facet_t::S_numPoints; ++j)
216 UInt pid = baremesh.facets (j, i);
217 f.setPoint (j, mesh.point (pid) );
222 template <
class S,
class MC>
229 typedef typename mesh_t::ridge_Type ridge_t;
231 std::cout <<
"[INFO:convertBareMesh] Updating ridges" 234 UInt numberRidges = baremesh.ridges.numberOfColumns();
235 mesh.setMaxNumRidges (numberRidges);
236 mesh.setMaxNumGlobalRidges (numberRidges);
237 mesh.setNumRidges (numberRidges);
238 mesh.setNumBoundaryRidges (0);
239 for (
UInt i = 0; i < numberRidges; ++i)
242 ridge_t& r = mesh.addRidge (
false);
243 r.setId (baremesh.ridgeIDs[i]);
244 r.setMarkerID (baremesh.ridgeMarkers[i]);
246 for (
UInt j = 0; j < ridge_t::S_numPoints; ++j)
248 UInt pid = baremesh.ridges (j, i);
249 r.setPoint (j, mesh.point (pid) );
254 template <
class S,
class MC>
258 std::stringstream discardedLog;
259 std::ostream& oStr = verbose ? std::cout : discardedLog;
260 return checkMesh3D (mesh, sw,
true, verbose, oStr, std::cerr, oStr);
267 struct convert_spec<2>
269 template <
class S,
class MC>
272 convert_spec<3>::
template add_facets (baremesh, mesh, verbose);
275 template <
class S,
class MC>
279 template <
class S,
class MC>
289 struct convert_spec<1>
291 template <
class S,
class MC>
295 template <
class S,
class MC>
299 template <
class S,
class MC>
318 template <
typename GeoShapeType,
typename MCType>
322 bool verbose =
false)
324 return converter<GeoShapeType, MCType>::convert (bareMesh, mesh, verbose);
static bool convert(bmesh_t &baremesh, mesh_t &mesh, bool verbose=false)
static bool check(RegionMesh< S, MC > &mesh, bool verbose)
static void add_ridges(BareMesh< S > &, RegionMesh< S, MC > &, bool)
bool convertBareMesh(BareMesh< GeoShapeType > &bareMesh, RegionMesh< GeoShapeType, MCType > &mesh, bool verbose=false)
convertBareMesh - convert a previously read BareMesh in a RegionMesh object
static void add_ridges(BareMesh< S > &, RegionMesh< S, MC > &, bool)
I use standard constructor/destructors.
static bool check(RegionMesh< S, MC > &, bool)
static bool check(RegionMesh< S, MC > &, bool)
static void add_facets(BareMesh< S > &, RegionMesh< S, MC > &, bool)
static void add_facets(BareMesh< S > &baremesh, RegionMesh< S, MC > &mesh, bool verbose)
static void add_facets(BareMesh< S > &baremesh, RegionMesh< S, MC > &mesh, bool verbose)
RegionMesh< S, MC > mesh_t
Class for 3D, 2D and 1D Mesh.
mesh_t::ridge_Type ridge_t
static void add_ridges(BareMesh< S > &baremesh, RegionMesh< S, MC > &mesh, bool verbose)
mesh_t::element_Type element_t
mesh_t::facet_Type facet_t
A struct for a bare mesh.
mesh_t::point_Type point_t
uint32_type UInt
generic unsigned integer (used mainly for addressing)