FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Geometry::MeshPermutation< Shape_ > Class Template Reference

Mesh permutation class template. More...

#include <mesh_permutation.hpp>

Public Types

typedef std::array< Adjacency::Permutation, shape_dim+1 > PermArray
 permutation array typedef More...
 
typedef Shape_ ShapeType
 the underlying shape type More...
 

Public Member Functions

 MeshPermutation ()
 standard constructor More...
 
 MeshPermutation (const MeshPermutation &)=delete
 delete copy constructor
 
 MeshPermutation (MeshPermutation &&other)
 move constructor More...
 
template<int num_coords_, typename Coord_ >
 MeshPermutation (PermutationStrategy strategy, const IndexSetHolder< Shape_ > &ish, const VertexSet< num_coords_, Coord_ > &vtx)
 Creates a mesh permutation for a conformal mesh. More...
 
virtual ~MeshPermutation ()
 virtual destructor More...
 
std::size_t bytes () const
 
MeshPermutation clone () const
 
void clone (const MeshPermutation &other)
 Clones another mesh permutation object into this object. More...
 
template<int num_coords_, typename Coord_ >
void create (PermutationStrategy strategy, const IndexSetHolder< Shape_ > &ish, const VertexSet< num_coords_, Coord_ > &vtx)
 Creates a mesh permutation for a conformal mesh. More...
 
void create_cmk (const IndexSetHolder< Shape_ > &ish, bool reverse)
 Creates a (reversed) algebraic Cuthill-McKee mesh permutation for a conformal mesh. More...
 
void create_colored (const IndexSetHolder< Shape_ > &ish)
 Creates a colored mesh permutation for a conformal mesh. More...
 
template<int num_coords_, typename Coord_ >
void create_gcmk (const IndexSetHolder< Shape_ > &ish, const VertexSet< num_coords_, Coord_ > &vtx, bool reverse)
 Creates a (reversed) geometric Cuthill-McKee mesh permutation for a conformal mesh. More...
 
void create_inverse_permutations ()
 (Re)Creates the inverse permutations from the forward ones. More...
 
template<int num_coords_, typename Coord_ >
void create_lexicographic (const IndexSetHolder< Shape_ > &ish, const VertexSet< num_coords_, Coord_ > &vtx)
 Creates a lexicographic mesh permutation for a conformal mesh. More...
 
PermArraycreate_other ()
 Initializes a custom permutation. More...
 
void create_random (const IndexSetHolder< Shape_ > &ish)
 Creates random mesh permutation for a conformal mesh. More...
 
void create_random (const IndexSetHolder< Shape_ > &ish, Random &rng)
 Creates random mesh permutation for a conformal mesh. More...
 
bool empty () const
 Checks whether this permutation is empty. More...
 
const std::vector< Index > & get_element_coloring () const
 Returns a const reference to the element coloring vector. More...
 
const std::vector< Index > & get_element_layering () const
 Returns a const reference to the element layering vector. More...
 
const Adjacency::Permutationget_inv_perm (int dim=shape_dim) const
 Returns a const reference to an inverse permutation. More...
 
const PermArrayget_inv_perms () const
 
const Adjacency::Permutationget_perm (int dim=shape_dim) const
 Returns a const reference to a (forward) permutation. More...
 
const PermArrayget_perms () const
 
PermutationStrategy get_strategy () const
 
MeshPermutationoperator= (const MeshPermutation &)=delete
 delete copy-assign operator
 
MeshPermutationoperator= (MeshPermutation &&other)
 move-assignment operator More...
 
int validate_sizes (const Index *num_entities) const
 Validates the permutation sizes. More...
 

Static Public Attributes

static constexpr int shape_dim = ShapeType::dimension
 the shape dimension More...
 

Static Protected Member Functions

static Index _pick_gcmk_root (const Adjacency::Graph &v_at_e, const Adjacency::Graph &e_at_v, const std::vector< int > &mask)
 Auxiliary helper function: pick an unmasked root element for GCMK. More...
 

Protected Attributes

std::vector< Index_element_coloring
 
std::vector< Index_element_layering
 
PermArray _inv_perms
 the inverse permutations More...
 
PermArray _perms
 the actual permutations More...
 
PermutationStrategy _strategy
 the permutation strategy More...
 

Detailed Description

template<typename Shape_>
class FEAT::Geometry::MeshPermutation< Shape_ >

Mesh permutation class template.

This class is responsible for computing and managing mesh permutations for conformal meshes. An object of this class is stored as a member variable of the ConformalMesh class.

