Fluid structure interaction suite
ParsedTools::Components Namespace Reference

Utilities for extracting components and boundary condition types from strings. More...

Enumerations

enum class  Type {
  all = 0 , scalar = 1 , vector = 2 , normal = 3 ,
  tangential = 4
}
 Enumerator used to identify patterns of components and their size in the a block system. More...
 

Functions

template<int dim, int spacedim>
std::unique_ptr< FiniteElement< dim, spacedim > > get_lagrangian_finite_element (const Triangulation< dim, spacedim > &tria, const unsigned int degree=1, const int continuity=0)
 Get a Lagrangian FiniteElement object compatible with the given Triangulation object. More...
 
template<int dim, int spacedim>
Quadrature< dim > get_cell_quadrature (const Triangulation< dim, spacedim > &tria, const unsigned int degree)
 Return a Quadrature object that can be used on the given Triangulation cells. More...
 
template<int dim, int spacedim>
Quadrature< dim - 1 > get_face_quadrature (const Triangulation< dim, spacedim > &tria, const unsigned int degree)
 Return a Quadrature object that can be used on the given Triangulation faces. More...
 
template<typename Container >
std::string join (const Container &strings, const std::string &separator)
 Join strings in a container together using a given separator. More...
 
unsigned int n_components (const std::string &component_names)
 Count the number of components in the given list of comma separated components. More...
 
unsigned int n_blocks (const std::string &component_names)
 Count the number of components in the given list of comma separated components. More...
 
std::string blocks_to_names (const std::vector< std::string > &components, const std::vector< unsigned int > &multiplicities)
 Build component names from block names and multiplicities. More...
 
std::pair< std::vector< std::string >, std::vector< unsigned int > > names_to_blocks (const std::string &component_names)
 Build block names and multiplicities from component names. More...
 
std::vector< unsigned int > block_indices (const std::string &component_names, const std::string &selected_components)
 Return the indices within the block corresponding to the given selected components, or numbers::invalid_unsigned_int if the selected components could not be found. More...
 
std::vector< unsigned int > component_indices (const std::string &component_names, const std::string &selected_components)
 Return the indices within the components corresponding to first component of the given selected components, or numbers::invalid_unsigned_int if the selected components could not be found. More...
 
std::pair< unsigned int, unsigned int > component_to_indices (const std::string &component_names, const std::string &selected_component)
 Return the indices within the components and within the blocks corresponding to first component of the given selected component, or numbers::invalid_unsigned_int if the selected components could not be found. More...
 
std::string component_name (const std::string &component_names, const std::string &selected_component)
 Return the canonical component name for the given selected component. More...
 
Type type (const std::string &component_name, const std::string &selected_component)
 Return the component type for the given selected component. More...
 
ComponentMask mask (const std::string &component_names, const std::string &selected_component)
 Return a component mask corresponding to a given selected component, from a list of comma separated components. More...
 

Detailed Description

Utilities for extracting components and boundary condition types from strings.

Enumeration Type Documentation

◆ Type

Enumerator used to identify patterns of components and their size in the a block system.

Enumerator
all 

All components.

scalar 

Scalar.

vector 

Vector.

normal 

Normal component of a vector.

tangential 

Tangential component of a vector.

Definition at line 43 of file components.h.

Function Documentation

◆ get_lagrangian_finite_element()

template<int dim, int spacedim>
std::unique_ptr<FiniteElement<dim, spacedim> > ParsedTools::Components::get_lagrangian_finite_element ( const Triangulation< dim, spacedim > &  tria,
const unsigned int  degree = 1,
const int  continuity = 0 
)

Get a Lagrangian FiniteElement object compatible with the given Triangulation object.

The returned object can be either FE_Q, FE_DGQ, FE_P, or FE_DGP according to the types of elements of the Triangulation (quads/hexes VS tria/tets)

Parameters
triaThe triangulation to inspect
degreeThe polynomial degree of the Lagrangian FiniteElement
continuityThe continuity of the Lagrangian FiniteElement: 0 for continuous, -1 for discontinuous
Returns
std::unique_ptr<FiniteElement<dim, spacedim>>

Referenced by PDEs::Serial::ReducedLagrange< dim, spacedim >::generate_grids_and_fes().

◆ get_cell_quadrature()

template<int dim, int spacedim>
Quadrature<dim> ParsedTools::Components::get_cell_quadrature ( const Triangulation< dim, spacedim > &  tria,
const unsigned int  degree 
)

◆ get_face_quadrature()

