ESScript  Revision_
dudley/src/Mesh.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15 
16 #ifndef INC_DUDLEY_MESH
17 #define INC_DUDLEY_MESH
18 
19 /************************************************************************************/
20 
21 /* Dudley: Mesh */
22 
23 /* A mesh is built from nodes and elements which are describing the
24  domain, the surface and point sources. (the latter are needed to
25  establish links with other codes, in particular to particle
26  codes). The nodes are stored a Dudley_NodeFile and elements in a
27  Dudley_ElementFile. A Dudley_NodeFile and three Dudley_ElementFile
28  containing the elements describing the domain, surface and point
29  sources respectively. Notice that the surface elements do not
30  necessaryly cover the entire surface of the domain. */
31 
32 /* The element type is fixed by the reference element, see
33  ReferenceElement.h. The numbering of the nodes starts with 0. */
34 
35 /* Important: it is assumed that every node is appearing in at least
36  one element or surface element and that any node used in an
37  element, surface element or as a point is specified in the
38  Dudley_Node, see also Dudley_resolveNodeIds. */
39 
40 /* In some cases it is useful to refer to a mesh entirly built from
41  order 1 (=linear) elements. The linear version of the mesh can be
42  accessed by referning to the first few nodes of each element
43  (thanks to the way the nodes are ordered). As the numbering of
44  these nodes is not continuous a relabeling vectors are introduced
45  in the Dudley_NodeFile. This feature is not fully implemented
46  yet. */
47 
48 /* allnodes and elements are tagged. the tag allows to group nodes and
49  elements. A typical application is to mark surface elements on a
50  certain portion of the domain with the same tag. All these surface
51  elements can then assigned the same value eg. for the pressure. */
52 
53 /* Thespacial dimension is determined by the type of elements
54  used. The spacial dimension should be accessed by the function
55  Dudley_Mesh_getDim. Notice that the element type also determines
56  the type of surface elements to be used. */
57 
58 /************************************************************************************/
59 
60 #include "Dudley.h"
61 #include "NodeFile.h"
62 #include "ElementFile.h"
63 #include "TagMap.h"
64 #include "Util.h"
65 #include "paso/SystemMatrixPattern.h"
66 #include "escript/DataC.h"
67 
68 #ifdef ESYS_MPI
69 #include "esysUtils/Esys_MPI.h"
70 #endif
71 
72 /************************************************************************************/
73 
74 /* this struct holds a mesh: */
75 
76 struct Dudley_Mesh {
77  char *Name; /* the name of the mesh */
78  dim_t reference_counter; /* counts the number of references to the mesh; */
83  Dudley_NodeFile *Nodes; /* the table of the nodes */
84  Dudley_ElementFile *Elements; /* the table of the elements */
85  Dudley_ElementFile *FaceElements; /* the table of the face elements */
86  Dudley_ElementFile *Points; /* the table of points (treated as elements of dimension 0) */
87  Dudley_TagMap *TagMap; /* the tag map mapping names to tag keys */
88 
89  /* pointer to the sparse matrix pattern */
90 
96 };
97 
98 typedef struct Dudley_Mesh Dudley_Mesh;
99 
100 /* these structures are used for matching surfaces elements: */
101 
104  double x[MAX_numDim];
105 };
107 
108 /************************************************************************************/
109 
110 /* interfaces: */
111 Dudley_Mesh *Dudley_Mesh_alloc(char *name, dim_t numDim, Esys_MPIInfo * mpi_info);
115 
116 void Dudley_Mesh_addTagMap(Dudley_Mesh * mesh_p, const char *name, index_t tag_key);
117 index_t Dudley_Mesh_getTag(Dudley_Mesh * mesh_p, const char *name);
118 bool Dudley_Mesh_isValidTagName(Dudley_Mesh * mesh_p, const char *name);
119 void Dudley_Mesh_distributeByRankOfDOF(Dudley_Mesh * in, dim_t * distribution);
120 Paso_SystemMatrixPattern *Dudley_getPattern(Dudley_Mesh * mesh, bool reduce_row_order, bool reduce_col_order);
121 Paso_SystemMatrixPattern *Dudley_makePattern(Dudley_Mesh * mesh, bool reduce_row_order, bool reduce_col_order);
122 void Dudley_Mesh_write(Dudley_Mesh *, char *);
123 void Dudley_Mesh_dump(Dudley_Mesh * in, char *fname);
124 void Dudley_PrintMesh_Info(Dudley_Mesh *, bool);
125 Dudley_Mesh *Dudley_Mesh_load(char *fname);
127 Dudley_Mesh *Dudley_Mesh_readGmsh(char *, index_t, index_t, index_t, bool, bool);
129 
130 void Dudley_Mesh_setCoordinates(Dudley_Mesh *, escriptDataC *);
133 void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements);
134 
135 void Dudley_Mesh_optimizeDOFDistribution(Dudley_Mesh * in, dim_t * distribution);
136 void Dudley_Mesh_prepare(Dudley_Mesh * in, bool optimize);
137 void Dudley_Mesh_createColoring(Dudley_Mesh * in, index_t * node_localDOF_map);
140 void Dudley_Mesh_createMappings(Dudley_Mesh * in, index_t * dof_distribution, index_t * node_distribution);
141 void Dudley_Mesh_createNodeFileMappings(Dudley_Mesh * in, dim_t numReducedNodes, index_t * indexReducedNodes,
142  index_t * dof_first_component, index_t * nodes_first_component);
143 void Dudley_Mesh_markDOFsConnectedToRange(index_t * mask, index_t offset, index_t marker, index_t firstDOF,
144  index_t lastDOF, Dudley_Mesh * in, bool useLinear);
145 
147 
149 
150 void Dudley_Mesh_relableElementNodes(int *, int, Dudley_Mesh *);
151 void Dudley_Mesh_markNodes(int *, int, Dudley_Mesh *, bool);
152 
153 void Dudley_Mesh_glueFaces(Dudley_Mesh * self, double safety_factor, double tolerance, bool);
154 void Dudley_Mesh_joinFaces(Dudley_Mesh * self, double safety_factor, double tolerance, bool);
155 
156 int Dudley_Mesh_findMatchingFaces_compar(const void *, const void *);
157 void Dudley_Mesh_findMatchingFaces(Dudley_NodeFile *, Dudley_ElementFile *, double, double, int *, int *, int *, int *);
158 void Dudley_Mesh_print(Dudley_Mesh * in);
160 dim_t Dudley_Mesh_FindMinDegreeNode(Paso_SystemMatrixPattern * pattern_p, index_t * available, index_t indicator);
164 
165 #endif /* #ifndef INC_DUDLEY_MESH */