FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
FEAT::Global::Splitter< LocalVector_, Mirror_ > Class Template Reference

Global base-mesh vector splitter (and joiner) implementation. More...

#include <splitter.hpp>

Public Types

typedef Global::Vector< LocalVector_, Mirror_ > GlobalVectorType
 our global vector type More...
 
typedef LocalVector_ LocalVectorType
 our local vector type More...
 
typedef Mirror_ MirrorType
 our mirror type More...
 
typedef Global::Muxer< LocalVector_, Mirror_ > MuxerType
 our internal muxer type More...
 

Public Member Functions

 Splitter ()
 standard constructor More...
 
 Splitter (MuxerType &&muxer, LocalVector_ &&base_vector_tmpl)
 
 Splitter (Splitter &&other)
 move-constructor More...
 
virtual ~Splitter ()
 destructor More...
 
std::size_t bytes () const
 Returns the internal data size in bytes. More...
 
void compile (const LocalVector_ &vec_tmp_)
 Compiles the muxer. More...
 
template<typename LVT2_ >
void convert (const Splitter< LVT2_, Mirror_ > &other, LocalVector_ &&vector, LAFEM::CloneMode mode=LAFEM::CloneMode::Shallow)
 Conversion function for different vector container type. More...
 
template<typename LVT2_ , typename MT2_ >
void convert (const Splitter< LVT2_, MT2_ > &other)
 Conversion function for same vector container type but with different MDI-Type. More...
 
LocalVector_ create_base_vector () const
 Creates a new base-mesh vector. More...
 
const LocalVector_ & get_base_vector_template () const
 Returns the base vector template. More...
 
const MuxerTypeget_muxer () const
 Returns the internal muxer. More...
 
bool is_root () const
 Checks whether this is the root process. More...
 
bool is_single () const
 Checks whether there is only one process in the communicator. More...
 
LocalVector_ join (const Global::Vector< LocalVector_, Mirror_ > &vector) const
 Joins a global vector into a base-mesh local vector on the root process. More...
 
void join (LocalVector_ &vec_base, const Global::Vector< LocalVector_, Mirror_ > &vector) const
 Joins a global vector into a base-mesh local vector on the root process. More...
 
void join_write_out (const Global::Vector< LocalVector_, Mirror_ > &vector, const String &filename, LAFEM::FileMode mode=LAFEM::FileMode::fm_binary) const
 Joins a global vector into a base-mesh local vector and writes it to a file. More...
 
Splitteroperator= (Splitter &&other)
 move-assign operator More...
 
void push_patch (Mirror_ &&patch_mirror)
 Adds a child rank and mirror for the parent process. More...
 
void set_base_vector_template (LocalVector_ &&vector_template)
 Sets the base-vector template on the root process. More...
 
void set_root (const Dist::Comm *comm, int root_rank, Mirror_ &&root_mirror)
 Sets the root communicator. More...
 
void split (Global::Vector< LocalVector_, Mirror_ > &vector, const LocalVector_ &vec_base) const
 Splits a base-mesh local vector on the root process into a global vector. More...
 
void split (LocalVector_ &vector, const LocalVector_ &vec_base) const
 Splits a base-mesh local vector on the root process into a patch-local vector. More...
 
void split_read_from (Global::Vector< LocalVector_, Mirror_ > &vector, const String &filename, LAFEM::FileMode mode=LAFEM::FileMode::fm_binary) const
 Reads in a base-mesh local vector and splits it into a global vector. More...
 
void split_read_from (LocalVector_ &vector, const String &filename, LAFEM::FileMode mode=LAFEM::FileMode::fm_binary) const
 Reads in a base-mesh local vector and splits it into a patch-local vector. More...
 

Public Attributes

LocalVector_ _base_vector_tmpl
 our base-mesh vector template; only required for join() but not for split() More...
 
MuxerType _muxer
 our internal muxer More...
 

Detailed Description

template<typename LocalVector_, typename Mirror_>
class FEAT::Global::Splitter< LocalVector_, Mirror_ >

Global base-mesh vector splitter (and joiner) implementation.

