deal2lkit: A ToolKit library for Deal.II
ParsedMappedFunctions< spacedim > Class Template Reference

ParsedMappedFunctions object. More...

#include <parsed_mapped_functions.h>

Inheritance diagram for ParsedMappedFunctions< spacedim >:
ParameterAcceptor Subscriptor ParsedDirichletBCs< dim, spacedim >

Public Member Functions

 ParsedMappedFunctions (const std::string &name="Mapped Functions", const unsigned int &n_components=1, const std::string &component_names="", const std::string &default_id_components="0=ALL", const std::string &default_id_functions="", const std::string &default_constants="")
 Constructor. More...
 
shared_ptr< dealii::Functions::ParsedFunction< spacedim > > get_mapped_function (const unsigned int &id) const
 return a shared_ptr to the ParsedFunction corresponding to the given id More...
 
shared_ptr< dealii::Functions::ParsedFunction< spacedim > > get_mapped_normal_function (const unsigned int &id, const unsigned int &fcv) const
 return a shared_ptr to the ParsedFunction corresponding to the given id the function has spacedim components More...
 
ComponentMask get_mapped_mask (const unsigned int &id) const
 return the ComponentMask corresponding to the given id More...
 
std::vector< unsigned int > get_mapped_ids () const
 return the list of the mapped ids More...
 
std::vector< unsigned int > get_mapped_normal_ids () const
 return the list of the mapped ids for which normal components have been set More...
 
virtual void declare_parameters (ParameterHandler &prm)
 declare_parameters is inherithed by ParameterAcceptor More...
 
virtual void parse_parameters_call_back ()
 parse_parameters_call_back is inherithed by ParameterAcceptor More...
 
bool acts_on_id (unsigned int &id) const
 return true if there is a function that acts on the passed id More...
 
void set_time (const double &t)
 set time equal to t for all the mapped functions More...
 
 DeclException2 (ExcIdsMismatch, unsigned int, unsigned int,<< "The number of ids specified in the field "<< "'IDs and component masks' ("<< arg1<< ") "<< "must match the number of ids "<< "set in the field 'IDs and expressions' ("<< arg2<<").")
 Mismatch between the number of ids set in 'IDs and component masks' and 'IDs and expressions'. More...
 
 DeclException1 (ExcIdNotFound, unsigned int,<< "No entry with the id "<< arg1<< " exists.")
 An entry with this id does not exist in this object. More...
 
 DeclException1 (ExcIdNotMatch, unsigned int,<< "No component mask associated to the id "<< arg1<< " are defined.")
 No component mask are defined on this id. More...
 
 DeclException3 (ExcWrongComponent, unsigned int, unsigned int, unsigned int,<< "At id "<< arg1<< ", wrong component number has been used: "<< arg2<< " is not in the range [0, "<< arg3<<").")
 Wrong number of component mask is defined on this id. More...
 
 DeclException3 (ExcWrongVariable, unsigned int, std::string, std::vector< std::string >,<< "At id "<< arg1<< ", wrong variabile name has been used: "<< arg2<< " does not belong to the knwon variables: "<< print(unique(arg3))<<".")
 Wrong variable name is defined on this id. More...
 
- Public Member Functions inherited from ParameterAcceptor
 ParameterAcceptor (const std::string section_name="")
 The constructor adds derived classes to the list of acceptors. More...
 
virtual ~ParameterAcceptor ()
 The destructor sets to zero the pointer relative to this index, so that it is safe to destroy the mother class. More...
 
virtual void parse_parameters (ParameterHandler &prm)
 Parse the parameter file. More...
 
std::string get_section_name () const
 Return the section name of this class. More...
 
std::vector< std::string > get_section_path () const
 Travers all registered classes, and figure out what subsections we need to enter. More...
 
template<class T >
void add_parameter (ParameterHandler &prm, T *parameter, const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation=std::string())
 Add a parameter the given parameter list. More...
 
