Loading...
Searching...
No Matches
basis_on_pointset.h
Go to the documentation of this file.
#ifndef _RHEO_BASIS_ON_POINTSET_V2_H
#define _RHEO_BASIS_ON_POINTSET_V2_H
/*Class:basis_on_pointset
NAME: @code{basis_on_pointset} - pre-evaluated polynomial basis
@cindex polynomial basis
@clindex basis
@cindex reference element
@clindex reference_element
SYNOPSIS:
@noindent
The @code{basis_on_pointset} class is able to memorize the evaluation
of a polynomial basis and its derivatives on a set of point of the reference element
(@pxref{reference_element iclass}).
The basis is described by the @code{basis} class (@pxref{basis class}).
The set of points could be
either quadrature nodes on the reference element (@pxref{quadrature iclass})
or Lagrange nodes associated to another basis.
For application of an integration of on a side, the set of nodes could
be defined on a specific side only.
In all these cases, the evaluation of polynomials could be performed
one time for all on the reference element and its result stored and reused
for all elements of the mesh: the speedup is important, espcially for
high order polynomials.
AUTHOR: Pierre.Saramito@imag.fr
DATE: 4 january 2018
End:
*/
#include "rheolef/basis.h"
#include "rheolef/quadrature.h"
namespace rheolef {
// -----------------------------------------------------------------------
// basis evaluated on lattice of quadrature formulae
// -----------------------------------------------------------------------
template<class T>
class basis_on_pointset_rep {
public:
// typedefs:
typedef typename std::vector<T>::size_type size_type;
typedef enum {
quad_mode = 0,
nodal_mode = 1,
max_mode = 2
} mode_type;
// allocators:
~basis_on_pointset_rep();
basis_on_pointset_rep (const std::string& name = "");
basis_on_pointset_rep (const basis_on_pointset_rep<T>&);
basis_on_pointset_rep<T>& operator= (const basis_on_pointset_rep<T>&);
// modifiers:
void reset (const std::string& name);
// accessors:
std::string name() const;
bool is_set() const { return _mode != max_mode; }
size_type ndof (reference_element hat_K) const;
size_type nnod (reference_element hat_K) const;
const basis_basic<T>& get_basis() const { return _b; }
bool has_quadrature() const { return _mode == quad_mode; }
const quadrature<T>& get_quadrature() const;
const basis_basic<T>& get_nodal_basis() const;
template<class Value>
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
evaluate (reference_element hat_K) const;
template<class Value>
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
evaluate_on_side (
reference_element tilde_L,
const side_information_type& sid) const;
template<class Value>
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
grad_evaluate (reference_element hat_K) const;
template<class Value>
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
grad_evaluate_on_side (
reference_element tilde_L,
const side_information_type& sid) const;
// internal:
static basis_on_pointset_rep<T>* make_ptr (const std::string& name);
static std::string _make_name(
mode_type mode,
const std::string& basis_name,
const std::string& pointset_name);
static mode_type _parse_name (
const std::string& name,
std::string& basis_name,
std::string& node_name);
protected:
// data:
basis_basic<T> _b;
mutable mode_type _mode;
quadrature<T> _quad; // when mode: on quadrature pointset
basis_basic<T> _nb; // when mode: on nodal basis pointset
public:
// _val [tilde_K] (inod,idof)
#define _RHEOLEF_declare_member(VALUE,MEMBER) \
mutable std::array< \
Eigen::Matrix<VALUE,Eigen::Dynamic,Eigen::Dynamic> \
,reference_element::max_variant> MEMBER; \
_RHEOLEF_declare_member(T,_scalar_val)
_RHEOLEF_declare_member(point_basic<T>,_vector_val)
_RHEOLEF_declare_member(tensor_basic<T>,_tensor_val)
_RHEOLEF_declare_member(tensor3_basic<T>,_tensor3_val)
_RHEOLEF_declare_member(tensor4_basic<T>,_tensor4_val)
#undef _RHEOLEF_declare_member
// sid_val [tilde_L][loc_isid][orient][shift] (inod,idof)
#define _RHEOLEF_declare_member(VALUE,MEMBER) \
mutable std::array< \
std::array< \
std::array< \
std::array< \
Eigen::Matrix<VALUE,Eigen::Dynamic,Eigen::Dynamic>, \
8>, \
2>, \
8>, \
reference_element::max_variant> MEMBER;
_RHEOLEF_declare_member(T,_sid_scalar_val)
_RHEOLEF_declare_member(point_basic<T>,_sid_vector_val)
_RHEOLEF_declare_member(tensor_basic<T>,_sid_tensor_val)
_RHEOLEF_declare_member(tensor3_basic<T>,_sid_tensor3_val)
_RHEOLEF_declare_member(tensor4_basic<T>,_sid_tensor4_val)
#undef _RHEOLEF_declare_member
protected:
mutable std::array<bool,
reference_element::max_variant> _initialized;
mutable std::array<bool,
reference_element::max_variant> _grad_initialized;
mutable std::array<bool,
reference_element::max_variant> _sid_initialized;
// internals:
void _initialize (reference_element hat_K) const;
void _grad_initialize (reference_element hat_K) const;
void _initialize_continued (reference_element hat_K,
const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& hat_node) const;
void _grad_initialize_continued (reference_element hat_K,
const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& hat_node) const;
void _sid_initialize (reference_element tilde_L) const;
void _sid_grad_initialize (reference_element tilde_L) const;
void _sid_initialize (reference_element tilde_L, const side_information_type& sid) const;
void _sid_grad_initialize (reference_element tilde_L, const side_information_type& sid) const;
void _sid_initialize_continued (reference_element tilde_L, const side_information_type& sid,
const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& hat_node) const;
void _sid_grad_initialize_continued (reference_element tilde_L, const side_information_type& sid,
const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& hat_node) const;
};
// -----------------------------------------------------------------------
// interface with shallow copy semantic
// -----------------------------------------------------------------------
//<verbatim:
template<class T>
class basis_on_pointset: public smart_pointer<basis_on_pointset_rep<T>>,
public persistent_table<basis_on_pointset<T>> {
public:
typedef basis_on_pointset_rep<T> rep;
typedef smart_pointer<rep> base;
typedef typename rep::size_type size_type;
// allocators:
basis_on_pointset (const std::string& name = "");
basis_on_pointset (const quadrature<T>& quad, const basis_basic<T>& b);
basis_on_pointset (const basis_basic<T>& nb, const basis_basic<T>& b);
// modifiers:
void reset (const std::string& name);
void set (const quadrature<T>& quad, const basis_basic<T>& b);
void set (const basis_basic<T>& nb, const basis_basic<T>& b);
// accessors:
bool is_set() const;
const basis_basic<T>& get_basis() const;
size_type ndof (reference_element hat_K) const;
size_type nnod (reference_element hat_K) const;
bool has_quadrature() const;
const quadrature<T>& get_quadrature() const;
const basis_basic<T>& get_nodal_basis() const;
template<class Value>
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
evaluate (reference_element hat_K) const;
template<class Value>
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
evaluate_on_side (
reference_element tilde_L,
const side_information_type& sid) const;
template<class Value>
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
grad_evaluate (reference_element hat_K) const;
template<class Value>
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
grad_evaluate_on_side (
reference_element tilde_L,
const side_information_type& sid) const;
};
//>verbatim:
// -----------------------------------------------------------------------
// inlined
// -----------------------------------------------------------------------
template<class T>
inline
const basis_basic<T>&
basis_on_pointset<T>::get_basis() const
{
return base::data().get_basis();
}
template<class T>
inline
typename basis_on_pointset<T>::size_type
basis_on_pointset<T>::ndof (reference_element hat_K) const
{
return base::data().ndof (hat_K);
}
template<class T>
inline
typename basis_on_pointset<T>::size_type
basis_on_pointset<T>::nnod (reference_element hat_K) const
{
return base::data().nnod (hat_K);
}
template<class T>
inline
bool
basis_on_pointset<T>::has_quadrature() const
{
return base::data().has_quadrature();
}
template<class T>
inline
const quadrature<T>&
basis_on_pointset<T>::get_quadrature() const
{
return base::data().get_quadrature();
}
template<class T>
inline
const basis_basic<T>&
basis_on_pointset<T>::get_nodal_basis() const
{
return base::data().get_nodal_basis();
}
template<class T>
inline
bool
basis_on_pointset<T>::is_set() const
{
return base::data().is_set();
}
template<class T>
template<class Value>
inline
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
basis_on_pointset<T>::evaluate (reference_element hat_K) const
{
return base::data().template evaluate<Value> (hat_K);
}
template<class T>
template<class Value>
inline
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
basis_on_pointset<T>::grad_evaluate (reference_element hat_K) const
{
return base::data().template grad_evaluate<Value> (hat_K);
}
template<class T>
template<class Value>
inline
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
basis_on_pointset<T>::evaluate_on_side (
reference_element tilde_L,
const side_information_type& sid) const
{
return base::data().template evaluate_on_side<Value> (tilde_L, sid);
}
template<class T>
template<class Value>
inline
const Eigen::Matrix<Value,Eigen::Dynamic,Eigen::Dynamic>&
basis_on_pointset<T>::grad_evaluate_on_side (
reference_element tilde_L,
const side_information_type& sid) const
{
return base::data().template grad_evaluate_on_side<Value> (tilde_L, sid);
}
}// namespace rheolef
#endif // _RHEO_BASIS_ON_POINTSET_V2_H
size_type
field::size_type size_type
Definition branch.cc:430
rheolef::basis_basic
Definition basis.h:566
rheolef::basis_basic::ndof
size_type ndof(reference_element hat_K) const
Definition basis.h:735
rheolef::basis_on_pointset_rep
Definition basis_on_pointset.h:59
rheolef::basis_on_pointset_rep::_sid_grad_initialize
void _sid_grad_initialize(reference_element tilde_L) const
Definition basis_on_pointset.cc:500
rheolef::basis_on_pointset_rep::make_ptr
static basis_on_pointset_rep< T > * make_ptr(const std::string &name)
Definition basis_on_pointset.cc:82
rheolef::basis_on_pointset_rep::_make_name
static std::string _make_name(mode_type mode, const std::string &basis_name, const std::string &pointset_name)
Definition basis_on_pointset.cc:32
rheolef::basis_on_pointset_rep::mode_type
mode_type
Definition basis_on_pointset.h:65
rheolef::basis_on_pointset_rep::quad_mode
@ quad_mode
Definition basis_on_pointset.h:66
rheolef::basis_on_pointset_rep::nodal_mode
@ nodal_mode
Definition basis_on_pointset.h:67
rheolef::basis_on_pointset_rep::max_mode
@ max_mode
Definition basis_on_pointset.h:68
rheolef::basis_on_pointset_rep::grad_evaluate_on_side
const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > & grad_evaluate_on_side(reference_element tilde_L, const side_information_type &sid) const
Definition basis_on_pointset.cc:536
rheolef::basis_on_pointset_rep::name
std::string name() const
Definition basis_on_pointset.cc:47
rheolef::basis_on_pointset_rep::get_basis
const basis_basic< T > & get_basis() const
Definition basis_on_pointset.h:88
rheolef::basis_on_pointset_rep::operator=
basis_on_pointset_rep< T > & operator=(const basis_on_pointset_rep< T > &)
Definition basis_on_pointset.cc:206
rheolef::basis_on_pointset_rep::_RHEOLEF_declare_member
_RHEOLEF_declare_member(T, _scalar_val) _RHEOLEF_declare_member(point_basic< T >
rheolef::basis_on_pointset_rep::has_quadrature
bool has_quadrature() const
Definition basis_on_pointset.h:89
rheolef::basis_on_pointset_rep::_initialized
std::array< bool, reference_element::max_variant > _initialized
Definition basis_on_pointset.h:165
rheolef::basis_on_pointset_rep::_mode
mode_type _mode
Definition basis_on_pointset.h:126
rheolef::basis_on_pointset_rep::reset
void reset(const std::string &name)
Definition basis_on_pointset.cc:167
rheolef::basis_on_pointset_rep::_parse_name
static mode_type _parse_name(const std::string &name, std::string &basis_name, std::string &node_name)
Definition basis_on_pointset.cc:59
rheolef::basis_on_pointset_rep::_b
basis_basic< T > _b
Definition basis_on_pointset.h:125
rheolef::basis_on_pointset_rep::_grad_initialize
void _grad_initialize(reference_element hat_K) const
Definition basis_on_pointset.cc:322
rheolef::basis_on_pointset_rep::_sid_initialize
void _sid_initialize(reference_element tilde_L) const
Definition basis_on_pointset.cc:479
rheolef::basis_on_pointset_rep::ndof
size_type ndof(reference_element hat_K) const
Definition basis_on_pointset.cc:240
rheolef::basis_on_pointset_rep::_sid_grad_initialize
void _sid_grad_initialize(reference_element tilde_L, const side_information_type &sid) const
rheolef::basis_on_pointset_rep::nnod
size_type nnod(reference_element hat_K) const
Definition basis_on_pointset.cc:230
rheolef::basis_on_pointset_rep::_initialize_continued
void _initialize_continued(reference_element hat_K, const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_node) const
Definition basis_on_pointset.cc:263
rheolef::basis_on_pointset_rep::_sid_grad_initialize_continued
void _sid_grad_initialize_continued(reference_element tilde_L, const side_information_type &sid, const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_node) const
rheolef::basis_on_pointset_rep::is_set
bool is_set() const
Definition basis_on_pointset.h:85
rheolef::basis_on_pointset_rep::_grad_initialize_continued
void _grad_initialize_continued(reference_element hat_K, const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_node) const
Definition basis_on_pointset.cc:287
rheolef::basis_on_pointset_rep::size_type
std::vector< T >::size_type size_type
Definition basis_on_pointset.h:63
rheolef::basis_on_pointset_rep::_nb
basis_basic< T > _nb
Definition basis_on_pointset.h:128
rheolef::basis_on_pointset_rep::_sid_initialized
std::array< bool, reference_element::max_variant > _sid_initialized
Definition basis_on_pointset.h:169
rheolef::basis_on_pointset_rep::get_quadrature
const quadrature< T > & get_quadrature() const
Definition basis_on_pointset.cc:246
rheolef::basis_on_pointset_rep::_grad_initialized
std::array< bool, reference_element::max_variant > _grad_initialized
Definition basis_on_pointset.h:167
rheolef::basis_on_pointset_rep::get_nodal_basis
const basis_basic< T > & get_nodal_basis() const
Definition basis_on_pointset.cc:253
rheolef::basis_on_pointset_rep::grad_evaluate
const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > & grad_evaluate(reference_element hat_K) const
Definition basis_on_pointset.cc:518
rheolef::basis_on_pointset_rep::_initialize
void _initialize(reference_element hat_K) const
Definition basis_on_pointset.cc:308
rheolef::basis_on_pointset_rep::evaluate_on_side
const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > & evaluate_on_side(reference_element tilde_L, const side_information_type &sid) const
Definition basis_on_pointset.cc:526
rheolef::basis_on_pointset_rep::_sid_initialize_continued
void _sid_initialize_continued(reference_element tilde_L, const side_information_type &sid, const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_node) const
Definition basis_on_pointset.cc:393
rheolef::basis_on_pointset_rep::evaluate
const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > & evaluate(reference_element hat_K) const
Definition basis_on_pointset.cc:510
rheolef::basis_on_pointset_rep::_quad
quadrature< T > _quad
Definition basis_on_pointset.h:127
rheolef::basis_on_pointset_rep::~basis_on_pointset_rep
~basis_on_pointset_rep()
Definition basis_on_pointset.cc:87
rheolef::basis_on_pointset
Definition basis_on_pointset.h:192
rheolef::basis_on_pointset::set
void set(const quadrature< T > &quad, const basis_basic< T > &b)
Definition basis_on_pointset.cc:128
rheolef::basis_on_pointset::grad_evaluate_on_side
const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > & grad_evaluate_on_side(reference_element tilde_L, const side_information_type &sid) const
Definition basis_on_pointset.h:325
rheolef::basis_on_pointset::ndof
size_type ndof(reference_element hat_K) const
Definition basis_on_pointset.h:256
rheolef::basis_on_pointset::get_basis
const basis_basic< T > & get_basis() const
Definition basis_on_pointset.h:249
rheolef::basis_on_pointset::has_quadrature
bool has_quadrature() const
Definition basis_on_pointset.h:270
rheolef::basis_on_pointset::reset
void reset(const std::string &name)
Definition basis_on_pointset.cc:95
rheolef::basis_on_pointset::is_set
bool is_set() const
Definition basis_on_pointset.h:291
rheolef::basis_on_pointset::nnod
size_type nnod(reference_element hat_K) const
Definition basis_on_pointset.h:263
rheolef::basis_on_pointset::base
smart_pointer< rep > base
Definition basis_on_pointset.h:196
rheolef::basis_on_pointset::rep
basis_on_pointset_rep< T > rep
Definition basis_on_pointset.h:195
rheolef::basis_on_pointset::get_quadrature
const quadrature< T > & get_quadrature() const
Definition basis_on_pointset.h:277
rheolef::basis_on_pointset::size_type
rep::size_type size_type
Definition basis_on_pointset.h:197
rheolef::basis_on_pointset::get_nodal_basis
const basis_basic< T > & get_nodal_basis() const
Definition basis_on_pointset.h:284
rheolef::basis_on_pointset::grad_evaluate
const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > & grad_evaluate(reference_element hat_K) const
Definition basis_on_pointset.h:307
rheolef::basis_on_pointset::evaluate_on_side
const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > & evaluate_on_side(reference_element tilde_L, const side_information_type &sid) const
Definition basis_on_pointset.h:315
rheolef::basis_on_pointset::evaluate
const Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > & evaluate(reference_element hat_K) const
Definition basis_on_pointset.h:299
rheolef::persistent_table
see the persistent_table page for the full documentation
Definition persistent_table.h:84
rheolef::point_basic
Definition point.h:86
rheolef::quadrature
Definition quadrature.h:186
rheolef::reference_element
see the reference_element page for the full documentation
Definition reference_element.h:66
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition reference_element.h:82
rheolef::smart_pointer
see the smart_pointer page for the full documentation
Definition smart_pointer.h:351
rheolef::tensor3_basic
Definition tensor3.h:73
rheolef::tensor4_basic
Definition tensor4.h:80
rheolef::tensor_basic
Definition tensor.h:90
T
Expr1::float_type T
Definition field_expr.h:230
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::side_information_type
Definition reference_element_face_transformation.h:37