Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
test.h
Go to the documentation of this file.
1# ifndef _RHEOLEF_TEST_H
2# define _RHEOLEF_TEST_H
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
24namespace rheolef {
74} // namespace rheolef
75
76#include "rheolef/space.h"
77#include "rheolef/fem_on_pointset.h"
78#include "rheolef/band.h"
79#include "rheolef/piola_util.h"
80#include "rheolef/vf_tag.h"
81
82namespace rheolef {
83
84namespace details {
85
86// forward declaration:
87template <class T, class M, class VfTag> class test_component;
88
89} // namespace details
90
91
92template <class T, class M>
93class test_rep {
94public :
95// typedefs:
96
97 using size_type = std::size_t;
98 using memory_type = M;
100 using scalar_type = T;
102 using geo_type = geo_basic <float_type,M>;
105 using is_elementwise = std::true_type;
106
107// allocator/deallocator:
108
109 explicit test_rep (const space_type& V);
110 test_rep (const test_rep<T,M>&);
112
113// accessors:
114
115 const space_type& get_vf_space() const { return _V; }
117 space_constant::valued_type valued_tag() const { return get_vf_space().valued_tag(); }
118 size_type n_derivative() const { return 0; }
119
120// initializers:
121
122 void initialize (
124 const integrate_option& iopt);
125 void initialize (
126 const band_basic<float_type,memory_type>& gh,
128 const integrate_option& iopt);
129 void initialize (
132 const integrate_option& iopt);
133
134// evaluators:
135
136 template<class Value, diff_type Diff>
137 void evaluate (
138 const geo_basic<T,M>& omega_K,
139 const geo_element& K,
140 const details::differentiate_option& gopt,
141 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const;
142
143 template<class Value, diff_type Diff>
144 void evaluate_on_side (
145 const geo_basic<T,M>& omega_K,
146 const geo_element& K,
147 const side_information_type& sid,
148 const details::differentiate_option& gopt,
149 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const;
150
151 template<class Value>
152 void valued_check() const {
154 check_macro (_V.valued_tag() == valued_tag, "unexpected "<<_V.valued()
155 << "-valued field while a " << space_constant::valued_name(valued_tag)
156 << "-valued one is expected in expression");
157 }
158 template<class Value>
159 void grad_valued_check() const {
160 typedef typename space_constant::rank_down<Value>::type A1;
162 check_macro (_V.valued_tag() == arg_valued_tag, "grad(): unexpected "<<_V.valued()
163 << "-valued field while a " << space_constant::valued_name(arg_valued_tag)
164 << "-valued one is expected in expression");
165 }
166 template<class Value>
167 void div_valued_check() const {
168 typedef typename space_constant::rank_up<Value>::type A1;
170 check_macro (_V.valued_tag() == arg_valued_tag, "div(): unexpected "<<_V.valued()
171 << "-valued field while a " << space_constant::valued_name(arg_valued_tag)
172 << "-valued one is expected in expression");
173 }
174 template<class Value>
175 void curl_valued_check() const {
176 // TODO: depend on dim
177 }
178 template<class Value>
180 const geo_basic<T,M>& omega_K,
181 const geo_element& S,
182 const geo_element& K0,
183 const geo_element& K1,
184 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value0,
185 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value1,
186 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const;
187
188protected:
189// internals
190 void _element_initialize (const geo_element& K) const;
191 void _element_initialize_on_side (const geo_element& K, const side_information_type& sid); //BUG with const for DG
192 void _evaluate_init (const reference_element& hat_K) const;
193
194// data:
195public:
201};
202// ----------------------
203// smart_pointer version:
204// ----------------------
205// [verbatim_test_basic]
206template <class T, class M, class VfTag>
207class test_basic : public smart_pointer<test_rep<T,M> > {
208public :
209// typedefs:
210
213 using size_type = typename rep::size_type;
215 using value_type = typename rep::value_type;
217 using float_type = typename rep::float_type;
218 using geo_type = typename rep::geo_type;
219 using space_type = typename rep::space_type;
220 using diff_type = typename rep::diff_type;
222 using vf_tag_type = VfTag;
226
227// allocator/deallocator:
228
229 explicit test_basic (const space_type& V) : base(new_macro(rep(V))) {}
230
231// accessors:
232
233 const space_type& get_vf_space() const { return base::data().get_vf_space(); }
235 space_constant::valued_type valued_tag() const { return base::data().valued_tag(); }
236 size_type n_derivative() const { return base::data().n_derivative(); }
237
238 size_type size() const { return get_vf_space().size(); }
240// [verbatim_test_basic]
241
242// mutable modifiers:
243
246 const integrate_option& iopt)
247 { base::data().initialize (pops, iopt); }
251 const integrate_option& iopt)
252 { base::data().initialize (gh, pops, iopt); }
256 const integrate_option& iopt)
257 { base::data().initialize (Xh, pops, iopt); }
258
259// evaluators :
260
261 template<class Value, diff_type Diff>
262 void evaluate (
263 const geo_basic<T,M>& omega_K,
264 const geo_element& K,
266 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const
267 { base::data().template evaluate<Value,Diff> (omega_K, K, gopt, value); }
268
269 template<class Value, diff_type Diff>
271 const geo_basic<T,M>& omega_K,
272 const geo_element& K,
273 const side_information_type& sid,
275 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value,
276 bool do_local_component_assembly_unused) const
277 { base::data().template evaluate_on_side<Value,Diff> (omega_K, K, sid, gopt, value); }
278
279 // abbreviation: evaluate without differentiation
280 template<class Value>
281 void evaluate (
282 const geo_basic<T,M>& omega_K,
283 const geo_element& K,
284 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const
285 {
287 base::data().template evaluate<Value,details::differentiate_option::none> (omega_K, K, none, value);
288 }
289 template<class Value>
291 const geo_basic<T,M>& omega_K,
292 const geo_element& K,
293 const side_information_type& sid,
294 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value,
295 bool do_local_component_assembly_unused) const
296 {
298 base::data().template evaluate_on_side<Value,details::differentiate_option::none> (omega_K, K, sid, none, value);
299 }
300 template<class Value>
301 void valued_check() const { base::data().template valued_check<Value>(); }
302 template<class Value>
303 void grad_valued_check() const { base::data().template grad_valued_check<Value>(); }
304 template<class Value>
305 void div_valued_check() const { base::data().template div_valued_check<Value>(); }
306 template<class Value>
307 void curl_valued_check() const { base::data().template curl_valued_check<Value>(); }
308
309 template<class Value>
311 const geo_basic<T,M>& omega_K,
312 const geo_element& S,
313 const geo_element& K0,
314 const geo_element& K1,
315 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value0,
316 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value1,
317 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const
318 { base::data().local_dg_merge_on_side (omega_K, S, K0, K1, value0, value1, value); }
319// [verbatim_test_basic_cont]
320};
321// [verbatim_test_basic_cont]
322
323// [verbatim_test]
328// [verbatim_test]
329
330}// namespace rheolef
331# endif /* _RHEOLEF_TEST_H */
field::size_type size_type
Definition branch.cc:430
field gh(Float epsilon, Float t, const field &uh, const test &v)
see the geo_element page for the full documentation
see the integrate_option page for the full documentation
see the reference_element page for the full documentation
see the smart_pointer page for the full documentation
VfTag vf_tag_type
Definition test.h:222
void curl_valued_check() const
Definition test.h:307
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
Definition test.h:244
typename rep::memory_type memory_type
Definition test.h:214
void initialize(const band_basic< float_type, memory_type > &gh, const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
Definition test.h:248
void evaluate(const geo_basic< T, M > &omega_K, const geo_element &K, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
Definition test.h:281
typename rep::size_type size_type
Definition test.h:213
void div_valued_check() const
Definition test.h:305
void evaluate_on_side(const geo_basic< T, M > &omega_K, const geo_element &K, const side_information_type &sid, const details::differentiate_option &gopt, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value, bool do_local_component_assembly_unused) const
Definition test.h:270
void grad_valued_check() const
Definition test.h:303
size_type size() const
Definition test.h:238
typename rep::diff_type diff_type
Definition test.h:220
void valued_check() const
Definition test.h:301
test_basic< T, M, vf_dual_tag_type > dual_self_type
Definition test.h:225
typename rep::value_type value_type
Definition test.h:215
test_basic< T, M, VfTag > self_type
Definition test.h:224
static const space_constant::valued_type valued_hint
Definition test.h:234
size_type n_derivative() const
Definition test.h:236
details::test_component< T, M, VfTag > operator[](size_type i_comp) const
typename rep::float_type float_type
Definition test.h:217
smart_pointer< rep > base
Definition test.h:212
typename rep::space_type space_type
Definition test.h:219
typename rep::geo_type geo_type
Definition test.h:218
typename details::dual_vf_tag< VfTag >::type vf_dual_tag_type
Definition test.h:223
test_basic(const space_type &V)
Definition test.h:229
typename rep::is_elementwise is_elementwise
Definition test.h:221
void evaluate_on_side(const geo_basic< T, M > &omega_K, const geo_element &K, const side_information_type &sid, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value, bool do_local_component_assembly_unused) const
Definition test.h:290
void local_dg_merge_on_side(const geo_basic< T, M > &omega_K, const geo_element &S, const geo_element &K0, const geo_element &K1, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value0, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value1, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
Definition test.h:310
void evaluate(const geo_basic< T, M > &omega_K, const geo_element &K, const details::differentiate_option &gopt, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
Definition test.h:262
void initialize(const space_basic< float_type, memory_type > &Xh, const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
Definition test.h:253
typename rep::scalar_type scalar_type
Definition test.h:216
space_constant::valued_type valued_tag() const
Definition test.h:235
const space_type & get_vf_space() const
Definition test.h:233
undeterminated_basic< T > value_type
Definition test.h:99
void curl_valued_check() const
Definition test.h:175
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
Definition test.cc:65
space_type _V
Definition test.h:196
band_basic< float_type, M > _gh
Definition test.h:200
void div_valued_check() const
Definition test.h:167
void grad_valued_check() const
Definition test.h:159
void valued_check() const
Definition test.h:152
fem_on_pointset< float_type > _fops
Definition test.h:197
bool _is_inside_on_local_sides
Definition test.h:198
void _element_initialize_on_side(const geo_element &K, const side_information_type &sid)
static const space_constant::valued_type valued_hint
Definition test.h:116
size_type n_derivative() const
Definition test.h:118
geo_basic< float_type, M > geo_type
Definition test.h:102
details::differentiate_option::type diff_type
Definition test.h:104
bool _is_on_band
Definition test.h:199
space_basic< float_type, M > space_type
Definition test.h:103
void evaluate_on_side(const geo_basic< T, M > &omega_K, const geo_element &K, const side_information_type &sid, const details::differentiate_option &gopt, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
Definition test.cc:410
void local_dg_merge_on_side(const geo_basic< T, M > &omega_K, const geo_element &S, const geo_element &K0, const geo_element &K1, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value0, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value1, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
Definition test.cc:467
void _evaluate_init(const reference_element &hat_K) const
void _element_initialize(const geo_element &K) const
std::true_type is_elementwise
Definition test.h:105
void evaluate(const geo_basic< T, M > &omega_K, const geo_element &K, const details::differentiate_option &gopt, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
Definition test.cc:288
test_rep< T, M > & operator=(const test_rep< T, M > &)
Definition test.cc:50
typename float_traits< T >::type float_type
Definition test.h:101
std::size_t size_type
Definition test.h:97
space_constant::valued_type valued_tag() const
Definition test.h:117
const space_type & get_vf_space() const
Definition test.h:115
test_basic< Float, rheo_default_memory_model, details::vf_tag_10 > trial
Definition test.h:327
test_basic< Float, rheo_default_memory_model, details::vf_tag_01 > test
Definition test.h:324
Expr1::float_type T
Definition field_expr.h:230
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
const std::string & valued_name(valued_type valued_tag)
This file is part of Rheolef.
undeterminated_basic< typename scalar_traits< T >::type > type
point_basic< typename scalar_traits< T >::type > type
helper for generic field value_type: T, point_basic<T> or tensor_basic<T>
Expr1::memory_type M