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