ESYS13  Revision_
Mesh.h
Go to the documentation of this file.
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 
00015 #ifndef INC_FINLEY_MESH
00016 #define INC_FINLEY_MESH
00017 
00018 /**************************************************************/
00019 
00020 /* Finley: Mesh */
00021 
00022 /* A mesh is built from nodes and elements which are describing the
00023    domain, the surface and point sources (the latter are needed to
00024    establish links with other codes, in particular to particle
00025    codes). The nodes are stored in a Finley_NodeFile and elements in a
00026    Finley_ElementFile. Four Finley_ElementFiles containing the elements
00027    describe the domain, surface, contact and point sources, respectively.
00028    Notice that the surface elements do not necessarily cover the entire
00029    surface of the domain. */
00030 
00031 /* The element type is fixed by the reference element, see
00032    ReferenceElement.h. The numbering of the nodes starts with 0. */
00033 
00034 /* Important: it is assumed that every node appears in at least
00035    one element or surface element and that any node used in an
00036    element, surface element or as a point is specified in the
00037    Finley_NodeFile, see also Finley_resolveNodeIds. */
00038 
00039 /* In some cases it is useful to refer to a mesh entirely built from
00040    order 1 (=linear) elements. The linear version of the mesh can be
00041    accessed by referring to the first few nodes of each element
00042    (thanks to the way the nodes are ordered). As the numbering of
00043    these nodes is not continuous a relabeling vector is introduced
00044    in the Finley_NodeFile. This feature is not fully implemented
00045    yet. */
00046 
00047 /* All nodes and elements are tagged. The tag allows to group nodes and
00048    elements. A typical application is to mark surface elements on a
00049    certain portion of the domain with the same tag. All these surface
00050    elements can then be assigned the same value e.g. for the pressure. */
00051 
00052 /* The spatial dimension is determined by the type of elements
00053    used. The spatial dimension should be accessed by the function
00054    Finley_Mesh_getDim. Notice that the element type also determines
00055    the type of surface elements to be used. */
00056 
00057 /**************************************************************/
00058 
00059 #include "Finley.h"
00060 #include "NodeFile.h"
00061 #include "ElementFile.h"
00062 #include "TagMap.h"
00063 #include "Util.h"
00064 #include "paso/SystemMatrixPattern.h"
00065 #include "escript/DataC.h"
00066 
00067 #ifdef ESYS_MPI
00068 #include "esysUtils/Esys_MPI.h"
00069 #endif
00070 
00071 /**************************************************************/
00072 
00073 /*  this struct holds a mesh: */
00074 
00075 struct Finley_Mesh {
00076   char* Name;                           /* the name of the mesh */
00077   dim_t reference_counter;              /* counts the number of references to the mesh */
00078   dim_t approximationOrder;                        
00079   dim_t reducedApproximationOrder;                
00080   dim_t integrationOrder;                
00081   dim_t reducedIntegrationOrder;           
00082   Finley_NodeFile* Nodes;               /* the table of the nodes */
00083   Finley_ElementFile* Elements;         /* the table of the elements */
00084   Finley_ElementFile* FaceElements;     /* the table of the face elements */
00085   Finley_ElementFile* ContactElements;  /* the table of the contact elements */
00086   Finley_ElementFile* Points;           /* the table of points (treated as elements of dimension 0) */
00087   Finley_TagMap* TagMap;                /* the tag map mapping names to tag keys */
00088 
00089   /* pointer to the sparse matrix pattern */
00090 
00091   Paso_SystemMatrixPattern *FullFullPattern;
00092   Paso_SystemMatrixPattern *FullReducedPattern;
00093   Paso_SystemMatrixPattern *ReducedFullPattern;
00094   Paso_SystemMatrixPattern *ReducedReducedPattern;
00095   Esys_MPIInfo *MPIInfo;
00096 };
00097 
00098 typedef struct Finley_Mesh Finley_Mesh;
00099 
00100 /* these structures are used for matching surface elements: */
00101 
00102 struct Finley_Mesh_findMatchingFaces_center{
00103    index_t refId;
00104    double x[MAX_numDim];
00105 };
00106 typedef struct Finley_Mesh_findMatchingFaces_center Finley_Mesh_findMatchingFaces_center;
00107 
00108 /**************************************************************/
00109 
00110 /*  interfaces: */
00111 Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, Esys_MPIInfo *mpi_info);
00112 Finley_Mesh* Finley_Mesh_reference(Finley_Mesh*);
00113 dim_t Finley_Mesh_getDim(Finley_Mesh*);
00114 void Finley_Mesh_free(Finley_Mesh*);
00115 
00116 void Finley_Mesh_addTagMap(Finley_Mesh *mesh_p,const char* name, index_t tag_key);
00117 index_t Finley_Mesh_getTag(Finley_Mesh *mesh_p,const char* name);
00118 bool_t Finley_Mesh_isValidTagName(Finley_Mesh *mesh_p,const char* name);
00119 void Finley_Mesh_distributeByRankOfDOF(Finley_Mesh* in, dim_t *distribution);
00120 Paso_SystemMatrixPattern* Finley_getPattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order);
00121 Paso_SystemMatrixPattern* Finley_makePattern(Finley_Mesh *mesh,bool_t reduce_row_order, bool_t reduce_col_order);
00122 void Finley_Mesh_write(Finley_Mesh*,char*);
00123 void Finley_Mesh_dump(Finley_Mesh *in,char* fname);
00124 void Finley_PrintMesh_Info(Finley_Mesh *, bool_t);
00125 Finley_Mesh* Finley_Mesh_load(char* fname);
00126 Finley_Mesh* Finley_Mesh_read(char*,index_t, index_t, bool_t);
00127 Finley_Mesh* Finley_Mesh_readGmsh(char*,index_t, index_t, index_t, bool_t, bool_t);
00128 void Finley_Mesh_setOrders(Finley_Mesh *in);
00129 
00130 void Finley_Mesh_setCoordinates(Finley_Mesh*,escriptDataC*);
00131 void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements);
00132 void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements);
00133 void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements);
00134 void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements);
00135 
00136 void Finley_Mesh_optimizeDOFDistribution(Finley_Mesh* in,dim_t *distribution);
00137 void Finley_Mesh_prepare(Finley_Mesh* in, bool_t optimize);
00138 void Finley_Mesh_createColoring(Finley_Mesh* in, index_t *node_localDOF_map);
00139 void Finley_Mesh_optimizeElementOrdering(Finley_Mesh* in);
00140 void Finley_Mesh_resolveNodeIds(Finley_Mesh*);
00141 void Finley_Mesh_createMappings(Finley_Mesh* in, index_t *dof_distribution, index_t *node_distribution);
00142 void Finley_Mesh_createNodeFileMappings(Finley_Mesh* in, dim_t numReducedNodes, index_t* indexReducedNodes, index_t* dof_first_component, index_t* nodes_first_component);
00143 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);
00144 
00145 void Finley_Mesh_optimizeDOFLabeling(Finley_Mesh*,dim_t *);
00146 
00147 
00148 Finley_Mesh* Finley_Mesh_merge(dim_t, Finley_Mesh**);
00149 
00150 void Finley_Mesh_relableElementNodes(int*,int,Finley_Mesh*);
00151 void Finley_Mesh_markNodes(int*,int,Finley_Mesh*,int);
00152 
00153 void Finley_Mesh_glueFaces(Finley_Mesh* self,double safety_factor,double tolerance, bool_t);
00154 void Finley_Mesh_joinFaces(Finley_Mesh* self,double safety_factor,double tolerance, bool_t);
00155 
00156 int Finley_Mesh_findMatchingFaces_compar(const void*,const void*);
00157 void Finley_Mesh_findMatchingFaces(Finley_NodeFile*,Finley_ElementFile *,double,double, int*, int*,int*,int*);
00158 void Finley_Mesh_print(Finley_Mesh *in);
00159 void Finley_Mesh_saveDX(const char * filename_p, Finley_Mesh *mesh_p, const dim_t num_data,char* *names_p,escriptDataC* *data_pp);
00160 void Finley_Mesh_optimizeNodeLabeling(Finley_Mesh* mesh_p);
00161 dim_t Finley_Mesh_FindMinDegreeNode(Paso_SystemMatrixPattern* pattern_p,index_t* available,index_t indicator);
00162 index_t Finley_Mesh_getDegree(Paso_SystemMatrixPattern* pattern_p, index_t *label);
00163 
00164 void Finley_Mesh_saveVTK(const char * filename_p, Finley_Mesh *mesh_p, const dim_t num_data,char* *names_p,escriptDataC* *data_pp, const char* metadata, const char*metadata_schema);
00165 void Finley_Mesh_setTagsInUse(Finley_Mesh* in);
00166 
00167 int  Finley_Mesh_getStatus(Finley_Mesh* in);
00168 void Finley_Mesh_addPoints(Finley_Mesh* mesh, const dim_t numPoints, const double *points_ptr, const index_t *tags_ptr);
00169 
00170 #endif /* #ifndef INC_FINLEY_MESH */
00171