33 #ifndef __H__UG_PCL_COMPOL_ATTACHMENT_REDUCE__
34 #define __H__UG_PCL_COMPOL_ATTACHMENT_REDUCE__
44 template <
class TValue>
95 for(
int i = 0; i <
dim; ++i)
96 v[i] = std::min(v1[i], v2[i]);
102 for(
int i = 0; i <
dim; ++i)
103 v[i] = std::max(v1[i], v2[i]);
115 for(
int i = 0; i <
dim; ++i)
116 v[i] = v1[i] * v2[i];
122 for(
int i = 0; i <
dim; ++i)
123 v[i] = v1[i] && v2[i];
130 for(
int i = 0; i <
dim; ++i)
131 v[i] = v1[i] || v2[i];
164 if (v1.size() == v2.size())
return;
166 if (v1.size() > v2.size())
168 v2.resize(v1.size(), 0.0);
172 v1.resize(v2.size(), 0.0);
178 size_t sz = v1.size();
180 for (
size_t i = 0; i < sz; i++)
181 v[i] = std::min(v1[i], v2[i]);
188 size_t sz = v1.size();
190 for (
size_t i = 0; i < sz; i++)
191 v[i] = std::max(v1[i], v2[i]);
198 size_t sz = v1.size();
200 for (
size_t i = 0; i < sz; i++)
201 v[i] = v1[i] + v2[i];
208 size_t sz = v1.size();
210 for (
size_t i = 0; i < sz; i++)
211 v[i] = v1[i] * v2[i];
218 size_t sz = v1.size();
220 for (
size_t i = 0; i < sz; i++)
221 v[i] = v1[i] && v2[i];
227 UG_THROW(
"Vectors of number do not support a binary and operation.");
233 size_t sz = v1.size();
235 for (
size_t i = 0; i < sz; i++)
236 v[i] = v1[i] || v2[i];
242 UG_THROW(
"Vectors of number do not support a binary or operation.");
272 template <
class TLayout,
class TAttachment>
280 typedef typename TAttachment::ValueType
Value;
281 typedef typename Interface::const_iterator
iiter_t;
299 m_aa(grid, attachment),
315 m_aa(grid, attachment),
342 template <
class TLayout,
class TAttachment>
346 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter)
347 Serialize(buff, m_aa[interface.get_element(iter)]);
351 template <
class TLayout,
class TAttachment>
356 case MAX:
return extract_max(buff, interface);
357 case MIN:
return extract_min(buff, interface);
358 case SUM:
return extract_sum(buff, interface);
359 case PROD:
return extract_prod(buff, interface);
360 case LAND:
return extract_land(buff, interface);
361 case BAND:
return extract_band(buff, interface);
362 case LOR:
return extract_lor(buff, interface);
363 case BOR:
return extract_bor(buff, interface);
365 UG_THROW(
"Unsupported reduce operation in ComPol_AttachmentReduce::extract:"
372 template <
class TLayout,
class TAttachment>
378 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter){
380 Element e = interface.get_element(iter);
381 m_aa[e] = art::max(v, m_aa[e]);
386 template <
class TLayout,
class TAttachment>
392 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter){
394 Element e = interface.get_element(iter);
395 m_aa[e] = art::min(v, m_aa[e]);
400 template <
class TLayout,
class TAttachment>
405 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter){
407 Element e = interface.get_element(iter);
408 m_aa[e] = art::sum(v, m_aa[e]);
413 template <
class TLayout,
class TAttachment>
418 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter){
420 Element e = interface.get_element(iter);
421 m_aa[e] = art::prod(v, m_aa[e]);
426 template <
class TLayout,
class TAttachment>
431 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter){
433 Element e = interface.get_element(iter);
434 m_aa[e] = art::land(v, m_aa[e]);
439 template <
class TLayout,
class TAttachment>
444 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter){
446 Element e = interface.get_element(iter);
447 m_aa[e] = art::band(v, m_aa[e]);
452 template <
class TLayout,
class TAttachment>
457 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter){
459 Element e = interface.get_element(iter);
460 m_aa[e] = art::lor(v, m_aa[e]);
465 template <
class TLayout,
class TAttachment>
470 for(
iiter_t iter = interface.begin(); iter != interface.end(); ++iter){
472 Element e = interface.get_element(iter);
473 m_aa[e] = art::bor(v, m_aa[e]);
specializations are responsible to pack and unpack interface data during communication.
Definition: pcl_communication_structs.h:790
A Buffer for binary data.
Definition: binary_buffer.h:56
Performs reduce operations on the specified attachment.
Definition: compol_attachment_reduce.h:274
bool collect(BinaryBuffer &buff, const Interface &interface)
writes the data for the given interface to the buffer.
Definition: compol_attachment_reduce.h:344
ComPol_AttachmentReduce(Grid &grid, TAttachment &attachment, pcl::ReduceOperation op)
Definition: compol_attachment_reduce.h:296
Grid & m_grid
Definition: compol_attachment_reduce.h:336
bool extract(BinaryBuffer &buff, const Interface &interface)
reads the data from the buffer to the given interface .
Definition: compol_attachment_reduce.h:353
bool extract_lor(BinaryBuffer &buff, const Interface &interface)
Definition: compol_attachment_reduce.h:454
ComPol_AttachmentReduce(Grid &grid, TAttachment &attachment, ReduceOperation op)
Definition: compol_attachment_reduce.h:312
ReduceOperation
Definition: compol_attachment_reduce.h:284
@ LAND
Definition: compol_attachment_reduce.h:290
@ SUM
Definition: compol_attachment_reduce.h:288
@ MIN
Definition: compol_attachment_reduce.h:287
@ PROD
Definition: compol_attachment_reduce.h:289
@ BAND
Definition: compol_attachment_reduce.h:291
@ NONE
Definition: compol_attachment_reduce.h:285
@ LOR
Definition: compol_attachment_reduce.h:292
@ MAX
Definition: compol_attachment_reduce.h:286
@ BOR
Definition: compol_attachment_reduce.h:293
Layout::Type GeomObj
Definition: compol_attachment_reduce.h:277
attachment_reduce_traits< Value > art
Definition: compol_attachment_reduce.h:282
bool extract_prod(BinaryBuffer &buff, const Interface &interface)
Definition: compol_attachment_reduce.h:415
bool extract_sum(BinaryBuffer &buff, const Interface &interface)
Definition: compol_attachment_reduce.h:402
TLayout Layout
Definition: compol_attachment_reduce.h:276
TAttachment::ValueType Value
Definition: compol_attachment_reduce.h:280
bool extract_band(BinaryBuffer &buff, const Interface &interface)
Definition: compol_attachment_reduce.h:441
Grid::AttachmentAccessor< GeomObj, TAttachment > m_aa
Definition: compol_attachment_reduce.h:337
Layout::Interface Interface
Definition: compol_attachment_reduce.h:279
bool extract_bor(BinaryBuffer &buff, const Interface &interface)
Definition: compol_attachment_reduce.h:467
bool extract_max(BinaryBuffer &buff, const Interface &interface)
Definition: compol_attachment_reduce.h:374
Interface::const_iterator iiter_t
Definition: compol_attachment_reduce.h:281
ReduceOperation m_op
Definition: compol_attachment_reduce.h:338
bool extract_min(BinaryBuffer &buff, const Interface &interface)
Definition: compol_attachment_reduce.h:388
Layout::Element Element
Definition: compol_attachment_reduce.h:278
bool extract_land(BinaryBuffer &buff, const Interface &interface)
Definition: compol_attachment_reduce.h:428
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
#define PCL_RO_SUM
Definition: pcl_methods.h:63
#define PCL_RO_MAX
Definition: pcl_methods.h:61
#define PCL_RO_MIN
Definition: pcl_methods.h:62
MPI_Op ReduceOperation
Definition: pcl_methods.h:74
#define PCL_RO_BOR
Definition: pcl_methods.h:68
#define PCL_RO_PROD
Definition: pcl_methods.h:64
#define PCL_RO_LAND
Definition: pcl_methods.h:65
#define PCL_RO_BAND
Definition: pcl_methods.h:66
#define PCL_RO_LOR
Definition: pcl_methods.h:67
#define UG_THROW(msg)
Definition: error.h:57
Definition: smart_pointer.h:814
void Deserialize(TIStream &buf, ParallelVector< T > &v)
Deerialize for ParallelVector<T>
Definition: restart_bridge.cpp:112
void Serialize(TOStream &buf, const ParallelVector< T > &v)
Serialize for ParallelVector<T>
Definition: restart_bridge.cpp:103
static value_t land(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:82
static value_t prod(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:81
static value_t band(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:83
static value_t sum(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:80
static value_t min(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:78
double value_t
Definition: compol_attachment_reduce.h:77
static value_t max(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:79
static value_t bor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:85
static value_t lor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:84
static value_t band(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:68
float value_t
Definition: compol_attachment_reduce.h:62
static value_t min(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:63
static value_t bor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:70
static value_t sum(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:65
static value_t max(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:64
static value_t land(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:67
static value_t prod(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:66
static value_t lor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:69
methods defined in those traits are used by ComPol_AttachmentReduce
Definition: compol_attachment_reduce.h:46
static value_t lor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:54
static value_t sum(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:50
static value_t max(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:49
TValue value_t
Definition: compol_attachment_reduce.h:47
static value_t prod(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:51
static value_t land(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:52
static value_t min(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:48
static value_t bor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:55
static value_t band(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:53
Definition: compol_attachment_reduce.h:156
static value_t min(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:175
static value_t prod(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:205
std::vector< number > value_t
Definition: compol_attachment_reduce.h:157
static value_t land(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:215
static value_t sum(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:195
static void check_length(value_t &v1, value_t &v2)
Definition: compol_attachment_reduce.h:162
static value_t bor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:240
static value_t band(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:225
static value_t lor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:230
static value_t max(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:185
Definition: compol_attachment_reduce.h:90
static value_t min(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:92
static value_t lor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:127
static value_t sum(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:106
static value_t land(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:119
static value_t max(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:99
MathVector< dim > value_t
Definition: compol_attachment_reduce.h:91
static value_t band(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:126
static value_t bor(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:134
static value_t prod(value_t v1, value_t v2)
Definition: compol_attachment_reduce.h:112