1 /***************************************************************************** 2 * * 3 * Elmer, A Finite Element Software for Multiphysical Problems * 4 * * 5 * Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland * 6 * * 7 * This program is free software; you can redistribute it and/or * 8 * modify it under the terms of the GNU General Public License * 9 * as published by the Free Software Foundation; either version 2 * 10 * of the License, or (at your option) any later version. * 11 * * 12 * This program is distributed in the hope that it will be useful, * 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 * GNU General Public License for more details. * 16 * * 17 * You should have received a copy of the GNU General Public License * 18 * along with this program (in file fem/GPL-2); if not, write to the * 19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 20 * Boston, MA 02110-1301, USA. * 21 * * 22 *****************************************************************************/ 23 24 /***************************************************************************** 25 * * 26 * ElmerGUI mesh_t (Elmer mesh structure) * 27 * * 28 ***************************************************************************** 29 * * 30 * Authors: Mikko Lyly, Juha Ruokolainen and Peter Råback * 31 * Email: Juha.Ruokolainen@csc.fi * 32 * Web: http://www.csc.fi/elmer * 33 * Address: CSC - IT Center for Science Ltd. * 34 * Keilaranta 14 * 35 * 02101 Espoo, Finland * 36 * * 37 * Original Date: 15 Mar 2008 * 38 * * 39 *****************************************************************************/ 40 41 #ifndef MESHTYPE_H 42 #define MESHTYPE_H 43 44 enum GenTypes { 45 GEN_UNKNOWN, 46 GEN_TETLIB, 47 GEN_NGLIB, 48 GEN_ELMERGRID 49 }; 50 51 enum PdeTypes { 52 PDE_UNKNOWN, 53 PDE_BOUNDARY, 54 PDE_BULK 55 }; 56 57 // node class 58 class node_t { 59 public: 60 node_t(); 61 ~node_t(); 62 63 void setX(int, double); 64 double getX(int) const; 65 void setXvec(double*); 66 double* getXvec(); 67 void setIndex(int); 68 int getIndex() const; 69 70 private: 71 double x[3]; // 3d-coordinates 72 int index; // optional tag 73 }; 74 75 // base element class 76 class element_t { 77 public: 78 element_t(); 79 ~element_t(); 80 81 void setNature(int); 82 int getNature() const; 83 void setCode(int); 84 int getCode() const; 85 void setNodes(int); 86 int getNodes() const; 87 void setIndex(int); 88 int getIndex() const; 89 void setSelected(int); 90 int getSelected() const; 91 int getNodeIndex(int) const; 92 void setNodeIndex(int, int); 93 int* getNodeIndexes() const; 94 void newNodeIndexes(int); 95 void deleteNodeIndexes(); 96 97 private: 98 int nature; // PDE_BULK, ... 99 int code; // element code for Elmer (504, 808, ...) 100 int nodes; // number of nodes 101 int index; // bc/mat index as defined in input file 102 int selected; // element is selected or not 103 int* node; // list of nodes 104 }; 105 106 // zero dimensional elements 107 class point_t: public element_t { 108 public: 109 point_t(); 110 ~point_t(); 111 112 void setSharp(bool); 113 bool isSharp() const; 114 void setEdges(int); 115 int getEdges() const; 116 void setEdgeIndex(int, int); 117 int getEdgeIndex(int) const; 118 void newEdgeIndexes(int); 119 void deleteEdgeIndexes(); 120 121 private: 122 bool sharp_point; // marker 123 int edges; // number of parent edges 124 int* edge; // list of parent edges 125 }; 126 127 // one dimensional elements 128 class edge_t: public element_t { 129 public: 130 edge_t(); 131 ~edge_t(); 132 133 void setSharp(bool); 134 bool isSharp() const; 135 void setPoints(int); 136 int getPoints() const; 137 void setPointIndex(int, int); 138 int getPointIndex(int) const; 139 void newPointIndexes(int); 140 void deletePointIndexes(); 141 void setSurfaces(int); 142 int getSurfaces() const; 143 void setSurfaceIndex(int, int); 144 int getSurfaceIndex(int) const; 145 void newSurfaceIndexes(int); 146 void deleteSurfaceIndexes(); 147 148 private: 149 bool sharp_edge; // marker 150 int points; // number of child points 151 int* point; // list of points 152 int surfaces; // number of parent surfaces 153 int* surface; // list of parent surfaces 154 }; 155 156 // two dimensional elements 157 class surface_t: public element_t { 158 public: 159 surface_t(); 160 ~surface_t(); 161 162 void setEdges(int); 163 int getEdges() const; 164 void setEdgeIndex(int, int); 165 int getEdgeIndex(int) const; 166 void newEdgeIndexes(int); 167 void deleteEdgeIndexes(); 168 void setElements(int); 169 int getElements() const; 170 void setElementIndex(int, int); 171 int getElementIndex(int) const; 172 void newElementIndexes(int); 173 void deleteElementIndexes(); 174 void setNormalVec(double*); 175 double* getNormalVec(); 176 double getNormal(int) const; 177 void setNormal(int, double); 178 void setVertexNormalVec(int, double*); 179 void addVertexNormalVec(int, double*); 180 void subVertexNormalVec(int, double*); 181 double* getVertexNormalVec(int); 182 183 private: 184 int edges; // number of child edges 185 int* edge; // list of child edges 186 int elements; // number of parent elements 187 int* element; // list of parent elements 188 double normal[3]; // unit (outward) normal 189 double vertex_normals[4][3]; // unit (outward) normal on corner points 190 }; 191 192 // mesh class 193 class mesh_t { 194 public: 195 mesh_t(); 196 ~mesh_t(); 197 198 bool isUndefined() const; 199 void clear(); 200 bool load(char*); 201 bool save(char*); 202 double* boundingBox(); 203 void setCdim(int); 204 int getCdim() const; 205 void setDim(int); 206 int getDim() const; 207 void setNodes(int); 208 int getNodes() const; 209 void setPoints(int); 210 int getPoints() const; 211 void setEdges(int); 212 int getEdges() const; 213 void setSurfaces(int); 214 int getSurfaces() const; 215 void setElements(int); 216 int getElements() const; 217 node_t* getNode(int); 218 void setNodeArray(node_t*); 219 void newNodeArray(int); 220 void deleteNodeArray(); 221 point_t* getPoint(int); 222 void setPointArray(point_t*); 223 void newPointArray(int); 224 void deletePointArray(); 225 edge_t* getEdge(int); 226 void setEdgeArray(edge_t*); 227 void newEdgeArray(int); 228 void deleteEdgeArray(); 229 surface_t* getSurface(int); 230 void setSurfaceArray(surface_t*); 231 void newSurfaceArray(int); 232 void deleteSurfaceArray(); 233 element_t* getElement(int); 234 void setElementArray(element_t*); 235 void newElementArray(int); 236 void deleteElementArray(); 237 238 private: 239 void setDefaults(); 240 241 int cdim; // model coordinate dimension 242 int dim; // model max element dimension 243 int nodes; // number of nodes 244 int points; // number of point elements 245 int edges; // number of edge elements 246 int surfaces; // number of surface elements 247 int elements; // number of volume elements 248 249 node_t* node; // array of nodes 250 point_t* point; // array of point elements 251 edge_t* edge; // array of edge elements 252 surface_t* surface; // array of surface elements 253 element_t* element; // array of volume elements 254 255 }; 256 257 #endif // MESHTYPE_H 258