curveMesh.h
1 /******************************************************************************
2 
3  (c) 2004-2014 Scientific Computation Research Center,
4  Rensselaer Polytechnic Institute. All rights reserved.
5 
6  The LICENSE-SCOREC file included with this distribution describes the terms
7  of the SCOREC Non-Commercial License this program is distributed under.
8 
9 *******************************************************************************/
10 #ifndef MESHADAPT_CURVEMESH_H_
11 #define MESHADAPT_CURVEMESH_H_
12 
13 #include "CMAFwd.h"
14 #include "FMDBInternals.h"
15 #include "FMDB_cint.h"
16 #include "AdaptUtil.h"
17 
18 #include "MeshAdapt.h"
19 
20 #include <map>
21 #include <vector>
22 #include <list>
23 
24 class CrvTet;
25 class CrvFace;
26 class CrvEdge;
27 
28 class DSplitClpsMod;
29 class faceSwapMod;
30 class regionCollapsMod;
31 
32 class NullSField;
33 class evalResults;
34 class MeanRatio;
35 
36 class Field;
37 
41 class curveMesh : public meshAdapt{
42 public:
45  static curveMesh * instance() {
46  assert(m_crv_mesh_inst);
47  return m_crv_mesh_inst;
48  }
49 
55  curveMesh(pMeshMdl mesh_instance, int sizefield_type, int model_type);
56 
58  virtual ~curveMesh();
59 
60  /* START OF C++ API */
61 
62  int CMA_SetModelType(int iTheMdlType);
63  int CMA_CheckMesh();
64  int CMA_CheckMeshQuality();
65  int CMA_LockSurfaceMesh();
66 // int CMA_ImproveSurfaceMesh();
67 // int CMA_ImproveWorstRegion();
68 
69  int CMA_CreateHOEdges();
70 
71  int CMA_UncurveInvalidRgns();
72  int CMA_SetCrvMeshQualityThreshold(double dThreshold);
73 
75  int CMA_Untangle();
76 
78  int CMA_Optimize();
79 
82 
85  int CMA_Linearize();
86 
90  int CMA_GlobPtn();
91 
94  int CMA_CreateG1Mesh();
95 
98  int CMA_CreateD4C0Mesh();
99 
102  int CMA_CreateC0Mesh(int iEdgeOrder, int iFaceOrder);
103 
107 
109  int CMA_NumVertsOnGBdry();
110 
112  int CMA_NumVertsOnGEdge();
113 
114  double CMA_AverageEdgeLengthOnGBdry();
115  double CMA_AverageEdgeLengthOnGEdge();
116  double CMA_InterpErrorOnGEdge();
117  /* END OF C++ API */
118 
120  bool hasCad();
121 
122 protected:
126  apf::Mesh * m_apf_mesh;
128  apf::MeshTag * m_geom_order;
133 
134  rEdShpInfo * FindBestReShapeEdge(std::vector<rEdShpInfo*> &);
135 
136  // create mesh shape field
137  int create_mesh_shape_field();
138  int destroy_mesh_shape_field();
139  // create edge nodes from mesh shape field
140  int create_edge_nodes_from_shape_field();
141 
143  double m_max_angle_;
144 
145  NullSField * pNullSF_;
146  evalResults * pResults_;
147  MeanRatio * pShpMeasure_;
148 
149  // from the curving branch //
150  double dShapeThresh_;
151 
152  double _GWORSTSHAPE;
153 
154  std::map<pRegion, crShpInfo*> invalidCurvedRgns; //used in fromCrvBranch.cc
155  pPList _invalidRgnPList;
156 
157  // attachable data Ids
158  pMeshDataId fixedEnt_;
159  pMeshDataId _onPartBdry;
160 
161  // counters for various mesh mod operations
162  int iOpCounts_[9];
163 
164  // internal functions
165 
166  void createInvalidRgns(double);
167  void invalidRgnsInfo();
168 
169  int findBestMod(pRegion, crShpInfo *, pMeshMod *);
170  int findEdgeReShape(pRegion, crShpInfo *, pMeshMod *);
171 
173 // pRegion getRgnWithLowestQs();
174 
175  void fixInvalidRgnsByMods();
176  void ImproveRgnsByMods();
177  void applyGlobalNodalSmoothing();
178  void outPutOpsInfo();
179 
180  int isEdgeSplitModValid(edgeSplitMod *, pRegion, int &, double&);
181  int isDsplitClpsModValid(DSplitClpsMod *,pRegion, double &);
182  int isEdgeClpsModValid(edgeCollapsMod *, pRegion, double &);
183  int isFaceSwpModValid(faceSwapMod *, pRegion, double &);
184  int isEdgeSwpModValid(edgeSwapMod *, pRegion, double &);
185  int isEdgeSplitClpsModValid(EsplitClpsMod *, pRegion, double &);
186  int isRegionClpsModValid(regionCollapsMod *, pRegion, double &);
187  int isVertexMotionModValid(vertMotionsMod *, pRegion, double &);
188  int isDsplitClpsLooseModValid(pRegion, pMeshMod *);
189  int isUnCurvedModValid(pRegion, crShpInfo *, pPList *);
190  void updateNewReg(pPList *);
191  void applyBestMod(pMeshMod *);
192 
193  // check if its OK to use high-order node smoothing
194  int isExplicitHONSmoothingValid(vertMotionsMod *, pRegion, crShpInfo *, double &);
195  // This implementation is limited to the case where only one edge is in model region. Mar 28, 2011. Kai
196  int isExplicitNodalSmoothingValid(pRegion region, crShpInfo *, pEdge *targetEdge);
197 
198  int minDetJAmgVertices(crShpInfo *, int *edgeID, int *); // compute the minimum Det among four vertices
199  // return 0 if minimum is not located at vertex control point.
200  int computeMiddlePtTarget(pRegion, int, pEdge);
201 
206  void outPutEdgeVtxClassify(pRegion region);
207 
208  void unCurveInvalidRgns();
209  void createInvalidRgnList(pPList &);
210  // fix the input mesh ent
211  void fix_entity(pEntity);
213 // int isEntFixed(pEntity);
214 
216  template<class OPERATION>
218 
219  template<class OPERATION>
220  int traverse_mesh_faces_to_run();
221 
222  template<class OPERATION>
223  int traverse_mesh_rgns_to_run();
224 
229  bool is_g1();
230 
235  void set_g1();
236 
237 
238  private:
239  void call_smoothing_procedure() {
240  }
241 
242  virtual bool v_use_crv_adapt() {
243  return true;
244  }
246  std::vector<CrvTet *> m_crv_tets;
247 
249  std::vector<CrvFace *> m_crv_faces;
250 
252  std::vector<CrvEdge *> m_crv_edges;
253 };
254 typedef class curveMesh CrvMesh;
255 
256 // --- templated function implementations --- //
257 template<class OPERATION>
259 {
260 
261  pPart pumi_part;
262  PUMI_Mesh_GetPart(pMeshInst, 0, pumi_part);
263  // --- traverse mesh edges --- //
264  pPartEntIter pedge_iter;
265  pMeshEnt pcrnt_edge;
266 
267  int ient_end = PUMI_PartEntIter_Init(pumi_part, PUMI_EDGE, PUMI_ALLTOPO, pedge_iter);
268  while(!ient_end)
269  {
270  // get a mesh edge
271  ient_end = PUMI_PartEntIter_GetNext(pedge_iter, pcrnt_edge);
272  if(ient_end)
273  break;
274 
275  OPERATION * edge_op = new OPERATION(pcrnt_edge);
276  edge_op->run();
277  delete edge_op;
278 
279  }
280 
281  PUMI_PartEntIter_Del(pedge_iter);
282 
283  return 0;
284 
285 }
286 
287 template<class OPERATION>
288 int curveMesh::traverse_mesh_faces_to_run()
289 {
290 
291  pPart pumi_part;
292  PUMI_Mesh_GetPart(pMeshInst, 0, pumi_part);
293  // --- traverse mesh edges --- //
294  pPartEntIter pface_iter;
295  pMeshEnt pcrnt_face;
296 
297  int ient_end = PUMI_PartEntIter_Init(pumi_part, PUMI_FACE, PUMI_ALLTOPO, pface_iter);
298  while(!ient_end)
299  {
300  // get a mesh edge
301  ient_end = PUMI_PartEntIter_GetNext(pface_iter, pcrnt_face);
302  if(ient_end)
303  break;
304 
305  OPERATION * face_op = new OPERATION(pcrnt_face);
306  face_op->run();
307  delete face_op;
308 
309  }
310 
311  PUMI_PartEntIter_Del(pface_iter);
312 
313  return 0;
314 
315 }
316 
317 template<class OPERATION>
318 int curveMesh::traverse_mesh_rgns_to_run()
319 {
320 
321  pPart pumi_part;
322  PUMI_Mesh_GetPart(pMeshInst, 0, pumi_part);
323  // --- traverse mesh edges --- //
324  pPartEntIter prgn_iter;
325  pMeshEnt pcrnt_rgn;
326 
327  int ient_end = PUMI_PartEntIter_Init(pumi_part, PUMI_REGION, PUMI_ALLTOPO, prgn_iter);
328  while(!ient_end)
329  {
330  // get a mesh edge
331  ient_end = PUMI_PartEntIter_GetNext(prgn_iter, pcrnt_rgn);
332  if(ient_end)
333  break;
334 
335  OPERATION * rgn_op = new OPERATION(pcrnt_rgn);
336  rgn_op->run();
337  delete rgn_op;
338 
339  }
340 
341  PUMI_PartEntIter_Del(prgn_iter);
342 
343  return 0;
344 
345 }
346 
347 #endif//MESHADAPT_CURVEMESH_H_
This class is design to represent the 3D high-order curved tetrahedron element. The data member shoul...
Definition: CrvTet.h:23
curveMesh(pMeshMdl mesh_instance, int sizefield_type, int model_type)
ctor
Definition: CrvMeshInternal.cc:666
pField m_mesh_shape_field_
pointer to mesh shape field data
Definition: curveMesh.h:130
bool is_g1()
determine if the mesh has already been curved to G1
Definition: CrvMeshInternal.cc:2437
int traverse_mesh_edges_to_run()
whether the input mesh entity has been fixed
Definition: curveMesh.h:258
bool hasCad()
returns if a CAD model is loaded for the curved mesh
Definition: CrvMesh.cc:898
std::vector< CrvTet * > m_crv_tets
container for curved tets
Definition: curveMesh.h:246
static curveMesh * m_crv_mesh_inst
static member viariable for the curve mesh object itself
Definition: curveMesh.h:124
int CMA_Optimize()
optimize a given valid curved mesh
Definition: CrvMesh.cc:409
virtual ~curveMesh()
destructor
Definition: CrvMeshInternal.cc:704
apf::Mesh * m_apf_mesh
pointer to apf mesh object
Definition: curveMesh.h:126
void set_g1()
flag the mesh as having been curved to G1
Definition: CrvMeshInternal.cc:2455
int CMA_CreateG1Mesh()
Create a curved mesh with G1 surface mesh.
Definition: CrvMesh.cc:667
double m_max_angle_
the maximum allowed angle in the surface mesh
Definition: curveMesh.h:143
std::vector< CrvFace * > m_crv_faces
container for curved tris
Definition: curveMesh.h:249
base class for curved edge curve edge provides basic evaluation based on barycentric coordinate syste...
Definition: CrvEdge.h:28
int CMA_GlobPtn()
This function calls pumi mesh global partition API.
Definition: CrvMesh.cc:656
int CMA_CreateC0Mesh(int iEdgeOrder, int iFaceOrder)
Create arbitrary degree C0 interpolating surface mesh.
Definition: CrvMesh.cc:764
int CMA_NumVertsOnGEdge()
number of vertices on model verts and edges
Definition: CrvMesh.cc:49
void fixInvalidRgnsByMods()
return the region with lowest straight-side shape quality Qs
Definition: CrvMeshInternal.cc:942
int CMA_Untangle()
untangle a given curved mesh with a number of invalid elements
Definition: CrvMesh.cc:503
int CMA_CreateG1MeshFromAnalyticModel()
Create a curved mesh with G1 surface mesh of analytic boundary.
static curveMesh * instance()
static member function to get the pointer to the curveMesh object
Definition: curveMesh.h:45
int CMA_TagDrivenUniformRefine()
run tag-driven uniform refinement
Definition: CrvMesh.cc:647
abstract class representing curved mesh face
Definition: CrvFace.h:32
int CMA_NumVertsOnGBdry()
number of vertices on model boundary include model verts, edges and faces
Definition: CrvMesh.cc:37
The main driver class for curved mesh adaptation procedures.
Definition: curveMesh.h:41
pField m_vertex_normal_field_
pointer to vertex normal field
Definition: curveMesh.h:132
apf::MeshTag * m_geom_order
pointer to apf mesh tag for geometric order
Definition: curveMesh.h:128
void outPutEdgeVtxClassify(pRegion region)
output the classification info of the six edges
Definition: CrvMeshInternal.cc:558
int CMA_CreateD4C0Mesh()
Create degree 4 C0 interpolating surface mesh.
Definition: CrvMesh.cc:759
int CMA_Linearize()
Make all mesh entities linear by removing edge nodes if there is any.
Definition: CrvMesh.cc:61
std::vector< CrvEdge * > m_crv_edges
container for curved edges
Definition: curveMesh.h:252