This class provides the functionality for the transfer of primal vectors between a partitioned mesh and its underlying unpartitioned base-mesh on the same refinement level. Technically, this class is merely a special case of the more general Muxer class, however, this class additionally offers some direct file I/O methods. The purpose of this class is to enable the user to write a solution vector, that has been computed on a partitioned mesh in an MPI-parallel simulation, into a single output file on the corresponding unpartitioned mesh by using the join_write_out() function, which can then be read in by another possibly sequential application by the means of the standard LAFEM read_from methods. Furthermore, this class also offers the vice-versa functionality, i.e. it is possible to read in a vector on the unpartitioned mesh that has been written out by the standard LAFEM write_out methods and split it into the local vectors on the corresponding partitioned mesh in an MPI-parallel application by using the split_read_from() function. Of course, as a direct consequence, it is also possible to write a partitioned vector generated on N MPI processes and then read it in by an application running on a different number of MPI processes.

Template Parameters
LocalVector_The local vector type that the splitter is to be applied onto.
Mirror_The mirror type that is to be used.

To set up an object of this class, the following steps have to be performed:

  1. On each process, call the set_root() function and provide the communicator as well as the rank of the remaining root process as well as the identity mirror for all DOFs.
  2. On the root process, call the push_patch() function and provide the mirror for each corresponding child patch, which can be assembled from the 'patch:' meshparts that are (hopefully) generated by the partitioner.
  3. On the root process, provide a template vector on the unpartitioned base-mesh space by calling the set_base_vector_template() function. Note that this step is only required if you intend to use the join() or join_write_out() functions and can be skipped if you only want to use the split() or split_read_from() functions.
  4. Compile the splitter by calling the compile() function and supplying it with a temporary local vector.
Author
Peter Zajac

Definition at line 58 of file splitter.hpp.

Member Typedef Documentation

◆ GlobalVectorType

template<typename LocalVector_ , typename Mirror_ >
typedef Global::Vector<LocalVector_, Mirror_> FEAT::Global::Splitter< LocalVector_, Mirror_ >::GlobalVectorType

our global vector type

Definition at line 71 of file splitter.hpp.

◆ LocalVectorType

template<typename LocalVector_ , typename Mirror_ >
typedef LocalVector_ FEAT::Global::Splitter< LocalVector_, Mirror_ >::LocalVectorType

our local vector type

Definition at line 65 of file splitter.hpp.

◆ MirrorType

template<typename LocalVector_ , typename Mirror_ >
typedef Mirror_ FEAT::Global::Splitter< LocalVector_, Mirror_ >::MirrorType

our mirror type

Definition at line 68 of file splitter.hpp.

◆ MuxerType

template<typename LocalVector_ , typename Mirror_ >
typedef Global::Muxer<LocalVector_, Mirror_> FEAT::Global::Splitter< LocalVector_, Mirror_ >::MuxerType

our internal muxer type

Definition at line 62 of file splitter.hpp.

Constructor & Destructor Documentation

◆ Splitter() [1/3]

template<typename LocalVector_ , typename Mirror_ >
FEAT::Global::Splitter< LocalVector_, Mirror_ >::Splitter ( )
inline

standard constructor

Definition at line 81 of file splitter.hpp.

◆ Splitter() [2/3]

template<typename LocalVector_ , typename Mirror_ >
FEAT::Global::Splitter< LocalVector_, Mirror_ >::Splitter ( Splitter< LocalVector_, Mirror_ > &&  other)
inline

move-constructor

Definition at line 88 of file splitter.hpp.

◆ Splitter() [3/3]

template<typename LocalVector_ , typename Mirror_ >
FEAT::Global::Splitter< LocalVector_, Mirror_ >::Splitter ( MuxerType &&  muxer,
LocalVector_ &&  base_vector_tmpl 
)
inlineexplicit

Definition at line 94 of file splitter.hpp.

◆ ~Splitter()

template<typename LocalVector_ , typename Mirror_ >
virtual FEAT::Global::Splitter< LocalVector_, Mirror_ >::~Splitter ( )
inlinevirtual

destructor

Definition at line 101 of file splitter.hpp.

Member Function Documentation

◆ bytes()

template<typename LocalVector_ , typename Mirror_ >
std::size_t FEAT::Global::Splitter< LocalVector_, Mirror_ >::bytes ( ) const
inline

◆ compile()

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::compile ( const LocalVector_ &  vec_tmp_)
inline

