GetFEM  5.4.2
getfem_regular_meshes.h
Go to the documentation of this file.
1 /* -*- c++ -*- (enables emacs c++ mode) */
2 /*===========================================================================
3 
4  Copyright (C) 1999-2020 Yves Renard
5 
6  This file is a part of GetFEM
7 
8  GetFEM is free software; you can redistribute it and/or modify it
9  under the terms of the GNU Lesser General Public License as published
10  by the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version along with the GCC Runtime Library
12  Exception either version 3.1 or (at your option) any later version.
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  License and GCC Runtime Library Exception for more details.
17  You should have received a copy of the GNU Lesser General Public License
18  along with this program; if not, write to the Free Software Foundation,
19  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, you may use this file as it is a part of a free
22  software library without restriction. Specifically, if other files
23  instantiate templates or use macros or inline functions from this file,
24  or you compile this file and link it with other files to produce an
25  executable, this file does not by itself cause the resulting executable
26  to be covered by the GNU Lesser General Public License. This exception
27  does not however invalidate any other reasons why the executable file
28  might be covered by the GNU Lesser General Public License.
29 
30 ===========================================================================*/
31 
32 /**@file getfem_regular_meshes.h
33  @author Yves Renard <Yves.Renard@insa-lyon.fr>
34  @date December 20, 1999.
35  @brief Build regular meshes.
36 */
37 #ifndef GETFEM_REGULAR_MESHES_H__
38 #define GETFEM_REGULAR_MESHES_H__
39 
40 #include "getfem_mesh.h"
41 
42 namespace getfem
43 {
44  /* ******************************************************************** */
45  /* Generation de maillages reguliers de simplexes. */
46  /* ******************************************************************** */
47 
48  /* ******************************************************************** */
49  /* ajoute au maillage "me" un maillage regulier de dimension "N" */
50  /* a partir du point "org" defini par les parallelepipedes engendres */
51  /* par la liste des vecteurs "vect". La liste iref est une liste */
52  /* d'entiers correspondant au nombre de parallelepidedes sur chaque */
53  /* dimension. Chaque parallelepidede est simplexifie. */
54  /* ******************************************************************** */
55 
56  void parallelepiped_regular_simplex_mesh_(mesh &me, dim_type N,
57  const base_node &org, const base_small_vector *ivect, const size_type *iref);
58 
59  template<class ITER1, class ITER2>
60  void parallelepiped_regular_simplex_mesh(mesh &me,
61  dim_type N,
62  const base_node &org, ITER1 ivect, ITER2 iref)
63  {
64  std::vector<base_small_vector> vect(N);
65  std::copy(ivect, ivect+N, vect.begin());
66  std::vector<size_type> ref(N);
67  std::copy(iref, iref+N, ref.begin());
68  parallelepiped_regular_simplex_mesh_(me, N, org, &(vect[0]),
69  &(ref[0]));
70  }
71 
72  void parallelepiped_regular_prism_mesh_(mesh &me, dim_type N,
73  const base_node &org, const base_small_vector *ivect, const size_type *iref);
74 
75  template<class ITER1, class ITER2>
76  void parallelepiped_regular_prism_mesh(mesh &me,
77  dim_type N,
78  const base_node &org, ITER1 ivect, ITER2 iref)
79  {
80  std::vector<base_small_vector> vect(N);
81  std::copy(ivect, ivect+N, vect.begin());
82  std::vector<size_type> ref(N);
83  std::copy(iref, iref+N, ref.begin());
84  parallelepiped_regular_prism_mesh_(me, N, org, &(vect[0]),
85  &(ref[0]));
86  }
87 
88  void parallelepiped_regular_mesh_(mesh &me, dim_type N,
89  const base_node &org, const base_small_vector *ivect, const size_type *iref, bool linear_gt);
90 
91  template<class ITER1, class ITER2>
92  void parallelepiped_regular_mesh(mesh &me,
93  dim_type N,
94  const base_node &org, ITER1 ivect, ITER2 iref, bool linear_gt=false)
95  {
96  std::vector<base_small_vector> vect(N);
97  std::copy(ivect, ivect+N, vect.begin());
98  std::vector<size_type> ref(N);
99  std::copy(iref, iref+N, ref.begin());
100  parallelepiped_regular_mesh_(me, N, org, &(vect[0]), &(ref[0]), linear_gt);
101  }
102 
103  void parallelepiped_regular_pyramid_mesh_(mesh &me, const base_node &org,
104  const base_small_vector *ivect, const size_type *iref);
105 
106  template<class ITER1, class ITER2>
107  void parallelepiped_regular_pyramid_mesh(mesh &me,
108  const base_node &org, ITER1 ivect, ITER2 iref)
109  {
110  int N=3;
111  std::vector<base_small_vector> vect(N);
112  std::copy(ivect, ivect+N, vect.begin());
113  std::vector<size_type> ref(N);
114  std::copy(iref, iref+N, ref.begin());
115  parallelepiped_regular_pyramid_mesh_(me, org, &(vect[0]), &(ref[0]));
116  }
117 
118 
119  /**
120  Build a regular mesh of the unit square/cube/, etc.
121  @param m the output mesh.
122 
123  @param pgt the geometric transformation to use. For example, use
124  @code
125  pgt = geometric_trans_descriptor("GT_PK(2,1"); // to build a mesh of triangles
126  pgt = geometric_trans_descriptor("QK(3,2)"); // to build a mesh of order 2 parallelepiped
127  @endcode
128 
129  @param nsubdiv is the number of cells in each direction.
130 
131  @param noised if set, will cause the interior nodes to be randomly "shaken".
132  */
133  void regular_unit_mesh(mesh& m, std::vector<size_type> nsubdiv,
134  bgeot::pgeometric_trans pgt, bool noised = false);
135 
136  /**
137  Build a regular mesh parametrized by the string st.
138  The format of st is the following
139  std::string st("GT='GT_PK(2,1)'; NSUBDIV=[5,5]; ORG=[0,0]; SIZES=[1,1]; NOISED=0");
140  where GT is the geometric transformation, NSUBDIV a vector of the number
141  of subdivisions in each coordinate (default value 2), ORG is the origin
142  of the mesh (default value [0,0,...]), SIZES is a vector of the sizes
143  in each direction (default value [1, 1, ...] and if NOISED=1 the nodes
144  of the interior of the mesh are randomly "shaken" (default value NOISED=0).
145  All the parameters are optional but GT.
146 
147  @param m the output mesh.
148  */
149  void regular_mesh(mesh& m, const std::string &st);
150 
151  /**
152  Build a regular mesh on a ball, parametrized by the string st.
153  The format of st is similar to getfem::regular_mesh.
154  @see getfem::import_mesh.
155  All parameters except the geometric transformation GT are optional.
156  Here, parameter NSUBDIV has to be a vector of size 2 that holds the
157  number of subdivisions in the core and the peel sub-regions of the mesh.
158  SIZES is an one element vector that provides the ball radius
159  (default radius is equal to 1).
160  If NOISED=1 the nodes in the interior of the individual sub-regions
161  of the mesh are randomly "shaken" (default value NOISED=0).
162  An additional integer paramater called SYMMETRIES receiving the
163  values 1, 2 or 3 (in three dimensions) permits to respectively request
164  one half, one quarter or one eighth of the ball to be meshed
165  (default value SYMMETRIES=0).
166 
167  @param m the output mesh.
168  */
169  void regular_ball_mesh(mesh& m, const std::string &st);
170 
171  /**
172  Build a regular mesh on a ball shell, parametrized by the string st.
173  The format of st is similar to getfem::regular_mesh.
174  @see getfem::import_mesh.
175  All parameters except the geometric transformation GT are optional.
176  Here, parameter NSUBDIV has to be a vector of size 2 that holds the
177  number of subdivisions in the circumferential and radial direction
178  of the mesh.
179  SIZES is a two element vector that provides the ball radius and shell
180  thickness (default radius is equal to 1 and default thickness is
181  ewual to 0.5).
182  If NOISED=1 the nodes in the interior of the individual sub-regions
183  of the mesh are randomly "shaken" (default value NOISED=0).
184  An additional integer paramater called SYMMETRIES receiving the
185  values 1, 2 or 3 (in three dimensions) permits to respectively request
186  one half, one quarter or one eighth of the ball to be meshed
187  (default value SYMMETRIES=0).
188 
189  @param m the output mesh.
190  */
191  void regular_ball_shell_mesh(mesh& m, const std::string &st);
192 
193 } /* end of namespace getfem. */
194 
195 
196 #endif /* GETFEM_REGULAR_MESHES_H__ */
bgeot::size_type
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
getfem::regular_ball_mesh
void regular_ball_mesh(mesh &m, const std::string &st)
Build a regular mesh on a ball, parametrized by the string st.
Definition: getfem_regular_meshes.cc:352
getfem_mesh.h
Define a getfem::getfem_mesh object.
getfem::regular_ball_shell_mesh
void regular_ball_shell_mesh(mesh &m, const std::string &st)
Build a regular mesh on a ball shell, parametrized by the string st.
Definition: getfem_regular_meshes.cc:505
getfem::regular_mesh
void regular_mesh(mesh &m, const std::string &st)
Build a regular mesh parametrized by the string st.
Definition: getfem_regular_meshes.cc:289
getfem
GEneric Tool for Finite Element Methods.
Definition: getfem_accumulated_distro.h:46
bgeot::pgeometric_trans
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
Definition: bgeot_geometric_trans.h:186
getfem::regular_unit_mesh
void regular_unit_mesh(mesh &m, std::vector< size_type > nsubdiv, bgeot::pgeometric_trans pgt, bool noised=false)
Build a regular mesh of the unit square/cube/, etc.
Definition: getfem_regular_meshes.cc:238

Rabisu Mirror Service We provide mirrors to support Open source communities. Our mirror server is located in Istanbul/Turkey region.

Please do not hesitate to contact mirror@rabisu.com for new open source mirror submissions.