Rheolef  7.1
an efficient C++ finite element environment
basis_fem_tensor.cc
Go to the documentation of this file.
1 #include "basis_fem_tensor.h"
22 #include "rheolef/rheostream.h"
23 
24 namespace rheolef {
25 
26 using namespace std;
27 
28 // =========================================================================
29 // basis members
30 // =========================================================================
31 template<class T>
33 {
34 }
35 template<class T>
37  : basis_rep<T>(sopt),
38  _n_comp(0),
39  _scalar_basis(scalar_basis),
40  _scalar_value(),
41  _vector_value()
42 {
45  base::_piola_fem = _scalar_basis.get_piola_fem();
46  check_macro (base::option().dimension() != std::numeric_limits<basis_option::size_type>::max(),
47  "tensor(basis): basis.option.map_dimension should be initialized for component number");
49  _n_comp = d*(d+1)/2;
50  if (d == 2 &&
53  _n_comp++;
54  }
56 }
57 #ifdef TO_CLEAN
58 template<class T>
61 {
62  const size_type unset = std::numeric_limits<basis_option::size_type>::max();
63  size_type d = (base::option().dimension() == unset) ? map_d : base::option().dimension();
64  size_type n_comp = d*(d+1)/2;
65  if (d == 2 &&
68  n_comp++;
69  }
70  return n_comp;
71 }
72 #endif // TO_CLEAN
73 template<class T>
74 void
76 {
77  for (size_type map_d = 0; map_d < 4; ++map_d) {
78  for (size_type subgeo_variant = 0; subgeo_variant < reference_element::max_variant; ++subgeo_variant) {
79  base::_ndof_on_subgeo [map_d][subgeo_variant] = _n_comp*_scalar_basis.ndof_on_subgeo (map_d, subgeo_variant);
80  base::_nnod_on_subgeo [map_d][subgeo_variant] = _scalar_basis.nnod_on_subgeo (map_d, subgeo_variant);
81  }
82  }
84  reference_element hat_K (variant);
85  for (size_type subgeo_d = 0; subgeo_d < 5; ++subgeo_d) {
86  base::_first_idof_by_dimension [variant][subgeo_d] = _n_comp*_scalar_basis.first_idof_by_dimension (hat_K, subgeo_d);
87  base::_first_inod_by_dimension [variant][subgeo_d] = _scalar_basis.first_inod_by_dimension (hat_K, subgeo_d);
88  }
89  }
90 }
91 template<class T>
92 void
94 {
95 }
96 template<class T>
97 const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>&
99 {
100  return _scalar_basis.hat_node (hat_K);
101 }
102 template<class T>
103 void
105  reference_element hat_K,
106  const point_basic<T>& hat_x,
107  Eigen::Matrix<tensor_basic<T>,Eigen::Dynamic,1>& value) const
108 {
109  base::_initialize_data_guard (hat_K);
110  space_constant::coordinate_type sys_coord = base::option().coordinate_system();
111  _scalar_basis.evaluate (hat_K, hat_x, _scalar_value);
112  size_type loc_comp_ndof = _scalar_value.size();
113  size_type loc_ndof = _n_comp*loc_comp_ndof;
114  value.resize (loc_ndof);
115  value.fill (tensor_basic<T>()); // do not remove !
116  for (size_type loc_comp_idof = 0; loc_comp_idof < loc_comp_ndof; ++loc_comp_idof) {
117  for (size_type ij_comp = 0; ij_comp < _n_comp; ++ij_comp) {
118  size_type loc_idof = _n_comp*loc_comp_idof + ij_comp;
119  std::pair<size_type,size_type> ij = space_constant::tensor_subscript (space_constant::tensor, sys_coord, ij_comp);
120  size_type i_comp = ij.first;
121  size_type j_comp = ij.second;
122  value[loc_idof] (i_comp,j_comp) = _scalar_value[loc_comp_idof];
123  if (ij.first == ij.second) continue;
124  value[loc_idof] (j_comp,i_comp) = _scalar_value[loc_comp_idof];
125  }
126  }
127 }
128 template<class T>
129 void
131  reference_element hat_K,
132  const point_basic<T>& hat_x,
133  Eigen::Matrix<tensor3_basic<T>,Eigen::Dynamic,1>& value) const
134 {
135  base::_initialize_data_guard (hat_K);
136  space_constant::coordinate_type sys_coord = base::option().coordinate_system();
137  _scalar_basis.grad_evaluate (hat_K, hat_x, _vector_value);
138  size_type loc_comp_ndof = _vector_value.size();
139  size_type loc_ndof = _n_comp*loc_comp_ndof;
140  value.resize (loc_ndof);
141  value.fill (tensor3_basic<T>()); // do not remove !
142  for (size_type loc_comp_idof = 0; loc_comp_idof < loc_comp_ndof; ++loc_comp_idof) {
143  for (size_type ij_comp = 0; ij_comp < _n_comp; ++ij_comp) {
144  size_type loc_idof = _n_comp*loc_comp_idof + ij_comp;
145  std::pair<size_type,size_type> ij = space_constant::tensor_subscript (space_constant::tensor, sys_coord, ij_comp);
146  size_type i_comp = ij.first;
147  size_type j_comp = ij.second;
148  for (size_type k_comp = 0; k_comp < _n_comp; ++k_comp) {
149  value[loc_idof](i_comp,j_comp,k_comp) = _vector_value[loc_comp_idof][k_comp];
150  if (i_comp == j_comp) continue;
151  value[loc_idof](j_comp,i_comp,k_comp) = _vector_value[loc_comp_idof][k_comp];
152  }
153  }
154  }
155 }
156 // dofs for a scalar-valued function
157 template<class T>
158 void
160  reference_element hat_K,
161  const Eigen::Matrix<tensor_basic<T>,Eigen::Dynamic,1>& f_xnod,
162  Eigen::Matrix<T,Eigen::Dynamic,1>& dof) const
163 {
164  base::_initialize_data_guard (hat_K);
165  space_constant::coordinate_type sys_coord = base::option().coordinate_system();
166  size_type loc_comp_ndof = _scalar_basis.ndof (hat_K);
167  size_type loc_comp_nnod = _scalar_basis.nnod (hat_K);
168  size_type loc_ndof = _n_comp*loc_comp_ndof;
169  Eigen::Matrix<T,Eigen::Dynamic,1> f_comp_xnod (loc_comp_nnod); // TODO: class working array
170  Eigen::Matrix<T,Eigen::Dynamic,1> comp_dof (loc_comp_ndof); // TODO: class working array
171  dof.resize (loc_ndof);
172  for (size_type ij_comp = 0; ij_comp < _n_comp; ++ij_comp) {
173  std::pair<size_type,size_type> ij = space_constant::tensor_subscript (space_constant::tensor, sys_coord, ij_comp);
174  size_type i_comp = ij.first;
175  size_type j_comp = ij.second;
176  for (size_type loc_comp_inod = 0; loc_comp_inod < loc_comp_nnod; ++loc_comp_inod) {
177  // interpolate the symmetric value of the tensor-valued function
178  f_comp_xnod [loc_comp_inod]
179  = 0.5*( f_xnod [loc_comp_inod] (i_comp,j_comp)
180  + f_xnod [loc_comp_inod] (j_comp,i_comp));
181  }
182  _scalar_basis.compute_dofs (hat_K, f_comp_xnod, comp_dof);
183  for (size_type loc_comp_idof = 0; loc_comp_idof < loc_comp_ndof; ++loc_comp_idof) {
184  size_type loc_idof = _n_comp*loc_comp_idof + ij_comp;
185  dof [loc_idof] = comp_dof [loc_comp_idof];
186  }
187  }
188 }
189 // ----------------------------------------------------------------------------
190 // instanciation in library
191 // ----------------------------------------------------------------------------
192 #define _RHEOLEF_instanciation(T) \
193 template class basis_fem_tensor<T>;
194 
196 
197 }// namespace rheolef
rheolef::basis_fem_tensor::basis_fem_tensor
basis_fem_tensor(const basis_basic< T > &scalar_basis, const basis_option &sopt)
Definition: basis_fem_tensor.cc:36
rheolef::point_basic
Definition: point.h:87
check_macro
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
rheolef::basis_fem_tensor::_scalar_basis
basis_basic< T > _scalar_basis
Definition: basis_fem_tensor.h:101
rheolef::space_constant::n_component
size_type n_component(valued_type valued_tag, size_type d, coordinate_type sys_coord)
Definition: space_constant.cc:136
rheolef::_RHEOLEF_instanciation
_RHEOLEF_instanciation(Float, sequential, std::allocator< Float >) _RHEOLEF_instanciation(Float
rheolef::basis_fem_tensor::hat_node
const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > & hat_node(reference_element hat_K) const
Definition: basis_fem_tensor.cc:98
rheolef::value
rheolef::std value
rheolef::space_constant::tensor_subscript
std::pair< size_type, size_type > tensor_subscript(valued_type valued_tag, coordinate_type sys_coord, size_type i_comp)
Definition: space_constant.cc:209
rheolef::tensor_basic
Definition: tensor.h:90
rheolef::space_constant::axisymmetric_rz
Definition: space_constant.h:123
rheolef::basis_option
see the basis_option page for the full documentation
Definition: basis_option.h:93
rheolef::basis_fem_tensor::evaluate
void evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< tensor_basic< T >, Eigen::Dynamic, 1 > &value) const
Definition: basis_fem_tensor.cc:104
rheolef::basis_rep::size_type
reference_element::size_type size_type
Definition: basis.h:214
basis_fem_tensor.h
rheolef::basis_basic
Definition: basis.h:206
rheolef::reference_element
see the reference_element page for the full documentation
Definition: reference_element.h:66
rheolef::space_constant::tensor
Definition: space_constant.h:138
mkgeo_ball.variant
variant
Definition: mkgeo_ball.sh:149
rheolef::basis_rep::_piola_fem
piola_fem< T > _piola_fem
Definition: basis.h:394
rheolef::space_constant::axisymmetric_zr
Definition: space_constant.h:124
rheolef::basis_fem_tensor::_initialize_data
void _initialize_data(reference_element hat_K) const
Definition: basis_fem_tensor.cc:93
rheolef::tensor3_basic
Definition: tensor3.h:73
rheolef::basis_rep::_sopt
basis_option _sopt
Definition: basis.h:393
rheolef::basis_fem_tensor::grad_evaluate
void grad_evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< tensor3_basic< T >, Eigen::Dynamic, 1 > &value) const
Definition: basis_fem_tensor.cc:130
rheolef::basis_fem_tensor::_compute_dofs
void _compute_dofs(reference_element hat_K, const Eigen::Matrix< tensor_basic< T >, Eigen::Dynamic, 1 > &f_xnod, Eigen::Matrix< T, Eigen::Dynamic, 1 > &dof) const
Definition: basis_fem_tensor.cc:159
rheolef::basis_fem_tensor::family_index
size_type family_index() const
Definition: basis_fem_tensor.h:61
dimension
const size_t dimension
Definition: edge.icc:64
rheolef::basis_rep::_name
std::string _name
Definition: basis.h:392
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::basis_option::dimension
size_type dimension() const
Definition: basis_option.h:138
Float
see the Float page for the full documentation
rheolef::basis_fem_tensor::size_type
base::size_type size_type
Definition: basis_fem_tensor.h:49
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition: reference_element.h:82
rheolef::basis_option::set_valued_tag
void set_valued_tag(valued_type v)
Definition: basis_option.h:149
mkgeo_grid.sys_coord
sys_coord
Definition: mkgeo_grid.sh:171
mkgeo_ball.d
d
Definition: mkgeo_ball.sh:154
rheolef::basis_fem_tensor::~basis_fem_tensor
~basis_fem_tensor()
Definition: basis_fem_tensor.cc:32
rheolef::basis_rep::standard_naming
static std::string standard_naming(std::string family_name, size_t degree, const basis_option &sopt)
Definition: basis_rep.cc:44
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::basis_rep::option
const basis_option & option() const
Definition: basis.h:238
rheolef::basis_fem_tensor::_initialize_cstor_sizes
void _initialize_cstor_sizes() const
Definition: basis_fem_tensor.cc:75
rheolef::space_constant::coordinate_type
coordinate_type
Definition: space_constant.h:121
rheolef::space_constant::coordinate_system
coordinate_type coordinate_system(std::string sys_coord)
Definition: space_constant.cc:75
rheolef::basis_fem_tensor::family_name
std::string family_name() const
Definition: basis_fem_tensor.h:60
rheolef::basis_fem_tensor::_n_comp
size_type _n_comp
Definition: basis_fem_tensor.h:100
rheolef::basis_rep
Definition: basis.h:209
T
Expr1::float_type T
Definition: field_expr.h:218