muMECH  1.0
mesh.h
Go to the documentation of this file.
1 //********************************************************************************************************
2 // code: ### ### ##### #### ## ##
3 // ## ## ######## ## ## ## ## ##
4 // ## ## ## ## ## ### ## ######
5 // ## ## ## ## ## ## ## ## ##
6 // ##### ## ## ##### #### ## ##
7 // ##
8 //
9 // name: mesh.h
10 // author(s): Ladislav Svoboda
11 // language: C, C++
12 // license: This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation; either version 2 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 //********************************************************************************************************
31 #ifndef MUMECH_MESH_H
32 #define MUMECH_MESH_H
33 
34 #include "types.h"
35 
36 #include <stdlib.h>
37 
38 
39 namespace mumech {
40 
41 class Problems;
42 class Problem;
43 class mNode;
44 class mElement;
45 
46 
49 
50 
52 class Mesh
53 {
54  public:
55  // ASSIGNED PROBLEMS
56  long id;
57  int npa;
58  int np;
59  const Problems **P;
60 
61  // MESH GEOMETRY
62  // collapsed dimension
63  // -1 = no mesh - no readed geometry
64  // 0 = 3d mesh - no axis collapsed
65  // 1 = 2d mesh - x axis collapsed
66  // 2 = 2d mesh - y axis collapsed
67  // 3 = 2d mesh - z axis collapsed
68  int coll;
70  int md;
73 
74  double point1[3];
75  double point2[3];
76  double delta[3];
77  long nsegs[3];
78 
79  double volume;
80 
81 
82  // MESH COMPONENTS
83  long nNodes;
85  long nElems;
87 
88 
89  // MESH RESULTS
90  // Bude se drzet vice verzi vysledku, jedna pro kazdy problem, dimenze vysledku je stejna jako dimenze problemu,
91  // pri porovnavani dvou vysledku ruznych dimenzi se musi redukovat na tu nejnizsi.
92  int nLC;
93 
94  bool **no_dspl_rf;
95  bool **no_strn_rf;
96  bool **no_strs_rf;
97 
98  bool **el_dspl_rf;
99  bool **el_strn_rf;
100  bool **el_strs_rf;
101 
102  // double **displc; ///< averaged computed fields - displacement
103  // double **strain; ///< averaged computed fields - strain
104  // double **stress; ///< averaged computed fields - stress
105 
106 
107  public:
109  Mesh (long i, const Problems *p);
111  Mesh (long i, const Problems *p, const Mesh *src);
113  virtual ~Mesh();
114 
115  //
116  int add_problem (const Problems *p);
117  //
118  void set_coll (int val);
119 
120  //
121  int give_nlc (void) { if (nLC == -77) errol; return nLC; }
123  bool give_twodim (void) const { if (md != 2 && md != 3) errol; return (md == 2); }
124 
125  //
126  bool geom_is_readed (void) { return mtA != MT_VOID; }
127 
129  //int nstrain (void) const { return (this->coll==0 ? 6 : 3); }
130 
132  bool equal_dimensions (int pid) const;
133 
135  bool is_unset (void);
137  void scale (const double *s);
139  void local2global (const double *origin, const double *TInv);
140 
142  void shift_id (long snn, long sne);
143 
148  void read_geometry_file_vtk (const char *vtkMeshFile, int pid, int lc, bool add);
149 
156  void generate_regular_mesh (const double *p1, const double *p2, const long *n);
157 
161  void generate_regularSphereMesh_2d (int n, const double *a);
165  void generate_regularSphereMesh_3d (int n, const double *a);
166 
167 
169  void compute_node_fields (char flag, bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC, PFCmode pfcMode);
171  void compute_element_fields (char flag, bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC, PFCmode pfcMode);
172 
173 
174 
179  void print_geometry_file_vtk (const char *rsltFileName, int pid, int lc, int nLC);
180 
181 
182 
183 
185  double give_total_energy (int pid, int lc);
187  double give_homog_energy (int lc, int pid=0);
189  void integrate_energy_at_elems (int lc, int nLC);
191  double give_error (int pid1, int pid2, int lc);
192 
193 
195  double give_total_volume (void) const;
196 
198  double give_regular_element_volume (void) const;
199 
200  protected:
202  void set_and_alloc_nNodes (long nn);
204  void set_and_alloc_nElems (long ne);
205 
206  private:
207 
209  int file_type_s2e (const char *s);
211  void set_node_rslt_flags (bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC);
213  void set_elem_rslt_flags (bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC);
214 
215 
217  void average_fields (bool displc_flag, bool strain_flag, bool stress_flag, int lc, int nLC);
218 
219 
220 
221 };//end of class declaration
222 
223 } // end of namespace mumech
224 
225 #endif // end of MUMECH_MESH_H
226 
227 /*end of file*/
void print_geometry_file_vtk(const char *rsltFileName, int pid, int lc, int nLC)
Print output file with mesh geometry with results to vtk file.
Definition: mesh.cpp:956
void generate_regular_mesh(const double *p1, const double *p2, const long *n)
Generate regular mesh geometry of rectangular cuboid shape compound of rectangular cuboid shape eleme...
Definition: mesh.cpp:260
void shift_id(long snn, long sne)
Definition: mesh.cpp:246
file of various types and symbolic constant definitions
void generate_regularSphereMesh_2d(int n, const double *a)
Function generates uniform mesh on an unit circle.
Definition: mesh.cpp:767
long nsegs[3]
Definition: mesh.h:77
double volume
Volume/Area.
Definition: mesh.h:79
void integrate_energy_at_elems(int lc, int nLC)
void local2global(const double *origin, const double *TInv)
Local to global transformation of all nodes.
Definition: mesh.cpp:212
void set_coll(int val)
Definition: mesh.cpp:166
bool ** no_strn_rf
Definition: mesh.h:95
Class mNode contains and handles all mesh node data.
Definition: mnode.h:43
Mesh(long i, const Problems *p)
Constructor.
Definition: mesh.cpp:49
long id
identification number
Definition: mesh.h:56
void generate_regularSphereMesh_3d(int n, const double *a)
Function generates uniform mesh on an unit sphere.
Definition: mesh.cpp:808
long nNodes
Number of nodes.
Definition: mesh.h:83
mNode ** Nodes
1d array of pointers to Node.
Definition: mesh.h:84
PFCmode
Algorithm type of a point fields calculation.
Definition: types.h:97
bool is_unset(void)
Returns true, if the receiver is unset, only constructor was called.
Definition: mesh.cpp:187
#define errol
Definition: gelib.h:151
int np
number of pointers to problems
Definition: mesh.h:58
void average_fields(bool displc_flag, bool strain_flag, bool stress_flag, int lc, int nLC)
int nLC
number of load cases
Definition: mesh.h:92
virtual ~Mesh()
Destructor.
Definition: mesh.cpp:124
int md
mesh dimension
Definition: mesh.h:70
bool ** el_strs_rf
Definition: mesh.h:100
void compute_node_fields(char flag, bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC, PFCmode pfcMode)
Definition: mesh.cpp:1111
int give_nlc(void)
Definition: mesh.h:121
void read_geometry_file_vtk(const char *vtkMeshFile, int pid, int lc, bool add)
Read input file with mesh geometry from vtk file.
Definition: mesh.cpp:355
long nElems
Number of elements.
Definition: mesh.h:85
double give_homog_energy(int lc, int pid=0)
Definition: mesh.cpp:1238
int npa
number of allocated pointers
Definition: mesh.h:57
double give_error(int pid1, int pid2, int lc)
Definition: mesh.cpp:1284
MeshType mtA
type of mesh, structured grid or unstructured
Definition: mesh.h:72
double point1[3]
Definition: mesh.h:74
bool ** no_strs_rf
Definition: mesh.h:96
void compute_element_fields(char flag, bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC, PFCmode pfcMode)
predpokladame trojuhelnikove nebo tetrahedron prvky, tj. na elementu budeme drzet jednu hodnotu ...
Definition: mesh.cpp:1138
bool ** no_dspl_rf
Definition: mesh.h:94
void set_and_alloc_nElems(long ne)
Set nElems and allocate array Elems.
Definition: mesh.cpp:236
bool equal_dimensions(int pid) const
Returns true when mesh and problem dimensions are same.
Definition: mesh.cpp:180
bool give_twodim(void) const
Definition: mesh.h:123
void set_node_rslt_flags(bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC)
Definition: mesh.cpp:1078
void set_and_alloc_nNodes(long nn)
Set nNodes and allocate array Nodes.
Definition: mesh.cpp:227
bool ** el_dspl_rf
pid x nlc
Definition: mesh.h:98
int coll
Definition: mesh.h:68
MeshType
Type of mesh.
Definition: mesh.h:48
int file_type_s2e(const char *s)
Definition: mesh.cpp:341
double delta[3]
Definition: mesh.h:76
void set_elem_rslt_flags(bool displc_flag, bool strain_flag, bool stress_flag, int pid, int lc, int nLC)
Definition: mesh.cpp:1094
const Problems ** P
set of pointers to solved problems
Definition: mesh.h:59
double give_total_energy(int pid, int lc)
Definition: mesh.cpp:1269
bool geom_is_readed(void)
Definition: mesh.h:126
Class Mesh contains and handles all mesh data.
Definition: mesh.h:52
int add_problem(const Problems *p)
Definition: mesh.cpp:148
double point2[3]
Definition: mesh.h:75
mElement ** Elems
1d array of pointers to Element.
Definition: mesh.h:86
double give_regular_element_volume(void) const
Definition: mesh.cpp:1190
void scale(const double *s)
Scale all nodes coordinates by vector s.
Definition: mesh.cpp:199
Class mElement contains and handles all mesh element data.
Definition: melement.h:42
double give_total_volume(void) const
Definition: mesh.cpp:1165
bool ** el_strn_rf
Definition: mesh.h:99