basis_rep.cc
Go to the documentation of this file.
#include "rheolef/basis.h"
#include "rheolef/basis_get.h"
namespace rheolef {
using namespace std;
// =========================================================================
// naming scheme for standard FEM families
// =========================================================================
static
bool
is_family_no_index (const std::string& family_name)
{
// TODO: how to merge this keywords list with basis_lex.flex ?
// basis::have_index_parameter() givzes the response, but requires a
// previously builded basis
if (family_name == "bubble") return true;
if (family_name == "P1qd") return true;
if (family_name == "empty") return true;
return false;
}
template <class T>
std::string
basis_rep<T>::standard_naming (
std::string family_name,
size_type index,
const basis_option& sopt)
{
string opt_d = (sopt.is_continuous() || (family_name == "P" && index == 0)) ? "" : "d";
string basename = is_family_no_index (family_name) ? family_name : family_name + itos(index) + opt_d;
string scalar_name = basename + sopt.stamp();
if (sopt.valued_tag() == space_constant::scalar) {
trace_macro("standard_naming("<<family_name<<","<<index<<",opts)=\""<<scalar_name<<"\"");
if (! sopt.is_restricted_to_sides()) {
return scalar_name;
} else {
return "trace(" + scalar_name + ")";
}
}
const size_type unset = std::numeric_limits<basis_option::size_type>::max();
string opt_dim = (sopt.dimension() == unset) ? "" : "d=" + itos(sopt.dimension());
string opt_sc = (sopt.valued_tag() == space_constant::vector || sopt.coordinate_system() == space_constant::cartesian) ?
"" : space_constant::coordinate_system_name(sopt.coordinate_system());
string coma = (opt_dim == "" || opt_sc == "") ? "" : ",";
string opt_valued = (opt_dim == "" && opt_sc == "") ? "" : "[" + opt_dim + coma + opt_sc + "]";
string braced_name = sopt.valued() + opt_valued + "(" + scalar_name + ")";
if (! sopt.is_restricted_to_sides()) {
return braced_name;
} else {
return "trace(" + braced_name + ")";
}
}
// =========================================================================
// basis members (should be inlined)
// =========================================================================
template<class T>
void
basis_basic<T>::reset (std::string& name_in)
{
if (name_in == "") {
base::operator= (0);
} else {
// strip name_in as name: drop "scalar(Pk)" as "Pk" or "P0d" as "P0", to get unique name scheme
family_index_option_type fio;
basis_parse_from_string (name_in, fio);
std::string name = basis_rep<T>::standard_naming (fio.family, fio.index, fio.option);
base::operator= (persistent_table<basis_basic<T>>::load (name));
_clear();
}
}
template<class T>
void
basis_basic<T>::reset_family_index (size_type k)
{
std::string fname = family_name();
basis_option bopt = option();
std::string name = basis_rep<T>::standard_naming (fname, k, bopt); \
reset (name);
}
template <class T>
basis_rep<T>::~basis_rep()
{
persistent_table<basis_basic<T>>::unload (_name);
}
template<class T>
basis_rep<T>::basis_rep (const basis_option& sopt)
: _name(""),
_sopt(sopt),
_piola_fem(),
_have_initialize_data(),
_ndof_on_subgeo(),
_nnod_on_subgeo(),
_first_idof_by_dimension(),
_first_inod_by_dimension()
{
_clear();
}
template<class T>
void
basis_rep<T>::_clear() const
{
_have_initialize_data.fill (false);
}
template <class T>
void
basis_rep<T>::_initialize_data_guard (reference_element hat_K) const
{
if (_have_initialize_data [hat_K.variant()]) return;
_have_initialize_data [hat_K.variant()] = true;
_initialize_data (hat_K);
}
// inplace change nxxx_on_subgeo for discontinuous elements
template <class T>
void
basis_rep<T>::_helper_discontinuous_ndof_on_subgeo_inplace_change (
bool is_continuous,
std::array<
std::array<
size_type
,reference_element::max_variant>
,4>& nxxx_on_subgeo)
{
std::array<
std::array<
size_type
,reference_element::max_variant>
,4> nxxx_on_subgeo_d;
for (size_type map_dim = 0; map_dim < 4; ++map_dim) {
nxxx_on_subgeo_d [map_dim].fill (0);
}
if (is_continuous) return; // no changes
for (size_type variant = 0;
variant < reference_element::max_variant;
variant++)
{
reference_element hat_K (variant);
size_type map_dim = hat_K.dimension();
size_type sum = 0;
for (size_type subgeo_variant = 0;
subgeo_variant < reference_element:: last_variant_by_dimension(map_dim);
subgeo_variant++)
{
size_type n_subgeo = hat_K.n_subgeo_by_variant (subgeo_variant);
sum += n_subgeo*nxxx_on_subgeo [map_dim][subgeo_variant];
}
nxxx_on_subgeo_d [map_dim][variant] = sum;
}
nxxx_on_subgeo = nxxx_on_subgeo_d;
}
// deduce automatically first_ixxx_by_dimension from nxxx_on_subgeo
template <class T>
void
basis_rep<T>::_helper_initialize_first_ixxx_by_dimension_from_nxxx_on_subgeo (
const std::array<
std::array<
size_type
,reference_element::max_variant>
,4>& nxxx_on_subgeo,
std::array<
std::array<
size_type
,5>
,reference_element::max_variant>& first_ixxx_by_dimension)
{
for (size_type variant = 0;
variant < reference_element::max_variant;
variant++)
{
reference_element hat_K (variant);
size_type map_dim = hat_K.dimension();
first_ixxx_by_dimension [variant].fill(0);
for (size_type subgeo_dim = 0; subgeo_dim <= map_dim; ++subgeo_dim) {
size_type sum = first_ixxx_by_dimension [variant][subgeo_dim];
for (size_type subgeo_variant = reference_element::first_variant_by_dimension(subgeo_dim);
subgeo_variant < reference_element:: last_variant_by_dimension(subgeo_dim);
subgeo_variant++)
{
size_type n_subgeo = hat_K.n_subgeo_by_variant (subgeo_variant);
sum += n_subgeo*nxxx_on_subgeo [map_dim][subgeo_variant];
}
first_ixxx_by_dimension [variant][subgeo_dim+1] = sum;
}
}
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
#define _RHEOLEF_instanciation(T) \
template class basis_rep<T>; \
template void basis_basic<T>::reset (std::string&); \
template void basis_basic<T>::reset_family_index (size_type); \
_RHEOLEF_instanciation(Float)
}// namespace rheolef
rheolef::reference_element::last_variant_by_dimension
static variant_type last_variant_by_dimension(size_type dim)
Definition: reference_element.h:150
rheolef::space_constant::coordinate_system_name
std::string coordinate_system_name(coordinate_type i)
Definition: space_constant.cc:69
rheolef::basis_option::valued
const std::string & valued() const
Definition: basis_option.h:251
rheolef::basis_option::is_restricted_to_sides
bool is_restricted_to_sides() const
Definition: basis_option.h:239
rheolef::family_index_option_type::family
std::string family
Definition: basis_get.h:34
rheolef::basis_basic::reset
void reset(std::string &name)
Definition: basis_rep.cc:78
rheolef::basis_rep::_initialize_data_guard
void _initialize_data_guard(reference_element hat_K) const
Definition: basis_rep.cc:126
rheolef::basis_option::is_continuous
bool is_continuous() const
Definition: basis_option.h:227
rheolef::family_index_option_type::index
size_t index
Definition: basis_get.h:35
rheolef::basis_rep::_helper_discontinuous_ndof_on_subgeo_inplace_change
static void _helper_discontinuous_ndof_on_subgeo_inplace_change(bool is_continuous, std::array< std::array< size_type, reference_element::max_variant >, 4 > &nxxx_on_subgeo)
Definition: basis_rep.cc:135
rheolef::basis_option::stamp
std::string stamp() const
Definition: basis_option.cc:124
rheolef::_RHEOLEF_instanciation
_RHEOLEF_instanciation(Float, sequential, std::allocator< Float >) _RHEOLEF_instanciation(Float
rheolef::space_constant::cartesian
@ cartesian
Definition: space_constant.h:122
rheolef::basis_rep::_helper_initialize_first_ixxx_by_dimension_from_nxxx_on_subgeo
static void _helper_initialize_first_ixxx_by_dimension_from_nxxx_on_subgeo(const std::array< std::array< size_type, reference_element::max_variant >, 4 > &_nxxx_on_subgeo, std::array< std::array< size_type, 5 >, reference_element::max_variant > &_first_ixxx_by_dimension)
Definition: basis_rep.cc:173
rheolef::size_type
size_t size_type
Definition: basis_get.cc:76
rheolef::basis_option
see the basis_option page for the full documentation
Definition: basis_option.h:93
rheolef::basis_rep::size_type
reference_element::size_type size_type
Definition: basis.h:214
rheolef::reference_element::first_variant_by_dimension
static variant_type first_variant_by_dimension(size_type dim)
Definition: reference_element.h:148
rheolef::basis_basic
Definition: basis.h:206
rheolef::persistent_table
see the persistent_table page for the full documentation
Definition: persistent_table.h:84
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::space_constant::scalar
@ scalar
Definition: space_constant.h:136
rheolef::basis_rep::basis_rep
basis_rep(const basis_option &sopt)
Definition: basis_rep.cc:106
rheolef::basis_option::coordinate_system
coordinate_type coordinate_system() const
Definition: basis_option.h:139
rheolef::basis_rep::_clear
void _clear() const
Definition: basis_rep.cc:120
rheolef::reference_element::variant
variant_type variant() const
Definition: reference_element.h:99
rheolef::basis_rep::~basis_rep
virtual ~basis_rep()
Definition: basis_rep.cc:101
rheolef::family_index_option_type
Definition: basis_get.h:31
rheolef::basis_basic::reset_family_index
void reset_family_index(size_type k)
Definition: basis_rep.cc:93
rheolef::basis_basic::size_type
rep::size_type size_type
Definition: basis.h:539
mkgeo_couette.basename
basename
Definition: mkgeo_couette.sh:73
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::basis_option::dimension
size_type dimension() const
Definition: basis_option.h:138
Float
see the Float page for the full documentation
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition: reference_element.h:82
rheolef::reference_element::dimension
size_type dimension() const
Definition: reference_element.h:101
rheolef::family_index_option_type::option
basis_option option
Definition: basis_get.h:36
load
void load(idiststream &in, Float &p, field &uh)
Definition: p_laplacian_post.cc:64
rheolef::space_constant::vector
@ vector
Definition: space_constant.h:137
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::basis_parse_from_string
void basis_parse_from_string(const std::string &str, family_index_option_type &fio)
Definition: basis_get.cc:142
mkgeo_ball.map_dim
map_dim
Definition: mkgeo_ball.sh:337
rheolef::reference_element::n_subgeo_by_variant
size_type n_subgeo_by_variant(size_type subgeo_variant) const
Definition: reference_element.h:107
rheolef::itos
std::string itos(std::string::size_type i)
itos: see the rheostream page for the full documentation
mkgeo_contraction.name
name
Definition: mkgeo_contraction.sh:133
trace_macro
#define trace_macro(message)
Definition: dis_macros.h:111
rheolef::basis_option::valued_tag
valued_type valued_tag() const
Definition: basis_option.h:245