Escript  Revision_4320
finley/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 
17 #ifndef INC_FINLEY_MESH
18 #define INC_FINLEY_MESH
19 
20 /************************************************************************************/
21 
22 /* Finley: Mesh */
23 
24 /* A mesh is built from nodes and elements which are describing the
25  domain, the surface and point sources (the latter are needed to
26  establish links with other codes, in particular to particle
27  codes). The nodes are stored in a Finley_NodeFile and elements in a
28  Finley_ElementFile. Four Finley_ElementFiles containing the elements
29  describe the domain, surface, contact and point sources, respectively.
30  Notice that the surface elements do not necessarily cover the entire
31  surface of the domain. */
32 
33 /* The element type is fixed by the reference element, see
34  ReferenceElement.h. The numbering of the nodes starts with 0. */
35 
36 /* Important: it is assumed that every node appears in at least
37  one element or surface element and that any node used in an
38  element, surface element or as a point is specified in the
39  Finley_NodeFile, see also Finley_resolveNodeIds. */
40 
41 /* In some cases it is useful to refer to a mesh entirely built from
42  order 1 (=linear) elements. The linear version of the mesh can be
43  accessed by referring to the first few nodes of each element
44  (thanks to the way the nodes are ordered). As the numbering of
45  these nodes is not continuous a relabeling vector is introduced
46  in the Finley_NodeFile. This feature is not fully implemented
47  yet. */
48 
49 /* All nodes and elements are tagged. The tag allows to group nodes and
50  elements. A typical application is to mark surface elements on a
51  certain portion of the domain with the same tag. All these surface
52  elements can then be assigned the same value e.g. for the pressure. */
53 
54 /* The spatial dimension is determined by the type of elements
55  used. The spatial dimension should be accessed by the function
56  Finley_Mesh_getDim. Notice that the element type also determines
57  the type of surface elements to be used. */
58 
59 /************************************************************************************/
60 
61 #include "Finley.h"
62 #include "NodeFile.h"
63 #include "ElementFile.h"
64 #include "TagMap.h"
65 #include "Util.h"
66 #include "paso/SystemMatrixPattern.h"
67 #include "escript/DataC.h"
68 
69 #ifdef ESYS_MPI
70 #include "esysUtils/Esys_MPI.h"
71 #endif
72 
73 /************************************************************************************/
74 
75 /* this struct holds a mesh: */
76 
77 struct Finley_Mesh {
78  char* Name; /* the name of the mesh */
79  dim_t reference_counter; /* counts the number of references to the mesh */
84  Finley_NodeFile* Nodes; /* the table of the nodes */
85  Finley_ElementFile* Elements; /* the table of the elements */
86  Finley_ElementFile* FaceElements; /* the table of the face elements */
87  Finley_ElementFile* ContactElements; /* the table of the contact elements */
88  Finley_ElementFile* Points; /* the table of points (treated as elements of dimension 0) */
89  Finley_TagMap* TagMap; /* the tag map mapping names to tag keys */
90 
91  /* pointer to the sparse matrix pattern */
92 
98 };
99 
100 typedef struct Finley_Mesh Finley_Mesh;
101 
102 /* these structures are used for matching surface elements: */
103 
106  double x[MAX_numDim];
107 };
109 
110 /************************************************************************************/
111 
112 /* interfaces: */
113 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, Esys_MPIInfo *mpi_info);
117 
118 void Finley_Mesh_addTagMap(Finley_Mesh *mesh_p,const char* name, index_t tag_key);
119 index_t Finley_Mesh_getTag(Finley_Mesh *mesh_p,const char* name);
120 bool_t Finley_Mesh_isValidTagName(Finley_Mesh *mesh_p,const char* name);
121 void Finley_Mesh_distributeByRankOfDOF(Finley_Mesh* in, dim_t *distribution);
122 Paso_SystemMatrixPattern* Finley_getPattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order);
123 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order);
124 void Finley_Mesh_write(Finley_Mesh*,char*);
125 void Finley_Mesh_dump(Finley_Mesh *in,char* fname);
127 Finley_Mesh* Finley_Mesh_load(char* fname);
131 
137 
139 void Finley_Mesh_prepare(Finley_Mesh* in, bool_t optimize);
140 void Finley_Mesh_createColoring(Finley_Mesh* in, index_t *node_localDOF_map);
143 void Finley_Mesh_createMappings(Finley_Mesh* in, index_t *dof_distribution, index_t *node_distribution);
144 void Finley_Mesh_createNodeFileMappings(Finley_Mesh* in, dim_t numReducedNodes, index_t* indexReducedNodes, index_t* dof_first_component, index_t* nodes_first_component);
145 void Finley_Mesh_markDOFsConnectedToRange(index_t* mask, index_t offset, index_t marker,index_t firstDOF,index_t lastDOF,Finley_Mesh* in, bool_t useLinear);
146 
148 
149 
151 
153 void Finley_Mesh_markNodes(int*,int,Finley_Mesh*,int);
154 
155 void Finley_Mesh_glueFaces(Finley_Mesh* self,double safety_factor,double tolerance, bool_t);
156 void Finley_Mesh_joinFaces(Finley_Mesh* self,double safety_factor,double tolerance, bool_t);
157 
158 int Finley_Mesh_findMatchingFaces_compar(const void*,const void*);
159 void Finley_Mesh_findMatchingFaces(Finley_NodeFile*,Finley_ElementFile *,double,double, int*, int*,int*,int*);
164 
167 void Finley_Mesh_addPoints(Finley_Mesh* mesh, const dim_t numPoints, const double *points_ptr, const index_t *tags_ptr);
168 
169 #endif /* #ifndef INC_FINLEY_MESH */
170