Rheolef  7.1
an efficient C++ finite element environment
form_concat.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_FORM_CONCAT_H
2 #define _RHEOLEF_FORM_CONCAT_H
3 // build form from initializer list (c++ 2011)
24 //
25 #include "rheolef/form.h"
26 #include "rheolef/csr_concat.h"
27 #include "rheolef/field_expr_recursive.h"
28 
29 namespace rheolef { namespace details {
30 
31 // =========================================================================
32 // 1rst case : one-line matrix initializer
33 // A = {a, b}; // matrix & vector
34 // =========================================================================
35 
36 template <class T, class M>
39  std::vector<field_basic<T,M> > vv;
40 };
41 
42 } // namespace details
43 
44 template <class T, class M>
45 inline
48 {
50 }
51 
52 namespace details {
53 
54 template <class T, class M>
56 public:
57 
58 // typedef:
59 
61  typedef typename csr_concat_value<T,M>::sizes_type sizes_type; // [size,dis_size]
62  typedef typename csr_concat_value<T,M>::sizes_pair_type sizes_pair_type; // [nrow,ncol] = [[nrow,dis_nrow],[ncol,dis_ncol]]
63 
64  static constexpr size_type undef = std::numeric_limits<size_type>::max();
65  static constexpr size_type zero = 0;
66 
67  typedef enum {
73  form
75 
77  trans_
79  >
81 
82 // allocators:
83 
84  template <class U,
85  class Sfinae
86  = typename std::enable_if<
88  ,void
89  >::type
90  >
91  form_concat_value (const U& x) : s(x), v(), vv(), m(), variant(scalar) {}
92  form_concat_value (const field_basic<T,M>& x) : s(), v(x), vv(), m(), variant(field) {}
93  form_concat_value (const trans_field_type& x) : s(), v(x.expr().expr()), vv(), m(), variant(field_transpose) {}
96  form_concat_value (const form_basic<T,M>& x) : s(), v(), vv(), m(x), variant(form) {}
97 
98 // io/debug:
99  friend std::ostream& operator<< (std::ostream& o, const form_concat_value<T,M>& x) {
100  if (x.variant == scalar) return o << "s";
101  else if (x.variant == field) return o << "f";
102  else if (x.variant == field_transpose) return o << "ft";
103  else if (x.variant == vector_field) return o << "vf";
104  else if (x.variant == vector_field_transpose) return o << "vft";
105  else return o << "m";
106  }
107 // data:
108 public:
109  T s;
111  std::vector<field_basic<T,M>> vv;
114 };
115 template <class T, class M>
117 public:
118 
119 // typedef:
120 
122  typedef typename csr_concat_value<T,M>::sizes_type sizes_type; // [size,dis_size]
123  typedef typename csr_concat_value<T,M>::sizes_pair_type sizes_pair_type; // [nrow,ncol] = [[nrow,dis_nrow],[ncol,dis_ncol]]
124 
125  static constexpr size_type undef = std::numeric_limits<size_type>::max();
126  static constexpr size_type zero = 0;
127 
129  typedef typename std::list<value_type>::const_iterator const_iterator;
130 
131 // allocators:
132 
134 
135  form_concat_line (const std::initializer_list<value_type>& il) : _l() {
136  typedef typename std::initializer_list<value_type>::const_iterator const_iterator;
137  for(const_iterator iter = il.begin(); iter != il.end(); ++iter) {
138  _l.push_back(*iter);
139  }
140  }
141 
142 // accessors:
143 
144  const_iterator begin() const { return _l.begin(); }
145  const_iterator end() const { return _l.end(); }
146 
147  friend std::ostream& operator<< (std::ostream& o, const form_concat_line<T,M>& x) {
148  std::cout << "{";
149  for(typename std::list<value_type>::const_iterator iter = x._l.begin(); iter != x._l.end(); ++iter) {
150  std::cout << *iter << " ";
151  }
152  return std::cout << "}";
153  }
154 // internals:
155 
156  void build_form_pass0 (std::vector<std::pair<bool,space_basic<T,M> > >& l_Xh, space_basic<T,M>& Yh, size_t i_comp = 0) const;
157  static void build_first_space (const std::vector<std::pair<bool,space_basic<T,M> > >& l_Xh, space_basic<T,M>& Xh);
158  void build_form_pass1 (space_basic<T,M>& Xh, space_basic<T,M>& Yh) const;
160  form_basic<T,M> build_form () const;
161 
162 // data:
163 protected:
164  std::list<value_type> _l;
165 };
166 
167 } // namespace details
168 
169 // -------------------------------
170 // form cstor from std::initializer
171 // -------------------------------
172 template <class T, class M>
173 inline
174 form_basic<T,M>::form_basic (const std::initializer_list<details::form_concat_value<T,M> >& init_list)
175  : _X(), _Y(), _uu(), _ub(), _bu(), _bb()
176 {
177  details::form_concat_line<T,M> cc (init_list);
179 }
180 
181 namespace details {
182 // =========================================================================
183 // 2nd case : multi-line form initializer
184 // A = { {a, b },
185 // {c, d} };
186 // =========================================================================
187 template <class T, class M>
188 class form_concat {
189 public:
190 
191 // typedef:
192 
194  typedef typename csr_concat_value<T,M>::sizes_type sizes_type; // [size,dis_size]
195  typedef typename csr_concat_value<T,M>::sizes_pair_type sizes_pair_type; // [nrow,ncol] = [[nrow,dis_nrow],[ncol,dis_ncol]]
196 
197  static constexpr size_type undef = std::numeric_limits<size_type>::max();
198  static constexpr size_type zero = 0;
199 
202 
203 // allocators:
204 
205  form_concat () : _l() {}
206 
207  form_concat (const std::initializer_list<line_type>& il) : _l() {
208  typedef typename std::initializer_list<line_type>::const_iterator const_iterator;
209  for(const_iterator iter = il.begin(); iter != il.end(); ++iter) {
210  _l.push_back(*iter);
211  }
212  }
213  friend std::ostream& operator<< (std::ostream& o, const form_concat<T,M>& x) {
214  std::cout << "{";
215  for(typename std::list<line_type>::const_iterator iter = x._l.begin(); iter != x._l.end(); ++iter) {
216  std::cout << *iter << " ";
217  }
218  return std::cout << "}";
219  }
220 // internals:
221  form_basic<T,M> build_form () const;
222 
223 // data:
224 protected:
225  std::list<line_type> _l;
226 };
227 
228 } // namespace details
229 
230 template <class T, class M>
231 inline
232 form_basic<T,M>::form_basic (const std::initializer_list<details::form_concat_line<T,M> >& init_list)
233  : _X(), _Y(), _uu(), _ub(), _bu(), _bb()
234 {
235  details::form_concat<T,M> cc (init_list);
237 }
238 
239 } // namespace rheolef
240 #endif // _RHEOLEF_FORM_CONCAT_H
rheolef::details::form_concat_value::sizes_pair_type
csr_concat_value< T, M >::sizes_pair_type sizes_pair_type
Definition: form_concat.h:62
rheolef::details::form_concat_value::vector_field
@ vector_field
Definition: form_concat.h:71
rheolef::details::form_concat_line::sizes_type
csr_concat_value< T, M >::sizes_type sizes_type
Definition: form_concat.h:122
rheolef::details::form_concat::build_form
form_basic< T, M > build_form() const
Definition: form_concat.cc:242
rheolef::details::form_concat::form_concat
form_concat()
Definition: form_concat.h:205
rheolef::details::form_concat_value::zero
static constexpr size_type zero
Definition: form_concat.h:65
rheolef::details::form_concat_value::form_concat_value
form_concat_value(const field_basic< T, M > &x)
Definition: form_concat.h:92
rheolef::details::form_concat_line::_l
std::list< value_type > _l
Definition: form_concat.h:164
form
see the form page for the full documentation
rheolef::details::form_concat_line::end
const_iterator end() const
Definition: form_concat.h:145
rheolef::details::form_concat_value::form_concat_value
form_concat_value(const U &x)
Definition: form_concat.h:91
rheolef::details::csr_concat_value::sizes_type
std::pair< size_type, size_type > sizes_type
Definition: csr_concat.h:57
rheolef::details::form_concat_value::m
form_basic< T, M > m
Definition: form_concat.h:112
rheolef::details::form_concat_line::build_form_pass0
void build_form_pass0(std::vector< std::pair< bool, space_basic< T, M > > > &l_Xh, space_basic< T, M > &Yh, size_t i_comp=0) const
Definition: form_concat.cc:36
rheolef::details::csr_concat_value::size_type
csr< T, M >::size_type size_type
Definition: csr_concat.h:56
rheolef::details::form_concat::form_concat
form_concat(const std::initializer_list< line_type > &il)
Definition: form_concat.h:207
rheolef::details::vector_field_trans
Definition: form_concat.h:37
rheolef::details::form_concat_line::const_iterator
std::list< value_type >::const_iterator const_iterator
Definition: form_concat.h:129
rheolef::details::form_concat_line::form_concat_line
form_concat_line(const std::initializer_list< value_type > &il)
Definition: form_concat.h:135
rheolef::details::form_concat::line_type
form_concat_line< T, M > line_type
Definition: form_concat.h:200
rheolef::details::form_concat_value::trans_field_type
field_expr_v2_nonlinear_node_unary< trans_,field_expr_v2_nonlinear_terminal_field< T, M, differentiate_option::none > > trans_field_type
Definition: form_concat.h:80
field
see the field page for the full documentation
rheolef::details::form_concat_line::form_concat_line
form_concat_line()
Definition: form_concat.h:133
rheolef::details::form_concat_value::form_concat_value
form_concat_value(const vector_field_trans< T, M > &x)
Definition: form_concat.h:95
rheolef::details::form_concat_line::begin
const_iterator begin() const
Definition: form_concat.h:144
rheolef::space_basic
the finite element space
Definition: space.h:352
rheolef::details::form_concat_value::scalar
@ scalar
Definition: form_concat.h:68
rheolef::details::form_concat_value::form_concat_value
form_concat_value(const std::vector< field_basic< T, M >> &x)
Definition: form_concat.h:94
rheolef::details::form_concat_line::zero
static constexpr size_type zero
Definition: form_concat.h:126
rheolef::details::form_concat_value
Definition: form_concat.h:55
rheolef::details::form_concat_line::sizes_pair_type
csr_concat_value< T, M >::sizes_pair_type sizes_pair_type
Definition: form_concat.h:123
rheolef::details::vector_field_trans::vv
std::vector< field_basic< T, M > > vv
Definition: form_concat.h:39
rheolef::details::form_concat_value::operator<<
friend std::ostream & operator<<(std::ostream &o, const form_concat_value< T, M > &x)
Definition: form_concat.h:99
rheolef::details::form_concat_value::vv
std::vector< field_basic< T, M > > vv
Definition: form_concat.h:111
rheolef::details::form_concat_line::undef
static constexpr size_type undef
Definition: form_concat.h:125
rheolef::form_basic::form_basic
form_basic()
Definition: form.h:300
rheolef::details::form_concat_value::field_transpose
@ field_transpose
Definition: form_concat.h:70
rheolef::details::form_concat::_l
std::list< line_type > _l
Definition: form_concat.h:225
rheolef::details::form_concat_line::operator<<
friend std::ostream & operator<<(std::ostream &o, const form_concat_line< T, M > &x)
Definition: form_concat.h:147
rheolef::details::form_concat_line
Definition: form_concat.h:116
rheolef::type
rheolef::std type
rheolef::details::form_concat_value::undef
static constexpr size_type undef
Definition: form_concat.h:64
rheolef::details::field_expr_v2_nonlinear_node_unary
Definition: field_expr_recursive.h:59
rheolef::details::form_concat_value::variant
variant_type variant
Definition: form_concat.h:113
rheolef::field_basic
Definition: field.h:235
rheolef::details::form_concat_line::build_form
form_basic< T, M > build_form() const
Definition: form_concat.cc:228
rheolef::form_basic::operator=
form_basic< T, M > & operator=(const form_basic< T, M > &)
Definition: form.h:313
rheolef::details::form_concat::value_type
form_concat_value< T, M > value_type
Definition: form_concat.h:201
rheolef::details::form_concat_line::size_type
csr_concat_value< T, M >::size_type size_type
Definition: form_concat.h:121
rheolef::details::form_concat::operator<<
friend std::ostream & operator<<(std::ostream &o, const form_concat< T, M > &x)
Definition: form_concat.h:213
rheolef::details::form_concat_value::vector_field_transpose
@ vector_field_transpose
Definition: form_concat.h:72
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::details::trans_
Definition: expression.h:325
rheolef::details::form_concat_value::form_concat_value
form_concat_value(const trans_field_type &x)
Definition: form_concat.h:93
rheolef::details::form_concat_value::form_concat_value
form_concat_value(const form_basic< T, M > &x)
Definition: form_concat.h:96
rheolef::details::form_concat_line::build_form_pass1
void build_form_pass1(space_basic< T, M > &Xh, space_basic< T, M > &Yh) const
Definition: form_concat.cc:189
rheolef::details::form_concat::size_type
csr_concat_value< T, M >::size_type size_type
Definition: form_concat.h:193
rheolef::form_basic
Definition: form.h:144
rheolef::const_iterator
Definition: field_expr_recursive.h:552
rheolef::details::form_concat::sizes_type
csr_concat_value< T, M >::sizes_type sizes_type
Definition: form_concat.h:194
rheolef::space_constant::vector
@ vector
Definition: space_constant.h:137
rheolef::details::form_concat::sizes_pair_type
csr_concat_value< T, M >::sizes_pair_type sizes_pair_type
Definition: form_concat.h:195
rheolef::details::is_rheolef_arithmetic
Definition: Float.h:150
rheolef::details::form_concat_value::variant_type
variant_type
Definition: form_concat.h:67
rheolef::details::form_concat_value::s
T s
Definition: form_concat.h:109
rheolef::details::field_expr_v2_nonlinear_terminal_field
Definition: field_expr_terminal.h:802
rheolef::details::form_concat_value::field
@ field
Definition: form_concat.h:69
rheolef::details::form_concat
Definition: form_concat.h:188
rheolef::details::form_concat_value::size_type
csr_concat_value< T, M >::size_type size_type
Definition: form_concat.h:60
rheolef::details::form_concat_value::v
field_basic< T, M > v
Definition: form_concat.h:110
rheolef::details::vector_field_trans::vector_field_trans
vector_field_trans(const std::vector< field_basic< T, M > > &vv1)
Definition: form_concat.h:38
rheolef::trans
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
Definition: csr.h:455
rheolef::details::form_concat_line::build_form_pass2
form_basic< T, M > build_form_pass2(const space_basic< T, M > &Xh, const space_basic< T, M > &Yh) const
Definition: form_concat.cc:200
rheolef::details::form_concat_line::value_type
form_concat_value< T, M > value_type
Definition: form_concat.h:128
rheolef::details::form_concat::undef
static constexpr size_type undef
Definition: form_concat.h:197
rheolef::details::csr_concat_value::sizes_pair_type
std::pair< sizes_type, sizes_type > sizes_pair_type
Definition: csr_concat.h:58
rheolef::details::form_concat_line::build_first_space
static void build_first_space(const std::vector< std::pair< bool, space_basic< T, M > > > &l_Xh, space_basic< T, M > &Xh)
Definition: form_concat.cc:172
rheolef::details::form_concat_value::sizes_type
csr_concat_value< T, M >::sizes_type sizes_type
Definition: form_concat.h:61
T
Expr1::float_type T
Definition: field_expr.h:261
rheolef::details::form_concat::zero
static constexpr size_type zero
Definition: form_concat.h:198