Welcome to the NetCologne GmbH open source mirroring service!

This machine mirrors various open-source projects. 20 Gbit/s uplink.

If there are any issues or you want another project mirrored, please contact mirror-service -=AT=- netcologne DOT de !

GetFEM: src/bgeot_torus.cc Source File
GetFEM  5.4.2
bgeot_torus.cc
1 /*===========================================================================
2 
3  Copyright (C) 2014-2020 Liang Jin Lim
4 
5  This file is a part of GetFEM
6 
7  GetFEM is free software; you can redistribute it and/or modify it
8  under the terms of the GNU Lesser General Public License as published
9  by the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version along with the GCC Runtime Library
11  Exception either version 3.1 or (at your option) any later version.
12  This program is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15  License and GCC Runtime Library Exception for more details.
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program; if not, write to the Free Software Foundation,
18  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20 ===========================================================================*/
21 #include "getfem/bgeot_torus.h"
22 
23 namespace bgeot{
24 
25  /**torus_structure which extends a 2 dimensional structure with a radial dimension*/
27 
28  friend pconvex_structure torus_structure_descriptor(pconvex_structure);
29  };
30 
31  class torus_reference : public convex_of_reference{
32 
33  public :
34  scalar_type is_in(const base_node& point) const{
35  GMM_ASSERT1(point.size() >= 2, "Invalid dimension of pt " << point);
36  base_node point_2d = point;
37  point_2d.resize(2);
38  return ori_ref_convex_->is_in(point_2d);
39  }
40 
41  scalar_type is_in_face(bgeot::short_type f, const base_node& point) const{
42  GMM_ASSERT1(point.size() >= 2, "Invalid dimension of pt " << point);
43  base_node point2D = point;
44  point2D.resize(2);
45  return ori_ref_convex_->is_in_face(f, point2D);
46  }
47  torus_reference(bgeot::pconvex_ref ori_ref_convex) :
48  convex_of_reference(
49  torus_structure_descriptor(ori_ref_convex->structure()), ori_ref_convex->is_basic())
50  {
51  ori_ref_convex_ = ori_ref_convex;
52  convex<base_node>::points().resize(cvs->nb_points());
53  normals_.resize(ori_ref_convex->normals().size());
54 
55  const std::vector<base_small_vector> &ori_normals = ori_ref_convex->normals();
56  const stored_point_tab &ori_points = ori_ref_convex->points();
57  for(size_type n = 0; n < ori_normals.size(); ++n){
58  normals_[n] = ori_normals[n];
59  normals_[n].resize(3);
60  }
61 
62  std::copy(ori_points.begin(), ori_points.end(), convex<base_node>::points().begin());
63  for(size_type pt = 0; pt < convex<base_node>::points().size(); ++pt){
64  convex<base_node>::points()[pt].resize(3);
65  }
66  ppoints = store_point_tab(convex<base_node>::points());
67  }
68 
69  private:
70  bgeot::pconvex_ref ori_ref_convex_;
71  };
72 
73  DAL_SIMPLE_KEY(torus_structure_key, pconvex_structure);
74 
75  pconvex_structure torus_structure_descriptor(pconvex_structure ori_structure){
76 
77  dal::pstatic_stored_object_key
78  pk = std::make_shared<torus_structure_key>(ori_structure);
79  dal::pstatic_stored_object o = dal::search_stored_object(pk);
80  if (o) return std::dynamic_pointer_cast<const convex_structure>(o);
81 
82  auto p = std::make_shared<torus_structure>();
83  pconvex_structure pcvs(p);
84  p->Nc = dim_type(ori_structure->dim() + 1);
85  p->nbpt = ori_structure->nb_points();
86  p->nbf = ori_structure->nb_faces();
87 
88  p->faces_struct.resize(p->nbf);
89  p->faces.resize(p->nbf);
90 
91  for (short_type j = 0; j < p->nbf; ++j){
92  p->faces_struct[j] = ori_structure->faces_structure()[j];
93  short_type nbIndex = ori_structure->nb_points_of_face(j);
94  p->faces[j].resize(nbIndex);
95  p->faces[j] = ori_structure->ind_points_of_face(j);
96  }
97 
98  p->dir_points_.resize(ori_structure->ind_dir_points().size());
99  p->dir_points_ = ori_structure->ind_dir_points();
100 
101  p->basic_pcvs = basic_structure(ori_structure);
102 
103  dal::add_stored_object(pk, pcvs, dal::PERMANENT_STATIC_OBJECT);
104  return pcvs;
105  }
106 
107  DAL_SIMPLE_KEY(torus_reference_key, pconvex_ref);
108 
109  pconvex_ref ptorus_reference(pconvex_ref ori_convex_reference)
110  {
111  dal::pstatic_stored_object_key
112  pk = std::make_shared<torus_reference_key>(ori_convex_reference);
113  dal::pstatic_stored_object o = dal::search_stored_object(pk);
114 
115  if (o) return std::dynamic_pointer_cast<const bgeot::convex_of_reference>(o);
116  pconvex_ref p = std::make_shared<torus_reference>(ori_convex_reference);
117  dal::add_stored_object(pk, p, p->structure(), p->pspt(),
118  dal::PERMANENT_STATIC_OBJECT);
119  return p;
120  }
121 
122  void torus_geom_trans::poly_vector_val(const base_node &pt, bgeot::base_vector &val) const{
123  base_node pt_2d(pt);
124  pt_2d.resize(2);
125  poriginal_trans_->poly_vector_val(pt_2d, val);
126  }
127 
128  void torus_geom_trans::poly_vector_val(const base_node &pt, const bgeot::convex_ind_ct &ind_ct,
129  bgeot::base_vector &val) const{
130  base_node pt_2d(pt);
131  pt_2d.resize(2);
132  poriginal_trans_->poly_vector_val(pt_2d, ind_ct, val);
133  }
134 
135  void torus_geom_trans::poly_vector_grad(const base_node &pt, bgeot::base_matrix &pc) const{
136  base_node pt2D(pt);
137  pt2D.resize(2);
138  bgeot::base_matrix pc2D(nb_points(), 2);
139  poriginal_trans_->poly_vector_grad(pt2D, pc2D);
140 
141  bgeot::base_vector base_value;
142  poriginal_trans_->poly_vector_val(pt2D, base_value);
143 
144  pc.resize(nb_points(), 3);
145 
146  for (size_type i = 0; i < nb_points(); ++i){
147  for (bgeot::dim_type n = 0; n < 2; ++n) pc(i, n) = pc2D(i, n);
148  pc(i, 2) = base_value[i]; // radial direction, pc = base_x;
149  }
150  }
151 
153  const bgeot::convex_ind_ct &ind_ct, bgeot::base_matrix &pc) const{
154  base_node pt2D(pt);
155  pt2D.resize(2);
156  bgeot::base_matrix pc2D(ind_ct.size(), 2);
157  poriginal_trans_->poly_vector_grad(pt2D, pc2D);
158  pc.resize(ind_ct.size(), dim());
159  for (size_type i = 0; i < ind_ct.size(); ++i){
160  for (bgeot::dim_type n = 0; n < 2; ++n) pc(i, n) = pc2D(i, n);
161  }
162  }
163 
165  (const bgeot::base_matrix &G, const bgeot::base_matrix &pc, bgeot::base_matrix &K) const{
167  K(2, 2) = 0.0;
168  for (short_type j = 0; j < nb_points(); ++ j) K(2, 2) += G(0, j) * pc(j, 2);
169  for (short_type i = 0; i < 2; ++i) K(2, i) = K(i, 2) = 0;
170  }
171 
173  bgeot::base_matrix & /*pc*/) const{
174  GMM_ASSERT1(false, "Sorry, Hessian is not supported in axisymmetric transformation.");
175  }
176 
177  void torus_geom_trans::project_into_reference_convex(base_node &pt) const {
178  poriginal_trans_->project_into_reference_convex(pt);
179  }
180 
181  torus_geom_trans::torus_geom_trans(pgeometric_trans poriginal_trans)
182  : poriginal_trans_(poriginal_trans){
183  geometric_trans::is_lin = poriginal_trans_->is_linear();
184  geometric_trans::cvr = ptorus_reference(poriginal_trans_->convex_ref());
185  complexity_ = poriginal_trans_->complexity();
186  fill_standard_vertices();
187  name_ = poriginal_trans->debug_name();
188  }
189 
190  pgeometric_trans torus_geom_trans::get_original_transformation() const{
191  return poriginal_trans_;
192  }
193 
194  bool is_torus_structure(pconvex_structure cvs){
195  const torus_structure *cvs_torus = dynamic_cast<const torus_structure *>(cvs.get());
196  return cvs_torus != NULL;
197  }
198 
199  DAL_SIMPLE_KEY(torus_geom_trans_key, pgeometric_trans);
200 
201  pgeometric_trans torus_geom_trans_descriptor(pgeometric_trans poriginal_trans){
202  dal::pstatic_stored_object_key
203  pk = std::make_shared<torus_geom_trans_key>(poriginal_trans);
204  dal::pstatic_stored_object o = dal::search_stored_object(pk);
205 
206  if (o) return std::dynamic_pointer_cast<const torus_geom_trans>(o);
207 
208  bgeot::pgeometric_trans p = std::make_shared<torus_geom_trans>(poriginal_trans);
209  dal::add_stored_object(pk, p, dal::PERMANENT_STATIC_OBJECT);
210  return p;
211  }
212 
213  bool is_torus_geom_trans(pgeometric_trans pgt){
214  const torus_geom_trans *pgt_torus = dynamic_cast<const torus_geom_trans *>(pgt.get());
215  return pgt_torus != NULL;
216  }
217 
218 }
bgeot::convex_structure
Structure of a convex.
Definition: bgeot_convex_structure.h:72
bgeot_torus.h
Provides mesh of torus.
bgeot::size_type
size_t size_type
used as the common size type in the library
Definition: bgeot_poly.h:49
bgeot::torus_geom_trans::poly_vector_hess
virtual void poly_vector_hess(const base_node &, bgeot::base_matrix &) const
Gives the hessian of the functions vector at a certain point.
Definition: bgeot_torus.cc:172
bgeot::basic_structure
pconvex_structure basic_structure(pconvex_structure cv)
Original structure (if concerned)
Definition: bgeot_convex_structure.h:172
bgeot::geometric_trans::dim
dim_type dim() const
Dimension of the reference element.
Definition: bgeot_geometric_trans.h:119
bgeot::torus_geom_trans::poly_vector_grad
virtual void poly_vector_grad(const base_node &, bgeot::base_matrix &) const
Gives the gradient of the functions vector at a certain point.
Definition: bgeot_torus.cc:135
bgeot::short_type
gmm::uint16_type short_type
used as the common short type integer in the library
Definition: bgeot_config.h:72
dal::search_stored_object
pstatic_stored_object search_stored_object(pstatic_stored_object_key k)
Gives a pointer to an object from a key pointer.
Definition: dal_static_stored_objects.cc:177
bgeot::torus_structure
torus_structure which extends a 2 dimensional structure with a radial dimension
Definition: bgeot_torus.cc:26
bgeot::torus_geom_trans::poly_vector_val
virtual void poly_vector_val(const base_node &, bgeot::base_vector &) const
Gives the value of the functions vector at a certain point.
Definition: bgeot_torus.cc:122
bgeot::torus_geom_trans::compute_K_matrix
virtual void compute_K_matrix(const bgeot::base_matrix &, const bgeot::base_matrix &, bgeot::base_matrix &) const
compute K matrix from multiplication of G with gradient
Definition: bgeot_torus.cc:165
bgeot::small_vector
container for small vectors of POD (Plain Old Data) types.
Definition: bgeot_small_vector.h:205
bgeot::convex_of_reference
Base class for reference convexes.
Definition: bgeot_convex_ref.h:91
dal::add_stored_object
void add_stored_object(pstatic_stored_object_key k, pstatic_stored_object o, permanence perm)
Add an object with two optional dependencies.
Definition: dal_static_stored_objects.cc:284
bgeot
Basic Geometric Tools.
Definition: bgeot_convex_ref.cc:27
bgeot::pconvex_structure
std::shared_ptr< const convex_structure > pconvex_structure
Pointer on a convex structure description.
Definition: bgeot_convex_structure.h:54
bgeot::geometric_trans::compute_K_matrix
virtual void compute_K_matrix(const base_matrix &G, const base_matrix &pc, base_matrix &K) const
compute K matrix from multiplication of G with gradient
Definition: bgeot_geometric_trans.cc:272
bgeot::pgeometric_trans
std::shared_ptr< const bgeot::geometric_trans > pgeometric_trans
pointer type for a geometric transformation
Definition: bgeot_geometric_trans.h:186
bgeot::geometric_trans::nb_points
size_type nb_points() const
Number of geometric nodes.
Definition: bgeot_geometric_trans.h:123