Loading...
Searching...
No Matches
field_concat.cc
Go to the documentation of this file.
// build field from initializer lists
//
#include "rheolef/field_concat.h"
#include "rheolef/field.h"
#include "rheolef/field_wdof_sliced.h"
#include "rheolef/field_expr.h"
#include "rheolef/space_mult.h"
namespace rheolef { namespace details {
template <class T, class M>
field_basic<T,M>
field_concat<T,M>::build_field() const
{
// ------------------------------------
// first pass: compute the field size
// ------------------------------------
space_basic<T,M> IR = space_basic<T,M>::real();
space_mult_list<T,M> sml;
for (typename std::list<value_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter) {
const field_concat_value<T,M>& x = *iter;
switch (x.variant) {
case value_type::scalar: {
sml *= IR;
break;
}
case value_type::vector_scalar: {
size_t n = x.vs.size();
space_basic<T,M> IRn = pow(IR,n);
sml *= IRn;
break;
}
case value_type::field: {
sml *= x.f.get_space();
break;
}
default: error_macro("field initializer list: unexpected element");
}
}
space_basic<T,M> Yh (sml);
// ------------------------
// second pass: copy values
// ------------------------
field_basic<T,M> yh (Yh);
size_type i_comp = 0;
for(typename std::list<value_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter, i_comp++) {
const field_concat_value<T,M>& x = *iter;
switch (x.variant) {
case value_type::scalar: {
field_basic<T,M> zh (IR, 0); // TODO: accept/check non-zero values ?
yh [i_comp] = zh;
break;
}
case value_type::vector_scalar: {
size_t n = x.vs.size();
space_basic<T,M> IRn = pow(IR,n);
field_basic<T,M> zh (IRn, 0); // TODO: accept/check non-zero values ?
yh [i_comp] = zh;
break;
}
case value_type::field: {
yh [i_comp] = x.f;
break;
}
default: error_macro("field initializer list: unexpected element");
}
}
return yh;
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
#define _RHEOLEF_instanciation(T,M) \
template class field_concat<T,M>;
_RHEOLEF_instanciation(Float,sequential)
#ifdef _RHEOLEF_HAVE_MPI
_RHEOLEF_instanciation(Float,distributed)
#endif // _RHEOLEF_HAVE_MPI
}} // namespace rheolef::details
_RHEOLEF_instanciation
#define _RHEOLEF_instanciation(T, M, A)
Definition asr.cc:223
Float
see the Float page for the full documentation
rheolef::details::field_concat_value
Definition field_concat.h:33
rheolef::details::field_concat_value::vs
std::vector< T > vs
Definition field_concat.h:62
rheolef::details::field_concat_value::variant
variant_type variant
Definition field_concat.h:64
rheolef::details::field_concat_value::f
field_basic< T, M > f
Definition field_concat.h:63
rheolef::details::field_concat::build_field
field_basic< T, M > build_field() const
Definition field_concat.cc:33
rheolef::details::field_concat::size_type
field_basic< T, M >::size_type size_type
Definition field_concat.h:73
rheolef::field_basic
Definition field.h:219
rheolef::field_basic::get_space
const space_type & get_space() const
Definition field.h:270
rheolef::space_basic
the finite element space
Definition space.h:382
rheolef::space_mult_list
Definition space_mult.h:54
error_macro
#define error_macro(message)
Definition dis_macros.h:49
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::pow
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
Definition space_mult.h:120