deal2lkit: A ToolKit library for Deal.II
ParsedFiniteElement< dim, spacedim > Class Template Reference

Parsed FiniteElement. More...

#include <parsed_finite_element.h>

Inheritance diagram for ParsedFiniteElement< dim, spacedim >:
ParameterAcceptor Subscriptor

Public Member Functions

 ParsedFiniteElement (const std::string &name="", const std::string &default_fe="FE_Q(1)", const std::string &default_component_names="u", const unsigned int n_components=0)
 Constructor. More...
 
virtual void declare_parameters (ParameterHandler &prm)
 Declare possible parameters of this class. More...
 
FiniteElement< dim, spacedim > * operator() () const
 Return a shared pointer to a newly created Finite Element. More...
 
virtual void parse_parameters_call_back ()
 Fill information about blocks after parsing the parameters. More...
 
std::string get_component_names () const
 Return the component names for this Finite Element. More...
 
std::vector< unsigned int > get_component_blocks () const
 Return the blocking of the components for this finite element. More...
 
std::string get_block_names () const
 Return the block names for this Finite Element. More...
 
unsigned int n_components () const
 Return the number of components of the Finite Element. More...
 
unsigned int n_blocks () const
 Return the number of blocks of the Finite Element, i.e., the number of variables. More...
 
unsigned int get_first_occurence (const std::string &var) const
 Return the first occurence of var in default_component_names. More...
 
bool is_vector (const std::string &var) const
 
- 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 Attributes

const unsigned int _n_components
 Number of components of this FiniteElement. More...
 
std::string fe_name
 Finite Element Name. More...
 
std::string default_component_names
 Default component names. More...
 
std::vector< std::string > component_names
 Block names. More...
 
std::vector< unsigned int > component_blocks
 The subdivision, in terms of component indices. More...
 
std::vector< std::string > block_names
 The subdivision, in terms of block names. More...
 
- 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 dim, int spacedim = dim>
class ParsedFiniteElement< dim, spacedim >

Parsed FiniteElement.

Read from a parameter file the name of a finite element, generate one for you, and return a pointer to it.

The name must be in the form which is returned by the FiniteElement::get_name() function, where dimension template parameters <2> etc. can be omitted. Alternatively, the explicit number can be replaced by dim or d. If a number is given, it must match the template parameter of this function.

The names of FESystem elements follow the pattern FESystem[FE_Base1^p1-FE_Base2^p2] The powers p1 etc. may either be numbers or can be replaced by dim or d.

If no finite element can be reconstructed from this string, an exception of type FETools::ExcInvalidFEName is thrown.

The operator() returns a pointer to a newly create finite element. It is in the caller's responsibility to destroy the object pointed to at an appropriate later time.

Since the value of the template argument can't be deduced from the (string) argument given to this function, you have to explicitly specify it when you call this function.

This function knows about all the standard elements defined in the library. However, it doesn't by default know about elements that you may have defined in your program. To make your own elements known to this function, use the add_fe_name() function.

Definition at line 62 of file parsed_finite_element.h.

Constructor & Destructor Documentation

§ ParsedFiniteElement()

template<int dim, int spacedim>
ParsedFiniteElement< dim, spacedim >::ParsedFiniteElement ( const std::string &  name = "",
const std::string &  default_fe = "FE_Q(1)",
const std::string &  default_component_names = "u",
const unsigned int  n_components = 0 
)

Constructor.

Takes a name for the section of the Parameter Handler to use.

This class is derived from ParameterAcceptor. Once you constructed an object of this class, if you call ParameterAcceptor::parse_all_parameters(prm), also the parameters of this class will be filled with values from the argument ParameterHandler.

The optional parameters specify the FiniteElement name, the component names, the allowed number of components. This class will throw an exception if the number of components is set to something different than zero and the corresponding FiniteElement does not match this number of components. If n_components is left to 0 (the default value), then any FiniteElement can be generated, with arbitrary numbers of components.

Definition at line 25 of file parsed_finite_element.cc.

Member Function Documentation

§ declare_parameters()

template<int dim, int spacedim>
void ParsedFiniteElement< dim, spacedim >::declare_parameters ( ParameterHandler prm)
virtual

Declare possible parameters of this class.

The first parameter which is declared here is "Finite element space". The parameter must be in the form which is returned by the FiniteElement::get_name function, where dimension template parameters <2> etc. can be omitted. Alternatively, the explicit number can be replaced by dim or d. If a number is given, it must match the template parameter of this function.

The names of FESystem elements follow the pattern FESystem[FE_Base1^p1-FE_Base2^p2] The powers p1 etc. may either be numbers or can be replaced by dim or d.

If no finite element can be reconstructed from this string, an exception of type FETools::ExcInvalidFEName is thrown.

The operator() returns a pointer to a newly create finite element. It is in the caller's responsibility to destroy the object pointed to at an appropriate later time.

The second parameter is "Block names". This is comma separeted list of component names which identifies the Finite Elemenet. If a name is repeated, then that component is assumed to be part of a vector field or Tensor field, and is treated as a single block. User classes can use this information to construct block matrices and vectors, or to group solution names according to components. For example, a Stokes problem may have "u,u,p" for dim = 2 or "u, u, u, p" for dim = 3.