template<class T >
void add_parameter (T &parameter, const std::string &entry, const std::string &documentation=std::string(), ParameterHandler &prm=ParameterAcceptor::prm)
 Add a parameter to the global parameter handler ParameterAcceptor::prm. More...
 
void enter_my_subsection (ParameterHandler &prm)
 Make sure we enter the right subsection of the global parameter file. More...
 
void leave_my_subsection (ParameterHandler &prm)
 This function undoes what the enter_my_subsection() function did. More...
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const double &)
 double More...
 
template<>
std::string to_string (const double &entry)
 
template<>
double to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const int &)
 int More...
 
template<>
std::string to_string (const int &entry)
 
template<>
int to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const unsigned int &)
 unsigned int More...
 
template<>
std::string to_string (const unsigned int &entry)
 
template<>
unsigned int to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const bool &)
 bool More...
 
template<>
std::string to_string (const bool &entry)
 
template<>
bool to_type (const std::string &parameter)
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
void serialize (Archive &ar, const unsigned int version)
 

Protected Member Functions

void split_id_components (const std::string &parsed_idcomponents)
 
void split_id_functions (const std::string &parsed_idfunctions, const std::string &constants)
 
void add_normal_components ()
 
void set_normal_functions ()
 

Protected Attributes

std::string name
 
std::string str_id_components
 
std::string str_id_functions
 
std::string str_component_names
 
std::string str_constants
 
std::vector< std::string > _component_names
 
std::vector< std::string > _normal_components
 
std::vector< std::string > _all_components
 
std::vector< unsigned int > ids
 
std::vector< unsigned int > normal_ids
 
std::map< unsigned int, ComponentMaskid_components
 
std::map< unsigned int, shared_ptr< dealii::Functions::ParsedFunction< spacedim > > > id_functions
 
std::map< unsigned int, std::pair< ComponentMask, shared_ptr< dealii::Functions::ParsedFunction< spacedim > > > > mapped_functions
 
std::map< std::string, std::pair< std::vector< unsigned int >, unsigned int > > mapped_normal_components
 
std::vector< std::pair< unsigned int, std::string > > normal_components
 
std::map< unsigned int, std::string > id_str_functions
 
std::map< std::pair< unsigned int, unsigned int >, shared_ptr< dealii::Functions::ParsedFunction< spacedim > > > _normal_functions
 
const unsigned int n_components
 
- Protected Attributes inherited from ParameterAcceptor
const std::string section_name
 The subsection name for this class. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ParameterAcceptor
static void initialize (const std::string filename="", const std::string outfilename="")
 Call declare_all_parameters(), read filename (if it is present as input parameter) and parse_all_parameters() on the static member prm. More...
 
static void clear ()
 Clear class list and global parameter file. More...
 
static void parse_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm)
 Parse the given ParameterHandler. More...
 
static void log_info ()
 Print information about all stored classes. More...
 
static void declare_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm)
 Initialize the ParameterHandler with all derived classes parameters.This function enters the subsection returned by get_section_name() for each derived class, and declares all parameters that were added using add_parameter(). More...
 
template<class T >
static std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const T &)
 Given a class T, construct its default pattern to be used when declaring parameters. More...
 
template<class T >
static T to_type (const std::string &)
 Given a string, fill the value of the given parameter. More...
 
template<class T >
static std::string to_string (const T &)
 Given a parameter, return a string containing the given parameter. More...
 
- Static Public Member Functions inherited from Subscriptor
static::ExceptionBase & ExcInUse (int arg1, char *arg2, std::string &arg3)
 
static::ExceptionBase & ExcNoSubscriber (char *arg1, char *arg2)
 
- Static Public Attributes inherited from ParameterAcceptor
static ParameterHandler prm
 Static parameter. More...
 

Detailed Description

template<int spacedim>
class ParsedMappedFunctions< spacedim >

