ug4
Parallel Algebra Util

Util Functions for parallel Algebra. More...

template<class TLayout >
void ug::GenerateGlobalAlgebraIDs (pcl::InterfaceCommunicator< TLayout > &communicator, std::vector< AlgebraID > &idsOut, size_t numIDs, const TLayout &masterLayout, const TLayout &slaveLayout)
 Generates a set of unique global algebra ids. More...
 
template<typename TMatrix >
void ug::MatAddSlaveRowsToMasterRowOverlap0 (TMatrix &mat)
 Generates a set of unique global algebra ids. More...
 
template<typename TMatrix >
void ug::MatMakeConsistentOverlap0 (TMatrix &mat)
 Generates a set of unique global algebra ids. More...
 
template<typename TVector >
void ug::AdditiveToConsistent (TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
 changes parallel storage type from additive to consistent More...
 
template<typename TVector >
void ug::UniqueToConsistent (TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
 changes parallel storage type from unique to consistent More...
 
template<typename TVector >
void ug::CopyValues (TVector *pVec, const IndexLayout &sourceLayout, const IndexLayout &targetLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
 Copies values from the source to the target layout. More...
 
template<typename TVector >
void ug::AdditiveToUnique (TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
 changes parallel storage type from additive to unique More...
 
template<typename TVector >
void ug::SetInterfaceValues (TVector *pVec, const IndexLayout::Interface &interface, typename TVector::value_type val)
 sets the values of a vector to a given number only on the interface indices More...
 
template<typename TVector >
void ug::SetLayoutValues (TVector *pVec, const IndexLayout &layout, typename TVector::value_type val)
 sets the values of a vector to a given number only on the layout indices More...
 
template<typename TVector >
void ug::ScaleLayoutValues (TVector *pVec, const IndexLayout &layout, number scale)
 scales the values of a vector by a given number only on the layout indices More...
 
template<typename TVector >
void ug::ConsistentToUnique (TVector *pVec, const IndexLayout &slaveLayout)
 changes parallel storage type from consistent to unique More...
 
template<typename TVector >
void ug::VecSubtractOnLayout (TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
 subtracts values of slave layout from master layout and sets slave layouts to negative of difference More...
 
template<typename TVector >
void ug::VecSubtractOneSlaveFromMaster (TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
 subtracts values of only one slave dof per master on layout More...
 
template<typename TVector >
void ug::VecCopy (TVector *pVec, const IndexLayout &masterLayout, const IndexLayout &slaveLayout, pcl::InterfaceCommunicator< IndexLayout > *pCom=NULL)
 copy a vector only at a layout More...
 
void ug::CommunicateConnections (std::vector< std::vector< int > > &connectionsToProcsOut, std::vector< std::vector< int > > &connectionsToSubDomsOut, IndexLayout &masterLayout, IndexLayout &slaveLayout, int highestReferencedIndex, pcl::IDomainDecompositionInfo &ddinfo)
 fills a connection list, which gives the connected processes to each interface. More...
 

Detailed Description

Util Functions for parallel Algebra.

In order to simplify the use of Communication Policies for Algebras some util functions are provided.

Function Documentation

◆ AdditiveToConsistent()

template<typename TVector >
void ug::AdditiveToConsistent ( TVector *  pVec,
const IndexLayout masterLayout,
const IndexLayout slaveLayout,
pcl::InterfaceCommunicator< IndexLayout > *  pCom = NULL 
)

changes parallel storage type from additive to consistent

This function changes the storage type of a parallel vector from additive to consistent. A InterfaceCommunicator is created iff no communicator passed.

Parameters
[in,out]pVecParallel Vector
[in]masterLayoutMaster Layout
[in]slaveLayoutSlave Layout
[in]pComParallel Communicator

References pcl::InterfaceCommunicator< TLayout >::communicate(), PROFILE_FUNC_GROUP, PU_PROFILE_BEGIN, PU_PROFILE_END, pcl::InterfaceCommunicator< TLayout >::receive_data(), and pcl::InterfaceCommunicator< TLayout >::send_data().

Referenced by ug::ParallelVector< Vector< double > >::clone_without_values(), ug::MatAdditiveToConsistentOnDiag(), and ug::StdTransfer< TDomain, TAlgebra >::prolongate().

◆ AdditiveToUnique()

template<typename TVector >
void ug::AdditiveToUnique ( TVector *  pVec,
const IndexLayout masterLayout,
const IndexLayout slaveLayout,
pcl::InterfaceCommunicator< IndexLayout > *  pCom = NULL 
)

changes parallel storage type from additive to unique

This function changes the storage type of a parallel vector from additive to unique. A InterfaceCommunicator is created iff no communicator passed.

Parameters
[in,out]pVecParallel Vector
[in]masterLayoutMaster Layout
[in]slaveLayoutSlave Layout
[in]pComParallel Communicator

References pcl::InterfaceCommunicator< TLayout >::communicate(), PROFILE_FUNC_GROUP, pcl::InterfaceCommunicator< TLayout >::receive_data(), and pcl::InterfaceCommunicator< TLayout >::send_data().

◆ CommunicateConnections()

void ug::CommunicateConnections ( std::vector< std::vector< int > > &  connectionsToProcsOut,
std::vector< std::vector< int > > &  connectionsToSubDomsOut,
IndexLayout masterLayout,
IndexLayout slaveLayout,
int  highestReferencedIndex,
pcl::IDomainDecompositionInfo ddinfo 
)

fills a connection list, which gives the connected processes to each interface.

The i-th entry in connectionsOut is a vector which contains the process-ids of all connected processes of the layout-entry with value i. This includes connections to all slaves of the associated master. The first entry for each connection is the process on which the master-element lies, followed by the processes where associated slaves lie.

Parameters
connectionsOutwill have the size highestReferencedIndex + 1 when the method is done. By indexing connectionsOut with an entry of one of the layouts interfaces, you will obtain a vector of all processes on which copies of that entry reside.
highestReferencedIndexhas to hold the highest index which is referenced either by entries in the interfaces of masterLayout or by entries in the interfaces of slaveLayout. Note that it can be obtained by a call to std::max(GetHighestReferencedIndex(masterLayout), GetHighestReferencedIndex(slaveLayout)).
Todo:
The method should probably automatically find the highestReferencedIndex, to avoid misuse.

◆ ConsistentToUnique()

template<typename TVector >
void ug::ConsistentToUnique ( TVector *  pVec,
const IndexLayout slaveLayout 
)

changes parallel storage type from consistent to unique

This function changes the storage type of a parallel vector from consistent to unique. Note, that no communication is needed.

Parameters
[in,out]pVecParallel Vector
[in]slaveLayoutSlave Layout

References PROFILE_FUNC_GROUP, and ug::SetLayoutValues().

◆ CopyValues()

template<typename TVector >
void ug::CopyValues ( TVector *  pVec,
const IndexLayout sourceLayout,
const IndexLayout targetLayout,
pcl::InterfaceCommunicator< IndexLayout > *  pCom = NULL 
)

◆ GenerateGlobalAlgebraIDs()

template<class TLayout >
void ug::GenerateGlobalAlgebraIDs ( pcl::InterfaceCommunicator< TLayout > &  communicator,
std::vector< AlgebraID > &  idsOut,
size_t  numIDs,
const TLayout &  masterLayout,
const TLayout &  slaveLayout 
)

Generates a set of unique global algebra ids.

Horizontal slaves have the same algebra-id as their associated horizontal masters. Make sure that masterLayout and slaveLayout do not reference indices >= numIDs.

References pcl::InterfaceCommunicator< TLayout >::communicate(), pcl::ProcRank(), PROFILE_FUNC_GROUP, pcl::InterfaceCommunicator< TLayout >::receive_data(), and pcl::InterfaceCommunicator< TLayout >::send_data().

Referenced by ug::CreateOverlap(), ug::MatAddSlaveRowsToMasterRowOverlap0(), ug::MatMakeConsistentOverlap0(), ug::ParallelNodes::ParallelNodes(), and ug::TestHorizontalAlgebraLayouts().

◆ MatAddSlaveRowsToMasterRowOverlap0()

template<typename TMatrix >
void ug::MatAddSlaveRowsToMasterRowOverlap0 ( TMatrix &  mat)

◆ MatMakeConsistentOverlap0()

template<typename TMatrix >
void ug::MatMakeConsistentOverlap0 ( TMatrix &  mat)

Generates a set of unique global algebra ids.

Horizontal slaves have the same algebra-id as their associated horizontal masters. Make sure that masterLayout and slaveLayout do not reference indices >= numIDs.

References pcl::InterfaceCommunicator< TLayout >::communicate(), ug::GenerateGlobalAlgebraIDs(), PROFILE_FUNC_GROUP, pcl::InterfaceCommunicator< TLayout >::receive_data(), and pcl::InterfaceCommunicator< TLayout >::send_data().

Referenced by ug::IExternalSolver< TAlgebra >::mat_preprocess(), ug::GaussSeidelBase< TAlgebra >::preprocess(), and ug::ILU< TAlgebra >::preprocess().

◆ ScaleLayoutValues()

template<typename TVector >
void ug::ScaleLayoutValues ( TVector *  pVec,
const IndexLayout layout,
number  scale 
)

scales the values of a vector by a given number only on the layout indices

Parameters
[in,out]pVecVector
[in]layoutLayout
[in]scaleScaling factor

References pcl::SingleLevelLayout< TInterface >::begin(), pcl::SingleLevelLayout< TInterface >::end(), pcl::OrderedInterface< TType, TContainer, TAlloc >::get_element(), and PROFILE_FUNC_GROUP.

Referenced by ug::StdTransfer< TDomain, TAlgebra >::prolongate().

◆ SetInterfaceValues()

template<typename TVector >
void ug::SetInterfaceValues ( TVector *  pVec,
const IndexLayout::Interface interface,
typename TVector::value_type  val 
)

sets the values of a vector to a given number only on the interface indices

Parameters
[in,out]pVecVector
[in]layoutLayout
[in]valValue to set on layout indices

References pcl::OrderedInterface< TType, TContainer, TAlloc >::begin(), pcl::OrderedInterface< TType, TContainer, TAlloc >::end(), pcl::OrderedInterface< TType, TContainer, TAlloc >::get_element(), and PROFILE_FUNC_GROUP.

◆ SetLayoutValues()

◆ UniqueToConsistent()

template<typename TVector >
void ug::UniqueToConsistent ( TVector *  pVec,
const IndexLayout masterLayout,
const IndexLayout slaveLayout,
pcl::InterfaceCommunicator< IndexLayout > *  pCom = NULL 
)

changes parallel storage type from unique to consistent

This function changes the storage type of a parallel vector from unique to consistent. A InterfaceCommunicator is created iff no communicator passed.

Parameters
[in,out]pVecParallel Vector
[in]masterLayoutMaster Layout
[in]slaveLayoutSlave Layout
[in]pComParallel Communicator

References pcl::InterfaceCommunicator< TLayout >::communicate(), PROFILE_FUNC_GROUP, pcl::InterfaceCommunicator< TLayout >::receive_data(), and pcl::InterfaceCommunicator< TLayout >::send_data().

Referenced by ug::ParallelVector< Vector< double > >::enforce_consistent_type().

◆ VecCopy()

template<typename TVector >
void ug::VecCopy ( TVector *  pVec,
const IndexLayout masterLayout,
const IndexLayout slaveLayout,
pcl::InterfaceCommunicator< IndexLayout > *  pCom = NULL 
)

copy a vector only at a layout

This function copies a vector only at a layout. Communication is performed. Information flow is from masters to slaves but not vice versa. Note: This function is basically 'UniqueToConsistent()', so "sender" and "receiver" in this function are the same as in 'UniqueToConsistent()').

Parameters
[in,out]pVecParallel Vector
[in]masterLayoutMaster Layout
[in]slaveLayoutSlave Layout
[in]pComParallel Communicator

References pcl::InterfaceCommunicator< TLayout >::communicate(), PROFILE_FUNC_GROUP, pcl::InterfaceCommunicator< TLayout >::receive_data(), and pcl::InterfaceCommunicator< TLayout >::send_data().

◆ VecSubtractOneSlaveFromMaster()

template<typename TVector >
void ug::VecSubtractOneSlaveFromMaster ( TVector *  pVec,
const IndexLayout masterLayout,
const IndexLayout slaveLayout,
pcl::InterfaceCommunicator< IndexLayout > *  pCom = NULL 
)

subtracts values of only one slave dof per master on layout

This function subtracts one slave value dof per master dof. Communication is performed. Information flow is from slaves to masters but not vice versa.

Parameters
[in,out]pVecParallel Vector
[in]masterLayoutMaster Layout
[in]slaveLayoutSlave Layout
[in]pComParallel Communicator

References pcl::InterfaceCommunicator< TLayout >::communicate(), PROFILE_FUNC_GROUP, pcl::InterfaceCommunicator< TLayout >::receive_data(), and pcl::InterfaceCommunicator< TLayout >::send_data().

Referenced by ug::ComputeDifferenceOnDelta().

◆ VecSubtractOnLayout()

template<typename TVector >
void ug::VecSubtractOnLayout ( TVector *  pVec,
const IndexLayout masterLayout,
const IndexLayout slaveLayout,
pcl::InterfaceCommunicator< IndexLayout > *  pCom = NULL 
)

subtracts values of slave layout from master layout and sets slave layouts to negative of difference

This function subtracts all slave values from the master value. Then, the slave values are set to the negative of the computed difference.

Parameters
[in,out]pVecParallel Vector
[in]masterLayoutMaster Layout
[in]slaveLayoutSlave Layout
[in]pComParallel Communicator

References pcl::InterfaceCommunicator< TLayout >::communicate(), PROFILE_FUNC_GROUP, pcl::InterfaceCommunicator< TLayout >::receive_data(), and pcl::InterfaceCommunicator< TLayout >::send_data().