Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
field_wdof.icc
Go to the documentation of this file.
1# ifndef _RHEOLEF_FIELD_WDOF_ICC
2# define _RHEOLEF_FIELD_WDOF_ICC
3//
4// This file is part of Rheolef.
5//
6// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7//
8// Rheolef is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 2 of the License, or
11// (at your option) any later version.
12//
13// Rheolef is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with Rheolef; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// =========================================================================
23// field_wdof: field with read & write accessors at the dof level
24// terminals: field_basic, field_wdof_sliced, field_indirect
25// AUTHOR: Pierre.Saramito@imag.fr
26// DATE: 21 april 2020
27
28#include "rheolef/field_wdof.h"
29#include "rheolef/field_wdof_indirect.h"
30#include "rheolef/field_wdof_sliced.h"
31#include "rheolef/field_wdof_convert.h"
32
33namespace rheolef { namespace details {
34
35// ============================================================================
36// 1) operator=
37// ============================================================================
38template<class Derived>
39template<class Value>
40inline
41typename std::enable_if<
42 details::is_rheolef_arithmetic<Value>::value
43 ,field_wdof_base<Derived>&
44>::type
46{
47 std::fill (derived().begin_dof(), derived().end_dof(), value);
48 return *this;
49}
50template<class Derived>
51template<class FieldRdof>
52inline
53typename std::enable_if<
56>::type
58{
59#ifdef TODO
60 // TODO: check "is_piecewise_polynomial" here:
61 using space_type = typename FieldRdof::space_type;
62 space_type Xh;
63 check_macro (rdof.have_homogeneous_space (Xh),
64 "field_wdof = field_rdof; rdof should have homogeneous space. HINT: field_wdof = interpolate(Xh, field_rdof)");
65#endif // TODO
66 space_type Xh = rdof.get_space();
67 check_macro (derived().get_space().name() == Xh.name(), "field_wdof = field_rdof : incompatible spaces "
68 << derived().get_space().name() << " and " << Xh.name());
69 assign_with_operator (derived().begin_dof(), derived().end_dof(), rdof.begin_dof(), generic_set_op());
70 return *this;
71}
72template<class Derived>
73template<class FieldLazy>
74inline
75typename std::enable_if<
79>::type
81{
82 // TODO: check "is_piecewise_polynomial" here:
83 space_type Xh = lazy.get_space();
84 check_macro (derived().get_space().name() == Xh.name(), "field_wdof = field_rdof : incompatible spaces "
85 << derived().get_space().name() << " and " << Xh.name());
86 derived().operator= (0);
87 convert_lazy2wdof (lazy, generic_set_plus_op(), derived());
88 return *this;
89}
90// ============================================================================
91// 2) operator+-=
92// ============================================================================
93template<class FieldWdof, class FieldRdof>
94typename std::enable_if<
97 ,FieldWdof&
98>::type
99operator+= (FieldWdof& wdof, const FieldRdof& rdof)
100{
101 // TODO: check "is_piecewise_polynomial" here:
102 auto Xh = rdof.get_space();
103 check_macro (wdof.get_space().name() == Xh.name(), "field_wdof = field_rdof : incompatible spaces "
104 << wdof.get_space().name() << " and " << Xh.name());
105 assign_with_operator (wdof.begin_dof(), wdof.end_dof(), rdof.begin_dof(), generic_set_plus_op());
106 return wdof;
107}
108template<class FieldWdof, class FieldRdof>
109typename std::enable_if<
112 ,FieldWdof&
113>::type
114operator-= (FieldWdof& wdof, const FieldRdof& rdof)
115{
116 // TODO: check "is_piecewise_polynomial" here:
117 auto Xh = rdof.get_space();
118 check_macro (wdof.get_space().name() == Xh.name(), "field_wdof = field_rdof : incompatible spaces "
119 << wdof.get_space().name() << " and " << Xh.name());
120 assign_with_operator (wdof.begin_dof(), wdof.end_dof(), rdof.begin_dof(), generic_set_minus_op());
121 return wdof;
122}
123template<class FieldWdof, class FieldLazy>
124typename std::enable_if<
128 ,FieldWdof&
129>::type
130operator+= (FieldWdof& wdof, const FieldLazy& lazy)
131{
132 // TODO: check "is_piecewise_polynomial" here:
133 auto Xh = lazy.get_space();
134 check_macro (wdof.get_space().name() == Xh.name(), "field_wdof = field_lazy : incompatible spaces "
135 << wdof.get_space().name() << " and " << Xh.name());
136 return convert_lazy2wdof (lazy, details::generic_set_plus_op(), wdof);
137}
138template<class FieldWdof, class FieldLazy>
139typename std::enable_if<
143 ,FieldWdof&
144>::type
145operator-= (FieldWdof& wdof, const FieldLazy& lazy)
146{
147 // TODO: check "is_piecewise_polynomial" here:
148 auto Xh = lazy.get_space();
149 check_macro (wdof.get_space().name() == Xh.name(), "field_wdof = field_lazy : incompatible spaces "
150 << wdof.get_space().name() << " and " << Xh.name());
151 return convert_lazy2wdof (lazy, details::generic_set_minus_op(), wdof);
152}
153// ============================================================================
154// 3) operator[]
155// ============================================================================
156template<class Derived>
157field_wdof_indirect<Derived>
158field_wdof_base<Derived>::operator[] (const std::string& dom_name)
159{
160 return field_wdof_indirect<Derived> (derived(), derived().get_geo().operator[](dom_name));
161}
162template<class Derived>
165{
166 return field_wdof_indirect<Derived> (derived(), dom);
167}
168template<class Derived>
171{
172 return field_wdof_sliced<Derived> (derived(), i_comp);
173}
174template<class Derived>
177{
178 space_constant::coordinate_type sys_coord = derived().get_geo().coordinate_system();
179 size_type ij_comp = space_constant::tensor_index (derived().valued_tag(), sys_coord, i_comp, j_comp);
180 return field_wdof_sliced<Derived> (derived(), ij_comp);
181}
182
183}}// namespace rheolef::details
184# endif /* _RHEOLEF_FIELD_WDOF_ICC */
std::enable_if< details::is_rheolef_arithmetic< Value >::value, field_wdof_base< Derived > & >::type operator=(const Value &)
typename field_traits< Derived >::size_type size_type
Definition field_wdof.h:40
field_wdof_sliced< Derived > operator()(size_type i_comp, size_type j_comp)
field_wdof_indirect< Derived > operator[](const std::string &dom_name)
void get_geo(istream &in, my_geo &omega)
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
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)
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)
void assign_with_operator(ForwardIterator first, ForwardIterator last, InputIterator iter_rhs, OpAssign op_assign)
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)
size_type tensor_index(valued_type valued_tag, coordinate_type sys_coord, size_type i, size_type j)
This file is part of Rheolef.
const_iterator begin_dof() const
space_constant::valued_type valued_tag() const