ParsedMappedFunctions object.

It allows you to set a mapped functions, i.e., parsed functions acting on specified id (boundary_id, material_id,etc..) and on specified components.

Dirichlet Boundary conditions, Neumann boundary conditions and forcing terms can be easily handled with this class.

A typical usage of this class is the following

// the following variables are set just for the sake of completeness
unsigned int spacedim = 2;
unsigned int n_components = 3; // number of components of the problem
// create parsed_mapped_functions object
parsed_mapped_functions("Forcing terms", // name for the section of the Parameter Handler to use
n_components, // The number of components of the function
"u,u,p", // names of known components that can be used instead of component numbers
"0=u % 1=2 % 6=ALL", // boundary_id = component;other_component % other_id = comp; other_comp
"0=x;y;0 % 1=0;0;0 % 6=y*k;0;k", // boundary_id = expression % other_id = other_expression
"k=1"); // list of constants that can be used in the above epressions
...
unsigned int id = cell->material_id();
std::vector<double> fs(n_q_points);
parsed_mapped_functions.get_mapped_function(id)->value_list(fe_values.get_quadrature_points(), fs);

Definition at line 71 of file parsed_mapped_functions.h.

Constructor & Destructor Documentation

§ ParsedMappedFunctions()

template<int spacedim>
ParsedMappedFunctions< spacedim >::ParsedMappedFunctions ( const std::string &  name = "Mapped Functions",
const unsigned int &  n_components = 1,
const std::string &  component_names = "",
const std::string &  default_id_components = "0=ALL",
const std::string &  default_id_functions = "",
const std::string &  default_constants = "" 
)

Constructor.

It takes:

  • the name for the section of the Parameter Handler to use
  • the number of components that this function has
  • the default names of known components that can be used instead of component numbers
  • a list of ids and components where the boundary conditions must be applied, which is a string with the following pattern boundary_id = component;other_component % other_id = comp; other_comp
  • a list of ids and exprssions defined over the ids (if this string is left empty, ZeroFunction is imposed on the above specified ids and components)
  • list of constants that can be used in the above epressions

Definition at line 22 of file parsed_mapped_functions.cc.

Member Function Documentation

§ acts_on_id()

template<int spacedim>
bool ParsedMappedFunctions< spacedim >::acts_on_id ( unsigned int &  id) const

return true if there is a function that acts on the passed id

Definition at line 306 of file parsed_mapped_functions.cc.

§ add_normal_components()

template<int spacedim>
void ParsedMappedFunctions< spacedim >::add_normal_components ( )
protected

Definition at line 38 of file parsed_mapped_functions.cc.

§ declare_parameters()

template<int spacedim>
void ParsedMappedFunctions< spacedim >::declare_parameters ( ParameterHandler prm)
virtual

declare_parameters is inherithed by ParameterAcceptor

Reimplemented from ParameterAcceptor.

Reimplemented in ParsedDirichletBCs< dim, spacedim >.

Definition at line 257 of file parsed_mapped_functions.cc.

§ DeclException1() [1/2]

template<int spacedim>
ParsedMappedFunctions< spacedim >::DeclException1 ( ExcIdNotFound  ,
unsigned  int,
<< "No entry with the id "<< arg1<< " exists."   
)

An entry with this id does not exist in this object.

§ DeclException1() [2/2]

template<int spacedim>
ParsedMappedFunctions< spacedim >::DeclException1 ( ExcIdNotMatch  ,
unsigned  int,
<< "No component mask associated to the id "<< arg1<< " are defined."   
)

No component mask are defined on this id.

§ DeclException2()

template<int spacedim>
ParsedMappedFunctions< spacedim >::DeclException2 ( ExcIdsMismatch  ,
unsigned  int,
unsigned  int,
<< "The number of ids specified in the field "<< "'IDs and component masks' ("<< arg1<< ") "<< "must match the number of ids "<< "set in the field 'IDs and expressions' ("<< arg2<<")."   
)