Compiles the muxer.

Parameters
[in]vec_tmp_A transient reference to a temporary vector for internal use.

Definition at line 253 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_muxer, and FEAT::Global::Muxer< LocalVector_, Mirror_ >::compile().

◆ convert() [1/2]

template<typename LocalVector_ , typename Mirror_ >
template<typename LVT2_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::convert ( const Splitter< LVT2_, Mirror_ > &  other,
LocalVector_ &&  vector,
LAFEM::CloneMode  mode = LAFEM::CloneMode::Shallow 
)
inline

Conversion function for different vector container type.

This function (re)creates this splitter from another gate with a different vector type, but the same mirrors. This can be used to create a splitter using DenseVectorBlocked from a splitter using DenseVector or vice versa.

Parameters
[in]otherA (transient) reference to the splitter using the other vector type to create this splitter from.
[in]vectorA temporary vector allocated to the correct size that is to be used for internal initialization.
[in]modeThe clone-mode to be used for cloning the mirrors. Defaults to shallow clone.
Attention
This function does not (because it can not) convert the base-mesh vector template, so this has to be provided afterwards by calling the set_base_vector_template() function.

Definition at line 153 of file splitter.hpp.

References FEAT::Global::Muxer< LocalVector_, Mirror_ >::convert().

◆ convert() [2/2]

template<typename LocalVector_ , typename Mirror_ >
template<typename LVT2_ , typename MT2_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::convert ( const Splitter< LVT2_, MT2_ > &  other)
inline

Conversion function for same vector container type but with different MDI-Type.

Parameters
[in]otherA transient reference to the splitter to convert from

Definition at line 124 of file splitter.hpp.

References FEAT::Global::Muxer< LocalVector_, Mirror_ >::convert().

◆ create_base_vector()

template<typename LocalVector_ , typename Mirror_ >
LocalVector_ FEAT::Global::Splitter< LocalVector_, Mirror_ >::create_base_vector ( ) const
inline

Creates a new base-mesh vector.

Returns
A new vector for the base-mesh space, which is allocated to correct size(s), but its numerical contents are uninitialized.

Definition at line 264 of file splitter.hpp.

References FEAT::LAFEM::Layout, and XASSERT.

◆ get_base_vector_template()

template<typename LocalVector_ , typename Mirror_ >
const LocalVector_ & FEAT::Global::Splitter< LocalVector_, Mirror_ >::get_base_vector_template ( ) const
inline

Returns the base vector template.

Definition at line 236 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_base_vector_tmpl.

◆ get_muxer()

template<typename LocalVector_ , typename Mirror_ >
const MuxerType & FEAT::Global::Splitter< LocalVector_, Mirror_ >::get_muxer ( ) const
inline

Returns the internal muxer.

Definition at line 242 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_muxer.

◆ is_root()

template<typename LocalVector_ , typename Mirror_ >
bool FEAT::Global::Splitter< LocalVector_, Mirror_ >::is_root ( ) const
inline

Checks whether this is the root process.

The root process is the process that receives the joined local vector and which is responsible for writing out and reading in the files.

Returns
true, if this is the root process, otherwise false.

Definition at line 176 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_muxer, FEAT::Global::Muxer< LocalVector_, Mirror_ >::get_sibling_comm(), and FEAT::Global::Muxer< LocalVector_, Mirror_ >::is_parent().

Referenced by FEAT::Global::Splitter< LocalVector_, Mirror_ >::join(), FEAT::Global::Splitter< LocalVector_, Mirror_ >::join_write_out(), and FEAT::Global::Splitter< LocalVector_, Mirror_ >::split_read_from().

◆ is_single()

template<typename LocalVector_ , typename Mirror_ >
bool FEAT::Global::Splitter< LocalVector_, Mirror_ >::is_single ( ) const
inline

Checks whether there is only one process in the communicator.

Returns
true, if there is only one process, otherwise false.

Definition at line 186 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_muxer, FEAT::Global::Muxer< LocalVector_, Mirror_ >::get_sibling_comm(), and FEAT::Dist::Comm::size().

Referenced by FEAT::Global::Splitter< LocalVector_, Mirror_ >::join(), and FEAT::Global::Splitter< LocalVector_, Mirror_ >::split().

