1# ifndef _RHEOLEF_FIELD_LAZY_NODE_H
2# define _RHEOLEF_FIELD_LAZY_NODE_H
35#include "rheolef/field_lazy_terminal.h"
46template<
class Unop,
class Expr>
88template<
class Unop,
class Expr>
92template<
class Unop,
class Expr>
100 uk = uk.unaryExpr(_unop);
106#define _RHEOLEF_field_lazy_unop(OP,NAME) \
107template<class Expr, class Sfinae = typename std::enable_if<details::is_field_lazy<Expr>::value, Expr>::type> \
108details::field_lazy_unop<NAME,Expr> \
109operator OP (const Expr& u) \
111 return details::field_lazy_unop<NAME,Expr> (NAME(),u); \
115#undef _RHEOLEF_field_lazy_unop
123template<
class Binop,
class Expr1,
class Expr2>
166template<
class Binop,
class Expr1,
class Expr2>
170template<
class Binop,
class Expr1,
class Expr2>
177 const geo_type& dom2 = _expr2.get_geo();
178 if (dom1 == dom2 || dom1 == dom2.get_background_geo() || dom1.is_broken()) {
179 trace_macro(
"lazy_add: union("<<dom1.name()<<
","<<dom2.name()<<
")="<<dom1.name());
181 }
else if (dom2 == dom1.get_background_geo() || dom2.is_broken()) {
182 trace_macro(
"lazy_add: union("<<dom1.name()<<
","<<dom2.name()<<
")="<<dom2.name());
185 error_macro(
"lazy_add: incompatible domains \""<<dom1.name()
186 <<
"\" and \"" << dom2.name() <<
"\"");
189 check_macro (_expr1.is_on_band() == _expr2.is_on_band(),
190 "lazy_add: invalid combination of banded and non-banded geoetry");
192template<
class Binop,
class Expr1,
class Expr2>
196 check_macro (_expr1.get_space() == _expr2.get_space(),
197 "lazy_add: incompatible spaces "
198 <<
"\"" <<_expr1.get_space().name()<<
"\" and \"" <<_expr2.get_space().name()<<
"\"");
200 _expr1.initialize (omega_K);
201 _expr2.initialize (omega_K);
203template<
class Binop,
class Expr1,
class Expr2>
211 _expr1.evaluate (omega_K, K, uk);
212 _expr2.evaluate (omega_K, K, vk);
213#ifdef _RHEOLEF_PARANO
214 check_macro (uk.size() == vk.size(),
"u+v: invalid sizes");
216 wk = uk.binaryExpr (vk, _binop);
222#define _RHEOLEF_field_lazy_add(OP,NAME) \
223template<class Expr1, class Expr2, \
224 class Sfinae1 = typename std::enable_if<details::is_field_lazy<Expr1>::value, Expr1>::type, \
225 class Sfinae2 = typename std::enable_if<details::is_field_lazy<Expr2>::value, Expr2>::type> \
226details::field_lazy_add<details::NAME,Expr1,Expr2> \
227operator OP (const Expr1& u, const Expr2& v) \
229 return details::field_lazy_add<details::NAME,Expr1,Expr2> (u,v); \
231template<class Expr1, \
232 class Sfinae1 = typename std::enable_if<details::is_field_lazy<Expr1>::value, Expr1>::type> \
233details::field_lazy_add< \
236 ,details::field_lazy_terminal_field<typename Expr1::scalar_type,typename Expr1::memory_type> \
238operator OP (const Expr1& u, const field_basic<typename Expr1::scalar_type,typename Expr1::memory_type>& v) \
240 using Expr2 = details::field_lazy_terminal_field<typename Expr1::scalar_type,typename Expr1::memory_type>; \
241 return details::field_lazy_add<details::NAME,Expr1,Expr2> (u,Expr2(v)); \
243template<class Expr2, \
244 class Sfinae2 = typename std::enable_if<details::is_field_lazy<Expr2>::value, Expr2>::type> \
245details::field_lazy_add< \
247 ,details::field_lazy_terminal_field<typename Expr2::scalar_type,typename Expr2::memory_type> \
250operator OP (const field_basic<typename Expr2::scalar_type,typename Expr2::memory_type>& u, const Expr2& v) \
252 using Expr1 = details::field_lazy_terminal_field<typename Expr2::scalar_type,typename Expr2::memory_type>; \
253 return details::field_lazy_add<details::NAME,Expr1,Expr2> (Expr1(u),v); \
257#undef _RHEOLEF_field_lazy_add
geo_element::size_type size_type
typename Expr1::scalar_type scalar_type
typename Expr1::memory_type memory_type
void evaluate(const geo_type &omega_K, const geo_element &K, vector_element_type &uk) const
void initialize(const geo_type &omega_K)
const geo_type & get_geo() const
Eigen::Matrix< scalar_type, Eigen::Dynamic, 1 > vector_element_type
typename float_traits< scalar_type >::type float_type
typename Expr1::space_type space_type
band_type get_band() const
const space_type & get_space() const
typename Expr1::geo_type geo_type
field_lazy_add(const Expr1 &expr1, const Expr2 &expr2)
geo_element::size_type size_type
void evaluate(const geo_type &omega_K, const geo_element &K, vector_element_type &uk) const
void initialize(const geo_type &omega_K)
typename Expr::geo_type geo_type
typename Expr::scalar_type scalar_type
typename Expr::memory_type memory_type
Eigen::Matrix< scalar_type, Eigen::Dynamic, 1 > vector_element_type
typename float_traits< scalar_type >::type float_type
band_type get_band() const
const geo_type & get_geo() const
const space_type & get_space() const
typename Expr::space_type space_type
field_lazy_unop(const Unop &unop, const Expr &expr)
see the geo_element page for the full documentation
reference_element::size_type size_type
#define trace_macro(message)
#define error_macro(message)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
#define _RHEOLEF_field_lazy_unop(OP, NAME)
-u, +u: see the field page for the full documentation
#define _RHEOLEF_field_lazy_add(OP, NAME)
u+v, u-v: see the field page for the full documentation
This file is part of Rheolef.