proteus  1.8.1
C/C++/Fortran libraries
mesh.h
Go to the documentation of this file.
1 #ifndef MESH_H
2 #define MESH_H
3 #include <set>
4 #include <vector>
5 #include <algorithm>
6 #include <map>
7 #include <list>
8 #include <iostream>
9 #include <iomanip>
10 #include <fstream>
12 #include <cassert>
13 #include <cmath>
22 extern "C"
23 {
24  /* The simple array based interface to meshes */
25  //forward declaration
26 
27  struct Mesh
28  {
29  //if you change this make sure to update initialize and delete below
41 
42  int *elementNodesArray, //the nodes numbers for each element
43  *nodeElementsArray, //the element numbers for each node
44  *nodeElementOffsets, //offsets for indexing into nodeElementsArray,
45  *elementNeighborsArray, //the elment numbers for each neighboring element
46  *elementBoundariesArray, //the global elementBoundary numbers for each element
48  *elementBoundaryElementsArray, //the element numbers for each element boundary
49  *elementBoundaryLocalElementBoundariesArray, //the local element boundary number for the left and right neighbors of the element boundary
50  *interiorElementBoundariesArray, //the element boundary numbers of the interior element boundaries
51  *exteriorElementBoundariesArray, //the element boundary numbers of the exterior element boundaries
55  *elementMaterialTypes, //ids for classifying elements,element boundaries,nodes
58 
59  // NURBS
60  int *elementIJK; // Cartesian indices of element
61  double *weights; // NURBS weight
62  double *U_KNOT,*V_KNOT,*W_KNOT; // Knot vectors
63  int nx,ny,nz;
64  int px,py,pz;
65  // NURBS
66 
71  //for adaptive mesh refinement
73 
74  //for parallel computations
75 
85  };
86 
87  inline void initializeMesh(Mesh& mesh)
88  {
89  //dimensions
90  mesh.nElements_global=0;
91  mesh.nNodes_global=0;
92  mesh.nNodes_element=0;
98  mesh.max_nElements_node=0;
99  mesh.nEdges_global=0;
100  //arrays
101  mesh.elementNodesArray=NULL;
102  mesh.nodeElementsArray=NULL;
103  mesh.nodeElementOffsets=NULL;
104  mesh.elementNeighborsArray=NULL;
105  mesh.elementBoundariesArray=NULL;
106  mesh.elementBoundaryNodesArray=NULL;
111  mesh.edgeNodesArray=NULL;
112  mesh.nodeStarArray=NULL;
113  mesh.nodeStarOffsets=NULL;
114  mesh.elementMaterialTypes=NULL;
116  mesh.nodeMaterialTypes=NULL;
117  mesh.nodeArray=NULL;
118  mesh.elementBarycentersArray=NULL;
120  mesh.nodeDiametersArray=NULL;
121  mesh.nodeSupportArray=NULL;
122  mesh.newestNodeBases=NULL;
123 
124  //parallel
127  mesh.nodeOffsets_subdomain_owned=NULL;
131  mesh.edgeOffsets_subdomain_owned=NULL;
133 
134  // NURBS
135  mesh.nx=mesh.ny=mesh.nz=0;
136  mesh.px=mesh.py=mesh.pz=0;
137  mesh.elementIJK=NULL;
138  mesh.weights=NULL;
139  mesh.U_KNOT=NULL;
140  mesh.V_KNOT=NULL;
141  mesh.W_KNOT=NULL;
142  // NURBS
143 
144  //geometry
145  mesh.elementDiametersArray=NULL;
146  mesh.h=0.0;
147  mesh.hMin=0.0;
148  mesh.sigmaMax=0.0;
149  mesh.volume=0.0;
150 
151  //parallel
154  mesh.nodeOffsets_subdomain_owned=NULL;
158  mesh.edgeOffsets_subdomain_owned=NULL;
160  mesh.subdomainp=NULL;
161 
162  }
163 
164  inline void deleteMesh(Mesh& mesh)
165  {
166 
167  //dimensions
168  mesh.nElements_global=0;
169  mesh.nNodes_global=0;
170  mesh.nNodes_element=0;
171  mesh.nNodes_elementBoundary=0;
176  mesh.max_nElements_node=0;
177  mesh.nEdges_global=0;
178 
179  //arrays
180  if(mesh.elementNodesArray!=NULL) delete [] mesh.elementNodesArray;
181  if(mesh.nodeElementsArray!=NULL) delete [] mesh.nodeElementsArray;
182  if(mesh.nodeElementOffsets!=NULL) delete [] mesh.nodeElementOffsets;
183  if(mesh.elementNeighborsArray!=NULL) delete [] mesh.elementNeighborsArray;
184  if(mesh.elementBoundariesArray!=NULL) delete [] mesh.elementBoundariesArray;
185  if(mesh.elementBoundaryNodesArray!=NULL) delete [] mesh.elementBoundaryNodesArray;
186  if(mesh.elementBoundaryElementsArray!=NULL) delete [] mesh.elementBoundaryElementsArray;
190  if(mesh.edgeNodesArray!=NULL) delete [] mesh.edgeNodesArray;
191  if(mesh.nodeStarArray!=NULL) delete [] mesh.nodeStarArray;
192  if(mesh.nodeStarOffsets!=NULL) delete [] mesh.nodeStarOffsets;
193  if(mesh.elementMaterialTypes!=NULL) delete [] mesh.elementMaterialTypes;
194  if(mesh.elementBoundaryMaterialTypes!=NULL) delete [] mesh.elementBoundaryMaterialTypes;
195  if(mesh.nodeMaterialTypes!=NULL) delete [] mesh.nodeMaterialTypes;
196  if(mesh.nodeArray!=NULL) delete [] mesh.nodeArray;
197  if(mesh.elementDiametersArray!=NULL) delete [] mesh.elementDiametersArray;
198  if(mesh.elementBarycentersArray!=NULL) delete [] mesh.elementBarycentersArray;
200  if(mesh.nodeDiametersArray!=NULL) delete [] mesh.nodeDiametersArray;
201  if(mesh.nodeSupportArray!=NULL) delete [] mesh.nodeSupportArray;
202  if(mesh.newestNodeBases!=NULL) delete [] mesh.newestNodeBases;
203 
204  // NURBS
205  mesh.nx=mesh.ny=mesh.nz=0;
206  mesh.px=mesh.py=mesh.pz=0;
207  if(mesh.elementIJK!=NULL) delete [] mesh.elementIJK;
208  if(mesh.weights!=NULL) delete [] mesh.weights;
209  if(mesh.U_KNOT!=NULL) delete [] mesh.U_KNOT;
210  if(mesh.V_KNOT!=NULL) delete [] mesh.V_KNOT;
211  if(mesh.W_KNOT!=NULL) delete [] mesh.W_KNOT;
212  // NURBS
213 
214  //parallel
217  if(mesh.nodeOffsets_subdomain_owned!=NULL) delete [] mesh.nodeOffsets_subdomain_owned;
221  if(mesh.edgeOffsets_subdomain_owned!=NULL) delete [] mesh.edgeOffsets_subdomain_owned;
222  if(mesh.edgeNumbering_subdomain2global!=NULL) delete [] mesh.edgeNumbering_subdomain2global;
223 
224  mesh.elementNodesArray=NULL;
225  mesh.nodeElementsArray=NULL;
226  mesh.nodeElementOffsets=NULL;
227  mesh.elementNeighborsArray=NULL;
228  mesh.elementBoundariesArray=NULL;
229  mesh.elementBoundaryNodesArray=NULL;
234  mesh.edgeNodesArray=NULL;
235  mesh.nodeStarArray=NULL;
236  mesh.nodeStarOffsets=NULL;
237  mesh.elementMaterialTypes=NULL;
239  mesh.nodeMaterialTypes=NULL;
240  mesh.nodeArray=NULL;
241  mesh.elementBarycentersArray=NULL;
243 
244  //parallel
247  mesh.nodeOffsets_subdomain_owned=NULL;
251  mesh.edgeOffsets_subdomain_owned=NULL;
253  mesh.subdomainp=NULL;
254 
255  }
256 
258  {
259  int nLevels;
261  int **elementParentsArray, //nLevels x nElements_global_level
263  **elementChildrenOffsets; //nLevels x nElements_global_level x nElementChildren_element
264  };
265 
266  inline void initializeMultilevelMesh(MultilevelMesh& multilevelMesh)
267  {
268  multilevelMesh.nLevels=0;
269  multilevelMesh.meshArray=NULL;
270  multilevelMesh.elementParentsArray=NULL;
271  multilevelMesh.elementChildrenArray=NULL;
272  multilevelMesh.elementChildrenOffsets=NULL;
273  }
274 
275  inline void deleteMultilevelMesh(MultilevelMesh& multilevelMesh)
276  {
277  for(int i=0;i<multilevelMesh.nLevels;i++)
278  {
279  deleteMesh(multilevelMesh.meshArray[i]);
280  if(i>0)
281  if (multilevelMesh.elementParentsArray[i] != NULL) delete [] multilevelMesh.elementParentsArray[i];
282  if(i<multilevelMesh.nLevels-1)
283  {
284  if (multilevelMesh.elementChildrenArray[i] != NULL) delete [] multilevelMesh.elementChildrenArray[i];
285  if (multilevelMesh.elementChildrenOffsets[i] != NULL) delete [] multilevelMesh.elementChildrenOffsets[i];
286  }
287  }
288  if (multilevelMesh.meshArray != NULL) delete [] multilevelMesh.meshArray;
289  if (multilevelMesh.elementParentsArray != NULL) delete [] multilevelMesh.elementParentsArray;
290  if (multilevelMesh.elementChildrenArray != NULL) delete [] multilevelMesh.elementChildrenArray;
291  if (multilevelMesh.elementChildrenOffsets != NULL) delete [] multilevelMesh.elementChildrenOffsets;
292 
293  multilevelMesh.nLevels=0;
294  multilevelMesh.meshArray=NULL;
295  multilevelMesh.elementParentsArray=NULL;
296  multilevelMesh.elementChildrenArray=NULL;
297  multilevelMesh.elementChildrenOffsets=NULL;
298  }
299 
300  int edgeMeshElements(const int& nx, Mesh& mesh);
301  int regularEdgeMeshNodes(const int& nx, const double& Lx, Mesh& mesh);
302  int globallyRefineEdgeMesh(const int& nLevels, Mesh& mesh, MultilevelMesh& multilevelMesh, bool averageNewNodeFlags=false);
303  int locallyRefineEdgeMesh(MultilevelMesh& multilevelMesh,
304  int * elementTagArray);
305  int locallyRefineTriangleMesh(MultilevelMesh& multilevelMesh,
306  int * elementTagArray);
307  int locallyRefineTriangleMesh_4T(MultilevelMesh& multilevelMesh,
308  int * elementTagArray);
310  int * elementTagArray);
311  int setNewestNodeBasesToLongestEdge(MultilevelMesh& multilevelMesh);
312 
313  int regularRectangularToTriangularMeshElements(const int& nx,const int& ny,Mesh& mesh, int triangleFlag);
314  int regularRectangularToTriangularMeshNodes(const int& nx, const int& ny, const double& Lx, const double& Ly, Mesh& mesh);
315  int regularRectangularToTriangularElementBoundaryMaterials(const double& Lx, const double& Ly, Mesh& mesh);
316  int globallyRefineTriangularMesh(const int& nLevels, Mesh& mesh, MultilevelMesh& multilevelMesh, bool averageNewNodeFlags=false);
317 
318  int regularQuadrilateralMeshElements(const int& nx,const int& ny,Mesh& mesh);
319  int regularQuadrilateralMeshElementBoundaryMaterials(const double& Lx, const double& Ly, Mesh& mesh);
320  int globallyRefineQuadrilateralMesh(const int& nLevels, Mesh& mesh, MultilevelMesh& multilevelMesh, bool averageNewNodeFlags=false);
321 
322 
323  int regularMeshNodes(const int& nx,const int& ny,const int& nz, const double& Lx, const double& Ly, const double& Lz, Mesh& mesh);
324  int regularMeshNodes2D(const int& nx,const int& ny, const double& Lx, const double& Ly, Mesh& mesh);
325  int regularHexahedralMeshElementBoundaryMaterials(const double& Lx, const double& Ly, const double& Lz, Mesh& mesh);
326  int regularHexahedralToTetrahedralMeshNodes(const int& nx,const int& ny,const int& nz, const double& Lx, const double& Ly, const double& Lz, Mesh& mesh);
327  int regularHexahedralToTetrahedralMeshElements(const int& nx,const int& ny,const int& nz,Mesh& mesh);
328  int regularHexahedralToTetrahedralElementBoundaryMaterials(const double& Lx, const double& Ly, const double& Lz, Mesh& mesh);
329  int regularHexahedralMeshElements(const int& nx,const int& ny,const int& nz,const int& px,const int& py,const int& pz, Mesh& mesh);
330  int reorientTetrahedralMesh(Mesh& mesh);
331  int regularNURBSMeshElements(const int& nx,const int& ny,const int& nz,const int& px,const int& py,const int& pz,Mesh& mesh);
332  int globallyRefineHexahedralMesh(const int& nLevels, Mesh& mesh, MultilevelMesh& multilevelMesh, bool averageNewNodeFlags=false);
333 
334  int globallyRefineTetrahedralMesh(const int& nLevels, Mesh& mesh, MultilevelMesh& multilevelMesh, bool averageNewNodeFlags=false);
335 
342 
347 
354 
355  int writeElements(std::ostream& meshFile, const Mesh& mesh);
356  int writeNodes(std::ostream& meshFile, const Mesh& mesh);
357  int readElements(std::istream& meshFile, Mesh& mesh);
358 
361  int allocateGeometricInfo_edge(Mesh& mesh);
365 
368  int computeGeometricInfo_edge(Mesh& mesh);
371  int computeGeometricInfo_NURBS(Mesh& mesh);
372 
373  int assignElementBoundaryMaterialTypesFromParent(Mesh& parentMesh, Mesh& childMesh, const int* levelElementParentsArray,
374  const int& nSpace_global);
375  int allocateNodeAndElementNodeDataStructures(Mesh& mesh, int nElements_global, int nNodes_global, int nNodes_element);
376  //mwf added for converting from triangle data structure
377  struct triangulateio;
378 
379  int setFromTriangleElements(triangulateio* trimesh, Mesh& mesh, int base);
380  int setFromTriangleNodes(triangulateio* trimesh, Mesh& mesh, int base);
381  int readTriangleMesh(Mesh& mesh, const char* filebase, int base);
382  int readTriangleElementBoundaryMaterialTypes(Mesh& mesh, const char* filebase, int base);
383  int writeTriangleMesh(Mesh& mesh, const char* filebase, int base);
384  int readTetgenMesh(Mesh& mesh, const char* filebase, int base);
385  int readTetgenElementBoundaryMaterialTypes(Mesh& mesh, const char* filebase, int base);
386  int writeTetgenMesh(Mesh& mesh, const char* filebase, int base);
387  int read3DM(Mesh& mesh, const char* filebase, int indexBase);
388  int read2DM(Mesh& mesh, const char* filebase, int indexBase);
389  int readHex(Mesh& mesh, const char* filebase, int indexBase);
390  int readBC(Mesh& mesh, const char* filebase, int indexBase);
391  int write3dmMesh(Mesh& mesh, const char* filebase, int base);
392  int write2dmMesh(Mesh& mesh, const char* filebase, int base);
393  int copyElementBoundaryMaterialTypesFromTriangle(triangulateio* trimesh,
394  Mesh& mesh, int base);
395 }//extern "C"
396 
397 /* A sorted tuple of node numbers to use as a key in maps */
398 template<int nNodes>
400 {
401 public:
402  inline NodeTuple(const int* nodesIn)
403  {
404  //sort
405  int position;
406  for(int i=0;i<nNodes;i++)
407  {
408  position=0;
409  //dumb sorting seems fast enough for now
410  for(int j=0;j<nNodes;j++)
411  if(nodesIn[i] > nodesIn[j])
412  position++;
413  nodes[position]=nodesIn[i];
414  nodes_unsorted[i] = nodesIn[i];
415  }
416 // for(int i=0;i<nNodes;i++)
417 // nodes[i] = nodesIn[i];
418 // std::sort(nodes,nodes+nNodes);
419  }
420  inline NodeTuple(const NodeTuple<nNodes>& nt)
421  {
422  for(int i=0;i<nNodes;i++)
423  {
424  nodes[i]=nt.nodes[i];
426  }
427  }
428  int nodes[nNodes];
429  int nodes_unsorted[nNodes];
430 };
431 
432 template<int nNodes>
433 inline bool operator<(const NodeTuple<nNodes>& left, const NodeTuple<nNodes>& right)
434 {
435  for (int i=0;i<nNodes;i++)
436  {
437  if(left.nodes[i]<right.nodes[i])
438  return true;
439  else if(left.nodes[i]>right.nodes[i])
440  return false;
441  }
442  return false;
443 }
444 
445 class Node
446 {
447 public:
448  int nN;
449  double x,y,z;
450  int flag;
451 };
452 
453 inline void midpoint(const double* left, const double* right, Node& midpoint)
454 {
455  midpoint.x = 0.5*(left[0]+right[0]);
456  midpoint.y = 0.5*(left[1]+right[1]);
457  midpoint.z = 0.5*(left[2]+right[2]);
458 }
459 
460 inline double edgeLength(const Node& left, const Node& right)
461 {
462  return sqrt( (right.x - left.x)*(right.x - left.x) +
463  (right.y - left.y)*(right.y - left.y) +
464  (right.z - left.z)*(right.z - left.z) );
465 }
466 
467 inline double edgeLengthFromNodeNumbers(double* nodeArray,const int& left, const int& right)
468 {
469  return sqrt( (nodeArray[right*3+0] - nodeArray[left*3+0])*(nodeArray[right*3+0] - nodeArray[left*3+0]) +
470  (nodeArray[right*3+1] - nodeArray[left*3+1])*(nodeArray[right*3+1] - nodeArray[left*3+1]) +
471  (nodeArray[right*3+2] - nodeArray[left*3+2])*(nodeArray[right*3+2] - nodeArray[left*3+2]) );
472 }
473 
474 inline bool operator<(const Node& left, const Node& right)
475 {
476  if(left.x < right.x)
477  return true;
478  else if (left.x > right.x)
479  return false;
480  else if (left.y < right.y)
481  return true;
482  else if (left.y > right.y)
483  return false;
484  else if (left.z < right.z)
485  return true;
486  else if (left.z > left.z)
487  return false;
488  return false;
489 }
490 
492 {
493 public:
494  inline ElementNeighbors(int leftIn,int left_ebN_elementIn){left=leftIn;left_ebN_element=left_ebN_elementIn;right=-1;right_ebN_element=-1;}
497 };
498 
499 inline int newEdge(int eN,int* nodes,int n0,int n1)
500 {
501  nodes[eN*2+0] = n0;
502  nodes[eN*2+1] = n1;
503  eN++;
504  return eN;
505 }
506 inline int newTriangle(int eN,int* nodes,int n0,int n1,int n2)
507 {
508  nodes[eN*3+0] = n0;
509  nodes[eN*3+1] = n1;
510  nodes[eN*3+2] = n2;
511  eN++;
512  return eN;
513 }
514 
515 inline int newTetrahedron(int eN,int* nodes,int n0,int n1,int n2,int n3)
516 {
517  nodes[eN*4+0] = n0;
518  nodes[eN*4+1] = n1;
519  nodes[eN*4+2] = n2;
520  nodes[eN*4+3] = n3;
521  eN++;
522  return eN;
523 }
524 
525 inline int newQuadrilateral(int eN,int* nodes,int n0,int n1,int n2,int n3)
526 {
527  nodes[eN*4+0] = n0;
528  nodes[eN*4+1] = n1;
529  nodes[eN*4+2] = n2;
530  nodes[eN*4+3] = n3;
531  eN++;
532  return eN;
533 }
534 
535 inline int newHexahedron(int eN,int* nodes,int n0,int n1,int n2,int n3,int n4,int n5,int n6,int n7)
536 {
537  nodes[eN*8+0] = n0;
538  nodes[eN*8+1] = n1;
539  nodes[eN*8+2] = n2;
540  nodes[eN*8+3] = n3;
541  nodes[eN*8+4] = n4;
542  nodes[eN*8+5] = n5;
543  nodes[eN*8+6] = n6;
544  nodes[eN*8+7] = n7;
545  eN++;
546  return eN;
547 }
548 
549 
550 bool newestNodeBisect(int eN,
551  int& nElements_global,
552  int& nNodes_global,
553  std::vector<double>& nodeArray,
554  std::vector<int>& elementNodesArray,
555  std::vector<int>& elementNeighborsArray,
556  std::vector<std::list<int> >& childrenList,
557  std::vector<int>& elementParentsArray,
558  std::vector<int>& bases,
559  std::vector<bool>& refined);
560 
561 
562 bool add4TnodesForRefinement2d(int eN,//element to be refined
563  int& nNodes_global,//number of nodes in mesh, will grow as refine
564  std::vector<bool>& refined, //is an element to be refined or not?
565  std::vector<int>& edgeMidNodesArray,//edge--> new node from bisection (-1 = none)
566  const int* elementNodesArray, //parent mesh representation
567  const int* elementBoundariesArray,
568  const int* elementNeighborsArray,
569  const double * nodeArray);
570 
571 bool add4TnodesForConformity2d(int eN, int ebN_longest,
572  int ebN_neig,int eN_neig,
573  int& nNodes_global,
574  std::vector<bool>& refined,
575  std::vector<int>& edgeMidNodesArray,
576  const int* elementNodesArray, //parent mesh representation
577  const int* elementBoundariesArray,
578  const int* elementNeighborsArray,
579  const double * nodeArray);
580 
581 int findLocalLongestEdge2d(int eN,
582  const int* elementNodesArray,
583  const double * nodeArray);
584 
585 bool subdivideTriangle4T(int eN_parent,
586  int& eN_new,
587  int* elementParentsArray,
588  int* elementChildrenOffsets,
589  int* elementChildrenArray,
590  int* elementNodesArray_child,
591  const std::vector<int>& edgeMidNodesArray,
592  const std::vector<bool>& refined,
593  const int* elementNodesArray_parent,
594  const int* elementBoundariesArray_parent,
595  const double* nodeArray_parent);
596 
597 
600 #endif
readTriangleElementBoundaryMaterialTypes
int readTriangleElementBoundaryMaterialTypes(Mesh &mesh, const char *filebase, int base)
Definition: mesh.cpp:5060
newHexahedron
int newHexahedron(int eN, int *nodes, int n0, int n1, int n2, int n3, int n4, int n5, int n6, int n7)
Definition: mesh.h:535
add4TnodesForConformity2d
bool add4TnodesForConformity2d(int eN, int ebN_longest, int ebN_neig, int eN_neig, int &nNodes_global, std::vector< bool > &refined, std::vector< int > &edgeMidNodesArray, const int *elementNodesArray, const int *elementBoundariesArray, const int *elementNeighborsArray, const double *nodeArray)
Definition: mesh.cpp:7336
Mesh::nodeDiametersArray
double * nodeDiametersArray
Definition: mesh.h:69
regularHexahedralMeshElements
int regularHexahedralMeshElements(const int &nx, const int &ny, const int &nz, const int &px, const int &py, const int &pz, Mesh &mesh)
Definition: mesh.cpp:470
computeGeometricInfo_edge
int computeGeometricInfo_edge(Mesh &mesh)
Definition: mesh.cpp:3925
NodeTuple::nodes
int nodes[nNodes]
Definition: mesh.h:428
Mesh::elementBoundaryOffsets_subdomain_owned
int * elementBoundaryOffsets_subdomain_owned
Definition: mesh.h:80
Mesh::interiorElementBoundariesArray
int * interiorElementBoundariesArray
Definition: mesh.h:50
ElementNeighbors::ElementNeighbors
ElementNeighbors()
Definition: mesh.h:495
Mesh::elementBoundaryNodesArray
int * elementBoundaryNodesArray
Definition: mesh.h:47
write3dmMesh
int write3dmMesh(Mesh &mesh, const char *filebase, int base)
Definition: mesh.cpp:5770
MultilevelMesh
Definition: mesh.h:258
readBC
int readBC(Mesh &mesh, const char *filebase, int indexBase)
Definition: mesh.cpp:5732
Mesh::nodeArray
double * nodeArray
Definition: mesh.h:67
regularRectangularToTriangularElementBoundaryMaterials
int regularRectangularToTriangularElementBoundaryMaterials(const double &Lx, const double &Ly, Mesh &mesh)
Definition: mesh.cpp:139
Mesh::nodeElementsArray
int * nodeElementsArray
Definition: mesh.h:43
Mesh::max_nElements_node
int max_nElements_node
Definition: mesh.h:38
Mesh::pz
int pz
Definition: mesh.h:64
regularMeshNodes2D
int regularMeshNodes2D(const int &nx, const int &ny, const double &Lx, const double &Ly, Mesh &mesh)
Definition: mesh.cpp:419
constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_tetrahedron
int constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_tetrahedron(Mesh &mesh)
Definition: mesh.cpp:3115
ElementNeighbors
Definition: mesh.h:492
constructElementBoundaryElementsArray_triangle
int constructElementBoundaryElementsArray_triangle(Mesh &mesh)
Definition: mesh.cpp:780
Mesh::newestNodeBases
int * newestNodeBases
Definition: mesh.h:72
locallyRefineEdgeMesh
int locallyRefineEdgeMesh(MultilevelMesh &multilevelMesh, int *elementTagArray)
Definition: mesh.cpp:5854
copyElementBoundaryMaterialTypesFromTriangle
int copyElementBoundaryMaterialTypesFromTriangle(triangulateio *trimesh, Mesh &mesh, int base)
Definition: mesh.cpp:4935
subdivideTriangle4T
bool subdivideTriangle4T(int eN_parent, int &eN_new, int *elementParentsArray, int *elementChildrenOffsets, int *elementChildrenArray, int *elementNodesArray_child, const std::vector< int > &edgeMidNodesArray, const std::vector< bool > &refined, const int *elementNodesArray_parent, const int *elementBoundariesArray_parent, const double *nodeArray_parent)
Definition: mesh.cpp:7435
NodeTuple
Definition: mesh.h:400
operator<
bool operator<(const NodeTuple< nNodes > &left, const NodeTuple< nNodes > &right)
Definition: mesh.h:433
constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_triangle
int constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_triangle(Mesh &mesh)
Definition: mesh.cpp:2785
Mesh::nodeElementOffsets
int * nodeElementOffsets
Definition: mesh.h:44
newTetrahedron
int newTetrahedron(int eN, int *nodes, int n0, int n1, int n2, int n3)
Definition: mesh.h:515
constructElementBoundaryElementsArrayWithGivenElementBoundaryNumbers_quadrilateral
int constructElementBoundaryElementsArrayWithGivenElementBoundaryNumbers_quadrilateral(Mesh &mesh)
Definition: mesh.cpp:2277
initializeMultilevelMesh
void initializeMultilevelMesh(MultilevelMesh &multilevelMesh)
Definition: mesh.h:266
Mesh
Definition: mesh.h:28
Mesh::nEdges_global
int nEdges_global
Definition: mesh.h:39
Mesh::exteriorElementBoundariesArray
int * exteriorElementBoundariesArray
Definition: mesh.h:51
ElementNeighbors::left
int left
Definition: mesh.h:496
MultilevelMesh::elementChildrenArray
int ** elementChildrenArray
Definition: mesh.h:262
NodeTuple::NodeTuple
NodeTuple(const NodeTuple< nNodes > &nt)
Definition: mesh.h:420
locallyRefineTriangleMesh_4T
int locallyRefineTriangleMesh_4T(MultilevelMesh &multilevelMesh, int *elementTagArray)
Definition: mesh.cpp:6722
ElementNeighbors::right
int right
Definition: mesh.h:496
regularHexahedralToTetrahedralElementBoundaryMaterials
int regularHexahedralToTetrahedralElementBoundaryMaterials(const double &Lx, const double &Ly, const double &Lz, Mesh &mesh)
Definition: mesh.cpp:268
Mesh::nodeStarOffsets
int * nodeStarOffsets
Definition: mesh.h:54
allocateGeometricInfo_hexahedron
int allocateGeometricInfo_hexahedron(Mesh &mesh)
Definition: mesh.cpp:3638
Mesh::volume
double volume
Definition: mesh.h:70
Mesh::nNodes_elementBoundary
int nNodes_elementBoundary
Definition: mesh.h:33
setNewestNodeBasesToLongestEdge
int setNewestNodeBasesToLongestEdge(MultilevelMesh &multilevelMesh)
Definition: mesh.cpp:6183
Mesh::nElementBoundaries_global
int nElementBoundaries_global
Definition: mesh.h:35
allocateNodeAndElementNodeDataStructures
int allocateNodeAndElementNodeDataStructures(Mesh &mesh, int nElements_global, int nNodes_global, int nNodes_element)
Definition: mesh.cpp:3994
Mesh::hMin
double hMin
Definition: mesh.h:70
locallyRefineTriangleMesh
int locallyRefineTriangleMesh(MultilevelMesh &multilevelMesh, int *elementTagArray)
Definition: mesh.cpp:6004
computeGeometricInfo_quadrilateral
int computeGeometricInfo_quadrilateral(Mesh &mesh)
Definition: mesh.cpp:3853
deleteMesh
void deleteMesh(Mesh &mesh)
Definition: mesh.h:164
edgeLength
double edgeLength(const Node &left, const Node &right)
Definition: mesh.h:460
newTriangle
int newTriangle(int eN, int *nodes, int n0, int n1, int n2)
Definition: mesh.h:506
Node::y
double y
Definition: mesh.h:449
Mesh::nInteriorElementBoundaries_global
int nInteriorElementBoundaries_global
Definition: mesh.h:36
Mesh::ny
int ny
Definition: mesh.h:63
Mesh::nodeOffsets_subdomain_owned
int * nodeOffsets_subdomain_owned
Definition: mesh.h:78
MultilevelMesh::meshArray
Mesh * meshArray
Definition: mesh.h:260
deleteMultilevelMesh
void deleteMultilevelMesh(MultilevelMesh &multilevelMesh)
Definition: mesh.h:275
findLocalLongestEdge2d
int findLocalLongestEdge2d(int eN, const int *elementNodesArray, const double *nodeArray)
Definition: mesh.cpp:7407
Mesh::nodeStarArray
int * nodeStarArray
Definition: mesh.h:53
midpoint
void midpoint(const double *left, const double *right, Node &midpoint)
Definition: mesh.h:453
assignElementBoundaryMaterialTypesFromParent
int assignElementBoundaryMaterialTypesFromParent(Mesh &parentMesh, Mesh &childMesh, const int *levelElementParentsArray, const int &nSpace_global)
Definition: mesh.cpp:4557
Mesh::h
double h
Definition: mesh.h:70
allocateGeometricInfo_NURBS
int allocateGeometricInfo_NURBS(Mesh &mesh)
Definition: mesh.cpp:3730
constructElementBoundaryElementsArrayWithGivenElementBoundaryNumbers_edge
int constructElementBoundaryElementsArrayWithGivenElementBoundaryNumbers_edge(Mesh &mesh)
Definition: mesh.cpp:1942
constructElementBoundaryElementsArrayWithGivenElementBoundaryNumbers_tetrahedron
int constructElementBoundaryElementsArrayWithGivenElementBoundaryNumbers_tetrahedron(Mesh &mesh)
Definition: mesh.cpp:2450
globallyRefineQuadrilateralMesh
int globallyRefineQuadrilateralMesh(const int &nLevels, Mesh &mesh, MultilevelMesh &multilevelMesh, bool averageNewNodeFlags=false)
Definition: mesh.cpp:4234
regularHexahedralToTetrahedralMeshElements
int regularHexahedralToTetrahedralMeshElements(const int &nx, const int &ny, const int &nz, Mesh &mesh)
Definition: mesh.cpp:232
locallyRefineTriangleMesh_redGreen
int locallyRefineTriangleMesh_redGreen(MultilevelMesh &multilevelMesh, int *elementTagArray)
Definition: mesh.cpp:6211
MultilevelMesh::nLevels
int nLevels
Definition: mesh.h:259
ElementNeighbors::ElementNeighbors
ElementNeighbors(int leftIn, int left_ebN_elementIn)
Definition: mesh.h:494
readTetgenMesh
int readTetgenMesh(Mesh &mesh, const char *filebase, int base)
Definition: mesh.cpp:5118
globallyRefineHexahedralMesh
int globallyRefineHexahedralMesh(const int &nLevels, Mesh &mesh, MultilevelMesh &multilevelMesh, bool averageNewNodeFlags=false)
Definition: mesh.cpp:4538
regularHexahedralMeshElementBoundaryMaterials
int regularHexahedralMeshElementBoundaryMaterials(const double &Lx, const double &Ly, const double &Lz, Mesh &mesh)
Definition: mesh.cpp:312
constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_quadrilateral
int constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_quadrilateral(Mesh &mesh)
Definition: mesh.cpp:2960
Mesh::nNodes_element
int nNodes_element
Definition: mesh.h:32
Node
Definition: mesh.h:446
Mesh::elementBoundaryLocalElementBoundariesArray
int * elementBoundaryLocalElementBoundariesArray
Definition: mesh.h:49
readElements
int readElements(std::istream &meshFile, Mesh &mesh)
Definition: mesh.cpp:4743
Mesh::elementBoundaryMaterialTypes
int * elementBoundaryMaterialTypes
Definition: mesh.h:56
Mesh::edgeNumbering_subdomain2global
int * edgeNumbering_subdomain2global
Definition: mesh.h:83
regularRectangularToTriangularMeshNodes
int regularRectangularToTriangularMeshNodes(const int &nx, const int &ny, const double &Lx, const double &Ly, Mesh &mesh)
Definition: mesh.cpp:166
Mesh::elementInnerDiametersArray
double * elementInnerDiametersArray
Definition: mesh.h:67
writeTriangleMesh
int writeTriangleMesh(Mesh &mesh, const char *filebase, int base)
Definition: mesh.cpp:5030
newestNodeBisect
bool newestNodeBisect(int eN, int &nElements_global, int &nNodes_global, std::vector< double > &nodeArray, std::vector< int > &elementNodesArray, std::vector< int > &elementNeighborsArray, std::vector< std::list< int > > &childrenList, std::vector< int > &elementParentsArray, std::vector< int > &bases, std::vector< bool > &refined)
Definition: mesh.cpp:6900
writeNodes
int writeNodes(std::ostream &meshFile, const Mesh &mesh)
Definition: mesh.cpp:4807
globallyRefineEdgeMesh
int globallyRefineEdgeMesh(const int &nLevels, Mesh &mesh, MultilevelMesh &multilevelMesh, bool averageNewNodeFlags=false)
Definition: mesh.cpp:4014
constructElementBoundaryElementsArray_NURBS
int constructElementBoundaryElementsArray_NURBS(Mesh &mesh)
Definition: mesh.cpp:1514
edgeMeshElements
int edgeMeshElements(const int &nx, Mesh &mesh)
Definition: mesh.cpp:59
Mesh::edgeOffsets_subdomain_owned
int * edgeOffsets_subdomain_owned
Definition: mesh.h:82
regularQuadrilateralMeshElementBoundaryMaterials
int regularQuadrilateralMeshElementBoundaryMaterials(const double &Lx, const double &Ly, Mesh &mesh)
Definition: mesh.cpp:362
newQuadrilateral
int newQuadrilateral(int eN, int *nodes, int n0, int n1, int n2, int n3)
Definition: mesh.h:525
readTriangleMesh
int readTriangleMesh(Mesh &mesh, const char *filebase, int base)
Definition: mesh.cpp:4970
regularQuadrilateralMeshElements
int regularQuadrilateralMeshElements(const int &nx, const int &ny, Mesh &mesh)
Definition: mesh.cpp:513
readTetgenElementBoundaryMaterialTypes
int readTetgenElementBoundaryMaterialTypes(Mesh &mesh, const char *filebase, int base)
Definition: mesh.cpp:5177
Mesh::V_KNOT
double * V_KNOT
Definition: mesh.h:62
computeGeometricInfo_tetrahedron
int computeGeometricInfo_tetrahedron(Mesh &mesh)
Definition: mesh.cpp:3536
constructElementBoundaryElementsArray_tetrahedron
int constructElementBoundaryElementsArray_tetrahedron(Mesh &mesh)
Definition: mesh.cpp:1118
regularMeshNodes
int regularMeshNodes(const int &nx, const int &ny, const int &nz, const double &Lx, const double &Ly, const double &Lz, Mesh &mesh)
Definition: mesh.cpp:368
add4TnodesForRefinement2d
bool add4TnodesForRefinement2d(int eN, int &nNodes_global, std::vector< bool > &refined, std::vector< int > &edgeMidNodesArray, const int *elementNodesArray, const int *elementBoundariesArray, const int *elementNeighborsArray, const double *nodeArray)
Definition: mesh.cpp:7278
constructElementBoundaryElementsArray_quadrilateral
int constructElementBoundaryElementsArray_quadrilateral(Mesh &mesh)
Definition: mesh.cpp:949
Mesh::elementNodesArray
int * elementNodesArray
Definition: mesh.h:42
constructElementBoundaryElementsArray_edge
int constructElementBoundaryElementsArray_edge(Mesh &mesh)
Definition: mesh.cpp:622
Mesh::elementBoundaryBarycentersArray
double * elementBoundaryBarycentersArray
Definition: mesh.h:68
Mesh::py
int py
Definition: mesh.h:64
Mesh::nz
int nz
Definition: mesh.h:63
Mesh::elementBoundariesArray
int * elementBoundariesArray
Definition: mesh.h:46
Mesh::elementBarycentersArray
double * elementBarycentersArray
Definition: mesh.h:68
constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_NURBS
int constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_NURBS(Mesh &mesh)
Definition: mesh.cpp:1736
Mesh::nElements_global
int nElements_global
Definition: mesh.h:30
Mesh::nodeMaterialTypes
int * nodeMaterialTypes
Definition: mesh.h:57
Mesh::subdomainp
Mesh * subdomainp
Definition: mesh.h:84
regularEdgeMeshNodes
int regularEdgeMeshNodes(const int &nx, const double &Lx, Mesh &mesh)
Definition: mesh.cpp:73
computeGeometricInfo_triangle
int computeGeometricInfo_triangle(Mesh &mesh)
Definition: mesh.cpp:3755
Mesh::nElementBoundaries_element
int nElementBoundaries_element
Definition: mesh.h:34
Node::flag
int flag
Definition: mesh.h:450
Mesh::elementMaterialTypes
int * elementMaterialTypes
Definition: mesh.h:55
Mesh::elementOffsets_subdomain_owned
int * elementOffsets_subdomain_owned
Definition: mesh.h:76
Mesh::elementDiametersArray
double * elementDiametersArray
Definition: mesh.h:67
allocateGeometricInfo_edge
int allocateGeometricInfo_edge(Mesh &mesh)
Definition: mesh.cpp:3913
computeGeometricInfo_hexahedron
int computeGeometricInfo_hexahedron(Mesh &mesh)
Definition: mesh.cpp:3650
Mesh::elementBoundaryNumbering_subdomain2global
int * elementBoundaryNumbering_subdomain2global
Definition: mesh.h:81
setFromTriangleNodes
int setFromTriangleNodes(triangulateio *trimesh, Mesh &mesh, int base)
Definition: mesh.cpp:4897
initializeMesh
void initializeMesh(Mesh &mesh)
Definition: mesh.h:87
Mesh::nNodes_global
int nNodes_global
Definition: mesh.h:31
writeTetgenMesh
int writeTetgenMesh(Mesh &mesh, const char *filebase, int base)
Definition: mesh.cpp:5455
read3DM
int read3DM(Mesh &mesh, const char *filebase, int indexBase)
Definition: mesh.cpp:5490
Mesh::nExteriorElementBoundaries_global
int nExteriorElementBoundaries_global
Definition: mesh.h:37
ElementNeighbors::right_ebN_element
int right_ebN_element
Definition: mesh.h:496
Mesh::px
int px
Definition: mesh.h:64
MultilevelMesh::elementParentsArray
int ** elementParentsArray
Definition: mesh.h:261
constructElementBoundaryElementsArrayWithGivenElementBoundaryNumbers_triangle
int constructElementBoundaryElementsArrayWithGivenElementBoundaryNumbers_triangle(Mesh &mesh)
Definition: mesh.cpp:2103
regularNURBSMeshElements
int regularNURBSMeshElements(const int &nx, const int &ny, const int &nz, const int &px, const int &py, const int &pz, Mesh &mesh)
Definition: mesh.cpp:541
Node::z
double z
Definition: mesh.h:449
regularHexahedralToTetrahedralMeshNodes
int regularHexahedralToTetrahedralMeshNodes(const int &nx, const int &ny, const int &nz, const double &Lx, const double &Ly, const double &Lz, Mesh &mesh)
Definition: mesh.cpp:457
Mesh::W_KNOT
double * W_KNOT
Definition: mesh.h:62
Mesh::elementIJK
int * elementIJK
Definition: mesh.h:60
constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_hexahedron
int constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_hexahedron(Mesh &mesh)
Definition: mesh.cpp:3294
constructElementBoundaryElementsArray_hexahedron
int constructElementBoundaryElementsArray_hexahedron(Mesh &mesh)
Definition: mesh.cpp:1306
Mesh::max_nNodeNeighbors_node
int max_nNodeNeighbors_node
Definition: mesh.h:40
Node::nN
int nN
Definition: mesh.h:448
Mesh::nodeNumbering_subdomain2global
int * nodeNumbering_subdomain2global
Definition: mesh.h:79
ElementNeighbors::left_ebN_element
int left_ebN_element
Definition: mesh.h:496
vector
float * vector(long nl, long nh)
reorientTetrahedralMesh
int reorientTetrahedralMesh(Mesh &mesh)
Definition: mesh.cpp:225
constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_edge
int constructElementBoundaryElementsArrayWithGivenElementBoundaryAndEdgeNumbers_edge(Mesh &mesh)
Definition: mesh.cpp:2630
Node::x
double x
Definition: mesh.h:449
globallyRefineTetrahedralMesh
int globallyRefineTetrahedralMesh(const int &nLevels, Mesh &mesh, MultilevelMesh &multilevelMesh, bool averageNewNodeFlags=false)
Definition: mesh.cpp:4253
Mesh::sigmaMax
double sigmaMax
Definition: mesh.h:70
write2dmMesh
int write2dmMesh(Mesh &mesh, const char *filebase, int base)
Definition: mesh.cpp:5790
Mesh::nodeSupportArray
double * nodeSupportArray
Definition: mesh.h:69
read2DM
int read2DM(Mesh &mesh, const char *filebase, int indexBase)
Definition: mesh.cpp:5574
globallyRefineTriangularMesh
int globallyRefineTriangularMesh(const int &nLevels, Mesh &mesh, MultilevelMesh &multilevelMesh, bool averageNewNodeFlags=false)
Definition: mesh.cpp:4109
Mesh::elementNumbering_subdomain2global
int * elementNumbering_subdomain2global
Definition: mesh.h:77
NodeTuple::NodeTuple
NodeTuple(const int *nodesIn)
Definition: mesh.h:402
Mesh::weights
double * weights
Definition: mesh.h:61
regularRectangularToTriangularMeshElements
int regularRectangularToTriangularMeshElements(const int &nx, const int &ny, Mesh &mesh, int triangleFlag)
Definition: mesh.cpp:88
allocateGeometricInfo_triangle
int allocateGeometricInfo_triangle(Mesh &mesh)
Definition: mesh.cpp:3743
Mesh::edgeNodesArray
int * edgeNodesArray
Definition: mesh.h:52
Mesh::nx
int nx
Definition: mesh.h:63
Mesh::elementBoundaryDiametersArray
double * elementBoundaryDiametersArray
Definition: mesh.h:67
newEdge
int newEdge(int eN, int *nodes, int n0, int n1)
Definition: mesh.h:499
writeElements
int writeElements(std::ostream &meshFile, const Mesh &mesh)
Definition: mesh.cpp:4819
readHex
int readHex(Mesh &mesh, const char *filebase, int indexBase)
Definition: mesh.cpp:5657
allocateGeometricInfo_quadrilateral
int allocateGeometricInfo_quadrilateral(Mesh &mesh)
Definition: mesh.cpp:3843
Mesh::elementBoundaryElementsArray
int * elementBoundaryElementsArray
Definition: mesh.h:48
NodeTuple::nodes_unsorted
int nodes_unsorted[nNodes]
Definition: mesh.h:429
MultilevelMesh::elementChildrenOffsets
int ** elementChildrenOffsets
Definition: mesh.h:263
edgeLengthFromNodeNumbers
double edgeLengthFromNodeNumbers(double *nodeArray, const int &left, const int &right)
Definition: mesh.h:467
Mesh::elementNeighborsArray
int * elementNeighborsArray
Definition: mesh.h:45
setFromTriangleElements
int setFromTriangleElements(triangulateio *trimesh, Mesh &mesh, int base)
Definition: mesh.cpp:4863
computeGeometricInfo_NURBS
int computeGeometricInfo_NURBS(Mesh &mesh)
Definition: mesh.cpp:3736
Mesh::U_KNOT
double * U_KNOT
Definition: mesh.h:62
allocateGeometricInfo_tetrahedron
int allocateGeometricInfo_tetrahedron(Mesh &mesh)
Definition: mesh.cpp:3524