Loading...
Searching...
No Matches
test.h
Go to the documentation of this file.
# ifndef _RHEOLEF_TEST_H
# define _RHEOLEF_TEST_H
//
// 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
//
// =========================================================================
namespace rheolef {
} // namespace rheolef
#include "rheolef/space.h"
#include "rheolef/fem_on_pointset.h"
#include "rheolef/band.h"
#include "rheolef/piola_util.h"
#include "rheolef/vf_tag.h"
namespace rheolef {
namespace details {
// forward declaration:
template <class T, class M, class VfTag> class test_component;
} // namespace details
template <class T, class M>
class test_rep {
public :
// typedefs:
using size_type = std::size_t;
using memory_type = M;
using value_type = undeterminated_basic<T>;
using scalar_type = T;
using float_type = typename float_traits<T>::type;
using geo_type = geo_basic <float_type,M>;
using space_type = space_basic<float_type,M>;
using diff_type = details::differentiate_option::type;
using is_elementwise = std::true_type;
// allocator/deallocator:
explicit test_rep (const space_type& V);
test_rep (const test_rep<T,M>&);
test_rep<T,M>& operator= (const test_rep<T,M>&);
// accessors:
const space_type& get_vf_space() const { return _V; }
static const space_constant::valued_type valued_hint = space_constant::last_valued;
space_constant::valued_type valued_tag() const { return get_vf_space().valued_tag(); }
size_type n_derivative() const { return 0; }
// initializers:
void initialize (
const piola_on_pointset<float_type>& pops,
const integrate_option& iopt);
void initialize (
const band_basic<float_type,memory_type>& gh,
const piola_on_pointset<float_type>& pops,
const integrate_option& iopt);
void initialize (
const space_basic<float_type,memory_type>& Xh,
const piola_on_pointset<float_type>& pops,
const integrate_option& iopt);
// evaluators:
template<class Value, diff_type Diff>
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;
template<class Value, diff_type Diff>
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;
template<class Value>
void valued_check() const {
space_constant::valued_type valued_tag = space_constant::valued_tag_traits<Value>::value;
check_macro (_V.valued_tag() == valued_tag, "unexpected "<<_V.valued()
<< "-valued field while a " << space_constant::valued_name(valued_tag)
<< "-valued one is expected in expression");
}
template<class Value>
void grad_valued_check() const {
typedef typename space_constant::rank_down<Value>::type A1;
space_constant::valued_type arg_valued_tag = space_constant::valued_tag_traits<A1>::value;
check_macro (_V.valued_tag() == arg_valued_tag, "grad(): unexpected "<<_V.valued()
<< "-valued field while a " << space_constant::valued_name(arg_valued_tag)
<< "-valued one is expected in expression");
}
template<class Value>
void div_valued_check() const {
typedef typename space_constant::rank_up<Value>::type A1;
space_constant::valued_type arg_valued_tag = space_constant::valued_tag_traits<A1>::value;
check_macro (_V.valued_tag() == arg_valued_tag, "div(): unexpected "<<_V.valued()
<< "-valued field while a " << space_constant::valued_name(arg_valued_tag)
<< "-valued one is expected in expression");
}
template<class Value>
void curl_valued_check() const {
// TODO: depend on dim
}
template<class Value>
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;
protected:
// internals
void _element_initialize (const geo_element& K) const;
void _element_initialize_on_side (const geo_element& K, const side_information_type& sid); //BUG with const for DG
void _evaluate_init (const reference_element& hat_K) const;
// data:
public:
space_type _V;
fem_on_pointset<float_type> _fops;
bool _is_inside_on_local_sides;
bool _is_on_band;
band_basic<float_type,M> _gh;
};
// ----------------------
// smart_pointer version:
// ----------------------
// [verbatim_test_basic]
template <class T, class M, class VfTag>
class test_basic : public smart_pointer<test_rep<T,M> > {
public :
// typedefs:
using rep = test_rep<T,M>;
using base = smart_pointer<rep>;
using size_type = typename rep::size_type;
using memory_type = typename rep::memory_type;
using value_type = typename rep::value_type;
using scalar_type = typename rep::scalar_type;
using float_type = typename rep::float_type;
using geo_type = typename rep::geo_type;
using space_type = typename rep::space_type;
using diff_type = typename rep::diff_type;
using is_elementwise = typename rep::is_elementwise;
using vf_tag_type = VfTag;
using vf_dual_tag_type = typename details::dual_vf_tag<VfTag>::type;
using self_type = test_basic<T,M,VfTag>;
using dual_self_type = test_basic<T,M,vf_dual_tag_type>;
// allocator/deallocator:
explicit test_basic (const space_type& V) : base(new_macro(rep(V))) {}
// accessors:
const space_type& get_vf_space() const { return base::data().get_vf_space(); }
static const space_constant::valued_type valued_hint = rep::valued_hint;
space_constant::valued_type valued_tag() const { return base::data().valued_tag(); }
size_type n_derivative() const { return base::data().n_derivative(); }
size_type size() const { return get_vf_space().size(); }
details::test_component<T,M,VfTag> operator[] (size_type i_comp) const;
// [verbatim_test_basic]
// mutable modifiers:
void initialize (
const piola_on_pointset<float_type>& pops,
const integrate_option& iopt)
{ base::data().initialize (pops, iopt); }
void initialize (
const band_basic<float_type,memory_type>& gh,
const piola_on_pointset<float_type>& pops,
const integrate_option& iopt)
{ base::data().initialize (gh, pops, iopt); }
void initialize (
const space_basic<float_type,memory_type>& Xh,
const piola_on_pointset<float_type>& pops,
const integrate_option& iopt)
{ base::data().initialize (Xh, pops, iopt); }
// evaluators :
template<class Value, diff_type Diff>
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
{ base::data().template evaluate<Value,Diff> (omega_K, K, gopt, value); }
template<class Value, diff_type Diff>
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
{ base::data().template evaluate_on_side<Value,Diff> (omega_K, K, sid, gopt, value); }
// abbreviation: evaluate without differentiation
template<class Value>
void evaluate (
const geo_basic<T,M>& omega_K,
const geo_element& K,
Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>& value) const
{
details::differentiate_option none;
base::data().template evaluate<Value,details::differentiate_option::none> (omega_K, K, none, value);
}
template<class Value>
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
{
details::differentiate_option none;
base::data().template evaluate_on_side<Value,details::differentiate_option::none> (omega_K, K, sid, none, value);
}
template<class Value>
void valued_check() const { base::data().template valued_check<Value>(); }
template<class Value>
void grad_valued_check() const { base::data().template grad_valued_check<Value>(); }
template<class Value>
void div_valued_check() const { base::data().template div_valued_check<Value>(); }
template<class Value>
void curl_valued_check() const { base::data().template curl_valued_check<Value>(); }
template<class Value>
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
{ base::data().local_dg_merge_on_side (omega_K, S, K0, K1, value0, value1, value); }
// [verbatim_test_basic_cont]
};
// [verbatim_test_basic_cont]
// [verbatim_test]
typedef test_basic<Float,rheo_default_memory_model,details::vf_tag_01> test;
typedef test_basic<Float,rheo_default_memory_model,details::vf_tag_10> trial;
// [verbatim_test]
}// namespace rheolef
# endif /* _RHEOLEF_TEST_H */
gh
field gh(Float epsilon, Float t, const field &uh, const test &v)
Definition burgers_diffusion_operators.icc:37
rheolef::band_basic
Definition band.h:95
rheolef::details::test_component
Definition test_component.h:405
rheolef::fem_on_pointset
Definition fem_on_pointset.h:117
rheolef::geo_basic
generic mesh with rerefence counting
Definition geo.h:1089
rheolef::geo_element
see the geo_element page for the full documentation
Definition geo_element.h:102
rheolef::integrate_option
see the integrate_option page for the full documentation
Definition integrate_option.h:125
rheolef::piola_on_pointset
Definition piola_on_pointset.h:142
rheolef::reference_element
see the reference_element page for the full documentation
Definition reference_element.h:66
rheolef::smart_pointer_base::data
const T & data() const
Definition smart_pointer.h:266
rheolef::smart_pointer< test_rep< T, M > >::smart_pointer
smart_pointer(T *p=0)
Definition smart_pointer.h:357
rheolef::space_basic
the finite element space
Definition space.h:382
rheolef::test_basic::vf_tag_type
VfTag vf_tag_type
Definition test.h:222
rheolef::test_basic::curl_valued_check
void curl_valued_check() const
Definition test.h:307
rheolef::test_basic::initialize
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
Definition test.h:244
rheolef::test_basic::memory_type
typename rep::memory_type memory_type
Definition test.h:214
rheolef::test_basic::initialize
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
rheolef::test_basic::evaluate
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
rheolef::test_basic::size_type
typename rep::size_type size_type
Definition test.h:213
rheolef::test_basic::div_valued_check
void div_valued_check() const
Definition test.h:305
rheolef::test_basic::evaluate_on_side
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
rheolef::test_basic::grad_valued_check
void grad_valued_check() const
Definition test.h:303
rheolef::test_basic::size
size_type size() const
Definition test.h:238
rheolef::test_basic::diff_type
typename rep::diff_type diff_type
Definition test.h:220
rheolef::test_basic::valued_check
void valued_check() const
Definition test.h:301
rheolef::test_basic::dual_self_type
test_basic< T, M, vf_dual_tag_type > dual_self_type
Definition test.h:225
rheolef::test_basic::value_type
typename rep::value_type value_type
Definition test.h:215
rheolef::test_basic::rep
test_rep< T, M > rep
Definition test.h:211
rheolef::test_basic::self_type
test_basic< T, M, VfTag > self_type
Definition test.h:224
rheolef::test_basic< T, M, vf_dual_tag_type >::valued_hint
static const space_constant::valued_type valued_hint
Definition test.h:234
rheolef::test_basic::n_derivative
size_type n_derivative() const
Definition test.h:236
rheolef::test_basic::operator[]
details::test_component< T, M, VfTag > operator[](size_type i_comp) const
Definition test_component.h:534
rheolef::test_basic::float_type
typename rep::float_type float_type
Definition test.h:217
rheolef::test_basic::base
smart_pointer< rep > base
Definition test.h:212
rheolef::test_basic::space_type
typename rep::space_type space_type
Definition test.h:219
rheolef::test_basic::geo_type
typename rep::geo_type geo_type
Definition test.h:218
rheolef::test_basic::vf_dual_tag_type
typename details::dual_vf_tag< VfTag >::type vf_dual_tag_type
Definition test.h:223
rheolef::test_basic::test_basic
test_basic(const space_type &V)
Definition test.h:229
rheolef::test_basic::is_elementwise
typename rep::is_elementwise is_elementwise
Definition test.h:221
rheolef::test_basic::evaluate_on_side
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
rheolef::test_basic::local_dg_merge_on_side
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
rheolef::test_basic::evaluate
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
rheolef::test_basic::initialize
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
rheolef::test_basic::scalar_type
typename rep::scalar_type scalar_type
Definition test.h:216
rheolef::test_basic::valued_tag
space_constant::valued_type valued_tag() const
Definition test.h:235
rheolef::test_basic::get_vf_space
const space_type & get_vf_space() const
Definition test.h:233
rheolef::test_rep
Definition test.h:93
rheolef::test_rep::value_type
undeterminated_basic< T > value_type
Definition test.h:99
rheolef::test_rep::curl_valued_check
void curl_valued_check() const
Definition test.h:175
rheolef::test_rep::initialize
void initialize(const piola_on_pointset< float_type > &pops, const integrate_option &iopt)
Definition test.cc:65
rheolef::test_rep::_V
space_type _V
Definition test.h:196
rheolef::test_rep::_gh
band_basic< float_type, M > _gh
Definition test.h:200
rheolef::test_rep::div_valued_check
void div_valued_check() const
Definition test.h:167
rheolef::test_rep::grad_valued_check
void grad_valued_check() const
Definition test.h:159
rheolef::test_rep::valued_check
void valued_check() const
Definition test.h:152
rheolef::test_rep::_fops
fem_on_pointset< float_type > _fops
Definition test.h:197
rheolef::test_rep::_is_inside_on_local_sides
bool _is_inside_on_local_sides
Definition test.h:198
rheolef::test_rep::_element_initialize_on_side
void _element_initialize_on_side(const geo_element &K, const side_information_type &sid)
rheolef::test_rep::valued_hint
static const space_constant::valued_type valued_hint
Definition test.h:116
rheolef::test_rep::test_rep
test_rep(const space_type &V)
Definition test.cc:30
rheolef::test_rep::n_derivative
size_type n_derivative() const
Definition test.h:118
rheolef::test_rep::diff_type
details::differentiate_option::type diff_type
Definition test.h:104
rheolef::test_rep::_is_on_band
bool _is_on_band
Definition test.h:199
rheolef::test_rep::geo_type
geo_basic< float_type, M > geo_type
Definition test.h:102
rheolef::test_rep::space_type
space_basic< float_type, M > space_type
Definition test.h:103
rheolef::test_rep::evaluate_on_side
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
rheolef::test_rep::local_dg_merge_on_side
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
rheolef::test_rep::memory_type
M memory_type
Definition test.h:98
rheolef::test_rep::_evaluate_init
void _evaluate_init(const reference_element &hat_K) const
rheolef::test_rep::_element_initialize
void _element_initialize(const geo_element &K) const
rheolef::test_rep::is_elementwise
std::true_type is_elementwise
Definition test.h:105
rheolef::test_rep::evaluate
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
rheolef::test_rep::operator=
test_rep< T, M > & operator=(const test_rep< T, M > &)
Definition test.cc:50
rheolef::test_rep::float_type
typename float_traits< T >::type float_type
Definition test.h:101
rheolef::test_rep::scalar_type
T scalar_type
Definition test.h:100
rheolef::test_rep::size_type
std::size_t size_type
Definition test.h:97
rheolef::test_rep::valued_tag
space_constant::valued_type valued_tag() const
Definition test.h:117
rheolef::test_rep::get_vf_space
const space_type & get_vf_space() const
Definition test.h:115
rheolef::trial
test_basic< Float, rheo_default_memory_model, details::vf_tag_10 > trial
Definition test.h:327
rheolef::test
test_basic< Float, rheo_default_memory_model, details::vf_tag_01 > test
Definition test.h:324
T
Expr1::float_type T
Definition field_expr.h:230
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::space_constant::valued_type
valued_type
Definition space_constant.h:133
rheolef::space_constant::last_valued
@ last_valued
Definition space_constant.h:141
rheolef::space_constant::valued_name
const std::string & valued_name(valued_type valued_tag)
Definition space_constant.cc:43
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::details::differentiate_option
Definition piola.h:41
rheolef::details::differentiate_option::type
type
Definition piola.h:42
rheolef::details::dual_vf_tag::type
vf_tag_nonlinear type
Definition field_expr_variational_tag.h:58
rheolef::float_traits::type
T type
Definition Float.h:94
rheolef::side_information_type
Definition reference_element_face_transformation.h:37
rheolef::space_constant::rank_down::type
undeterminated_basic< typename scalar_traits< T >::type > type
Definition space_constant.h:178
rheolef::space_constant::rank_up::type
point_basic< typename scalar_traits< T >::type > type
Definition space_constant.h:184
rheolef::space_constant::valued_tag_traits::value
static const valued_type value
Definition space_constant.h:159
rheolef::undeterminated_basic
helper for generic field value_type: T, point_basic<T> or tensor_basic<T>
Definition undeterminated.h:32
M
Expr1::memory_type M
Definition vec_expr_v2.h:416