Mismatch between the number of ids set in 'IDs and component masks' and 'IDs and expressions'.

§ DeclException3() [1/2]

template<int spacedim>
ParsedMappedFunctions< spacedim >::DeclException3 ( ExcWrongComponent  ,
unsigned  int,
unsigned  int,
unsigned  int,
<< "At id "<< arg1<< "  ,
wrong component number has been used:"<< arg2<< " is not in the range [  0,
"<< arg3<<"   
)

Wrong number of component mask is defined on this id.

§ DeclException3() [2/2]

template<int spacedim>
ParsedMappedFunctions< spacedim >::DeclException3 ( ExcWrongVariable  ,
unsigned  int,
std::string  ,
std::vector< std::string >  ,
<< "At id "<< arg1<< "  ,
wrong variabile name has been used:"<< arg2<< " does not belong to the knwon variables:"<< print(unique(arg3))<<"."   
)

Wrong variable name is defined on this id.

§ get_mapped_function()

template<int spacedim>
shared_ptr< dealii::Functions::ParsedFunction< spacedim > > ParsedMappedFunctions< spacedim >::get_mapped_function ( const unsigned int &  id) const

return a shared_ptr to the ParsedFunction corresponding to the given id

Definition at line 229 of file parsed_mapped_functions.cc.

§ get_mapped_ids()

template<int spacedim>
std::vector< unsigned int > ParsedMappedFunctions< spacedim >::get_mapped_ids ( ) const

return the list of the mapped ids

Definition at line 245 of file parsed_mapped_functions.cc.

§ get_mapped_mask()

template<int spacedim>
ComponentMask ParsedMappedFunctions< spacedim >::get_mapped_mask ( const unsigned int &  id) const

return the ComponentMask corresponding to the given id

Definition at line 237 of file parsed_mapped_functions.cc.

§ get_mapped_normal_function()

template<int spacedim>
shared_ptr< dealii::Functions::ParsedFunction< spacedim > > ParsedMappedFunctions< spacedim >::get_mapped_normal_function ( const unsigned int &  id,
const unsigned int &  fcv 
) const

return a shared_ptr to the ParsedFunction corresponding to the given id the function has spacedim components

Definition at line 219 of file parsed_mapped_functions.cc.

§ get_mapped_normal_ids()

template<int spacedim>
std::vector< unsigned int > ParsedMappedFunctions< spacedim >::get_mapped_normal_ids ( ) const

return the list of the mapped ids for which normal components have been set

Definition at line 251 of file parsed_mapped_functions.cc.

§ parse_parameters_call_back()

template<int spacedim>
void ParsedMappedFunctions< spacedim >::parse_parameters_call_back ( )
virtual

parse_parameters_call_back is inherithed by ParameterAcceptor

Reimplemented from ParameterAcceptor.

Reimplemented in ParsedDirichletBCs< dim, spacedim >.

Definition at line 55 of file parsed_mapped_functions.cc.

§ set_normal_functions()

template<int spacedim>
void ParsedMappedFunctions< spacedim >::set_normal_functions ( )
protected

Definition at line 320 of file parsed_mapped_functions.cc.

§ set_time()

template<int spacedim>
void ParsedMappedFunctions< spacedim >::set_time ( const double &  t)

set time equal to t for all the mapped functions

Definition at line 312 of file parsed_mapped_functions.cc.

§ split_id_components()

template<int spacedim>
void ParsedMappedFunctions< spacedim >::split_id_components ( const std::string &  parsed_idcomponents)
protected

Definition at line 82 of file parsed_mapped_functions.cc.

§ split_id_functions()

template<int spacedim>
void ParsedMappedFunctions< spacedim >::split_id_functions ( const std::string &  parsed_idfunctions,
const std::string &  constants 
)
protected

Definition at line 146 of file parsed_mapped_functions.cc.

Member Data Documentation

§ _all_components

template<int spacedim>
std::vector<std::string> ParsedMappedFunctions< spacedim >::_all_components
protected

Definition at line 195 of file parsed_mapped_functions.h.

§ _component_names

template<int spacedim>
std::vector<std::string> ParsedMappedFunctions< spacedim >::_component_names
protected

Definition at line 193 of file parsed_mapped_functions.h.

§ _normal_components

template<int spacedim>
std::vector<std::string> ParsedMappedFunctions< spacedim >::_normal_components
protected

Definition at line 194 of file parsed_mapped_functions.h.

§ _normal_functions

template<int spacedim>
std::map<std::pair<unsigned int, unsigned int>, shared_ptr<dealii::Functions::ParsedFunction<spacedim> > > ParsedMappedFunctions< spacedim >::_normal_functions
protected

Definition at line 204 of file parsed_mapped_functions.h.

§ id_components

template<int spacedim>
std::map<unsigned int, ComponentMask> ParsedMappedFunctions< spacedim >::id_components
protected

Definition at line 198 of file parsed_mapped_functions.h.

§ id_functions

template<int spacedim>
std::map<unsigned int, shared_ptr<dealii::Functions::ParsedFunction<spacedim> > > ParsedMappedFunctions< spacedim >::id_functions
protected

Definition at line 199 of file parsed_mapped_functions.h.

§ id_str_functions

template<int spacedim>
std::map<unsigned int, std::string> ParsedMappedFunctions< spacedim >::id_str_functions
protected

Definition at line 203 of file parsed_mapped_functions.h.

§ ids

template<int spacedim>
std::vector<unsigned int> ParsedMappedFunctions< spacedim >::ids
protected

Definition at line 196 of file parsed_mapped_functions.h.

§ mapped_functions

template<int spacedim>
std::map<unsigned int, std::pair<ComponentMask, shared_ptr<dealii::Functions::ParsedFunction<spacedim> > > > ParsedMappedFunctions< spacedim >::mapped_functions
protected

Definition at line 200 of file parsed_mapped_functions.h.

§ mapped_normal_components

template<int spacedim>
std::map<std::string, std::pair<std::vector<unsigned int>, unsigned int > > ParsedMappedFunctions< spacedim >::mapped_normal_components
protected

Definition at line 201 of file parsed_mapped_functions.h.

§ n_components

template<int spacedim>
const unsigned int ParsedMappedFunctions< spacedim >::n_components
protected

Definition at line 206 of file parsed_mapped_functions.h.

§ name

template<int spacedim>
std::string ParsedMappedFunctions< spacedim >::name
protected

Definition at line 188 of file parsed_mapped_functions.h.

§ normal_components

template<int spacedim>
std::vector<std::pair<unsigned int, std::string> > ParsedMappedFunctions< spacedim >::normal_components
protected

Definition at line 202 of file parsed_mapped_functions.h.

§ normal_ids

template<int spacedim>
std::vector<unsigned int> ParsedMappedFunctions< spacedim >::normal_ids
protected

Definition at line 197 of file parsed_mapped_functions.h.

§ str_component_names

template<int spacedim>
std::string ParsedMappedFunctions< spacedim >::str_component_names
protected

Definition at line 191 of file parsed_mapped_functions.h.

§ str_constants

template<int spacedim>
std::string ParsedMappedFunctions< spacedim >::str_constants
protected

Definition at line 192 of file parsed_mapped_functions.h.

§ str_id_components

template<int spacedim>
std::string ParsedMappedFunctions< spacedim >::str_id_components
protected

Definition at line 189 of file parsed_mapped_functions.h.

§ str_id_functions

template<int spacedim>
std::string ParsedMappedFunctions< spacedim >::str_id_functions
protected

Definition at line 190 of file parsed_mapped_functions.h.


The documentation for this class was generated from the following files: