ESYS13
Revision_
|
00001 00002 /******************************************************* 00003 * 00004 * Copyright (c) 2003-2012 by University of Queensland 00005 * Earth Systems Science Computational Center (ESSCC) 00006 * http://www.uq.edu.au/esscc 00007 * 00008 * Primary Business: Queensland, Australia 00009 * Licensed under the Open Software License version 3.0 00010 * http://www.opensource.org/licenses/osl-3.0.php 00011 * 00012 *******************************************************/ 00013 00014 #ifndef INC_DUDLEY_MESH 00015 #define INC_DUDLEY_MESH 00016 00017 /**************************************************************/ 00018 00019 /* Dudley: Mesh */ 00020 00021 /* A mesh is built from nodes and elements which are describing the 00022 domain, the surface and point sources. (the latter are needed to 00023 establish links with other codes, in particular to particle 00024 codes). The nodes are stored a Dudley_NodeFile and elements in a 00025 Dudley_ElementFile. A Dudley_NodeFile and three Dudley_ElementFile 00026 containing the elements describing the domain, surface and point 00027 sources respectively. Notice that the surface elements do not 00028 necessaryly cover the entire surface of the domain. */ 00029 00030 /* The element type is fixed by the reference element, see 00031 ReferenceElement.h. The numbering of the nodes starts with 0. */ 00032 00033 /* Important: it is assumed that every node is appearing in at least 00034 one element or surface element and that any node used in an 00035 element, surface element or as a point is specified in the 00036 Dudley_Node, see also Dudley_resolveNodeIds. */ 00037 00038 /* In some cases it is useful to refer to a mesh entirly built from 00039 order 1 (=linear) elements. The linear version of the mesh can be 00040 accessed by referning to the first few nodes of each element 00041 (thanks to the way the nodes are ordered). As the numbering of 00042 these nodes is not continuous a relabeling vectors are introduced 00043 in the Dudley_NodeFile. This feature is not fully implemented 00044 yet. */ 00045 00046 /* allnodes and elements are tagged. the tag allows to group nodes and 00047 elements. A typical application is to mark surface elements on a 00048 certain portion of the domain with the same tag. All these surface 00049 elements can then assigned the same value eg. for the pressure. */ 00050 00051 /* Thespacial dimension is determined by the type of elements 00052 used. The spacial dimension should be accessed by the function 00053 Dudley_Mesh_getDim. Notice that the element type also determines 00054 the type of surface elements to be used. */ 00055 00056 /**************************************************************/ 00057 00058 #include "Dudley.h" 00059 #include "NodeFile.h" 00060 #include "ElementFile.h" 00061 #include "TagMap.h" 00062 #include "Util.h" 00063 #include "paso/SystemMatrixPattern.h" 00064 #include "escript/DataC.h" 00065 00066 #ifdef ESYS_MPI 00067 #include "esysUtils/Esys_MPI.h" 00068 #endif 00069 00070 /**************************************************************/ 00071 00072 /* this struct holds a mesh: */ 00073 00074 struct Dudley_Mesh { 00075 char *Name; /* the name of the mesh */ 00076 dim_t reference_counter; /* counts the number of references to the mesh; */ 00077 dim_t approximationOrder; 00078 dim_t reducedApproximationOrder; 00079 dim_t integrationOrder; 00080 dim_t reducedIntegrationOrder; 00081 Dudley_NodeFile *Nodes; /* the table of the nodes */ 00082 Dudley_ElementFile *Elements; /* the table of the elements */ 00083 Dudley_ElementFile *FaceElements; /* the table of the face elements */ 00084 Dudley_ElementFile *Points; /* the table of points (treated as elements of dimension 0) */ 00085 Dudley_TagMap *TagMap; /* the tag map mapping names to tag keys */ 00086 00087 /* pointer to the sparse matrix pattern */ 00088 00089 Paso_SystemMatrixPattern *FullFullPattern; 00090 Paso_SystemMatrixPattern *FullReducedPattern; 00091 Paso_SystemMatrixPattern *ReducedFullPattern; 00092 Paso_SystemMatrixPattern *ReducedReducedPattern; 00093 Esys_MPIInfo *MPIInfo; 00094 }; 00095 00096 typedef struct Dudley_Mesh Dudley_Mesh; 00097 00098 /* these structures are used for matching surfaces elements: */ 00099 00100 struct Dudley_Mesh_findMatchingFaces_center { 00101 index_t refId; 00102 double x[MAX_numDim]; 00103 }; 00104 typedef struct Dudley_Mesh_findMatchingFaces_center Dudley_Mesh_findMatchingFaces_center; 00105 00106 /**************************************************************/ 00107 00108 /* interfaces: */ 00109 Dudley_Mesh *Dudley_Mesh_alloc(char *name, dim_t numDim, Esys_MPIInfo * mpi_info); 00110 Dudley_Mesh *Dudley_Mesh_reference(Dudley_Mesh *); 00111 dim_t Dudley_Mesh_getDim(Dudley_Mesh *); 00112 void Dudley_Mesh_free(Dudley_Mesh *); 00113 00114 void Dudley_Mesh_addTagMap(Dudley_Mesh * mesh_p, const char *name, index_t tag_key); 00115 index_t Dudley_Mesh_getTag(Dudley_Mesh * mesh_p, const char *name); 00116 bool_t Dudley_Mesh_isValidTagName(Dudley_Mesh * mesh_p, const char *name); 00117 void Dudley_Mesh_distributeByRankOfDOF(Dudley_Mesh * in, dim_t * distribution); 00118 Paso_SystemMatrixPattern *Dudley_getPattern(Dudley_Mesh * mesh, bool_t reduce_row_order, bool_t reduce_col_order); 00119 Paso_SystemMatrixPattern *Dudley_makePattern(Dudley_Mesh * mesh, bool_t reduce_row_order, bool_t reduce_col_order); 00120 void Dudley_Mesh_write(Dudley_Mesh *, char *); 00121 void Dudley_Mesh_dump(Dudley_Mesh * in, char *fname); 00122 void Dudley_PrintMesh_Info(Dudley_Mesh *, bool_t); 00123 Dudley_Mesh *Dudley_Mesh_load(char *fname); 00124 Dudley_Mesh *Dudley_Mesh_read(char *, index_t, index_t, bool_t); 00125 Dudley_Mesh *Dudley_Mesh_readGmsh(char *, index_t, index_t, index_t, bool_t, bool_t); 00126 void Dudley_Mesh_setOrders(Dudley_Mesh * in); 00127 00128 void Dudley_Mesh_setCoordinates(Dudley_Mesh *, escriptDataC *); 00129 void Dudley_Mesh_setElements(Dudley_Mesh * self, Dudley_ElementFile * elements); 00130 void Dudley_Mesh_setFaceElements(Dudley_Mesh * self, Dudley_ElementFile * elements); 00131 void Dudley_Mesh_setPoints(Dudley_Mesh * self, Dudley_ElementFile * elements); 00132 00133 void Dudley_Mesh_optimizeDOFDistribution(Dudley_Mesh * in, dim_t * distribution); 00134 void Dudley_Mesh_prepare(Dudley_Mesh * in, bool_t optimize); 00135 void Dudley_Mesh_createColoring(Dudley_Mesh * in, index_t * node_localDOF_map); 00136 void Dudley_Mesh_optimizeElementOrdering(Dudley_Mesh * in); 00137 void Dudley_Mesh_resolveNodeIds(Dudley_Mesh *); 00138 void Dudley_Mesh_createMappings(Dudley_Mesh * in, index_t * dof_distribution, index_t * node_distribution); 00139 void Dudley_Mesh_createNodeFileMappings(Dudley_Mesh * in, dim_t numReducedNodes, index_t * indexReducedNodes, 00140 index_t * dof_first_component, index_t * nodes_first_component); 00141 void Dudley_Mesh_markDOFsConnectedToRange(index_t * mask, index_t offset, index_t marker, index_t firstDOF, 00142 index_t lastDOF, Dudley_Mesh * in, bool_t useLinear); 00143 00144 void Dudley_Mesh_optimizeDOFLabeling(Dudley_Mesh *, dim_t *); 00145 00146 Dudley_Mesh *Dudley_Mesh_merge(dim_t, Dudley_Mesh **); 00147 00148 void Dudley_Mesh_relableElementNodes(int *, int, Dudley_Mesh *); 00149 void Dudley_Mesh_markNodes(int *, int, Dudley_Mesh *, int); 00150 00151 void Dudley_Mesh_glueFaces(Dudley_Mesh * self, double safety_factor, double tolerance, bool_t); 00152 void Dudley_Mesh_joinFaces(Dudley_Mesh * self, double safety_factor, double tolerance, bool_t); 00153 00154 int Dudley_Mesh_findMatchingFaces_compar(const void *, const void *); 00155 void Dudley_Mesh_findMatchingFaces(Dudley_NodeFile *, Dudley_ElementFile *, double, double, int *, int *, int *, int *); 00156 void Dudley_Mesh_print(Dudley_Mesh * in); 00157 void Dudley_Mesh_saveDX(const char *filename_p, Dudley_Mesh * mesh_p, const dim_t num_data, char **names_p, 00158 escriptDataC * *data_pp); 00159 void Dudley_Mesh_optimizeNodeLabeling(Dudley_Mesh * mesh_p); 00160 dim_t Dudley_Mesh_FindMinDegreeNode(Paso_SystemMatrixPattern * pattern_p, index_t * available, index_t indicator); 00161 index_t Dudley_Mesh_getDegree(Paso_SystemMatrixPattern * pattern_p, index_t * label); 00162 00163 void Dudley_Mesh_saveVTK(const char *filename_p, Dudley_Mesh * mesh_p, const dim_t num_data, char **names_p, 00164 escriptDataC * *data_pp, const char *metadata, const char *metadata_schema); 00165 void Dudley_Mesh_setTagsInUse(Dudley_Mesh * in); 00166 00167 int Dudley_Mesh_getStatus(Dudley_Mesh * in); 00168 00169 #endif /* #ifndef INC_DUDLEY_MESH */