FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Adjacency::Graph Class Reference

Adjacency Graph implementation. More...

#include <graph.hpp>

Public Types

typedef IndexVector::const_iterator ImageIterator
 ImageIterator for Graph class. More...
 
using IndexVector = std::vector< Index >
 index vector type More...
 

Public Member Functions

 Graph ()
 Default constructor. More...
 
 Graph (const Graph &other, const Permutation &domain_perm, const Permutation &image_perm)
 "Permutation" copy CTOR More...
 
 Graph (const std::vector< char > &buffer)
 Deserialization CTOR. More...
 
 Graph (Graph &&other)
 move CTOR More...
 
 Graph (Index num_nodes_domain, Index num_nodes_image, Index num_indices_image)
 Allocation Constructor. More...
 
 Graph (Index num_nodes_domain, Index num_nodes_image, Index num_indices_image, const Index *domain_ptr, const Index *image_idx)
 "Copy-Arrays" Constructor More...
 
 Graph (Index num_nodes_image, const IndexVector &domain_ptr, const IndexVector &image_idx)
 "Copy-Vectors" Constructor More...
 
 Graph (Index num_nodes_image, IndexVector &&domain_ptr, IndexVector &&image_idx)
 "Move-Vectors" Constructor More...
 
template<typename Adjactor1_ , typename Adjactor2_ >
 Graph (RenderType render_type, const Adjactor1_ &adjactor1, const Adjactor2_ &adjactor2)
 Composite-Render constructor. More...
 
template<typename Adjactor_ >
 Graph (RenderType render_type, const Adjactor_ &adjactor)
 Render constructor. More...
 
virtual ~Graph ()
 virtual destructor More...
 
void clear ()
 Clears the graph. More...
 
Graph clone () const
 Clones this graph. More...
 
Index degree () const
 Returns the degree of the graph. More...
 
Index degree (Index domain_node) const
 Returns the degree of a domain node. More...
 
Indexget_domain_ptr ()
 Returns the domain pointer array. More...
 
const Indexget_domain_ptr () const
 Returns the domain pointer array. More...
 
Indexget_image_idx ()
 Returns the image node index array. More...
 
const Indexget_image_idx () const
 Returns the image node index array. More...
 
Index get_num_indices () const
 Returns the total number indices. More...
 
Index get_num_nodes_domain () const
 
Index get_num_nodes_image () const
 
ImageIterator image_begin (Index domain_node) const
 Returns an iterator for the first adjacent image node. More...
 
ImageIterator image_end (Index domain_node) const
 Returns an iterator for the first position past the last adjacent image node. More...
 
Graphoperator= (Graph &&other)
 move-assign operator More...
 
void permute_indices (const Adjacency::Permutation &inv_perm)
 Permutes the image indices. More...
 
std::vector< char > serialize () const
 Serializes the graph into a buffer. More...
 
void sort_indices ()
 Sorts the image indices to non-descending order. More...
 

Static Public Attributes

static constexpr std::uint64_t magic = 0x5052474A44413346ull
 magic number for Graph serialization More...
 

Protected Attributes

IndexVector _domain_ptr
 Domain pointer Vector. More...
 
IndexVector _image_idx
 Image node index Vector. More...
 
Index _num_nodes_image
 total number of image nodes More...
 

Detailed Description

Adjacency Graph implementation.

Todo:
detailed description
Author
Peter Zajac

Definition at line 33 of file graph.hpp.

Member Typedef Documentation

◆ ImageIterator

typedef IndexVector::const_iterator FEAT::Adjacency::Graph::ImageIterator

ImageIterator for Graph class.

For the purpose of the Adjactor interface implementation a const Index-pointer is the optimal choice for the image node iterator.

Definition at line 45 of file graph.hpp.

◆ IndexVector

index vector type

Definition at line 37 of file graph.hpp.

Constructor & Destructor Documentation

◆ Graph() [1/10]

FEAT::Adjacency::Graph::Graph ( )

Default constructor.

This constructor creates a new empty graph, but does not allocate any vectors.

Definition at line 15 of file graph.cpp.

Referenced by clone().

◆ Graph() [2/10]