Parameters
[in]Shape_The shape type of the mesh that is to be permuted.

This class stores both the forward and inverse permutations for the entities of each dimension. The forward permutation P defines the new positions within the old ordering, i.e. x_new[k] = x_old[P[k]], whereas the corresponding inverse permutation Q defined the old positions within the new array, i.e. x_new[Q[k]] = x_old[k], where x_old is the original unpermuted array and x_new is the permuted array.

Details about Element Coloring strategies:
The fundamental property (definition) of a valid element coloring strategy is as follows:
Let E1 != E2 be two elements which share at least one common vertex, and let C(E1) and C(E2) denote the colors of E1 and E2, respectively, then it must hold that C(E1) != C(E2).
In other words: Two different elements of the same color are not adjacent to each other.

If the mesh was permuted by a coloring strategy and the strategy required NC > 0 colors, then (by definition of the coloring strategy) all elements are sorted by their corresponding color, i.e. first come all elements of color 0, then all elements of color 1, etc.

This class stores the offsets of the first element for each color in an element coloring vector, whose total length is equal to NC+1, i.e. we have:

  • _element_coloring[0] = index of first element of color 0 = 0
  • _element_coloring[1] = index of first element of color 1
  • _element_coloring[2] = index of first element of color 2
  • ...
  • _element_coloring[NC-1] = index of first element of color NC
  • _element_coloring[NC] = total number of elements

Details about Element Layering strategies:
The fundamental property (definition) of a valid element layering strategy is as follows:
Let E1 != E2 be two elements which share at least one common vertex, and let L(E1) and L(E2) denote the layers of E1 and E2, respectively, then it must hold that |L(E1)- L(E2)| <= 1.
In other words: An element in layer L can only be adjacent to elements in the (same or adjacent) layers L or (L-1) or (L+1).

If the mesh was permuted by one of the layering strategies (e.g. one of the algebraic or geometric Cuthill-McKee permutations) and the strategy produced NL > 0 layers, then (by definition of the layering strategy) all elements are sorted by their corresponding layer, i.e. first come all elements in layer 0, then all elements in layer 1, etc.

This class stores the offsets of the first element for each layer in an element layering vector, whose total length is equal to NL+1, i.e. we have:

  • _element_layering[0] = index of first element of layer 0 = 0
  • _element_layering[1] = index of first element of layer 1
  • _element_layering[2] = index of first element of layer 2
  • ...
  • _element_layering[NL-1] = index of first element of layer NL
  • _element_layering[NL] = total number of elements
Author
Peter Zajac

Definition at line 360 of file mesh_permutation.hpp.

Member Typedef Documentation

◆ PermArray

template<typename Shape_ >
typedef std::array<Adjacency::Permutation, shape_dim+1> FEAT::Geometry::MeshPermutation< Shape_ >::PermArray

permutation array typedef

Definition at line 370 of file mesh_permutation.hpp.

◆ ShapeType

template<typename Shape_ >
typedef Shape_ FEAT::Geometry::MeshPermutation< Shape_ >::ShapeType

the underlying shape type

Definition at line 364 of file mesh_permutation.hpp.

Constructor & Destructor Documentation

◆ MeshPermutation() [1/3]

template<typename Shape_ >
FEAT::Geometry::MeshPermutation< Shape_ >::MeshPermutation ( )
inline

standard constructor

Definition at line 388 of file mesh_permutation.hpp.

◆ MeshPermutation() [2/3]

template<typename Shape_ >
template<int num_coords_, typename Coord_ >
FEAT::Geometry::MeshPermutation< Shape_ >::MeshPermutation ( PermutationStrategy  strategy,
const IndexSetHolder< Shape_ > &  ish,
const VertexSet< num_coords_, Coord_ > &  vtx 
)
inlineexplicit

Creates a mesh permutation for a conformal mesh.

Parameters
[in]strategyThe mesh permutation strategy to be used.
[in]ishA transient reference to the index set holder of the conformal mesh.
[in]vtxA transient reference to the vertex set of the conformal mesh.

Definition at line 406 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::create().

◆ MeshPermutation() [3/3]

template<typename Shape_ >
FEAT::Geometry::MeshPermutation< Shape_ >::MeshPermutation ( MeshPermutation< Shape_ > &&  other)
inline

move constructor

Definition at line 416 of file mesh_permutation.hpp.

◆ ~MeshPermutation()

template<typename Shape_ >
virtual FEAT::Geometry::MeshPermutation< Shape_ >::~MeshPermutation ( )
inlinevirtual

