basis_fem_Pk_sherwin.cc
Go to the documentation of this file.
#include "basis_fem_Pk_sherwin.h"
#include "basis_fem_Pk_lagrange.h"
#include "piola_fem_lagrange.h"
#include "rheolef/rheostream.h"
#include "equispaced.icc"
#include "warburton.icc"
#include "sherwin.icc"
#include "eigen_util.h"
#include "basis_on_pointset_evaluate.icc"
namespace rheolef {
using namespace std;
// =========================================================================
// basis members
// =========================================================================
template<class T>
basis_fem_Pk_sherwin<T>::~basis_fem_Pk_sherwin()
{
}
template<class T>
basis_fem_Pk_sherwin<T>::basis_fem_Pk_sherwin (size_type degree, const basis_option& sopt)
: base (sopt),
_degree(degree),
_alpha(1.0),
_beta(1.0)
#ifdef TODO
,
_value_ad(),
_work0_ad(),
_work1_ad(),
_work2_ad()
_work0(),
_work1(),
_work2()
#endif // TODO
{
base::_name = base::standard_naming (family_name(), degree, base::_sopt);
warning_macro ("cstor...");
_alpha = _beta = 1; // 1 or 2, see SheKar-2005 p. 53
_initialize_cstor_sizes();
// piola FEM transformatiion:
typedef piola_fem_lagrange<T> piola_fem_type;
base::_piola_fem.piola_fem<T>::base::operator= (new_macro(piola_fem_type));
warning_macro ("cstor done");
}
template<class T>
void
basis_fem_Pk_sherwin<T>::_initialize_cstor_sizes() const
{
basis_fem_Pk_lagrange<T>::initialize_local_first (
degree(),
base::is_continuous(),
base::_ndof_on_subgeo,
base::_nnod_on_subgeo,
base::_first_idof_by_dimension,
base::_first_inod_by_dimension);
}
template<class T>
void
basis_fem_Pk_sherwin<T>::_initialize_data (reference_element hat_K) const
{
// initialization is similar to Pk-Lagrange
size_type k = degree();
size_type variant = hat_K.variant();
fatal_macro ("sherwin: not yet");
#ifdef TODO // requires a _raw_basis here
// nodes: TODO: volume-internal nodes should be quadrature, because of integral dofs
switch (base::_sopt.get_node()) {
case basis_option::equispaced:
pointset_lagrange_equispaced (hat_K, k, base::_hat_node[variant]);
break;
case basis_option::warburton:
pointset_lagrange_warburton (hat_K, k, base::_hat_node[variant]); break;
default: error_macro ("unsupported node set: "<<base::_sopt.get_node_name());
}
// vdm:
details::basis_on_pointset_evaluate (_raw_basis, hat_K, base::_hat_node[variant], base::_vdm[variant]);
check_macro (invert(base::_vdm[variant], base::_inv_vdm[variant]),
"unisolvence failed for " << base::name() <<"(" << hat_K.name() << ") basis");
#endif // TODO
}
// evaluation of all basis functions at hat_x:
template<class T>
void
basis_fem_Pk_sherwin<T>::evaluate (
reference_element hat_K,
const point_basic<T>& hat_x,
Eigen::Matrix<T,Eigen::Dynamic,1>& value) const
{
base::_initialize_data_guard (hat_K);
Eigen::Matrix<T,Eigen::Dynamic,1> _work0, _work1, _work2; // TODO: allocate one time for all in class ?
eval_sherwin_basis (hat_x, hat_K, degree(), _alpha, _beta, _work0, _work1, _work2, value);
}
// evaluate the gradient:
template<class T>
void
basis_fem_Pk_sherwin<T>::grad_evaluate (
reference_element hat_K,
const point_basic<T>& hat_x,
Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& value) const
{
base::_initialize_data_guard (hat_K);
point_basic<ad3_basic<T> > hat_x_ad = ad3::point (hat_x);
std::vector<ad3_basic<T> > _work0_ad, _work1_ad, _work2_ad; // TODO: allocate one time for all in class ?
std::array<std::vector<ad3_basic<T> >,
reference_element::max_variant> _value_ad; // TODO: idem
std::vector<ad3_basic<T> >& value_ad = _value_ad [hat_K.variant()];
eval_sherwin_basis (hat_x_ad, hat_K, degree(), _alpha, _beta, _work0_ad, _work1_ad, _work2_ad, value_ad);
size_t loc_ndof = value_ad.size();
value.resize(loc_ndof);
for (size_t loc_idof = 0; loc_idof < loc_ndof; loc_idof++) {
value[loc_idof] = value_ad[loc_idof].grad();
}
}
// dofs for a scalar-valued function
template<class T>
void
basis_fem_Pk_sherwin<T>::_compute_dofs (
reference_element hat_K,
const Eigen::Matrix<T,Eigen::Dynamic,1>& f_xnod,
Eigen::Matrix<T,Eigen::Dynamic,1>& dof) const
{
#ifdef TODO
// TODO: nodal values + integrals inside, instead of Lagrange node
base::_initialize_data_guard (hat_K);
dof = base::_inv_vdm[hat_K.variant()]*f_xnod;
#endif // TODO
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
#define _RHEOLEF_instanciation(T) \
template class basis_fem_Pk_sherwin<T>;
_RHEOLEF_instanciation(Float)
}// namespace rheolef
warburton.icc
sherwin.icc
eigen_util.h
warning_macro
#define warning_macro(message)
Definition: dis_macros.h:53
rheolef::point_basic
Definition: point.h:87
rheolef::basis_fem_Pk_sherwin::_alpha
T _alpha
Definition: basis_fem_Pk_sherwin.h:100
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::basis_fem_Pk_sherwin::_initialize_data
void _initialize_data(reference_element hat_K) const
Definition: basis_fem_Pk_sherwin.cc:82
rheolef::piola_fem_lagrange
Definition: piola_fem_lagrange.h:65
rheolef::pointset_lagrange_equispaced
void pointset_lagrange_equispaced(reference_element hat_K, size_t order_in, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_xnod, size_t internal=0)
Definition: equispaced.icc:44
rheolef::basis_fem_Pk_sherwin::_initialize_cstor_sizes
void _initialize_cstor_sizes() const
Definition: basis_fem_Pk_sherwin.cc:70
rheolef::basis_fem_Pk_sherwin::~basis_fem_Pk_sherwin
~basis_fem_Pk_sherwin()
Definition: basis_fem_Pk_sherwin.cc:38
rheolef::details::basis_on_pointset_evaluate
void basis_on_pointset_evaluate(const Basis &b, const reference_element &hat_K, const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_x, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &vdm)
Definition: basis_on_pointset_evaluate.icc:31
basis_fem_Pk_lagrange.h
rheolef::_RHEOLEF_instanciation
_RHEOLEF_instanciation(Float, sequential, std::allocator< Float >) _RHEOLEF_instanciation(Float
rheolef::value
rheolef::std value
rheolef::basis_option::warburton
@ warburton
Definition: basis_option.h:103
rheolef::basis_fem_Pk_sherwin::basis_fem_Pk_sherwin
basis_fem_Pk_sherwin(size_type degree, const basis_option &sopt)
Definition: basis_fem_Pk_sherwin.cc:42
rheolef::basis_option
see the basis_option page for the full documentation
Definition: basis_option.h:93
rheolef::basis_fem_Pk_sherwin::_compute_dofs
void _compute_dofs(reference_element hat_K, const Eigen::Matrix< T, Eigen::Dynamic, 1 > &f_xnod, Eigen::Matrix< T, Eigen::Dynamic, 1 > &dof) const
Definition: basis_fem_Pk_sherwin.cc:146
rheolef::basis_rep::size_type
reference_element::size_type size_type
Definition: basis.h:214
rheolef::reference_element
see the reference_element page for the full documentation
Definition: reference_element.h:66
mkgeo_ball.variant
variant
Definition: mkgeo_ball.sh:149
rheolef::basis_rep::_piola_fem
piola_fem< T > _piola_fem
Definition: basis.h:394
rheolef::basis_fem_Pk_sherwin::evaluate
void evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< T, Eigen::Dynamic, 1 > &value) const
Definition: basis_fem_Pk_sherwin.cc:108
basis_fem_Pk_sherwin.h
rheolef::reference_element::name
char name() const
Definition: reference_element.h:100
rheolef::reference_element::variant
variant_type variant() const
Definition: reference_element.h:99
rheolef::pointset_lagrange_warburton
void pointset_lagrange_warburton(reference_element hat_K, size_t degree, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_xnod, bool map_on_reference_element=true)
Definition: warburton.icc:574
rheolef::basis_rep::_sopt
basis_option _sopt
Definition: basis.h:393
fatal_macro
#define fatal_macro(message)
Definition: dis_macros.h:33
rheolef::basis_fem_Pk_sherwin::_beta
T _beta
Definition: basis_fem_Pk_sherwin.h:101
rheolef::basis_rep::_name
std::string _name
Definition: basis.h:392
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::basis_fem_Pk_lagrange::initialize_local_first
static void initialize_local_first(size_type k, bool is_continuous, std::array< std::array< size_type, reference_element::max_variant >, 4 > &ndof_on_subgeo, std::array< std::array< size_type, reference_element::max_variant >, 4 > &nnod_on_subgeo, std::array< std::array< size_type, 5 >, reference_element::max_variant > &first_idof_by_dimension, std::array< std::array< size_type, 5 >, reference_element::max_variant > &first_inod_by_dimension)
Definition: basis_fem_Pk_lagrange.cc:41
error_macro
#define error_macro(message)
Definition: dis_macros.h:49
Float
see the Float page for the full documentation
basis_on_pointset_evaluate.icc
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition: reference_element.h:82
rheolef::basis_fem_Pk_sherwin::family_name
std::string family_name() const
Definition: basis_fem_Pk_sherwin.h:72
rheolef::basis_option::equispaced
@ equispaced
Definition: basis_option.h:102
rheolef::basis_fem_Pk_sherwin::grad_evaluate
void grad_evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &value) const
Definition: basis_fem_Pk_sherwin.cc:122
equispaced.icc
rheolef::basis_rep::standard_naming
static std::string standard_naming(std::string family_name, size_t degree, const basis_option &sopt)
Definition: basis_rep.cc:44
rheolef::invert
void invert(tiny_matrix< T > &a, tiny_matrix< T > &inv_a)
Definition: tiny_lu.h:127
rheolef::basis_fem_Pk_sherwin::degree
size_type degree() const
Definition: basis_fem_Pk_sherwin.h:73
piola_fem_lagrange.h
mkgeo_contraction.name
name
Definition: mkgeo_contraction.sh:133
rheolef::basis_rep
Definition: basis.h:209
T
Expr1::float_type T
Definition: field_expr.h:218