00001 /* 00002 00003 umesh2dgui, a GUI for umesh2d grid generator 00004 00005 Copyright (C) 2010 Gabriele Dini Ciacci <dark.schneider@iol.it> 00006 Based on a code from Luigi Quartapelle and Massimo Biava 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00021 00022 */ 00023 00024 00025 #ifndef U2D_MESH_H 00026 #define U2D_MESH_H 00027 00028 #include <iostream> 00029 00030 #include "boost/numeric/mtl/mtl.hpp" 00031 00032 #define NODE_SIZE 2 /* We are in 2d so nodes have two coordinates, that are 00033 * double numbers. 00034 */ 00035 #define DOMAIN_ELEMENT_SIZE 3 /* An element of the domain is made of three nodes 00036 * since we work with triangles, so we need a 00037 * triplet of integer numbers to represent it. 00038 */ 00039 #define BOUNDARY_ELEMENT_SIZE 2 /* An element of the boundary is made of two nodes 00040 * since it's a straight line, so we need a 00041 * couple of integer numbers to represent it. 00042 */ 00043 #define ZERO_SIZE 0 /* We allocate all matrices and vectors with dummy size 00044 * and change_dim them when we discover the correct size */ 00045 00046 using namespace mtl; 00047 00060 class u2d_Mesh { 00061 private: 00062 int spatial_dim; 00063 int d_nodes_n; 00064 int b_nodes_n; 00065 int d_elem_n; 00066 int b_elem_n; 00067 00068 public: 00069 //u2d_Mesh(); 00070 u2d_Mesh(int _spatial_dim = 0, 00071 int _d_nodes_n = 0, int _b_nodes_n = 0, 00072 int _d_elem_n = 0, int _b_elem_n = 0); 00073 int getDomainElementNumber(); 00074 int getBoundaryElementNumber(); 00075 int getDomainNodeNumber(); 00076 int getBoundaryNodeNumber(); 00077 int getSpatialDimension(); 00078 void resize(int _spatial_dim, int _d_nodes_n, int _b_nodes_n, int _d_elem_n, int _b_elem_n); 00079 void getReady(); 00080 00081 dense2D<double> rr; /* Coordinates of nodes */ 00082 dense2D<int> jjd; /* Triplets of node's ID of each domain element. 00083 * One for each column */ 00084 dense2D<int> jjb; /* Couples of node's ID of each boundary element. 00085 * One for each column */ 00086 dense2D<int> neigh; /* Elements that surround the element. 00087 * One for each column */ 00088 dense2D<int> jjb_s; /* Couples of node's ID of each boundary element. 00089 * NOT NUMBERED by domain nodes id, BUT by boundary 00090 * nodes id (as in neighs). One for each column */ 00091 dense_vector<int> neigh_s; /* Numeration of the boundary elements, same order 00092 * of b_id vector. */ 00093 dense_vector<int> b_id; /* Id of the boundary (the side) the boundary 00094 * element is part of. */ 00095 dense_vector<int> jjb_sd; /* Correspondence of the boundary IDs with the 00096 * domain IDs, so each position of this vector 00097 * contains the ID of the corresponding node in 00098 * domain node numeration. */ 00099 multi_vector<dense_vector<double> > getDomainElementNodes(int elem_id); 00100 multi_vector<dense_vector<double> > getBoundaryElementNodes(int elem_id); 00101 dense_vector<double> getDomainElementNodesId(int elem_id); 00102 int getElementSideId(int jjb_id); 00103 00104 00105 00106 }; 00107 00108 00109 00110 00111 #endif /* U2D_MESH_H */ 00112