FEAT::Adjacency::Graph::Graph ( Index  num_nodes_domain,
Index  num_nodes_image,
Index  num_indices_image 
)
explicit

Allocation Constructor.

This constructor creates a new graph and allocates the Graph's vectors to the corresponding lengths.

Note
This constructor does not initialize the allocated vectors – they have to be initialized by the user after construction.
Parameters
[in]num_nodes_domainThe total number of domain nodes for the graph.
[in]num_nodes_imageThe total number of image nodes for the graph.
[in]num_indices_imageThe total number of image node indices for the graph.

Definition at line 23 of file graph.cpp.

◆ Graph() [3/10]

FEAT::Adjacency::Graph::Graph ( Index  num_nodes_domain,
Index  num_nodes_image,
Index  num_indices_image,
const Index domain_ptr,
const Index image_idx 
)
explicit

"Copy-Arrays" Constructor

This constructor creates a new graph using copies of the arrays passed to this function.

Parameters
[in]num_nodes_domainThe total number of domain nodes for the graph.
[in]num_nodes_imageThe total number of image nodes for the graph.
[in]num_indices_imageThe total number of image node indices for the graph.
[in]domain_ptrThe transient domain pointer array for the graph. Must not be nullptr.
[in]image_idxThe transient image node index array for the graph. Must not be nullptr.

Definition at line 34 of file graph.cpp.

References _domain_ptr, and _image_idx.

◆ Graph() [4/10]

FEAT::Adjacency::Graph::Graph ( Index  num_nodes_image,
const IndexVector domain_ptr,
const IndexVector image_idx 
)
explicit

"Copy-Vectors" Constructor

This constructor creates a new graph using copies of the vectors passed to this function.

Parameters
[in]num_nodes_imageThe total number of image nodes for the graph.
[in]domain_ptrThe transient domain pointer vector for the graph. Must not be nullptr.
[in]image_idxThe transient image node index vector for the graph. Must not be nullptr.

Definition at line 57 of file graph.cpp.

◆ Graph() [5/10]

FEAT::Adjacency::Graph::Graph ( Index  num_nodes_image,
IndexVector &&  domain_ptr,
IndexVector &&  image_idx 
)
explicit

"Move-Vectors" Constructor

This constructor creates a new graph using copies of the vectors passed to this function.

Parameters
[in]num_nodes_imageThe total number of image nodes for the graph.
[in]domain_ptrThe transient domain pointer vector for the graph. Must not be nullptr.
[in]image_idxThe transient image node index vector for the graph. Must not be nullptr.

Definition at line 68 of file graph.cpp.

◆ Graph() [6/10]

template<typename Adjactor_ >
FEAT::Adjacency::Graph::Graph ( RenderType  render_type,
const Adjactor_ &  adjactor 
)
inlineexplicit

Render constructor.

This constructor renders an object implementing the Adjactor interface into a graph.

Parameters
[in]render_typeThe render type. See RenderType for details.
[in]adjactorA reference to the adjactor that is to be rendered.

Definition at line 175 of file graph.hpp.

References FEAT::Adjacency::as_is, FEAT::Adjacency::as_is_sorted, FEAT::Adjacency::injectify, FEAT::Adjacency::injectify_sorted, FEAT::Adjacency::injectify_transpose, FEAT::Adjacency::injectify_transpose_sorted, sort_indices(), FEAT::Adjacency::transpose, FEAT::Adjacency::transpose_sorted, and XABORTM.

◆ Graph() [7/10]

template<typename Adjactor1_ , typename Adjactor2_ >
FEAT::Adjacency::Graph::Graph ( RenderType  render_type,
const Adjactor1_ &  adjactor1,
const Adjactor2_ &  adjactor2 
)
inlineexplicit

Composite-Render constructor.

This constructor renders a composition of two objects implementing the Adjactor interface into a graph.

Parameters
[in]render_typeThe render type. See RenderType for details.
[in]adjactor1A transient reference to the first adjactor in the composition that is to be rendered.
[in]adjactor2A transient reference to the second adjactor in the composition that is to be rendered.

Definition at line 228 of file graph.hpp.

