Rheolef  7.1
an efficient C++ finite element environment
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 
24 namespace 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 
82 namespace rheolef {
83 
84 namespace details {
85 
86 // forward declaration:
87 template <class T, class M, class VfTag> class test_component;
88 
89 } // namespace details
90 
91 
92 template <class T, class M>
93 class test_rep {
94 public :
95 // typedefs:
96 
97  typedef typename std::size_t size_type;
98  typedef M memory_type;
100  typedef T scalar_type;
105 
106 // allocator/deallocator:
107 
108  explicit test_rep (const space_type& V);
109  test_rep (const test_rep<T,M>&);
111 
112 // accessors:
113 
114  const space_type& get_vf_space() const { return _V; }
116  space_constant::valued_type valued_tag() const { return get_vf_space().valued_tag(); }
117  size_type n_derivative() const { return 0; }
118 
119 // initializers:
120 
121  void initialize (
122  const piola_on_pointset<float_type>& pops,
123  const integrate_option& iopt) const;
124  void initialize (
125  const band_basic<float_type,memory_type>& gh,
126  const piola_on_pointset<float_type>& pops,
127  const integrate_option& iopt) const;
128  void initialize (
130  const piola_on_pointset<float_type>& pops,
131  const integrate_option& iopt) const;
132 
133 // evaluators:
134 
135  template<class Value, diff_type Diff>
136  void evaluate (
137  const geo_basic<T,M>& omega_K,
138  const geo_element& K,
139  const details::differentiate_option& gopt,
140  Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const;
141 
142  template<class Value, diff_type Diff>
143  void evaluate_on_side (
144  const geo_basic<T,M>& omega_K,
145  const geo_element& K,
146  const side_information_type& sid,
147  const details::differentiate_option& gopt,
148  Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const;
149 
150  template<class Value>
151  void valued_check() const {
153  check_macro (_V.valued_tag() == valued_tag, "unexpected "<<_V.valued()
154  << "-valued field while a " << space_constant::valued_name(valued_tag)
155  << "-valued one is expected in expression");
156  }
157  template<class Value>
158  void grad_valued_check() const {
159  typedef typename space_constant::rank_down<Value>::type A1;
161  check_macro (_V.valued_tag() == arg_valued_tag, "grad(): unexpected "<<_V.valued()
162  << "-valued field while a " << space_constant::valued_name(arg_valued_tag)
163  << "-valued one is expected in expression");
164  }
165  template<class Value>
166  void div_valued_check() const {
167  typedef typename space_constant::rank_up<Value>::type A1;
169  check_macro (_V.valued_tag() == arg_valued_tag, "div(): unexpected "<<_V.valued()
170  << "-valued field while a " << space_constant::valued_name(arg_valued_tag)
171  << "-valued one is expected in expression");
172  }
173  template<class Value>
174  void curl_valued_check() const {
175  // TODO: depend on dim
176  }
177  template<class Value>
179  const geo_basic<T,M>& omega_K,
180  const geo_element& S,
181  const geo_element& K0,
182  const geo_element& K1,
183  const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value0,
184  const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value1,
185  Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const;
186 
187 protected:
188 // internals
189  void _element_initialize (const geo_element& K) const;
190  void _element_initialize_on_side (const geo_element& K, const side_information_type& sid); //BUG with const for DG
191  void _evaluate_init (const reference_element& hat_K) const;
192 
193 // data:
194 public:
195  // TODO: fix it later for test_component
199  mutable bool _is_on_band;
201 };
202 // ----------------------
203 // smart_pointer version:
204 // ----------------------
205 // [verbatim_test_basic]
206 template <class T, class M, class VfTag>
207 class test_basic : public smart_pointer<test_rep<T,M> > {
208 public :
209 // typedefs:
210 
213  typedef typename rep::size_type size_type;
214  typedef typename rep::memory_type memory_type;
215  typedef typename rep::value_type value_type;
216  typedef typename rep::scalar_type scalar_type;
217  typedef typename rep::float_type float_type;
218  typedef typename rep::geo_type geo_type;
219  typedef typename rep::space_type space_type;
220  typedef typename rep::diff_type diff_type;
221  typedef VfTag vf_tag_type;
222  typedef typename details::dual_vf_tag<VfTag>::type
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 
244  void initialize (
245  const piola_on_pointset<float_type>& pops,
246  const integrate_option& iopt) const
247  { base::data().initialize (pops, iopt); }
248  void initialize (
250  const piola_on_pointset<float_type>& pops,
251  const integrate_option& iopt) const
252  { base::data().initialize (gh, pops, iopt); }
253  void initialize (
255  const piola_on_pointset<float_type>& pops,
256  const integrate_option& iopt) const
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,
265  const details::differentiate_option& gopt,
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,
274  const details::differentiate_option& gopt,
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]
324 typedef test_basic<Float,rheo_default_memory_model,details::vf_tag_01> test;
327 typedef test_basic<Float,rheo_default_memory_model,details::vf_tag_10> trial;
328 // [verbatim_test]
329 
330 }// namespace rheolef
331 # endif /* _RHEOLEF_TEST_H */
field::size_type size_type
Definition: branch.cc:425
field gh(Float epsilon, Float t, const field &uh, const test &v)
generic mesh with rerefence counting
Definition: geo.h:1089
see the geo_element page for the full documentation
Definition: geo_element.h:102
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
test_basic< T, M, vf_dual_tag_type > dual_self_type
Definition: test.h:225
rep::geo_type geo_type
Definition: test.h:218
void curl_valued_check() const
Definition: test.h:307
void initialize(const band_basic< float_type, memory_type > &gh, const piola_on_pointset< float_type > &pops, const integrate_option &iopt) const
Definition: test.h:248
rep::value_type value_type
Definition: test.h:215
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
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
rep::space_type space_type
Definition: test.h:219
size_type size() const
Definition: test.h:238
test_rep< T, M > rep
Definition: test.h:211
void valued_check() const
Definition: test.h:301
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt) const
Definition: test.h:244
static const space_constant::valued_type valued_hint
Definition: test.h:234
size_type n_derivative() const
Definition: test.h:236
void initialize(const space_basic< float_type, memory_type > &Xh, const piola_on_pointset< float_type > &pops, const integrate_option &iopt) const
Definition: test.h:253
rep::diff_type diff_type
Definition: test.h:220
details::test_component< T, M, VfTag > operator[](size_type i_comp) const
rep::float_type float_type
Definition: test.h:217
smart_pointer< rep > base
Definition: test.h:212
test_basic(const space_type &V)
Definition: test.h:229
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
test_basic< T, M, VfTag > self_type
Definition: test.h:224
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
rep::memory_type memory_type
Definition: test.h:214
rep::size_type size_type
Definition: test.h:213
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
const space_type & get_vf_space() const
Definition: test.h:233
VfTag vf_tag_type
Definition: test.h:221
details::dual_vf_tag< VfTag >::type vf_dual_tag_type
Definition: test.h:223
space_constant::valued_type valued_tag() const
Definition: test.h:235
rep::scalar_type scalar_type
Definition: test.h:216
void curl_valued_check() const
Definition: test.h:174
space_basic< float_type, M > space_type
Definition: test.h:103
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:166
void grad_valued_check() const
Definition: test.h:158
void valued_check() const
Definition: test.h:151
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt) const
Definition: test.cc:65
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:115
test_rep(const space_type &V)
Definition: test.cc:30
size_type n_derivative() const
Definition: test.h:117
std::size_t size_type
Definition: test.h:97
bool _is_on_band
Definition: test.h:199
details::differentiate_option::type diff_type
Definition: test.h:104
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
geo_basic< float_type, M > geo_type
Definition: test.h:102
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
undeterminated_basic< T > value_type
Definition: test.h:99
test_rep< T, M > & operator=(const test_rep< T, M > &)
Definition: test.cc:50
const space_type & get_vf_space() const
Definition: test.h:114
float_traits< T >::type float_type
Definition: test.h:101
space_constant::valued_type valued_tag() const
Definition: test.h:116
test_basic< Float, rheo_default_memory_model, details::vf_tag_10 > trial
Definition: test.h:327
rheolef::std value
test_basic< Float, rheo_default_memory_model, details::vf_tag_01 > test
Definition: test.h:324
Expr1::float_type T
Definition: field_expr.h:261
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.
helper for generic field value_type: T, point_basic<T> or tensor_basic<T>
Expr1::memory_type M
Definition: vec_expr_v2.h:416