◆ join() [1/2]

template<typename LocalVector_ , typename Mirror_ >
LocalVector_ FEAT::Global::Splitter< LocalVector_, Mirror_ >::join ( const Global::Vector< LocalVector_, Mirror_ > &  vector) const
inline

Joins a global vector into a base-mesh local vector on the root process.

Parameters
[in]vectorA transient reference to the global vector that is to be joined.
Returns
A base-mesh local vector that represents the joined input global vector.
Attention
A base-mesh vector template must have been given to this object on the root process by calling the set_base_vector_template() before calling this function.

Definition at line 283 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_base_vector_tmpl, FEAT::Global::Splitter< LocalVector_, Mirror_ >::is_root(), FEAT::Global::Splitter< LocalVector_, Mirror_ >::is_single(), FEAT::Global::Splitter< LocalVector_, Mirror_ >::join(), FEAT::LAFEM::Layout, FEAT::Global::Vector< LocalVector_, Mirror_ >::local(), and XASSERTM.

Referenced by FEAT::Global::Splitter< LocalVector_, Mirror_ >::join(), and FEAT::Global::Splitter< LocalVector_, Mirror_ >::join_write_out().

◆ join() [2/2]

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::join ( LocalVector_ &  vec_base,
const Global::Vector< LocalVector_, Mirror_ > &  vector 
) const
inline

Joins a global vector into a base-mesh local vector on the root process.

Parameters
[in,out]vec_baseA transient reference to a base-mesh local vector that receives the joined global vector. Must be allocated to correct size(s), but its numerical contents are ignored.
[in]vectorA transient reference to the type-1 global vector that is to be joined.
Note
It is not necessary to have supplied a base-mesh vector template by calling the set_base_vector_template() before calling this function, because the base-mesh vector is supplied here as a function parameter.

Definition at line 320 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_muxer, FEAT::Global::Vector< LocalVector_, Mirror_ >::clone(), FEAT::LAFEM::Deep, FEAT::Global::Vector< LocalVector_, Mirror_ >::from_1_to_0(), FEAT::Global::Muxer< LocalVector_, Mirror_ >::is_child(), FEAT::Global::Muxer< LocalVector_, Mirror_ >::is_parent(), FEAT::Global::Splitter< LocalVector_, Mirror_ >::is_single(), FEAT::Global::Muxer< LocalVector_, Mirror_ >::join(), FEAT::Global::Muxer< LocalVector_, Mirror_ >::join_send(), FEAT::Global::Vector< LocalVector_, Mirror_ >::local(), and XASSERT.

◆ join_write_out()

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::join_write_out ( const Global::Vector< LocalVector_, Mirror_ > &  vector,
const String filename,
LAFEM::FileMode  mode = LAFEM::FileMode::fm_binary 
) const
inline

Joins a global vector into a base-mesh local vector and writes it to a file.

Parameters
[in]vectorA transient reference to the type-1 global vector that is to be joined.
[in]filenameThe filename of the output file that is to be written.
[in]modeThe LAFEM::FileMode of the output file, defaults to binary format.
Attention
A base-mesh vector template must have been given to this object on the root process by calling the set_base_vector_template() before calling this function.

Definition at line 416 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::is_root(), and FEAT::Global::Splitter< LocalVector_, Mirror_ >::join().

◆ operator=()

template<typename LocalVector_ , typename Mirror_ >
Splitter & FEAT::Global::Splitter< LocalVector_, Mirror_ >::operator= ( Splitter< LocalVector_, Mirror_ > &&  other)
inline

◆ push_patch()

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::push_patch ( Mirror_ &&  patch_mirror)
inline

Adds a child rank and mirror for the parent process.

Parameters
[in]patch_mirrorThe mirror of the patch of this process.

Definition at line 214 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_muxer, and FEAT::Global::Muxer< LocalVector_, Mirror_ >::push_child().

◆ set_base_vector_template()

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::set_base_vector_template ( LocalVector_ &&  vector_template)
inline

Sets the base-vector template on the root process.

Note
Calling this function is only required on the root process if one wants to make use of the join() or join_write_out() functions and can be skipped on all other processes.
Parameters
[in]vector_templateA base-mesh vector that is allocated to correct size(s) and which is used as a template for the creation of temporary base-mesh vectors. Its numerical contents are ignored.