References FEAT::Adjacency::as_is, FEAT::Adjacency::as_is_sorted, FEAT::Adjacency::injectify, FEAT::Adjacency::injectify_sorted, FEAT::Adjacency::injectify_transpose, FEAT::Adjacency::injectify_transpose_sorted, sort_indices(), FEAT::Adjacency::transpose, FEAT::Adjacency::transpose_sorted, and XABORTM.

◆ Graph() [8/10]

FEAT::Adjacency::Graph::Graph ( Graph &&  other)

move CTOR

Definition at line 79 of file graph.cpp.

◆ Graph() [9/10]

FEAT::Adjacency::Graph::Graph ( const Graph other,
const Permutation domain_perm,
const Permutation image_perm 
)
explicit

"Permutation" copy CTOR

This constructor creates a new graph by permuting the domain and image set of the graph that is passed to this function.

Parameters
[in]otherThe transient graph that has to be permuted.
[in]domain_permThe transient permutation of the domain set.
[in]image_permThe transient permutation of the image set.

Definition at line 108 of file graph.cpp.

References _domain_ptr, _image_idx, and FEAT::Adjacency::Permutation::get_perm_pos().

◆ Graph() [10/10]

FEAT::Adjacency::Graph::Graph ( const std::vector< char > &  buffer)
explicit

Deserialization CTOR.

This constructor creates the graph from a buffer that has been created by using the serialize function.

Parameters
[in]bufferThe transient serialization buffer to create the graph from.

Definition at line 142 of file graph.cpp.

References _domain_ptr, _image_idx, _num_nodes_image, magic, and XASSERTM.

◆ ~Graph()

FEAT::Adjacency::Graph::~Graph ( )
virtual

virtual destructor

Definition at line 184 of file graph.cpp.

Member Function Documentation

◆ clear()

void FEAT::Adjacency::Graph::clear ( )

Clears the graph.

Definition at line 188 of file graph.cpp.

References _domain_ptr, _image_idx, and _num_nodes_image.

Referenced by FEAT::Assembly::DomainAssembler< Trafo_ >::clear().

◆ clone()

Graph FEAT::Adjacency::Graph::clone ( ) const
inline

Clones this graph.

Returns
A deep-copy of this graph.

Definition at line 311 of file graph.hpp.

References Graph(), _domain_ptr, _image_idx, and _num_nodes_image.

Referenced by FEAT::Control::Domain::PartiDomainControl< DomainLevel_ >::_check_parti_extern().

◆ degree() [1/2]

Index FEAT::Adjacency::Graph::degree ( ) const

Returns the degree of the graph.

This function returns the degree of the graph, i.e. the maximum of the degrees of all domain nodes.

Note
The degree of the graph might be greater than the total number of image nodes if the graph is not injective.
Attention
This function performs a loop over all domain nodes and therefore has linear runtime. It is recommended to store the result of this function in a variable if the degree is needed multiple times.
Returns
The degree of the graph.

Definition at line 195 of file graph.cpp.

References _domain_ptr.

◆ degree() [2/2]

Index FEAT::Adjacency::Graph::degree ( Index  domain_node) const
inline

Returns the degree of a domain node.

This function returns the degree of a domain node, i.e. the number of image nodes which are adjacent to the specified domain node.

Note
The degree might be greater than the total number of image nodes if the graph is not injective.
Parameters
[in]domain_nodeThe domain node index whose degree is to be returned.
Returns
The degree of the specified domain node.

Definition at line 333 of file graph.hpp.

References _domain_ptr, and ASSERTM.

Referenced by FEAT::Adjacency::Coloring::Coloring(), FEAT::Geometry::PatchMeshPartFactory< MeshType_ >::PatchMeshPartFactory(), FEAT::Assembly::DomainAssembler< Trafo_ >::_build_colors(), FEAT::Assembly::DomainAssembler< Trafo_ >::_build_layers(), FEAT::Assembly::TraceAssembler< Trafo_ >::compile_all_facets(), FEAT::Adjacency::CuthillMcKee::compute(), and FEAT::Geometry::MeshFileWriter::write_partition().

◆ get_domain_ptr() [1/2]

Index * FEAT::Adjacency::Graph::get_domain_ptr ( )
inline

Returns the domain pointer array.

Returns
The domain pointer array.

Definition at line 359 of file graph.hpp.