template<int dim, int spacedim>
Quadrature<dim - 1> ParsedTools::Components::get_face_quadrature ( const Triangulation< dim, spacedim > &  tria,
const unsigned int  degree 
)

Return a Quadrature object that can be used on the given Triangulation faces.

Parameters
triaTriangulation to insepct
degreeThe degree of the 1d quadrature used to generate the actual quadrature.
Returns
Quadrature<dim>

Referenced by PDEs::MPI::Poisson< dim, spacedim >::custom_estimator(), and PDEs::LinearElasticity< dim, spacedim, LacType >::postprocess().

◆ join()

template<typename Container >
std::string ParsedTools::Components::join ( const Container &  strings,
const std::string &  separator 
)

Join strings in a container together using a given separator.

◆ n_components()

unsigned int ParsedTools::Components::n_components ( const std::string &  component_names)

Count the number of components in the given list of comma separated components.

Definition at line 32 of file components.cc.

References Utilities::split_string_list().

Referenced by mask().

◆ n_blocks()

unsigned int ParsedTools::Components::n_blocks ( const std::string &  component_names)

Count the number of components in the given list of comma separated components.

Definition at line 217 of file components.cc.

References b(), and names_to_blocks().

◆ blocks_to_names()

std::string ParsedTools::Components::blocks_to_names ( const std::vector< std::string > &  components,
const std::vector< unsigned int > &  multiplicities 
)

Build component names from block names and multiplicities.

Definition at line 40 of file components.cc.

References AssertDimension, and Patterns::Tools::to_string().

◆ names_to_blocks()

std::pair< std::vector< std::string >, std::vector< unsigned int > > ParsedTools::Components::names_to_blocks ( const std::string &  component_names)

Build block names and multiplicities from component names.

Definition at line 56 of file components.cc.

References AssertDimension, and Utilities::split_string_list().

Referenced by block_indices(), component_indices(), mask(), n_blocks(), and type().

◆ block_indices()

std::vector< unsigned int > ParsedTools::Components::block_indices ( const std::string &  component_names,
const std::string &  selected_components 
)

Return the indices within the block corresponding to the given selected components, or numbers::invalid_unsigned_int if the selected components could not be found.

Accepted patterns are comma separated versions of the following string types:

  • single component names, e.g., "p"
  • block names, e.g., "u,p"
  • component indices, e.g., "0,1"
  • normal component names, e.g., "u.n" or "u.N"
  • tangent component names, e.g., "u.t" or "u.T"

Examples:

std::string names="u,u,p";
auto r = block_indices(names, "u"); // {0}
r = block_indices(names, "u, p"); // {0,1}
r = block_indices(names, "p"); // {1}
r = block_indices(names, "2"); // {1}
r = block_indices(names, "1"); // {0}
r = block_indices(names, "0,1,2"); // {0,0,1}
r = block_indices(names, "u.n"); // {0}
r = block_indices(names, "u.t"); // {0}
std::vector< unsigned int > block_indices(const std::string &component_names, const std::string &selected_components)
Return the indices within the block corresponding to the given selected components,...
Definition: components.cc:134

Definition at line 134 of file components.cc.

References AssertThrow, b(), component_name(), StandardExceptions::ExcMessage(), names_to_blocks(), and Utilities::split_string_list().

Referenced by component_indices(), component_to_indices(), mask(), and PDEs::Serial::Stokes< dim >::setup_system().

◆ component_indices()

std::vector< unsigned int > ParsedTools::Components::component_indices ( const std::string &  component_names,
const std::string &  selected_components 
)

Return the indices within the components corresponding to first component of the given selected components, or numbers::invalid_unsigned_int if the selected components could not be found.

Accepted patterns are comma separated versions of the following string types:

  • single component names, e.g., "p"
  • block names, e.g., "u,p"
  • component indices, e.g., "0,1"
  • normal component names, e.g., "u.n" or "u.N"
  • tangent component names, e.g., "u.t" or "u.T"

Examples:

std::string names="u,u,p";
auto r = component_indices(names, "u"); // {0}
r = component_indices(names, "u, p"); // {0,2}
r = component_indices(names, "p"); // {2}
r = component_indices(names, "2"); // {2}
r = component_indices(names, "1"); // {0}
r = component_indices(names, "0,1,2"); // {0,0,1}
r = component_indices(names, "u.n"); // {0}
r = component_indices(names, "u.T"); // {0}
std::vector< unsigned int > component_indices(const std::string &component_names, const std::string &selected_components)
Return the indices within the components corresponding to first component of the given selected compo...
Definition: components.cc:156

If the component names are unique, this is the same as the block_indices() function, otherwise it returns the first component indices.