virtual destructor

Definition at line 444 of file mesh_permutation.hpp.

Member Function Documentation

◆ _pick_gcmk_root()

template<typename Shape_ >
static Index FEAT::Geometry::MeshPermutation< Shape_ >::_pick_gcmk_root ( const Adjacency::Graph v_at_e,
const Adjacency::Graph e_at_v,
const std::vector< int > &  mask 
)
inlinestaticprotected

Auxiliary helper function: pick an unmasked root element for GCMK.

Definition at line 1027 of file mesh_permutation.hpp.

References FEAT::Adjacency::Graph::image_begin(), and FEAT::Adjacency::Graph::image_end().

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::create_gcmk().

◆ bytes()

◆ clone() [1/2]

template<typename Shape_ >
MeshPermutation FEAT::Geometry::MeshPermutation< Shape_ >::clone ( ) const
inline
Returns
An independent clone of this mesh permutation object.

Definition at line 467 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::clone().

◆ clone() [2/2]

template<typename Shape_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::clone ( const MeshPermutation< Shape_ > &  other)
inline

Clones another mesh permutation object into this object.

Parameters
[in]otherA reference to the source object that is to be cloned into this object.

Definition at line 454 of file mesh_permutation.hpp.

References FEAT::Geometry::other, and FEAT::Geometry::MeshPermutation< Shape_ >::shape_dim.

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::clone(), and FEAT::Geometry::ConformalMesh< Shape_, num_coords_, Coord_ >::clone().

◆ create()

template<typename Shape_ >
template<int num_coords_, typename Coord_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::create ( PermutationStrategy  strategy,
const IndexSetHolder< Shape_ > &  ish,
const VertexSet< num_coords_, Coord_ > &  vtx 
)
inline

◆ create_cmk()

template<typename Shape_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::create_cmk ( const IndexSetHolder< Shape_ > &  ish,
bool  reverse 
)
inline

Creates a (reversed) algebraic Cuthill-McKee mesh permutation for a conformal mesh.

Parameters
[in]ishA transient reference to the index set holder of the conformal mesh.
[in]reverseSpecifies whether the ordering is to be reversed.
Note
This function also creates an element layering automatically.
This function only creates a permutation for the mesh elements (entities of highest dimension) but not for the lower-dimensional entities.

Definition at line 778 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_inv_perms, FEAT::Geometry::MeshPermutation< Shape_ >::_perms, FEAT::Adjacency::CuthillMcKee::asc, FEAT::Adjacency::CuthillMcKee::compute(), FEAT::Geometry::cuthill_mckee, FEAT::Geometry::cuthill_mckee_reversed, FEAT::Adjacency::injectify, FEAT::Adjacency::CuthillMcKee::minimum_degree, FEAT::Geometry::none, FEAT::Adjacency::transpose, and XASSERTM.

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::create().

◆ create_colored()

template<typename Shape_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::create_colored ( const IndexSetHolder< Shape_ > &  ish)
inline

Creates a colored mesh permutation for a conformal mesh.

Parameters
[in]ishA transient reference to the index set holder of the conformal mesh.
Note
This function also creates an element coloring automatically.
This function only creates a permutation for the mesh elements (entities of highest dimension) but not for the lower-dimensional entities.

Definition at line 730 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_inv_perms, FEAT::Geometry::MeshPermutation< Shape_ >::_perms, FEAT::Geometry::colored, FEAT::Adjacency::Coloring::create_partition_graph(), FEAT::Adjacency::Graph::get_domain_ptr(), FEAT::Adjacency::Graph::get_image_idx(), FEAT::Adjacency::Graph::get_num_indices(), FEAT::Adjacency::injectify, FEAT::Geometry::none, FEAT::Adjacency::Permutation::perm, FEAT::Adjacency::transpose, XASSERT, and XASSERTM.

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::create().

◆ create_gcmk()

template<typename Shape_ >
template<int num_coords_, typename Coord_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::create_gcmk ( const IndexSetHolder< Shape_ > &  ish,
const VertexSet< num_coords_, Coord_ > &  vtx,
bool  reverse 
)
inline

Creates a (reversed) geometric Cuthill-McKee mesh permutation for a conformal mesh.

Parameters
[in]ishA transient reference to the index set holder of the conformal mesh.
[in]vtxA transient reference to the vertex set of the conformal mesh.
[in]reverseSpecifies whether the ordering is to be reversed.
Note
This function also creates an element layering automatically.
This function creates permutations for the mesh entities for each dimension.
Remarks
Currently, the vtx parameter is not used by this function, but it is still required for upwards compatibility, because it is possible to improve this algorithm by also using the vertex positioning information.