References _domain_ptr.

Referenced by FEAT::Adjacency::Coloring::Coloring(), FEAT::LAFEM::MatrixMirrorBuffer< DT_, IT_ >::MatrixMirrorBuffer(), FEAT::LAFEM::SparseMatrixBanded< DT_, IT_ >::SparseMatrixBanded(), FEAT::LAFEM::SparseMatrixBCSR< DT_, IT_, BlockHeight_, BlockWidth_ >::SparseMatrixBCSR(), FEAT::LAFEM::SparseMatrixCSCR< DT_, IT_ >::SparseMatrixCSCR(), FEAT::LAFEM::SparseMatrixCSR< DT_, IT_ >::SparseMatrixCSR(), FEAT::Control::Domain::PartiDomainControlBase< DomainLevel_ >::_apply_parti_naive(), FEAT::Global::PMDCDSCMatrix< Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, 1 >, MirrorV_, MirrorP_ >, Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, 1, dim_ >, MirrorP_, MirrorV_ > >::_asm_data_mirror(), FEAT::Global::PMDCDSCMatrix< Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, 1 >, MirrorV_, MirrorP_ >, Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, 1, dim_ >, MirrorP_, MirrorV_ > >::_asm_neighbor_schur_matrix(), FEAT::Global::PMDCDSCMatrix< Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, 1 >, MirrorV_, MirrorP_ >, Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, 1, dim_ >, MirrorP_, MirrorV_ > >::_asm_reduced_b(), FEAT::Assembly::DomainAssembler< Trafo_ >::_build_colors(), FEAT::Assembly::DomainAssembler< Trafo_ >::_build_graphs(), FEAT::Assembly::DomainAssembler< Trafo_ >::_build_layers(), FEAT::Assembly::SymbolicAssembler::assemble_graph_diag(), FEAT::Geometry::Parti2Lvl< ConformalMesh< Shape_, num_coords_, Coord_ > >::build_elems_at_rank(), FEAT::Geometry::PartiIterative< ConformalMesh< Shape_, num_coords_, Coord_ > >::build_elems_at_rank(), FEAT::Adjacency::CuthillMcKee::compute(), FEAT::Geometry::MeshPermutation< Shape_ >::create_colored(), FEAT::Adjacency::Coloring::create_partition_graph(), and FEAT::Geometry::MeshExtruder< ConformalMesh< Shape::Hypercube< 2 >, 2, Coord_ > >::extrude_partition().

◆ get_domain_ptr() [2/2]

const Index * FEAT::Adjacency::Graph::get_domain_ptr ( ) const
inline

Returns the domain pointer array.

Returns
The domain pointer array.

Definition at line 365 of file graph.hpp.

References _domain_ptr.

◆ get_image_idx() [1/2]

Index * FEAT::Adjacency::Graph::get_image_idx ( )
inline

Returns the image node index array.

Returns
The image node index array.

Definition at line 374 of file graph.hpp.

References _image_idx.

Referenced by FEAT::Adjacency::Coloring::Coloring(), FEAT::LAFEM::MatrixMirrorBuffer< DT_, IT_ >::MatrixMirrorBuffer(), FEAT::LAFEM::SparseMatrixBanded< DT_, IT_ >::SparseMatrixBanded(), FEAT::LAFEM::SparseMatrixBCSR< DT_, IT_, BlockHeight_, BlockWidth_ >::SparseMatrixBCSR(), FEAT::LAFEM::SparseMatrixCSCR< DT_, IT_ >::SparseMatrixCSCR(), FEAT::LAFEM::SparseMatrixCSR< DT_, IT_ >::SparseMatrixCSR(), FEAT::Control::Domain::PartiDomainControlBase< DomainLevel_ >::_apply_parti_naive(), FEAT::Global::PMDCDSCMatrix< Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, 1 >, MirrorV_, MirrorP_ >, Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, 1, dim_ >, MirrorP_, MirrorV_ > >::_asm_data_mirror(), FEAT::Global::PMDCDSCMatrix< Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, 1 >, MirrorV_, MirrorP_ >, Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, 1, dim_ >, MirrorP_, MirrorV_ > >::_asm_neighbor_schur_matrix(), FEAT::Global::PMDCDSCMatrix< Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, dim_, 1 >, MirrorV_, MirrorP_ >, Global::Matrix< LAFEM::SparseMatrixBCSR< DT_, IT_, 1, dim_ >, MirrorP_, MirrorV_ > >::_asm_reduced_b(), FEAT::Assembly::DomainAssembler< Trafo_ >::_build_colors(), FEAT::Assembly::DomainAssembler< Trafo_ >::_build_graphs(), FEAT::Assembly::DomainAssembler< Trafo_ >::_build_layers(), FEAT::Assembly::SymbolicAssembler::assemble_graph_diag(), FEAT::Geometry::Parti2Lvl< ConformalMesh< Shape_, num_coords_, Coord_ > >::build_elems_at_rank(), FEAT::Geometry::PartiIterative< ConformalMesh< Shape_, num_coords_, Coord_ > >::build_elems_at_rank(), FEAT::Adjacency::CuthillMcKee::compute(), FEAT::Geometry::MeshPermutation< Shape_ >::create_colored(), FEAT::Adjacency::Coloring::create_partition_graph(), and FEAT::Geometry::MeshExtruder< ConformalMesh< Shape::Hypercube< 2 >, 2, Coord_ > >::extrude_partition().

