Loading...
Searching...
No Matches
basis_option.cc
Go to the documentation of this file.
//
// author: Pierre.Saramito@imag.fr
//
// date: 2 september 2017
//
#include "basis_option.h"
namespace rheolef {
using namespace std;
static const char* static_node_name[basis_option::max_node+1] = {
"equispaced" ,
"warburton" ,
"fekete" ,
"undefined"
};
static const char* static_raw_polynomial_name[basis_option::max_raw_polynomial+1] = {
"monomial" ,
"bernstein" ,
"dubiner" ,
"undefined"
};
static
basis_option::node_type
node_name2type (string name)
{
for (size_t i = 0; i < basis_option::max_node; ++i) {
if (static_node_name[i] == name) {
return (basis_option::node_type) (i);
}
}
error_macro ("unexpected space node name `" << name << "'");
return basis_option::max_node;
}
static
basis_option::raw_polynomial_type
raw_polynomial_name2type (string name)
{
for (size_t i = 0; i < basis_option::max_raw_polynomial; ++i) {
if (static_raw_polynomial_name[i] == name) {
return (basis_option::raw_polynomial_type) (i);
}
}
error_macro ("unexpected raw polynomial name `" << name << "'");
return basis_option::max_raw_polynomial;
}
bool
basis_option::is_node_name (std::string name) const
{
for (size_t i = 0; i < basis_option::max_node; ++i)
if (static_node_name[i] == name) return true;
return false;
}
bool
basis_option::is_raw_polynomial_name (std::string name) const
{
for (size_t i = 0; i < basis_option::max_raw_polynomial; ++i)
if (static_raw_polynomial_name[i] == name) return true;
return false;
}
bool
basis_option::is_option_name (std::string name) const
{
return is_node_name(name) ||
is_raw_polynomial_name(name) ||
name == "trace_n";
}
void
basis_option::set_node (string name)
{
set_node (node_name2type (name));
}
void
basis_option::set_raw_polynomial (string name)
{
set_raw_polynomial (raw_polynomial_name2type (name));
}
string
basis_option::get_node_name() const
{
check_macro (_node >= 0 && _node <= max_node,
"unexpected space node number = " << _node);
return static_node_name[_node];
}
string
basis_option::get_raw_polynomial_name() const
{
check_macro (_poly >= 0 && _poly <= max_raw_polynomial,
"unexpected space raw polynomial number = " << _poly);
return static_raw_polynomial_name[_poly];
}
void
basis_option::set (std::string option_name)
{
if (is_node_name (option_name)) {
set_node (option_name);
} else if (is_raw_polynomial_name (option_name)) {
set_raw_polynomial (option_name);
} else if (option_name == "trace_n") {
set_trace_n();
} else {
error_macro ("unexpected option name `" << option_name << "'");
}
}
string
basis_option::stamp() const
{
if (_node == default_node && _poly == default_raw_polynomial) {
return "";
}
string opt_trace = ""; // trace_n : arround as "trace(Pkd)"
if (_poly == default_raw_polynomial) {
return "[" + opt_trace + get_node_name() + "]";
}
if (_node == default_node) {
return "[" + opt_trace + get_raw_polynomial_name() + "]";
}
return "[" + opt_trace + get_node_name() + "," + get_raw_polynomial_name() + "]";
}
} // namespace rheolef
basis_option.h
basis_option - finite element method options
rheolef::basis_option::_poly
raw_polynomial_type _poly
Definition basis_option.h:163
rheolef::basis_option::is_raw_polynomial_name
bool is_raw_polynomial_name(std::string name) const
Definition basis_option.cc:75
rheolef::basis_option::get_raw_polynomial_name
std::string get_raw_polynomial_name() const
Definition basis_option.cc:106
rheolef::basis_option::default_node
static const node_type default_node
Definition basis_option.h:115
rheolef::basis_option::set_trace_n
void set_trace_n(bool r=true)
Definition basis_option.h:281
rheolef::basis_option::node_type
node_type
Definition basis_option.h:101
rheolef::basis_option::max_node
@ max_node
Definition basis_option.h:105
rheolef::basis_option::get_node_name
std::string get_node_name() const
Definition basis_option.cc:99
rheolef::basis_option::default_raw_polynomial
static const raw_polynomial_type default_raw_polynomial
Definition basis_option.h:116
rheolef::basis_option::is_option_name
bool is_option_name(std::string name) const
Definition basis_option.cc:82
rheolef::basis_option::stamp
std::string stamp() const
Definition basis_option.cc:126
rheolef::basis_option::set
void set(std::string option_name)
Definition basis_option.cc:113
rheolef::basis_option::set_node
void set_node(node_type type)
Definition basis_option.h:257
rheolef::basis_option::is_node_name
bool is_node_name(std::string name) const
Definition basis_option.cc:68
rheolef::basis_option::_node
node_type _node
Definition basis_option.h:162
rheolef::basis_option::set_raw_polynomial
void set_raw_polynomial(raw_polynomial_type type)
Definition basis_option.h:263
rheolef::basis_option::raw_polynomial_type
raw_polynomial_type
Definition basis_option.h:108
rheolef::basis_option::max_raw_polynomial
@ max_raw_polynomial
Definition basis_option.h:112
rheolef::static_node_name
static const char * static_node_name[basis_option::max_node+1]
Definition basis_option.cc:31
rheolef::static_raw_polynomial_name
static const char * static_raw_polynomial_name[basis_option::max_raw_polynomial+1]
Definition basis_option.cc:37
error_macro
#define error_macro(message)
Definition dis_macros.h:49
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
This file is part of Rheolef.
Definition compiler_eigen.h:39
std
STL namespace.