Definition at line 819 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_inv_perms, FEAT::Geometry::MeshPermutation< Shape_ >::_perms, FEAT::Geometry::MeshPermutation< Shape_ >::_pick_gcmk_root(), FEAT::Geometry::geometric_cuthill_mckee, FEAT::Geometry::geometric_cuthill_mckee_reversed, FEAT::Adjacency::Graph::image_begin(), FEAT::Adjacency::Graph::image_end(), FEAT::Adjacency::Permutation::perm, FEAT::Geometry::MeshPermutation< Shape_ >::shape_dim, FEAT::Adjacency::transpose, and XASSERT.

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::create().

◆ create_inverse_permutations()

template<typename Shape_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::create_inverse_permutations ( )
inline

◆ create_lexicographic()

template<typename Shape_ >
template<int num_coords_, typename Coord_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::create_lexicographic ( const IndexSetHolder< Shape_ > &  ish,
const VertexSet< num_coords_, Coord_ > &  vtx 
)
inline

Creates a lexicographic mesh permutation for a conformal mesh.

Parameters
[in]ishA transient reference to the index set holder of the conformal mesh.
[in]vtxA transient reference to the vertex set of the conformal mesh.
Note
This function creates permutations for the mesh entities for each dimension.

Definition at line 700 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_inv_perms, FEAT::Geometry::MeshPermutation< Shape_ >::_perms, FEAT::Geometry::lexicographic, FEAT::Geometry::none, FEAT::Geometry::MeshPermutation< Shape_ >::shape_dim, and XASSERTM.

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::create().

◆ create_other()

template<typename Shape_ >
PermArray & FEAT::Geometry::MeshPermutation< Shape_ >::create_other ( )
inline

Initializes a custom permutation.

This functions sets the internal strategy enum to PermutationStrategy::other and returns a non-const reference to the internal forwards permutations array, which can then be filled by the caller with the actual permutation data.

Attention
Do not forget to call the create_inverse_permutations() function once you have filled the forward permutations arrays!
Returns
A non-const reference to the internal forward permutations array.

Definition at line 640 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_perms, FEAT::Geometry::none, FEAT::Geometry::other, and XASSERTM.

◆ create_random() [1/2]

template<typename Shape_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::create_random ( const IndexSetHolder< Shape_ > &  ish)
inline

Creates random mesh permutation for a conformal mesh.

Parameters
[in]ishA transient reference to the index set holder of the conformal mesh.
Note
This function creates permutations for the mesh entities for each dimension.

Definition at line 656 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::create_random().

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::create(), and FEAT::Geometry::MeshPermutation< Shape_ >::create_random().

◆ create_random() [2/2]

template<typename Shape_ >
void FEAT::Geometry::MeshPermutation< Shape_ >::create_random ( const IndexSetHolder< Shape_ > &  ish,
Random rng 
)
inline

Creates random mesh permutation for a conformal mesh.

Parameters
[in]ishA transient reference to the index set holder of the conformal mesh.
[in]rngA transient reference to the pseudo-random number generator to be used.
Note
This function creates permutations for the mesh entities for each dimension.

Definition at line 674 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_inv_perms, FEAT::Geometry::MeshPermutation< Shape_ >::_perms, FEAT::Geometry::none, FEAT::Geometry::random, FEAT::Geometry::MeshPermutation< Shape_ >::shape_dim, and XASSERTM.

◆ empty()

◆ get_element_coloring()

template<typename Shape_ >
const std::vector< Index > & FEAT::Geometry::MeshPermutation< Shape_ >::get_element_coloring ( ) const
inline

Returns a const reference to the element coloring vector.

The returned vector may be empty, which indicates that the permutation is not a colored permutation and therefore no element coloring exists.

Returns
A const reference to the element coloring vector.

Definition at line 551 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_element_coloring.

Referenced by FEAT::Geometry::AdaptiveMeshLayer< AdaptiveMeshType_ >::validate_element_coloring(), and FEAT::Geometry::ConformalMesh< Shape_, num_coords_, Coord_ >::validate_element_coloring().

◆ get_element_layering()

template<typename Shape_ >
const std::vector< Index > & FEAT::Geometry::MeshPermutation< Shape_ >::get_element_layering ( ) const
inline

Returns a const reference to the element layering vector.

The returned vector may be empty, which indicates that the permutation is not a layered permutation and therefore no element layering exists.