The third parameter defined by this function is "Block coupling", which is semicolumn separated list of comma separated indices from 0 to 2 (included), representing a table of coupling between the components (or the blocks). The default for this parameter is the empty string, which is interpreted as "all components couple with all other components". You can specify a block wise coupling (with two blocks, this would be a 2x2 matrix) or a component wise coupling (if a block is made of more than one component, but not all components of the same block couple with the other components). The numbers are interpreted as: 0=DoFTools::none, 1=DoFTools::always, 2=DoFTools::nonzero.

Reimplemented from ParameterAcceptor.

Definition at line 39 of file parsed_finite_element.cc.

§ get_block_names()

template<int dim, int spacedim>
std::string ParsedFiniteElement< dim, spacedim >::get_block_names ( ) const

Return the block names for this Finite Element.

This is the same as std::unique(get_component_names().begin(), get_component_names().end())

Definition at line 116 of file parsed_finite_element.cc.

§ get_component_blocks()

template<int dim, int spacedim>
std::vector< unsigned int > ParsedFiniteElement< dim, spacedim >::get_component_blocks ( ) const

Return the blocking of the components for this finite element.

This is what's needed by the block renumbering algorithm.

Definition at line 123 of file parsed_finite_element.cc.

§ get_component_names()

template<int dim, int spacedim>
std::string ParsedFiniteElement< dim, spacedim >::get_component_names ( ) const

Return the component names for this Finite Element.

Definition at line 109 of file parsed_finite_element.cc.

§ get_first_occurence()

template<int dim, int spacedim>
unsigned int ParsedFiniteElement< dim, spacedim >::get_first_occurence ( const std::string &  var) const

Return the first occurence of var in default_component_names.

Remark: this is the value required by FEValuesExtractors.

Definition at line 129 of file parsed_finite_element.cc.

§ is_vector()

template<int dim, int spacedim>
bool ParsedFiniteElement< dim, spacedim >::is_vector ( const std::string &  var) const

Definition at line 138 of file parsed_finite_element.cc.

§ n_blocks()

template<int dim, int spacedim>
unsigned int ParsedFiniteElement< dim, spacedim >::n_blocks ( ) const

Return the number of blocks of the Finite Element, i.e., the number of variables.

For example, simple Heat equation has 1 block, Navier-Stokes 2 blocks (u and p).

Definition at line 102 of file parsed_finite_element.cc.

§ n_components()

template<int dim, int spacedim>
unsigned int ParsedFiniteElement< dim, spacedim >::n_components ( ) const

Return the number of components of the Finite Element.

Definition at line 95 of file parsed_finite_element.cc.

§ operator()()

template<int dim, int spacedim>
FiniteElement< dim, spacedim > * ParsedFiniteElement< dim, spacedim >::operator() ( ) const

Return a shared pointer to a newly created Finite Element.

It will throw an exception if called before any parsing has occured, or if the number of components of the generated finite element is different from the number of components given at construction time.

Definition at line 66 of file parsed_finite_element.cc.

§ parse_parameters_call_back()

template<int dim, int spacedim>
void ParsedFiniteElement< dim, spacedim >::parse_parameters_call_back ( )
virtual

Fill information about blocks after parsing the parameters.

Reimplemented from ParameterAcceptor.

Definition at line 73 of file parsed_finite_element.cc.

Member Data Documentation

§ _n_components

template<int dim, int spacedim = dim>
const unsigned int ParsedFiniteElement< dim, spacedim >::_n_components
protected

Number of components of this FiniteElement.

If you want to allow for arbitrary components, leave this to its default value 0.

Definition at line 194 of file parsed_finite_element.h.

§ block_names

template<int dim, int spacedim = dim>
std::vector<std::string> ParsedFiniteElement< dim, spacedim >::block_names
protected

The subdivision, in terms of block names.

This is automatically computed from the the component names.

Definition at line 229 of file parsed_finite_element.h.

§ component_blocks

template<int dim, int spacedim = dim>
std::vector<unsigned int> ParsedFiniteElement< dim, spacedim >::component_blocks
protected

The subdivision, in terms of component indices.

This is automatically computed from the the component names.

Definition at line 222 of file parsed_finite_element.h.

§ component_names

template<int dim, int spacedim = dim>
std::vector<std::string> ParsedFiniteElement< dim, spacedim >::component_names
protected

Block names.

This is comma separeted list of component names which identifies the Finite Elemenet. If a name is repeated, then that component is assumed to be part of a vector field or Tensor field, and is treated as a single block. User classes can use this information to construct block matrices and vectors, or to group solution names according to components. For example, a Stokes problem may have "u,u,p" for dim = 2 or "u, u, u, p" for dim = 3.

Definition at line 216 of file parsed_finite_element.h.

§ default_component_names

template<int dim, int spacedim = dim>
std::string ParsedFiniteElement< dim, spacedim >::default_component_names
protected

Default component names.

Definition at line 204 of file parsed_finite_element.h.

§ fe_name

template<int dim, int spacedim = dim>
std::string ParsedFiniteElement< dim, spacedim >::fe_name
protected

Finite Element Name.

Definition at line 199 of file parsed_finite_element.h.


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