33#ifndef __H__LIB_ALGEBRA__PARALLELIZATION__COMMUNICATION_POLICIES__
34#define __H__LIB_ALGEBRA__PARALLELIZATION__COMMUNICATION_POLICIES__
86template <
class TVector>
121 return interface.
size() *
sizeof(
typename TVector::value_type);
146 iter != interface.
end(); ++iter)
176 iter != interface.
end(); ++iter)
202template <
class TVector>
233 return interface.
size() *
sizeof(
typename TVector::value_type);
251 if(
m_pVec == NULL)
return false;
258 iter != interface.
end(); ++iter)
281 if(
m_pVec == NULL)
return false;
288 iter != interface.
end(); ++iter)
317template <
class TVector>
352 return interface.
size() *
sizeof(
typename TVector::value_type);
377 iter != interface.
end(); ++iter)
406 typename TVector::value_type entry;
410 iter != interface.
end(); ++iter)
438template <
class TVector>
468 return interface.
size() *
sizeof(
typename TVector::value_type);
486 if(
m_pVec == NULL)
return false;
493 iter != interface.
end(); ++iter)
516 if(
m_pVec == NULL)
return false;
522 typename TVector::value_type entry;
526 iter != interface.
end(); ++iter)
562template <
class TVector>
589 return interface.
size() *
sizeof(
typename TVector::value_type);
609 if(
m_pVec == NULL)
return false;
615 iter != interface.
end(); ++iter)
640 if(
m_pVec == NULL)
return false;
646 typename TVector::value_type entry;
650 iter != interface.
end(); ++iter)
677template <
class TVector>
704 return interface.
size() *
sizeof(
typename TVector::value_type);
722 if(
m_pVec == NULL)
return false;
729 iter != interface.
end(); ++iter)
752 if(
m_pVec == NULL)
return false;
758 typename TVector::value_type entry;
762 iter != interface.
end(); ++iter)
781template <
class TVector>
799 return interface.
size() *
sizeof(
typename TVector::value_type);
810 if(
m_pVec == NULL)
return false;
813 const TVector& v = *
m_pVec;
817 iter != interface.
end(); ++iter)
834 if(
m_pVec == NULL)
return false;
837 const TVector& v = *
m_pVec;
840 typename TVector::value_type entry, diff;
844 iter != interface.
end(); ++iter)
879template <
class TVector>
920 return interface.
size() *
sizeof(
typename TVector::value_type);
939 if(
m_pVec == NULL)
return false;
946 iter != interface.
end(); ++iter)
969 if(
m_pVec == NULL)
return false;
975 typename TVector::value_type entry;
979 iter != interface.
end(); ++iter)
1015template <
class TAlgebra>
1048 return interface.
size() *
sizeof(
typename TMatrix::value_type);
1058 typedef typename TMatrix::value_type block_type;
1062 iter != interface.
end(); ++iter)
1066 block_type& a_ii =
m_rMat(index, index);
1069 block_type out_ii = a_ii;
1097 typedef typename TMatrix::value_type block_type;
1103 iter != interface.
end(); ++iter)
1113 m_rMat(index, index) += in_ii;
1140template <
class TMatrix>
1152 UG_ASSERT(vGlobalID.size() >=
m_rMat.num_rows(),
"too few Global ids");
1159 typedef typename TMatrix::row_iterator row_iterator;
1160 typedef typename TMatrix::value_type block_type;
1164 iter != interface.
end(); ++iter)
1170 const row_iterator rowEnd =
m_rMat.end_row(index);
1171 size_t numRowEntry = 0;
1172 for(row_iterator it_k =
m_rMat.begin_row(index); it_k != rowEnd; ++it_k)
1179 for(row_iterator it_k =
m_rMat.begin_row(index); it_k != rowEnd; ++it_k)
1181 const size_t k = it_k.index();
1182 block_type& a_ik = it_k.value();
1209 typedef typename TMatrix::value_type block_type;
1219 iter != interface.
end(); ++iter)
1225 size_t numConnections = 0;
1229 for(
size_t i_conn = 0; i_conn < numConnections; ++i_conn){
1238 m_rMat(index, conInd) += block;
1270template <
class TMatrix>
1282 UG_ASSERT(vGlobalID.size() >=
m_rMat.num_rows(),
"too few Global ids");
1289 typedef typename TMatrix::row_iterator row_iterator;
1290 typedef typename TMatrix::value_type block_type;
1294 iter != interface.
end(); ++iter)
1300 const row_iterator rowEnd =
m_rMat.end_row(index);
1301 size_t numRowEntry = 0;
1302 for(row_iterator it_k =
m_rMat.begin_row(index); it_k != rowEnd; ++it_k)
1309 for(row_iterator it_k =
m_rMat.begin_row(index); it_k != rowEnd; ++it_k)
1311 const size_t k = it_k.index();
1312 block_type& a_ik = it_k.value();
1339 typedef typename TMatrix::value_type block_type;
1349 iter != interface.
end(); ++iter)
1355 size_t numConnections = 0;
1359 for(
size_t i_conn = 0; i_conn < numConnections; ++i_conn){
1367 m_rMat(index, conInd) = block;
1393template <
class TMatrix>
1406 PROFILE_BEGIN_GROUP(ComPol_MatAddInnerInterfaceCouplings_collect,
"algebra parallelization");
1407 typedef typename TMatrix::row_iterator row_iterator;
1408 typedef typename TMatrix::value_type block_type;
1412 size_t interfaceIndex = 0;
1415 iter != interface.
end(); ++iter, ++interfaceIndex){
1421 iter != interface.
end(); ++iter)
1427 const row_iterator rowEnd =
m_rMat.end_row(index);
1428 size_t numRowEntry = 0;
1429 for(row_iterator it_k =
m_rMat.begin_row(index); it_k != rowEnd; ++it_k){
1430 if(!hash.
has_entry(it_k.index()))
continue;
1438 for(row_iterator it_k =
m_rMat.begin_row(index); it_k != rowEnd; ++it_k)
1440 const size_t target = it_k.index();
1441 if(!hash.
get_entry(interfaceIndex, target))
continue;
1442 block_type& a_ik = it_k.value();
1463 typedef typename TMatrix::value_type block_type;
1466 std::vector<size_t> vMapInterfaceToGlob(interface.
size());
1469 iter != interface.
end(); ++iter, ++k){
1470 vMapInterfaceToGlob[k] = interface.
get_element(iter);
1479 iter != interface.
end(); ++iter)
1485 size_t numConnections = 0;
1489 for(
size_t i_conn = 0; i_conn < numConnections; ++i_conn){
1493 UG_ASSERT(locID < vMapInterfaceToGlob.size(),
"Invalid"
1494 " id: "<<locID<<
", size: "<<vMapInterfaceToGlob.size());
1495 m_rMat(index, vMapInterfaceToGlob[locID]) += block;
specializations are responsible to pack and unpack interface data during communication.
Definition pcl_communication_structs.h:790
You may add elements to this interface and iterate over them.
Definition pcl_communication_structs.h:207
ElemContainer::const_iterator const_iterator
Definition pcl_communication_structs.h:237
iterator end()
Definition pcl_communication_structs.h:293
iterator begin()
Definition pcl_communication_structs.h:292
Element & get_element(iterator iter)
Definition pcl_communication_structs.h:298
size_t size() const
returns the number of elements that are stored in the interface.
Definition pcl_communication_structs.h:306
A Buffer for binary data.
Definition binary_buffer.h:56
Communication Policy to check consistency of a vector.
Definition communication_policies.h:783
const TVector * m_pVec
Definition communication_policies.h:866
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:806
ComPol_CheckConsistency()
Default constructor.
Definition communication_policies.h:786
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
checks if recieved values are equal to process local values
Definition communication_policies.h:830
void set_vector(const TVector *pVec)
sets the vector used in communication
Definition communication_policies.h:792
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:796
ComPol_CheckConsistency(const TVector *pVec)
Constructor setting the values.
Definition communication_policies.h:789
Communication Policy to copy slave couplings to master row.
Definition communication_policies.h:1143
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:1156
TMatrix & m_rMat
Definition communication_policies.h:1249
virtual bool begin_layout_extraction(const Layout *pLayout)
signals the beginning of a layout extraction.
Definition communication_policies.h:1197
ComPol_MatAddRowsOverlap0(TMatrix &rMat, AlgebraIDVec &vGlobalID)
Constructor setting the vector.
Definition communication_policies.h:1149
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
writes values from a buffer into the interface
Definition communication_policies.h:1205
AlgebraIDVec & m_vGlobalID
Definition communication_policies.h:1252
AlgebraIDHashList m_algIDHash
Definition communication_policies.h:1255
Comm-Pol to add matrix rows of inner-interface couplings.
Definition communication_policies.h:1396
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:1404
TMatrix & m_rMat
Definition communication_policies.h:1505
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
writes values from a buffer into the interface
Definition communication_policies.h:1459
ComPol_MatAddSetZeroInnerInterfaceCouplings(TMatrix &rMat)
Constructor setting the matrix.
Definition communication_policies.h:1399
Communication Policy to copy couplings between interfaces.
Definition communication_policies.h:1273
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
writes values from a buffer into the interface
Definition communication_policies.h:1335
virtual bool begin_layout_extraction(const Layout *pLayout)
signals the beginning of a layout extraction.
Definition communication_policies.h:1327
AlgebraIDHashList m_algIDHash
Definition communication_policies.h:1384
AlgebraIDVec & m_vGlobalID
Definition communication_policies.h:1381
TMatrix & m_rMat
Definition communication_policies.h:1378
ComPol_MatCopyRowsOverlap0(TMatrix &rMat, AlgebraIDVec &vGlobalID)
Constructor setting the vector.
Definition communication_policies.h:1279
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:1286
Communication Policy sending fractions to.
Definition communication_policies.h:1018
virtual bool begin_layout_extraction(const Layout *pLayout)
signals the beginning of a layout extraction.
Definition communication_policies.h:1089
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:1045
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
writes values from a buffer into the interface
Definition communication_policies.h:1093
TAlgebra::vector_type TVector
Definition communication_policies.h:1022
TMatrix & m_rMat
Definition communication_policies.h:1122
ComPol_MatDistributeDiag(TMatrix &rMat, TVector &rWeight, double theta=1.0)
Constructor setting the vector.
Definition communication_policies.h:1028
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:1055
TAlgebra::matrix_type TMatrix
Definition communication_policies.h:1021
TVector & m_rWeight
Definition communication_policies.h:1123
double m_dTheta
Definition communication_policies.h:1124
Communication Policy to add values of a vector.
Definition communication_policies.h:319
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
adds values of a buffer to the interface values
Definition communication_policies.h:396
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:349
TVector * m_pVecDest
Definition communication_policies.h:425
ComPol_VecAdd(TVector *pVec)
Constructor setting the values.
Definition communication_policies.h:325
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:366
ComPol_VecAdd()
Default constructor.
Definition communication_policies.h:322
ComPol_VecAdd(TVector *pVecDest, const TVector *pVecSrc)
Constructor setting the values.
Definition communication_policies.h:328
void set_vector(TVector *pVecDest, const TVector *pVecSrc)
sets the vector used in communication
Definition communication_policies.h:335
const TVector * m_pVecSrc
Definition communication_policies.h:426
void set_vector(TVector *pVec)
sets the vector used in communication
Definition communication_policies.h:332
Communication Policy to add values of a vector and reset value to zero on sending interface.
Definition communication_policies.h:564
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
Definition communication_policies.h:605
ComPol_VecAddSetZero()
Default Constructor.
Definition communication_policies.h:567
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
adds the values of a buffer to the values on the interface
Definition communication_policies.h:636
ComPol_VecAddSetZero(TVector *pVec)
Constructor setting vector.
Definition communication_policies.h:570
TVector * m_pVec
Definition communication_policies.h:665
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:586
void set_vector(TVector *pVec)
sets the vector that we be used for communication
Definition communication_policies.h:573
Communication Policy to copy values of a vector.
Definition communication_policies.h:88
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
writes values from a buffer into the interface
Definition communication_policies.h:165
ComPol_VecCopy(TVector *pVec)
Constructor setting the vector.
Definition communication_policies.h:94
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:135
TVector * m_pVecDest
Definition communication_policies.h:189
ComPol_VecCopy()
Default constructor.
Definition communication_policies.h:91
void set_vector(TVector *pVec)
set the vector to work on
Definition communication_policies.h:101
void set_vector(TVector *pVecDest, const TVector *pVecSrc)
set the vector to work on
Definition communication_policies.h:104
ComPol_VecCopy(TVector *pVecDest, const TVector *pVecSrc)
Constructor setting the vector.
Definition communication_policies.h:97
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:118
const TVector * m_pVecSrc
Definition communication_policies.h:190
Communication Policy to add values of a vector.
Definition communication_policies.h:440
TVector * m_pVec
Definition communication_policies.h:541
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:482
ComPol_VecScaleAdd(TVector *pVec)
Constructor setting the values.
Definition communication_policies.h:446
void set_vector(TVector *pVec)
sets the vector used in communication
Definition communication_policies.h:449
number m_scale
Definition communication_policies.h:543
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:465
ComPol_VecScaleAdd()
Default constructor.
Definition communication_policies.h:443
void set_scale(number scale)
sets the scaling factor
Definition communication_policies.h:452
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
scales and adds values of a buffer to the interface values
Definition communication_policies.h:512
Communication Policy to copy scaled values of a vector.
Definition communication_policies.h:204
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:230
TVector * m_pVec
Definition communication_policies.h:303
void set_scale(number scale)
sets the scaling factor
Definition communication_policies.h:217
ComPol_VecScaleCopy()
Default Constructor.
Definition communication_policies.h:207
ComPol_VecScaleCopy(TVector *pVec, number scale)
Constructor setting vector and scaling factor.
Definition communication_policies.h:210
void set_vector(TVector *pVec)
sets the vector that we be used for communication
Definition communication_policies.h:214
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
scales values of a buffer and writes the into the interface
Definition communication_policies.h:277
number m_scale
Definition communication_policies.h:305
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:247
Communication Policy to subtract values of a vector.
Definition communication_policies.h:679
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:701
ComPol_VecSubtract(TVector *pVec)
Constructor setting the values.
Definition communication_policies.h:685
TVector * m_pVec
Definition communication_policies.h:777
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:718
void set_vector(TVector *pVec)
sets the vector used in communication
Definition communication_policies.h:688
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
subtracts values of a buffer to the interface values
Definition communication_policies.h:748
ComPol_VecSubtract()
Default constructor.
Definition communication_policies.h:682
Communication Policy to subtract only one slave value per master of a vector.
Definition communication_policies.h:881
virtual int get_required_buffer_size(const Interface &interface)
returns the buffer size
Definition communication_policies.h:917
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the interface values into a buffer that will be sent
Definition communication_policies.h:934
ComPol_VecSubtractOnlyOneSlave(TVector *pVec)
Constructor setting the values.
Definition communication_policies.h:887
void set_vector(TVector *pVec)
sets the vector used in communication
Definition communication_policies.h:893
ComPol_VecSubtractOnlyOneSlave()
Default constructor.
Definition communication_policies.h:884
std::vector< bool > m_vProcessed
Definition communication_policies.h:999
TVector * m_pVec
Definition communication_policies.h:998
void clear()
clear processed flag
Definition communication_policies.h:900
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
subtracts values of a buffer to the interface values
Definition communication_policies.h:965
void insert(const key_t &key, const value_t &val)
Definition hash_impl.hpp:199
value_t & get_entry(const key_t &key)
Definition hash_impl.hpp:158
bool has_entry(const key_t &key) const
Definition hash_impl.hpp:150
#define UG_LOG_ALL_PROCS(msg)
Definition log.h:371
#define UG_ASSERT(expr, msg)
Definition assert.h:70
double number
Definition types.h:124
double & BlockRef(T &vec, size_t i)
Definition blocks.h:66
void Deserialize(TIStream &buf, ParallelVector< T > &v)
Deerialize for ParallelVector<T>
Definition restart_bridge.cpp:112
std::vector< AlgebraID > AlgebraIDVec
Definition algebra_id.h:63
void GenerateAlgebraIDHashList(AlgebraIDHashList &hash, AlgebraIDVec &algebraIDs)
Creates a hash which allows a algebraID->localIndex mapping.
Definition algebra_id.h:70
void Serialize(TOStream &buf, const ParallelVector< T > &v)
Serialize for ParallelVector<T>
Definition restart_bridge.cpp:103
double VecNormSquared(const double &a)
returns norm_2^2(a)
Definition operations_vec.h:100
#define PROFILE_BEGIN_GROUP(name, groups)
Definition profiler.h:255
this type is used to identify distributed objects.
Definition algebra_id.h:46
Definition communication_policies.h:58
@ is_static
Definition communication_policies.h:60