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