Loading...
Searching...
No Matches
basis_fem_Pk_bernstein.cc
Go to the documentation of this file.
#include "basis_fem_Pk_bernstein.h"
#include "basis_fem_Pk_lagrange.h"
#include "piola_fem_lagrange.h"
#include "rheolef/rheostream.h"
#include "equispaced.icc"
#include "warburton.icc"
#include "eigen_util.h"
#include "basis_on_pointset_evaluate.icc"
namespace rheolef {
using namespace std;
// =========================================================================
// basis members
// =========================================================================
template<class T>
basis_fem_Pk_bernstein<T>::~basis_fem_Pk_bernstein()
{
}
template<class T>
basis_fem_Pk_bernstein<T>::basis_fem_Pk_bernstein (size_type degree, const basis_option& sopt)
: basis_rep<T> (sopt),
_raw_basis("B"+std::to_string(degree)),
_hat_node(),
_vdm(),
_inv_vdm()
{
// Bezier nodes are equispaced => forced
base::_sopt.set_node(basis_option::equispaced);
base::_name = base::standard_naming (family_name(), degree, base::_sopt);
_initialize_cstor_sizes();
// piola FEM transformation:
typedef piola_fem_lagrange<T> piola_fem_type;
base::_piola_fem.piola_fem<T>::base::operator= (new_macro(piola_fem_type));
}
template<class T>
void
basis_fem_Pk_bernstein<T>::_initialize_cstor_sizes() const
{
basis_fem_Pk_lagrange<T>::initialize_local_first (
degree(),
base::is_continuous(),
base::_ndof_on_subgeo_internal,
base::_ndof_on_subgeo,
base::_nnod_on_subgeo_internal,
base::_nnod_on_subgeo,
base::_first_idof_by_dimension_internal,
base::_first_idof_by_dimension,
base::_first_inod_by_dimension_internal,
base::_first_inod_by_dimension);
}
template<class T>
const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>&
basis_fem_Pk_bernstein<T>::hat_node (reference_element hat_K) const
{
base::_initialize_data_guard (hat_K);
return _hat_node [hat_K.variant()];
}
template<class T>
const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>&
basis_fem_Pk_bernstein<T>::vdm (reference_element hat_K) const
{
base::_initialize_data_guard (hat_K);
return _vdm [hat_K.variant()];
}
template<class T>
const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>&
basis_fem_Pk_bernstein<T>::inv_vdm (reference_element hat_K) const
{
base::_initialize_data_guard (hat_K);
return _inv_vdm [hat_K.variant()];
}
template<class T>
void
basis_fem_Pk_bernstein<T>::_initialize_data (reference_element hat_K) const
{
// initialization is similar to Pk-Lagrange
size_type k = degree();
size_type variant = hat_K.variant();
// nodes:
switch (base::_sopt.get_node()) {
case basis_option::equispaced:
pointset_lagrange_equispaced (hat_K, k, _hat_node[variant]);
break;
case basis_option::warburton:
pointset_lagrange_warburton (hat_K, k, _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, _hat_node[variant], _vdm[variant]);
check_macro (invert(_vdm[variant], _inv_vdm[variant]),
"unisolvence failed for " << base::name() <<"(" << hat_K.name() << ") basis");
}
// evaluation of all basis functions at hat_x:
template<class T>
void
basis_fem_Pk_bernstein<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);
_raw_basis.evaluate (hat_K, hat_x, value);
}
// evaluate the gradient:
template<class T>
void
basis_fem_Pk_bernstein<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);
_raw_basis.grad_evaluate (hat_K, hat_x, value);
}
// dofs for a scalar-valued function
template<class T>
void
basis_fem_Pk_bernstein<T>::_compute_dofs (
reference_element hat_K,
const Eigen::Matrix<T,Eigen::Dynamic,1>& f_xnod,
Eigen::Matrix<T,Eigen::Dynamic,1>& dof) const
{
base::_initialize_data_guard (hat_K);
dof = _inv_vdm[hat_K.variant()]*f_xnod;
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
#define _RHEOLEF_instanciation(T) \
template class basis_fem_Pk_bernstein<T>;
_RHEOLEF_instanciation(Float)
}// namespace rheolef
_RHEOLEF_instanciation
#define _RHEOLEF_instanciation(T, M, A)
Definition asr.cc:223
basis_fem_Pk_bernstein.h
basis_fem_Pk_lagrange.h
basis_on_pointset_evaluate.icc
Float
see the Float page for the full documentation
rheolef::basis_fem_Pk_bernstein::basis_fem_Pk_bernstein
basis_fem_Pk_bernstein(size_type degree, const basis_option &sopt)
Definition basis_fem_Pk_bernstein.cc:41
rheolef::basis_fem_Pk_bernstein::vdm
const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > & vdm(reference_element hat_K) const
Definition basis_fem_Pk_bernstein.cc:82
rheolef::basis_fem_Pk_bernstein::size_type
reference_element::size_type size_type
Definition basis_fem_Pk_bernstein.h:67
rheolef::basis_fem_Pk_bernstein::degree
size_type degree() const
Definition basis_fem_Pk_bernstein.h:78
rheolef::basis_fem_Pk_bernstein::_initialize_cstor_sizes
void _initialize_cstor_sizes() const
Definition basis_fem_Pk_bernstein.cc:59
rheolef::basis_fem_Pk_bernstein::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_bernstein.cc:119
rheolef::basis_fem_Pk_bernstein::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_bernstein.cc:130
rheolef::basis_fem_Pk_bernstein::~basis_fem_Pk_bernstein
~basis_fem_Pk_bernstein()
Definition basis_fem_Pk_bernstein.cc:37
rheolef::basis_fem_Pk_bernstein::_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_bernstein.cc:141
rheolef::basis_fem_Pk_bernstein::hat_node
const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > & hat_node(reference_element hat_K) const
Definition basis_fem_Pk_bernstein.cc:75
rheolef::basis_fem_Pk_bernstein::family_name
std::string family_name() const
Definition basis_fem_Pk_bernstein.h:77
rheolef::basis_fem_Pk_bernstein::inv_vdm
const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > & inv_vdm(reference_element hat_K) const
Definition basis_fem_Pk_bernstein.cc:89
rheolef::basis_fem_Pk_bernstein::_initialize_data
void _initialize_data(reference_element hat_K) const
Definition basis_fem_Pk_bernstein.cc:96
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_internal, 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_internal, 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_internal, 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_internal, std::array< std::array< size_type, 5 >, reference_element::max_variant > &first_inod_by_dimension)
Definition basis_fem_Pk_lagrange.cc:41
rheolef::basis_option
see the basis_option page for the full documentation
Definition basis_option.h:93
rheolef::basis_option::equispaced
@ equispaced
Definition basis_option.h:102
rheolef::basis_option::warburton
@ warburton
Definition basis_option.h:103
rheolef::basis_rep
Definition basis.h:209
rheolef::basis_rep::vector
vector
Definition basis.h:323
rheolef::piola_fem_lagrange
Definition piola_fem_lagrange.h:65
rheolef::point_basic
Definition point.h:86
rheolef::reference_element
see the reference_element page for the full documentation
Definition reference_element.h:66
rheolef::reference_element::variant
variant_type variant() const
Definition reference_element.h:99
rheolef::reference_element::name
char name() const
Definition reference_element.h:100
error_macro
#define error_macro(message)
Definition dis_macros.h:49
eigen_util.h
equispaced.icc
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::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
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
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::invert
void invert(tiny_matrix< T > &a, tiny_matrix< T > &inv_a)
Definition tiny_lu.h:127
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
std
STL namespace.
piola_fem_lagrange.h
warburton.icc