field_concat.h
Go to the documentation of this file.
#ifndef _RHEOLEF_FIELD_CONCAT_H
#define _RHEOLEF_FIELD_CONCAT_H
// build field from initializer lists
//
#include "rheolef/field.h"
// ----------------------------------------------------------------------------
// 1) field initializer handler
// ----------------------------------------------------------------------------
namespace rheolef { namespace details {
template <class T, class M>
class field_concat_value {
public:
// typedef:
typedef enum { scalar, vector_scalar, field} variant_type;
// allocators:
template <class U,
class Sfinae
= typename std::enable_if<
is_rheolef_arithmetic<U>::value
,void
>::type
>
field_concat_value (const U& x) : s(x), vs(), f(), variant(scalar) {}
field_concat_value (const std::vector<T>& x) : s(), vs(x), f(), variant(vector_scalar) {}
field_concat_value (const field_basic<T,M>& x) : s(), vs(), f(x), variant(field) {}
// io/debug:
friend std::ostream& operator<< (std::ostream& o, const field_concat_value<T,M>& x) {
if (x.variant == scalar) return o << "s";
if (x.variant == vector_scalar) return o << "vs";
else return o << "f";
}
// data:
public:
T s;
std::vector<T> vs;
field_basic<T,M> f;
variant_type variant;
};
template <class T, class M>
class field_concat {
public:
// typedef:
typedef typename field_basic<T,M>::size_type size_type;
typedef field_concat_value<T,M> value_type;
typedef typename std::initializer_list<value_type>::const_iterator const_iterator;
// allocators:
field_concat () : _l() {}
field_concat (const std::initializer_list<value_type>& il) : _l() {
for(const_iterator iter = il.begin(); iter != il.end(); ++iter) {
_l.push_back(*iter);
}
}
friend std::ostream& operator<< (std::ostream& o, const field_concat<T,M>& x) {
std::cout << "{";
for(typename std::list<value_type>::const_iterator iter = x._l.begin(); iter != x._l.end(); ++iter) {
std::cout << *iter << " ";
}
return std::cout << "}";
}
field_basic<T,M> build_field() const;
// data:
protected:
std::list<value_type> _l;
};
} // namespace details
// ----------------------------------------------------------------------------
// 2) field member functions
// ----------------------------------------------------------------------------
template <class T, class M>
inline
field_basic<T,M>::field_basic (const std::initializer_list<details::field_concat_value<T,M> >& init_list)
: _V(), _u(), _b(), _dis_dof_indexes_requires_update(true), _dis_dof_assembly_requires_update(true)
{
details::field_concat<T,M> vc (init_list);
field_basic<T,M>::operator= (vc.build_field());
}
template <class T, class M>
inline
field_basic<T,M>&
field_basic<T,M>::operator= (const std::initializer_list<details::field_concat_value<T,M> >& init_list)
{
details::field_concat<T,M> vc (init_list);
field_basic<T,M>::operator= (vc.build_field());
return *this;
}
} // namespace rheolef
#endif // _RHEOLEF_FIELD_CONCAT_H
rheolef::details::field_concat_value::vector_scalar
@ vector_scalar
Definition: field_concat.h:38
rheolef::details::field_concat_value::field_concat_value
field_concat_value(const U &x)
Definition: field_concat.h:49
field
see the field page for the full documentation
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::field_basic::field_basic
field_basic()
Definition: field.h:608
rheolef::details::field_concat::operator<<
friend std::ostream & operator<<(std::ostream &o, const field_concat< T, M > &x)
Definition: field_concat.h:86
rheolef::details::field_concat_value::field_concat_value
field_concat_value(const std::vector< T > &x)
Definition: field_concat.h:50
rheolef::type
rheolef::std type
rheolef::details::field_concat::field_concat
field_concat()
Definition: field_concat.h:79
rheolef::details::field_concat::field_concat
field_concat(const std::initializer_list< value_type > &il)
Definition: field_concat.h:81
rheolef::details::field_concat_value::variant_type
variant_type
Definition: field_concat.h:38
rheolef::field_basic
Definition: field_expr_utilities.h:38
rheolef::details::field_concat::_l
std::list< value_type > _l
Definition: field_concat.h:97
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::details::field_concat::const_iterator
std::initializer_list< value_type >::const_iterator const_iterator
Definition: field_concat.h:75
rheolef::details::field_concat_value::variant
variant_type variant
Definition: field_concat.h:64
rheolef::details::field_concat
Definition: field_concat.h:68
rheolef::details::field_concat_value::s
T s
Definition: field_concat.h:61
rheolef::details::field_concat_value
Definition: field.h:210
rheolef::details::field_concat_value::operator<<
friend std::ostream & operator<<(std::ostream &o, const field_concat_value< T, M > &x)
Definition: field_concat.h:54
rheolef::details::field_concat_value::field_concat_value
field_concat_value(const field_basic< T, M > &x)
Definition: field_concat.h:51
rheolef::details::is_rheolef_arithmetic
Definition: Float.h:150
rheolef::details::field_concat::size_type
field_basic< T, M >::size_type size_type
Definition: field_concat.h:73
f
Definition: cavity_dg.h:29
rheolef::details::field_concat_value::vs
std::vector< T > vs
Definition: field_concat.h:62
rheolef::field_basic::size_type
std::size_t size_type
Definition: field.h:239
T
Expr1::float_type T
Definition: field_expr.h:218
rheolef::details::field_concat_value::scalar
@ scalar
Definition: field_concat.h:38
rheolef::details::field_concat::value_type
field_concat_value< T, M > value_type
Definition: field_concat.h:74