Returns
A const reference to the element layering vector.

Definition at line 564 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_element_layering.

Referenced by FEAT::Geometry::AdaptiveMeshLayer< AdaptiveMeshType_ >::validate_element_layering(), and FEAT::Geometry::ConformalMesh< Shape_, num_coords_, Coord_ >::validate_element_layering().

◆ get_inv_perm()

template<typename Shape_ >
const Adjacency::Permutation & FEAT::Geometry::MeshPermutation< Shape_ >::get_inv_perm ( int  dim = shape_dim) const
inline

Returns a const reference to an inverse permutation.

Parameters
[in]dimThe dimension of the entities whose permutation is to be returned. Must be 0 <= dim <= shape_dim.
Returns
A const reference to the inverse permutation of the entities of dimension dim.

Definition at line 537 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::shape_dim, and XASSERT.

◆ get_inv_perms()

template<typename Shape_ >
const PermArray & FEAT::Geometry::MeshPermutation< Shape_ >::get_inv_perms ( ) const
inline
Returns
A const reference to the internal inverse permutations array.

Definition at line 508 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_inv_perms.

Referenced by FEAT::Geometry::MeshPart< MeshType_ >::permute().

◆ get_perm()

template<typename Shape_ >
const Adjacency::Permutation & FEAT::Geometry::MeshPermutation< Shape_ >::get_perm ( int  dim = shape_dim) const
inline

Returns a const reference to a (forward) permutation.

Parameters
[in]dimThe dimension of the entities whose permutation is to be returned. Must be 0 <= dim <= shape_dim.
Returns
A const reference to the (forward) permutation of the entities of dimension dim.

Definition at line 522 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::shape_dim, and XASSERT.

Referenced by FEAT::Geometry::AdaptiveMeshLayer< AdaptiveMeshType_ >::create_permutation(), FEAT::Geometry::ConformalMesh< Shape_, num_coords_, Coord_ >::create_permutation(), FEAT::Geometry::AdaptiveMeshLayer< AdaptiveMeshType_ >::set_permutation(), and FEAT::Geometry::ConformalMesh< Shape_, num_coords_, Coord_ >::set_permutation().

◆ get_perms()

◆ get_strategy()

template<typename Shape_ >
PermutationStrategy FEAT::Geometry::MeshPermutation< Shape_ >::get_strategy ( ) const
inline
Returns
The PermutationStrategy that has been used to create this permutation.

Definition at line 496 of file mesh_permutation.hpp.

References FEAT::Geometry::MeshPermutation< Shape_ >::_strategy.

◆ operator=()

◆ validate_sizes()

template<typename Shape_ >
int FEAT::Geometry::MeshPermutation< Shape_ >::validate_sizes ( const Index num_entities) const
inline

Validates the permutation sizes.

Parameters
[in]num_entitiesAn transient array of size shape_dim+1 that contains the number of entities for each dimension.
Returns
  • 0, if all permutation sizes are valid, or
  • j+1, if the permutations of dimension k have the wrong size

Definition at line 1003 of file mesh_permutation.hpp.

References FEAT::Adjacency::Permutation::empty(), FEAT::Geometry::MeshPermutation< Shape_ >::shape_dim, FEAT::Adjacency::Permutation::size(), and XASSERT.

Member Data Documentation

◆ _element_coloring

template<typename Shape_ >
std::vector<Index> FEAT::Geometry::MeshPermutation< Shape_ >::_element_coloring
protected

the element color array in case of colored strategy see the documentation of this class for details

Definition at line 381 of file mesh_permutation.hpp.

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::bytes(), FEAT::Geometry::MeshPermutation< Shape_ >::get_element_coloring(), and FEAT::Geometry::MeshPermutation< Shape_ >::operator=().

◆ _element_layering

template<typename Shape_ >
std::vector<Index> FEAT::Geometry::MeshPermutation< Shape_ >::_element_layering
protected

the layer array in case of algebraic/geometric Cuthill-McKee strategy see the documentation of this class for details

Definition at line 384 of file mesh_permutation.hpp.

Referenced by FEAT::Geometry::MeshPermutation< Shape_ >::bytes(), FEAT::Geometry::MeshPermutation< Shape_ >::get_element_layering(), and FEAT::Geometry::MeshPermutation< Shape_ >::operator=().

◆ _inv_perms

◆ _perms

◆ _strategy

template<typename Shape_ >
PermutationStrategy FEAT::Geometry::MeshPermutation< Shape_ >::_strategy
protected

◆ shape_dim


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