33 #ifndef __H__LIB_ALGEBRA__COLLECT_MATRIX_H_
34 #define __H__LIB_ALGEBRA__COLLECT_MATRIX_H_
42 template<
typename matrix_type>
57 for(
typename matrix_type::const_row_iterator conn = mat.begin_row(localRowIndex);
58 conn != mat.end_row(localRowIndex); ++conn)
60 size_t localColIndex = conn.index();
64 UG_DLOG(
LIB_ALG_AMG, 4, localColIndex <<
" (" << globalColIndex <<
") -> " << conn.value() <<
" ");
74 template<
typename matrix_type>
84 for(
size_t i=0; i<A.num_rows(); i++)
91 for(
size_t i=0; i<A.num_rows(); i++)
99 template<
typename TConnectionType>
109 UG_DLOG(
LIB_ALG_AMG, 4,
"Got row " << localRowIndex <<
" (" << globalRowIndex <<
"), ");
124 UG_DLOG(
LIB_ALG_AMG, 4, cons[i].iIndex <<
" (" << globalColIndex <<
") -> " << cons[i].dValue <<
" ");
127 return localRowIndex;
141 template<
typename matrix_type>
152 typedef std::map<int, BinaryBuffer> BufferMap;
156 for(
size_t i=0; i<srcprocs.size(); i++)
159 communicator.
receive_raw(srcprocs[i], streams[srcprocs[i]]);
164 AlgebraID globalRowIndex, globalColIndex;;
167 for(
size_t i=0; i<srcprocs.size(); i++)
169 int pid = srcprocs[i];
175 typename matrix_type::connection con;
178 for(
size_t i=0; i<numRows; i++)
186 verticalInterface.
push_back(localRowIndex);
187 UG_DLOG(
LIB_ALG_AMG, 4,
"Got row " << localRowIndex <<
" (" << globalRowIndex <<
"), ");
196 UG_DLOG(
LIB_ALG_AMG, 4, con.iIndex <<
" (" << globalColIndex <<
") -> " << con.dValue <<
" ");
205 for(
size_t i=0; i<srcprocs.size(); i++)
207 int pid = srcprocs[i];
213 for(
size_t i=0; i<numRows; i++)
217 M.add_matrix_row(localRowIndex, &cons[0], cons.size());
245 template<
typename matrix_type>
251 std::vector<int> srcprocs;
252 masterLayout.
clear();
260 srcprocs.resize(pc.
size()-1);
261 for(
size_t i=1; i<pc.
size(); i++)
293 com.
send_data(agglomeratedSlave, compolAdd);
299 UG_COND_THROW(&vec == &collectedVec,
"vec and collected vec may not be same");
300 collectedVec.
set(0.0);
301 for(
size_t i=0; i<vec.size(); i++)
302 collectedVec[i] = vec[i];
319 else {
UG_THROW(
"storage type " << type <<
"unsupported."); }
353 UG_COND_THROW(&vec == &collectedVec,
"vec and collected vec may not be same");
354 for(
size_t i=0; i<vec.size(); i++)
355 vec[i] = collectedVec[i];
361 com.
send_data(agglomeratedMaster, compolCopy);
376 else {
UG_THROW(
"storage type " << type <<
"unsupported."); }
Definition: smart_pointer.h:108
Performs communication between interfaces on different processes.
Definition: pcl_interface_communicator.h:68
void send_raw(int targetProc, const void *pBuff, int bufferSize, bool bSizeKnownAtTarget=false)
sends raw data to a target-proc.
Definition: pcl_interface_communicator_impl.hpp:61
void receive_raw(int srcProc, ug::BinaryBuffer &bufOut, int bufSize=-1)
registers a binary-stream to receive data from a source-proc.
Definition: pcl_interface_communicator_impl.hpp:166
bool communicate(int tag=749345)
sends and receives the collected data.
Definition: pcl_interface_communicator_impl.hpp:409
void send_data(int targetProc, const Interface &interface, ICommunicationPolicy< TLayout > &commPol)
collects data that will be send during communicate.
Definition: pcl_interface_communicator_impl.hpp:80
void receive_data(int srcProc, const Interface &interface, ICommunicationPolicy< TLayout > &commPol)
registers a communication-policy to receive data on communicate.
Definition: pcl_interface_communicator_impl.hpp:188
You may add elements to this interface and iterate over them.
Definition: pcl_communication_structs.h:207
iterator push_back(const Element &elem)
Definition: pcl_communication_structs.h:245
Definition: pcl_process_communicator.h:70
int get_proc_id(size_t index) const
returns the i-th process in the communicator
Definition: pcl_process_communicator.cpp:86
size_t size() const
returns the size of the communicator
Definition: pcl_process_communicator.cpp:71
Interface & interface(iterator iter)
returns the interface to the given iterator.
Definition: pcl_communication_structs.h:505
void clear()
clears the layout
Definition: pcl_communication_structs.h:522
Extends the HorizontalAlgebraLayouts by vertical layouts.
Definition: algebra_layouts.h:121
A Buffer for binary data.
Definition: binary_buffer.h:56
char * buffer()
returns the raw buffer pointer or NULL if the buffer is empty (capacity() == 0)
Definition: binary_buffer_impl.h:94
void set_read_pos(size_t pos)
sets the read position (in bytes).
Definition: binary_buffer.cpp:64
size_t write_pos() const
returns the current write-pos (in bytes)
Definition: binary_buffer_impl.h:53
Communication Policy to add values of a vector.
Definition: communication_policies.h:319
Communication Policy to copy values of a vector.
Definition: communication_policies.h:88
Wrapper for sequential matrices to handle them in parallel.
Definition: parallel_matrix.h:65
void set_layouts(ConstSmartPtr< AlgebraLayouts > layouts)
sets the algebra layouts
Definition: parallel_matrix.h:97
ConstSmartPtr< AlgebraLayouts > layouts() const
returns the algebra layouts
Definition: parallel_matrix.h:94
Definition: parallel_nodes.h:112
const AlgebraID & local_to_global(size_t i) const
Definition: parallel_nodes.h:278
size_t get_local_index_or_create_new(const AlgebraID &globalIndex, int distanceToMasterOrInner, bool &bCreated)
get_index_or_create_new: returns a local index by creating and saving a new one or returning an old
Definition: parallel_nodes.cpp:107
size_t local_size() const
Definition: parallel_nodes.h:273
size_t global_to_local(const AlgebraID &globalIndex) const
Definition: parallel_nodes.cpp:141
Definition: parallel_vector.h:60
bool has_storage_type(uint type) const
returns if the current storage type has a given representation
Definition: parallel_vector.h:119
ParallelStorageType get_storage_type() const
Definition: parallel_vector.h:124
void set(number w, ParallelStorageType type)
set all entries to value and the storage type
Definition: parallel_vector_impl.h:223
void set_storage_type(uint type)
sets the storage type
Definition: parallel_vector.h:104
Definition: stl_debug.h:45
ParallelStorageType
Definition: parallel_storage_type.h:66
@ PST_CONSISTENT
Definition: parallel_storage_type.h:68
@ PST_ADDITIVE
Definition: parallel_storage_type.h:69
int ProcRank()
returns the rank of the process
Definition: pcl_base.cpp:83
int NumProcs()
returns the number of processes
Definition: pcl_base.cpp:91
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_THROW(msg)
Definition: error.h:57
#define UG_DLOG(__debugID__, level, msg)
Definition: log.h:298
DebugID LIB_ALG_AMG
Definition: debug_id.h:131
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
CPUAlgebra::vector_type vector_type
void SerializeRow(BinaryBuffer &stream, const matrix_type &mat, size_t localRowIndex, ParallelNodes &PN)
Definition: collect_matrix.h:43
void CollectMatrixOnOneProc(const matrix_type &A, matrix_type &collectedA, IndexLayout &masterLayout, IndexLayout &slaveLayout)
Definition: collect_matrix.h:246
void Deserialize(TIStream &buf, ParallelVector< T > &v)
Deerialize for ParallelVector<T>
Definition: restart_bridge.cpp:112
size_t DeserializeRow(BinaryBuffer &stream, stdvector< TConnectionType > &cons, ParallelNodes &PN)
Definition: collect_matrix.h:100
void ReceiveMatrix(const matrix_type &A, matrix_type &M, IndexLayout &verticalMasterLayout, const std::vector< int > &srcprocs, ParallelNodes &PN)
Definition: collect_matrix.h:142
void GatherVectorOnOne(HorizontalAlgebraLayouts &agglomerationLayout, ParallelVector< T > &collectedVec, const ParallelVector< T > &vec, ParallelStorageType type)
Definition: agglomerating_solver.h:53
void BroadcastVectorFromOne(HorizontalAlgebraLayouts &agglomerationLayout, ParallelVector< T > &vec, const ParallelVector< T > &collectedVec, ParallelStorageType type)
Definition: agglomerating_solver.h:65
void Serialize(TOStream &buf, const ParallelVector< T > &v)
Serialize for ParallelVector<T>
Definition: restart_bridge.cpp:103
void SerializeLayout(BinaryBuffer &stream, const IndexLayout &layout, const TLocalToGlobal &localToGlobal)
Definition: serialize_interfaces.h:63
void SendMatrix(const matrix_type &A, IndexLayout &verticalSlaveLayout, int destproc, ParallelNodes &PN)
Definition: collect_matrix.h:75
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258
size_t num_connections(size_t row) const
this type is used to identify distributed objects.
Definition: algebra_id.h:46
int master_proc() const
Definition: algebra_id.h:54