Definition at line 230 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_base_vector_tmpl.

◆ set_root()

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::set_root ( const Dist::Comm comm,
int  root_rank,
Mirror_ &&  root_mirror 
)
inline

Sets the root communicator.

Parameters
[in]commThe communicator.
[in]root_rankThe rank of the root process in the comm.
[in]root_mirrorThe root mirror.

Definition at line 203 of file splitter.hpp.

References FEAT::Global::Muxer< LocalVector_, Mirror_ >::set_parent().

◆ split() [1/2]

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::split ( Global::Vector< LocalVector_, Mirror_ > &  vector,
const LocalVector_ &  vec_base 
) const
inline

Splits a base-mesh local vector on the root process into a global vector.

Parameters
[in,out]vectorA transient reference to the type-1 global vector that receives the split base-mesh vector. Must be allocated to correct size(s), but its numerical contents are ignored.
[in]vec_baseA transient reference to a base-mesh local vector that is to be split.

Definition at line 362 of file splitter.hpp.

References FEAT::Global::Vector< LocalVector_, Mirror_ >::local(), and FEAT::Global::Splitter< LocalVector_, Mirror_ >::split().

Referenced by FEAT::Global::Splitter< LocalVector_, Mirror_ >::split(), and FEAT::Global::Splitter< LocalVector_, Mirror_ >::split_read_from().

◆ split() [2/2]

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::split ( LocalVector_ &  vector,
const LocalVector_ &  vec_base 
) const
inline

Splits a base-mesh local vector on the root process into a patch-local vector.

Parameters
[in,out]vectorA transient reference to the type-1 patch-local vector that receives the split base-mesh vector. Must be allocated to correct size(s), but its numerical contents are ignored.
[in]vec_baseA transient reference to a base-mesh local vector that is to be split.

Definition at line 378 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::_muxer, FEAT::Global::Muxer< LocalVector_, Mirror_ >::is_child(), FEAT::Global::Muxer< LocalVector_, Mirror_ >::is_parent(), FEAT::Global::Splitter< LocalVector_, Mirror_ >::is_single(), FEAT::Global::Muxer< LocalVector_, Mirror_ >::split(), FEAT::Global::Muxer< LocalVector_, Mirror_ >::split_recv(), and XASSERT.

◆ split_read_from() [1/2]

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::split_read_from ( Global::Vector< LocalVector_, Mirror_ > &  vector,
const String filename,
LAFEM::FileMode  mode = LAFEM::FileMode::fm_binary 
) const
inline

Reads in a base-mesh local vector and splits it into a global vector.

Parameters
[in,out]vectorA transient reference to the type-1 global vector that is to be joined. Must be allocated to correct size(s), but its numerical contents are ignored.
[in]filenameThe filename of the input file that is to be read in.
[in]modeThe LAFEM::FileMode of the input file, defaults to binary format.

Definition at line 442 of file splitter.hpp.

References FEAT::Global::Vector< LocalVector_, Mirror_ >::local(), and FEAT::Global::Splitter< LocalVector_, Mirror_ >::split_read_from().

Referenced by FEAT::Global::Splitter< LocalVector_, Mirror_ >::split_read_from().

◆ split_read_from() [2/2]

template<typename LocalVector_ , typename Mirror_ >
void FEAT::Global::Splitter< LocalVector_, Mirror_ >::split_read_from ( LocalVector_ &  vector,
const String filename,
LAFEM::FileMode  mode = LAFEM::FileMode::fm_binary 
) const
inline

Reads in a base-mesh local vector and splits it into a patch-local vector.

Parameters
[in,out]vectorA transient reference to the type-1 patch-local vector that receives the split base-mesh vector. Must be allocated to correct size(s), but its numerical contents are ignored.
[in]filenameThe filename of the input file that is to be read in.
[in]modeThe LAFEM::FileMode of the input file, defaults to binary format.

Definition at line 461 of file splitter.hpp.

References FEAT::Global::Splitter< LocalVector_, Mirror_ >::is_root(), and FEAT::Global::Splitter< LocalVector_, Mirror_ >::split().

Member Data Documentation

◆ _base_vector_tmpl

◆ _muxer


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