Definition at line 156 of file components.cc.

References b(), block_indices(), and names_to_blocks().

Referenced by component_to_indices(), and mask().

◆ component_to_indices()

std::pair< unsigned int, unsigned int > ParsedTools::Components::component_to_indices ( const std::string &  component_names,
const std::string &  selected_component 
)

Return the indices within the components and within the blocks corresponding to first component of the given selected component, or numbers::invalid_unsigned_int if the selected components could not be found.

For example, for component names "u,u,p", there are three components (two for "u" and one for "p"), and two blocks ("u" and "p").

This function returns the indices of the first component of the selected component, and the index of the block, so, for "u" it would return {0,0} and for "p" it would return {2,1} (third component, second block).

Accepted patterns are the following string types:

  • single component or block names, e.g., "p"
  • a single component index, e.g., "0"
  • a normal component name, e.g., "u.n" or "u.N"
  • tangent component names, e.g., "u.t" or "u.T"

Examples:

std::string names="u,u,p";
auto r = component_to_block_indices_map(names, "u"); // {0,0}
r = component_to_block_indices_map(names, "p"); // {2,1}
r = component_to_block_indices_map(names, "p"); // {2}
r = component_to_block_indices_map(names, "2"); // {2}
r = component_to_block_indices_map(names, "1"); // {0}
r = component_to_block_indices_map(names, "0,1,2"); // {0,0,1}
r = component_to_block_indices_map(names, "u.n"); // {0}
r = component_to_block_indices_map(names, "u.t"); // {0}

Definition at line 170 of file components.cc.

References AssertDimension, AssertThrow, block_indices(), component_indices(), and StandardExceptions::ExcMessage().

Referenced by type().

◆ component_name()

std::string ParsedTools::Components::component_name ( const std::string &  component_names,
const std::string &  selected_component 
)

Return the canonical component name for the given selected component.

For example, for component names "u,u,p", there are three components (two for "u" and one for "p"), and two blocks ("u" and "p").

This function returns the canonical component name for an associated pattern of components.

Accepted patterns are the following string types:

  • single component or block names, e.g., "p"
  • a single component index, e.g., "0"
  • a normal component name, e.g., "u.n" or "u.N"

Examples:

std::string names="u,u,p";
auto r = component_name(names, "u"); // "u"
r = component_name(names, "p"); // "p"
r = component_name(names, "1"); // "u"
r = component_name(names, "2"); // "p"
r = component_name(names, "u.n"); // "u"
std::string component_name(const std::string &component_names, const std::string &selected_component)
Return the canonical component name for the given selected component.
Definition: components.cc:72

Definition at line 72 of file components.cc.

References AssertThrow, StandardExceptions::ExcMessage(), Utilities::int_to_string(), Utilities::split_string_list(), and Utilities::string_to_int().

Referenced by block_indices().

◆ type()

Type ParsedTools::Components::type ( const std::string &  component_name,
const std::string &  selected_component 
)

Return the component type for the given selected component.

For example, for component names "u,u,p", there are three components (two for "u" and one for "p"), and two blocks ("u" and "p").

This function returns the component type for an associated pattern of components, according to the multiplicity of the given component, and to the normal or tangential component.

Accepted patterns are the following string types:

  • single component or block names, e.g., "p"
  • a single component index, e.g., "0"
  • a normal component name, e.g., "u.n" or "u.N"
  • a tangential component name, e.g., "u.t" or "u.T"

Examples:

std::string names="u,u,p";
auto r = type(names, "u"); // vector
r = type(names, "p"); // scalar
r = type(names, "1"); // vector
r = type(names, "2"); // scalar
r = type(names, "u.n"); // normal
r = type(names, "u.t"); // tangential
Type type(const std::string &component_name, const std::string &selected_component)
Return the component type for the given selected component.
Definition: components.cc:186

Definition at line 186 of file components.cc.

References b(), component_to_indices(), names_to_blocks(), and Utilities::split_string_list().

Referenced by ParsedTools::DataOut< dim, spacedim >::add_data_vector().

◆ mask()

ComponentMask ParsedTools::Components::mask ( const std::string &  component_names,
const std::string &  selected_component 
)

Return a component mask corresponding to a given selected component, from a list of comma separated components.

Definition at line 226 of file components.cc.

References AssertDimension, AssertThrow, b(), block_indices(), component_indices(), StandardExceptions::ExcMessage(), Utilities::int_to_string(), mask(), n_components(), and names_to_blocks().

Referenced by mask(), and ParsedTools::BoundaryConditions< dim >::update_user_substitution_map().