Rheolef  7.1
an efficient C++ finite element environment
field_concat.cc
Go to the documentation of this file.
1 // build field from initializer lists
22 //
23 #include "rheolef/field_concat.h"
24 #include "rheolef/field_component.h"
25 #include "rheolef/field_expr.h"
26 #include "rheolef/space_mult.h"
27 
28 namespace rheolef { namespace details {
29 
30 template <class T, class M>
31 field_basic<T,M>
33 {
34  // ------------------------------------
35  // first pass: compute the field size
36  // ------------------------------------
39  for (typename std::list<value_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter) {
40  const field_concat_value<T,M>& x = *iter;
41  switch (x.variant) {
42  case value_type::scalar: {
43  sml *= IR;
44  break;
45  }
46  case value_type::vector_scalar: {
47  size_t n = x.vs.size();
48  space_basic<T,M> IRn = pow(IR,n);
49  sml *= IRn;
50  break;
51  }
52  case value_type::field: {
53  sml *= x.f.get_space();
54  break;
55  }
56  default: error_macro("field initializer list: unexpected element");
57  }
58  }
59  space_basic<T,M> Yh (sml);
60  // ------------------------
61  // second pass: copy values
62  // ------------------------
63  field_basic<T,M> yh (Yh);
64  size_type i_comp = 0;
65  for(typename std::list<value_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter, i_comp++) {
66  const field_concat_value<T,M>& x = *iter;
67  switch (x.variant) {
68  case value_type::scalar: {
69  field_basic<T,M> zh (IR, 0); // TODO: accept/check non-zero values ?
70  yh [i_comp] = zh;
71  break;
72  }
73  case value_type::vector_scalar: {
74  size_t n = x.vs.size();
75  space_basic<T,M> IRn = pow(IR,n);
76  field_basic<T,M> zh (IRn, 0); // TODO: accept/check non-zero values ?
77  yh [i_comp] = zh;
78  break;
79  }
80  case value_type::field: {
81  yh [i_comp] = x.f;
82  break;
83  }
84  default: error_macro("field initializer list: unexpected element");
85  }
86  }
87  return yh;
88 }
89 // ----------------------------------------------------------------------------
90 // instanciation in library
91 // ----------------------------------------------------------------------------
92 #define _RHEOLEF_instanciation(T,M) \
93 template class field_concat<T,M>;
94 
95 _RHEOLEF_instanciation(Float,sequential)
96 #ifdef _RHEOLEF_HAVE_MPI
98 #endif // _RHEOLEF_HAVE_MPI
99 
100 }} // namespace rheolef::details
rheolef::space_basic
the finite element space
Definition: space.h:352
rheolef::pow
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
Definition: space_mult.h:120
rheolef::details::field_concat::build_field
field_basic< T, M > build_field() const
Definition: field_concat.cc:32
rheolef::details::field_concat_value::f
field_basic< T, M > f
Definition: field_concat.h:63
rheolef::space_constant::scalar
Definition: space_constant.h:136
rheolef::field_basic
Definition: field_expr_utilities.h:38
rheolef::space_mult_list
Definition: space.h:111
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
error_macro
#define error_macro(message)
Definition: dis_macros.h:49
rheolef::details::field_concat_value::variant
variant_type variant
Definition: field_concat.h:64
Float
see the Float page for the full documentation
rheolef::details::field_concat_value
Definition: field.h:210
rheolef::details::_RHEOLEF_instanciation
_RHEOLEF_instanciation(Float, sequential) _RHEOLEF_instanciation(Float
mkgeo_ball.n
n
Definition: mkgeo_ball.sh:150
rheolef::details::field_concat::size_type
field_basic< T, M >::size_type size_type
Definition: field_concat.h:73
rheolef::distributed
distributed
Definition: asr.cc:228
rheolef::details::field_concat_value::vs
std::vector< T > vs
Definition: field_concat.h:62