1#ifndef _RHEOLEF_TEST_COMPONENT_H
2#define _RHEOLEF_TEST_COMPONENT_H
25#include "rheolef/test.h"
27namespace rheolef {
namespace details {
32template <
class T,
class M,
class VfTag>
65 {
_u_comp.initialize (pops, iopt); }
74 {
_u_comp.initialize (Xh, iopt); }
78 template<
class Value, details::differentiate_option::type Diff>
83 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const;
85 template<
class Value, details::differentiate_option::type Diff>
91 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value,
92 bool do_local_component_assembly)
const;
100 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value0,
101 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value1,
102 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const;
106 template<
class ValueType>
111 <<
"-valued one is expected in expression");
113 template<
class ValueType>
119 <<
"-valued one is expected in expression");
121 template<
class ValueType>
127 <<
"-valued one is expected in expression");
136 template<
class Value>
140 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value_comp,
141 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const;
142 template<
class Value>
147 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value_comp,
148 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const;
159 mutable std::array<size_type,reference_element::max_variant>
168template <
class T,
class M,
class VfTag>
170: _i_comp (x._i_comp),
173 _ptr_u_comp_upper_data (x._ptr_u_comp_upper_data),
174 _loc_ndof (x._loc_ndof),
175 _first_loc_idof (x._first_loc_idof),
176 _last_loc_idof (x._last_loc_idof),
177 _is_on_band (x._is_on_band)
179 trace_macro (
"** PHYSICAL COPY OF TEST_COMPONENT **");
181template <
class T,
class M,
class VfTag>
185 trace_macro (
"** PHYSICAL ASSIGN OF TEST_COMPONENT **");
196template <
class T,
class M,
class VfTag>
200 _u_comp (_init_space_comp(
u.get_vf_space(),i_comp)),
201 _ptr_u_comp_upper_data(),
209template <
class T,
class M,
class VfTag>
211 : _i_comp(i_subcomp),
212 _u(u_comp_upper.data()._u),
213 _u_comp (_init_space_comp(u_comp_upper.data()._u_comp.get_vf_space(),i_subcomp)),
214 _ptr_u_comp_upper_data(u_comp_upper),
222template <
class T,
class M,
class VfTag>
226 check_macro (i_comp < Xh.size(),
"test component index "<<i_comp<<
" is out of range [0:"<<Xh.size()<<
"[");
230template <
class T,
class M,
class VfTag>
237 if (_has_subcomponent()) {
238 const space_type& Xh_upper = get_u_comp_upper_data()._u_comp.get_vf_space();
239 get_u_comp_upper_data()._initialize_numbering (omega_K, K);
240 _loc_ndof[variant] = get_u_comp_upper_data()._loc_ndof [variant];
241 _first_loc_idof[variant] = get_u_comp_upper_data()._first_loc_idof[variant];
242 for (
size_type j_comp = 0; j_comp < _i_comp; ++j_comp) {
243 size_type loc_jcomp_ndof = Xh_upper.get_constitution()[j_comp].assembly_loc_ndof (omega_K, K);
244 _first_loc_idof[variant] += loc_jcomp_ndof;
246 size_type loc_icomp_ndof = Xh_upper.get_constitution()[_i_comp].assembly_loc_ndof (omega_K, K);
247 _last_loc_idof[variant] = _first_loc_idof[variant] + loc_icomp_ndof;
249 const space_type& Xh_upper = _u.get_vf_space();
250 _loc_ndof[variant] = _u.get_vf_space().get_constitution().assembly_loc_ndof (omega_K, K);
251 _first_loc_idof[variant] = 0;
252 for (
size_type j_comp = 0; j_comp < _i_comp; ++j_comp) {
253 size_type loc_jcomp_ndof = Xh_upper.get_constitution()[j_comp].assembly_loc_ndof (omega_K, K);
254 _first_loc_idof[variant] += loc_jcomp_ndof;
257 loc_icomp_ndof = Xh_upper.get_constitution()[_i_comp].assembly_loc_ndof (omega_K, K);
258 _last_loc_idof[
variant] = _first_loc_idof[
variant] + loc_icomp_ndof;
261template <
class T,
class M,
class VfTag>
262template<
class Value, details::differentiate_option::type Diff>
268 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
271 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic> value_comp;
272 _u_comp.template evaluate<Value,Diff> (omega_K, K, gopt, value_comp);
274 _evaluate_continued (omega_K, K, value_comp, value);
276template <
class T,
class M,
class VfTag>
282 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value_comp,
283 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
285 check_macro (!_is_on_band,
"test_component: not yet on band");
287 _initialize_numbering (omega_K, K);
291 "omega_K="<<omega_K.name()<<
", K="<<K.
name()<<K.
dis_ie()
292 <<
", space="<<_u.get_vf_space().name()<<
", i_comp="<<_i_comp<<
", comp_space="<<_u_comp.get_vf_space().name()
293 <<
", value_comp("<<value_comp.rows()<<
","<<value_comp.cols()<<
") has incompatible cols size : expect loc_comp_ndof="<<loc_comp_ndof
294 <<
" associated to local dof sub-range ["<<_first_loc_idof[hat_K.
variant()]<<
":"<< _last_loc_idof[hat_K.
variant()]<<
"["
295 <<
" in full local dof range [0:"<<loc_ndof<<
"[");
297 value.resize (loc_nnod, loc_ndof);
298 value.fill (Value());
299 for (
size_type loc_inod = 0; loc_inod < loc_nnod; ++loc_inod) {
300 for (
size_type loc_jdof = _first_loc_idof[hat_K.
variant()], loc_comp_jdof = 0; loc_comp_jdof < loc_comp_ndof; ++loc_jdof, ++loc_comp_jdof) {
301 value (loc_inod,loc_jdof) = value_comp (loc_inod,loc_comp_jdof);
304template <
class T,
class M,
class VfTag>
305template<
class Value, details::differentiate_option::type Diff>
312 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value,
313 bool do_local_component_assembly)
const
315 if (!do_local_component_assembly) {
318 _u_comp.template evaluate_on_side<Value,Diff> (omega_K, K, sid, gopt, value, do_local_component_assembly);
322 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic> value_comp;
323 _u_comp.template evaluate_on_side<Value,Diff> (omega_K, K, sid, gopt, value_comp, do_local_component_assembly);
324 _evaluate_on_side_continued (omega_K, K, sid, value_comp, value);
326template <
class T,
class M,
class VfTag>
333 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value_comp,
334 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
336 check_macro (!_is_on_band,
"test_component: not yet on band");
339 _initialize_numbering (omega_K, K);
345 "omega_K="<<omega_K.name()<<
", K="<<K.
name()<<K.
dis_ie()
346 <<
", space="<<_u.get_vf_space().name()<<
", i_comp="<<_i_comp<<
", comp_space="<<_u_comp.get_vf_space().name()
347 <<
", value_comp("<<value_comp.rows()<<
","<<value_comp.cols()<<
") has incompatible cols size : expect loc_comp_ndof="<<loc_comp_ndof
348 <<
" associated to local dof sub-range ["<<_first_loc_idof[hat_K.
variant()]<<
":"<< _last_loc_idof[hat_K.
variant()]<<
"["
349 <<
" in full local dof range [0:"<<loc_ndof<<
"[");
350 check_macro (first_loc_jdof + loc_comp_ndof <= loc_ndof,
"invalid sizes");
352 value.resize (loc_nnod, loc_ndof);
353 value.fill (Value());
354 for (
size_type loc_inod = 0; loc_inod < loc_nnod; ++loc_inod) {
355 for (
size_type loc_jdof = first_loc_jdof, loc_comp_jdof = 0; loc_comp_jdof < loc_comp_ndof; ++loc_jdof, ++loc_comp_jdof) {
356 value (loc_inod,loc_jdof) = value_comp (loc_inod,loc_comp_jdof);
359template <
class T,
class M,
class VfTag>
367 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value_comp0,
368 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value_comp1,
369 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
372 _initialize_numbering (omega_K, S);
379 "omega_K="<<omega_K.name()<<
", S="<<S.
name()<<S.
dis_ie()
380 <<
", space="<<_u.get_vf_space().name()<<
", i_comp="<<_i_comp<<
", comp_space="<<_u_comp.get_vf_space().name()
381 <<
", value_comp0("<<value_comp0.rows()<<
","<<value_comp0.cols()<<
") and "
382 <<
" value_comp1("<<value_comp1.rows()<<
","<<value_comp1.cols()<<
") have incompatible cols sizes : expect loc_comp_ndof="<<loc_comp_ndof
383 <<
" associated to local dof sub-range ["<<_first_loc_idof[hat_S.
variant()]<<
":"<< _last_loc_idof[hat_S.
variant()]<<
"["
384 <<
" in full local dof range [0:"<<loc_ndof<<
"[");
385 check_macro (value_comp0.rows() == value_comp1.rows(),
"invalid sizes");
386 check_macro (first_loc_jdof + loc_comp_ndof <= loc_ndof,
"invalid sizes");
387 value.resize (loc_nnod, loc_ndof);
388 value.fill (Value());
389 for (
size_type loc_inod = 0; loc_inod < loc_nnod; ++loc_inod) {
390 for (
size_type loc_jdof = first_loc_jdof, loc_comp0_jdof = 0, loc_comp0_ndof = value_comp0.cols();
391 loc_comp0_jdof < loc_comp0_ndof; ++loc_jdof, ++loc_comp0_jdof) {
392 value (loc_inod,loc_jdof) = value_comp0 (loc_inod,loc_comp0_jdof);
394 for (
size_type loc_jdof = first_loc_jdof + value_comp0.cols(), loc_comp1_jdof = 0, loc_comp1_ndof = value_comp1.cols();
395 loc_comp1_jdof < loc_comp1_ndof; ++loc_jdof, ++loc_comp1_jdof) {
396 value (loc_inod,loc_jdof) = value_comp1 (loc_inod,loc_comp1_jdof);
399trace_macro(
"local_dg_merge_on_side: omega_K="<<omega_K.name()<<
", S="<<S.
name()<<S.
dis_ie()<<
" done");
404template <
class T,
class M,
class VfTag>
450 { base::data().initialize (pops, iopt); }
455 { base::data().initialize (
gh, pops, iopt); }
459 { base::data().initialize (Xh, iopt); }
463 template<
class Value, diff_type Diff>
468 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
469 {
return base::data().template evaluate<Value,Diff> (omega_K, K, gopt, value); }
471 template<
class Value, diff_type Diff>
477 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value,
478 bool do_local_component_assembly)
const
479 {
return base::data().template evaluate_on_side<Value,Diff> (omega_K, K, sid, gopt, value, do_local_component_assembly); }
482 template<
class Value>
486 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
489 base::data().template evaluate<Value,details::differentiate_option::none> (omega_K, K, none, value);
491 template<
class Value>
496 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value,
497 bool do_local_component_assembly)
const
500 base::data().template evaluate_on_side<Value,details::differentiate_option::none> (omega_K, K, sid, none, value, do_local_component_assembly);
505 template<
class Value>
511 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value0,
512 const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value1,
513 Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value)
const
514 {
return base::data().local_dg_merge_on_side (omega_K, S, K0, K1, value0, value1, value); }
518 template<
class ValueType>
519 void valued_check()
const { base::data().template valued_check<ValueType>(); }
520 template<
class ValueType>
522 template<
class ValueType>
531template <
class T,
class M,
class VfTag>
533details::test_component<T,M,VfTag>
field::size_type size_type
field gh(Float epsilon, Float t, const field &uh, const test &v)
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, const details::differentiate_option &gopt, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
void _evaluate_continued(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value_comp, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
space_basic< float_type, M > space_type
std::array< size_type, reference_element::max_variant > _first_loc_idof
test_type::float_type float_type
void initialize(const piola_on_pointset< T > &pops, const integrate_option &iopt)
test_basic< T, M, VfTag > test_type
test_basic< T, M, VfTag > _u
void evaluate_on_side(const geo_basic< float_type, memory_type > &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) const
smart_pointer< test_component_rep< T, M, VfTag > > _ptr_u_comp_upper_data
void initialize(const space_basic< float_type, memory_type > &Xh, const integrate_option &iopt)
bool _has_subcomponent() const
void div_valued_check() const
void grad_valued_check() const
test_type::scalar_type scalar_type
std::array< size_type, reference_element::max_variant > _last_loc_idof
void valued_check() const
std::array< size_type, reference_element::max_variant > _loc_ndof
static space_type _init_space_comp(const space_type &Xh, size_type i_comp)
test_component_rep(const test_basic< T, M, VfTag > &u, size_type i_comp)
const test_component_rep< T, M, VfTag > & get_u_comp_upper_data() const
static const space_constant::valued_type valued_hint
void initialize(const band_basic< float_type, memory_type > &gh, const piola_on_pointset< T > &pops, const integrate_option &iopt)
test_component_rep< T, M, VfTag > & operator=(const test_component_rep< T, M, VfTag > &)
test_type::value_type value_type
details::differentiate_option::type diff_type
test_basic< T, M, VfTag > _u_comp
void _evaluate_on_side_continued(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, const side_information_type &sid, const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value_comp, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
test_type::size_type size_type
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
space_constant::valued_type valued_tag() const
void _initialize_numbering(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K) const
const space_type & get_vf_space() const
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
test_component< T, M, VfTag > operator[](size_t i_comp) const
void evaluate(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, const details::differentiate_option &gopt, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value) const
space_basic< float_type, M > space_type
test_type::float_type float_type
void initialize(const piola_on_pointset< T > &pops, const integrate_option &iopt)
test_basic< T, M, VfTag > test_type
void evaluate_on_side(const geo_basic< float_type, memory_type > &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) const
void initialize(const space_basic< float_type, memory_type > &Xh, const integrate_option &iopt)
void div_valued_check() const
void grad_valued_check() const
void evaluate_on_side(const geo_basic< float_type, memory_type > &omega_K, const geo_element &K, const side_information_type &sid, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &value, bool do_local_component_assembly) const
test_type::scalar_type scalar_type
test_component< T, M, vf_dual_tag_type > dual_self_type
test_component(const test_component< T, M, VfTag > &u)
void valued_check() const
test_component(const test_basic< T, M, VfTag > &u, size_type i_comp)
static const space_constant::valued_type valued_hint
size_type n_derivative() const
void initialize(const band_basic< float_type, memory_type > &gh, const piola_on_pointset< T > &pops, const integrate_option &iopt)
smart_pointer< rep > base
test_type::value_type value_type
details::differentiate_option::type diff_type
test_component< T, M, VfTag > self_type
test_component_rep< T, M, VfTag > rep
test_type::size_type size_type
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
geo_basic< float_type, M > geo_type
test_component(const test_component< T, M, VfTag > &u, size_type i_comp)
details::dual_vf_tag< VfTag >::type vf_dual_tag_type
space_constant::valued_type valued_tag() const
const space_type & get_vf_space() const
generic mesh with rerefence counting
see the geo_element page for the full documentation
size_type dimension() const
variant_type variant() const
see the integrate_option page for the full documentation
see the reference_element page for the full documentation
variant_type variant() const
see the smart_pointer page for the full documentation
typename rep::size_type size_type
typename rep::value_type value_type
details::test_component< T, M, VfTag > operator[](size_type i_comp) const
typename rep::float_type float_type
typename rep::scalar_type scalar_type
#define trace_macro(message)
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