◆ get_image_idx() [2/2]

const Index * FEAT::Adjacency::Graph::get_image_idx ( ) const
inline

Returns the image node index array.

Returns
The image node index array.

Definition at line 380 of file graph.hpp.

References _image_idx.

◆ get_num_indices()

◆ get_num_nodes_domain()

Index FEAT::Adjacency::Graph::get_num_nodes_domain ( ) const
inline

Definition at line 947 of file graph.hpp.

◆ get_num_nodes_image()

Index FEAT::Adjacency::Graph::get_num_nodes_image ( ) const
inline

Definition at line 952 of file graph.hpp.

◆ image_begin()

◆ image_end()

◆ operator=()

Graph & FEAT::Adjacency::Graph::operator= ( Graph &&  other)

move-assign operator

move assignment

Definition at line 90 of file graph.cpp.

References _domain_ptr, _image_idx, and _num_nodes_image.

◆ permute_indices()

void FEAT::Adjacency::Graph::permute_indices ( const Adjacency::Permutation inv_perm)

Permutes the image indices.

Parameters
[in]inv_permThe transient inverse image indices permutation.

Definition at line 221 of file graph.cpp.

References _image_idx, FEAT::Adjacency::Permutation::size(), XASSERT, and XASSERTM.

Referenced by FEAT::Assembly::SymbolicAssembler::assemble_graph_intermesh(), and FEAT::Geometry::Partition::permute().

◆ serialize()

std::vector< char > FEAT::Adjacency::Graph::serialize ( ) const

Serializes the graph into a buffer.

Definition at line 234 of file graph.cpp.

References _domain_ptr, _image_idx, _num_nodes_image, magic, and XASSERT.

◆ sort_indices()

Member Data Documentation

◆ _domain_ptr

IndexVector FEAT::Adjacency::Graph::_domain_ptr
protected

Domain pointer Vector.

Dimension: #_num_nodes_domain+1

Definition at line 59 of file graph.hpp.

Referenced by Graph(), clear(), clone(), degree(), get_domain_ptr(), image_begin(), image_end(), operator=(), serialize(), and sort_indices().

◆ _image_idx

IndexVector FEAT::Adjacency::Graph::_image_idx
protected

Image node index Vector.

Dimension: #_num_indices_image

Definition at line 66 of file graph.hpp.

Referenced by Graph(), clear(), clone(), get_image_idx(), get_num_indices(), image_begin(), image_end(), operator=(), permute_indices(), serialize(), and sort_indices().

◆ _num_nodes_image

Index FEAT::Adjacency::Graph::_num_nodes_image
protected

total number of image nodes

Definition at line 52 of file graph.hpp.

Referenced by Graph(), clear(), clone(), operator=(), and serialize().

◆ magic

constexpr std::uint64_t FEAT::Adjacency::Graph::magic = 0x5052474A44413346ull
staticconstexpr

magic number for Graph serialization

Definition at line 48 of file graph.hpp.

Referenced by Graph(), and serialize().


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