Loading...
Searching...
No Matches
field_wdof.icc
Go to the documentation of this file.
# ifndef _RHEOLEF_FIELD_WDOF_ICC
# define _RHEOLEF_FIELD_WDOF_ICC
//
// This file is part of Rheolef.
//
// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
//
// Rheolef is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Rheolef is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rheolef; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// =========================================================================
// field_wdof: field with read & write accessors at the dof level
// terminals: field_basic, field_wdof_sliced, field_indirect
// AUTHOR: Pierre.Saramito@imag.fr
// DATE: 21 april 2020
#include "rheolef/field_wdof.h"
#include "rheolef/field_wdof_indirect.h"
#include "rheolef/field_wdof_sliced.h"
#include "rheolef/field_wdof_convert.h"
namespace rheolef { namespace details {
// ============================================================================
// 1) operator=
// ============================================================================
template<class Derived>
template<class Value>
inline
typename std::enable_if<
details::is_rheolef_arithmetic<Value>::value
,field_wdof_base<Derived>&
>::type
field_wdof_base<Derived>::operator= (const Value& value)
{
std::fill (derived().begin_dof(), derived().end_dof(), value);
return *this;
}
template<class Derived>
template<class FieldRdof>
inline
typename std::enable_if<
has_field_rdof_interface<FieldRdof>::value
,field_wdof_base<Derived>&
>::type
field_wdof_base<Derived>::operator= (const FieldRdof& rdof)
{
#ifdef TODO
// TODO: check "is_piecewise_polynomial" here:
using space_type = typename FieldRdof::space_type;
space_type Xh;
check_macro (rdof.have_homogeneous_space (Xh),
"field_wdof = field_rdof; rdof should have homogeneous space. HINT: field_wdof = interpolate(Xh, field_rdof)");
#endif // TODO
space_type Xh = rdof.get_space();
check_macro (derived().get_space().name() == Xh.name(), "field_wdof = field_rdof : incompatible spaces "
<< derived().get_space().name() << " and " << Xh.name());
assign_with_operator (derived().begin_dof(), derived().end_dof(), rdof.begin_dof(), generic_set_op());
return *this;
}
template<class Derived>
template<class FieldLazy>
inline
typename std::enable_if<
has_field_lazy_interface<FieldLazy>::value
&& ! has_field_rdof_interface<FieldLazy>::value
,field_wdof_base<Derived>&
>::type
field_wdof_base<Derived>::operator= (const FieldLazy& lazy)
{
// TODO: check "is_piecewise_polynomial" here:
space_type Xh = lazy.get_space();
check_macro (derived().get_space().name() == Xh.name(), "field_wdof = field_rdof : incompatible spaces "
<< derived().get_space().name() << " and " << Xh.name());
derived().operator= (0);
convert_lazy2wdof (lazy, generic_set_plus_op(), derived());
return *this;
}
// ============================================================================
// 2) operator+-=
// ============================================================================
template<class FieldWdof, class FieldRdof>
typename std::enable_if<
details::has_field_wdof_interface<FieldWdof>::value
&& details::has_field_rdof_interface<FieldRdof>::value
,FieldWdof&
>::type
operator+= (FieldWdof& wdof, const FieldRdof& rdof)
{
// TODO: check "is_piecewise_polynomial" here:
auto Xh = rdof.get_space();
check_macro (wdof.get_space().name() == Xh.name(), "field_wdof = field_rdof : incompatible spaces "
<< wdof.get_space().name() << " and " << Xh.name());
assign_with_operator (wdof.begin_dof(), wdof.end_dof(), rdof.begin_dof(), generic_set_plus_op());
return wdof;
}
template<class FieldWdof, class FieldRdof>
typename std::enable_if<
details::has_field_wdof_interface<FieldWdof>::value
&& details::has_field_rdof_interface<FieldRdof>::value
,FieldWdof&
>::type
operator-= (FieldWdof& wdof, const FieldRdof& rdof)
{
// TODO: check "is_piecewise_polynomial" here:
auto Xh = rdof.get_space();
check_macro (wdof.get_space().name() == Xh.name(), "field_wdof = field_rdof : incompatible spaces "
<< wdof.get_space().name() << " and " << Xh.name());
assign_with_operator (wdof.begin_dof(), wdof.end_dof(), rdof.begin_dof(), generic_set_minus_op());
return wdof;
}
template<class FieldWdof, class FieldLazy>
typename std::enable_if<
details::has_field_wdof_interface<FieldWdof>::value
&& details::has_field_lazy_interface<FieldLazy>::value
&& ! details::has_field_rdof_interface<FieldLazy>::value
,FieldWdof&
>::type
operator+= (FieldWdof& wdof, const FieldLazy& lazy)
{
// TODO: check "is_piecewise_polynomial" here:
auto Xh = lazy.get_space();
check_macro (wdof.get_space().name() == Xh.name(), "field_wdof = field_lazy : incompatible spaces "
<< wdof.get_space().name() << " and " << Xh.name());
return convert_lazy2wdof (lazy, details::generic_set_plus_op(), wdof);
}
template<class FieldWdof, class FieldLazy>
typename std::enable_if<
details::has_field_wdof_interface<FieldWdof>::value
&& details::has_field_lazy_interface<FieldLazy>::value
&& ! details::has_field_rdof_interface<FieldLazy>::value
,FieldWdof&
>::type
operator-= (FieldWdof& wdof, const FieldLazy& lazy)
{
// TODO: check "is_piecewise_polynomial" here:
auto Xh = lazy.get_space();
check_macro (wdof.get_space().name() == Xh.name(), "field_wdof = field_lazy : incompatible spaces "
<< wdof.get_space().name() << " and " << Xh.name());
return convert_lazy2wdof (lazy, details::generic_set_minus_op(), wdof);
}
// ============================================================================
// 3) operator[]
// ============================================================================
template<class Derived>
field_wdof_indirect<Derived>
field_wdof_base<Derived>::operator[] (const std::string& dom_name)
{
return field_wdof_indirect<Derived> (derived(), derived().get_geo().operator[](dom_name));
}
template<class Derived>
field_wdof_indirect<Derived>
field_wdof_base<Derived>::operator[] (const geo_type& dom)
{
return field_wdof_indirect<Derived> (derived(), dom);
}
template<class Derived>
field_wdof_sliced<Derived>
field_wdof_base<Derived>::operator[] (size_type i_comp)
{
return field_wdof_sliced<Derived> (derived(), i_comp);
}
template<class Derived>
field_wdof_sliced<Derived>
field_wdof_base<Derived>::operator() (size_type i_comp, size_type j_comp)
{
space_constant::coordinate_type sys_coord = derived().get_geo().coordinate_system();
size_type ij_comp = space_constant::tensor_index (derived().valued_tag(), sys_coord, i_comp, j_comp);
return field_wdof_sliced<Derived> (derived(), ij_comp);
}
}}// namespace rheolef::details
# endif /* _RHEOLEF_FIELD_WDOF_ICC */
rheolef::details::field_wdof_base
Definition field_wdof.h:36
rheolef::details::field_wdof_base::operator=
std::enable_if< details::is_rheolef_arithmetic< Value >::value, field_wdof_base< Derived > & >::type operator=(const Value &)
Definition field_wdof.icc:45
rheolef::details::field_wdof_base::size_type
typename field_traits< Derived >::size_type size_type
Definition field_wdof.h:40
rheolef::details::field_wdof_base::operator()
field_wdof_sliced< Derived > operator()(size_type i_comp, size_type j_comp)
Definition field_wdof.icc:176
rheolef::details::field_wdof_base::derived
Derived & derived()
Definition field_wdof.h:82
rheolef::details::field_wdof_base::geo_type
geo_basic< float_type, memory_type > geo_type
Definition field_wdof.h:44
rheolef::details::field_wdof_base::space_type
space_basic< float_type, memory_type > space_type
Definition field_wdof.h:45
rheolef::details::field_wdof_base::operator[]
field_wdof_indirect< Derived > operator[](const std::string &dom_name)
Definition field_wdof.icc:158
rheolef::details::field_wdof_indirect
Definition field_wdof_indirect.h:317
rheolef::details::field_wdof_sliced
Definition field_wdof_sliced.h:268
rheolef::type
rheolef::std::enable_if< details::is_field_expr_v2_nonlinear_arg< Expr1 >::value &&! details::is_field_expr_v2_constant< Expr1 >::value &&details::is_field_expr_v2_nonlinear_arg< Expr2 >::value &&! details::is_field_expr_v2_constant< Expr2 >::value, details::field_expr_v2_nonlinear_node_binary< details::function_traits< Function >::functor_type, details::field_expr_v2_nonlinear_terminal_wrapper_traits< Expr1 >::type, details::field_expr_v2_nonlinear_terminal_wrapper_traits< Expr2 >::type > > type
get_geo
void get_geo(istream &in, my_geo &omega)
Definition field2gmsh_pos.cc:126
check_macro
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
rheolef::details::operator+=
std::enable_if< details::has_field_wdof_interface< FieldWdof >::value &&details::has_field_rdof_interface< FieldRdof >::value, FieldWdof & >::type operator+=(FieldWdof &wdof, const FieldRdof &rdof)
Definition field_wdof.icc:99
rheolef::details::operator-=
std::enable_if< details::has_field_wdof_interface< FieldWdof >::value &&details::has_field_rdof_interface< FieldRdof >::value, FieldWdof & >::type operator-=(FieldWdof &wdof, const FieldRdof &rdof)
Definition field_wdof.icc:114
rheolef::details::assign_with_operator
void assign_with_operator(ForwardIterator first, ForwardIterator last, InputIterator iter_rhs, OpAssign op_assign)
Definition expr_utilities.h:137
rheolef::details::convert_lazy2wdof
std::enable_if< has_field_lazy_interface< FieldLazy >::value &&has_field_wdof_interface< FieldWdof >::value, FieldWdof & >::type convert_lazy2wdof(const FieldLazy &expr0, const SetPlusOp &my_set_plus_op, FieldWdof &uh)
Definition field_wdof_convert.h:59
rheolef::space_constant::tensor_index
size_type tensor_index(valued_type valued_tag, coordinate_type sys_coord, size_type i, size_type j)
Definition space_constant.cc:181
rheolef::space_constant::coordinate_type
coordinate_type
Definition space_constant.h:119
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::begin_dof
const_iterator begin_dof() const
Definition field_expr_recursive.h:610
rheolef::valued_tag
space_constant::valued_type valued_tag() const
Definition field_expr_recursive.h:620
rheolef::details::has_field_lazy_interface
Definition field_concept.h:74
rheolef::details::has_field_rdof_interface
Definition field_concept.h:58
rheolef::details::has_field_wdof_interface
Definition field_concept.h:42
rheolef::details::type