ug4
compol_gather_vec_attachment.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3  * Author: Sebastian Reiter
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #include "pcl/pcl_base.h"
34 
35 #ifndef __H__PLG__COMPOL_GATHER_VEC_ATTACHMENT__
36 #define __H__PLG__COMPOL_GATHER_VEC_ATTACHMENT__
37 
38 namespace ug
39 {
40 
43 
46 
50 template <class TLayout, class TAttachment>
52 {
53  public:
54  typedef TLayout Layout;
55  typedef typename Layout::Type GeomObj;
56  typedef typename Layout::Element Element;
57  typedef typename Layout::Interface Interface;
58  typedef typename TAttachment::ValueType Vector;
59  typedef typename Vector::value_type Value;
60 
62 
64 
66  ComPol_GatherVecAttachment(Grid& grid, TAttachment& attachment);
67 
69 
71 
73  void set_attachment(Grid& grid, TAttachment& attachment);
74 
76 
79  virtual bool
80  collect(ug::BinaryBuffer& buff, const Interface& interface);
81 
83 
86  virtual bool
87  extract(ug::BinaryBuffer& buff, const Interface& interface);
88 
89  protected:
91 };
92 
93 
95 
98 // implementation of the methods of CollectorCopy
100 template <class TNodeLayout, class TAttachment>
103 {
104 }
105 
107 template <class TNodeLayout, class TAttachment>
109 ComPol_GatherVecAttachment(Grid& grid, TAttachment& attachment)
110 {
111  set_attachment(grid, attachment);
112 }
113 
115 template <class TNodeLayout, class TAttachment>
117 set_attachment(Grid& grid, TAttachment& attachment)
118 {
119  m_aaVec.access(grid, attachment);
120 }
121 
123 template <class TNodeLayout, class TAttachment>
125 collect(ug::BinaryBuffer& buff, const Interface& interface)
126 {
127  for(typename Interface::const_iterator iter = interface.begin();
128  iter != interface.end(); ++iter)
129  {
130  Serialize(buff, m_aaVec[interface.get_element(iter)]);
131  }
132  return true;
133 }
134 
136 template <class TNodeLayout, class TAttachment>
138 extract(ug::BinaryBuffer& buff, const Interface& interface)
139 {
140  Vector tvec;
141  for(typename Interface::const_iterator iter = interface.begin();
142  iter != interface.end(); ++iter)
143  {
144  Element e = interface.get_element(iter);
145  tvec.clear();
146  Deserialize(buff, tvec);
147  m_aaVec[e].reserve(m_aaVec[e].size() + tvec.size());
148  for(size_t i = 0; i < tvec.size(); ++i)
149  m_aaVec[e].push_back(tvec[i]);
150  }
151  return true;
152 }
153 
154 };
155 
156 #endif
Definition: vector_interface.h:38
size_t size()
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
Gathers the values stored in vector-attachments.
Definition: compol_gather_vec_attachment.h:52
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
reads the data from the buffer to the given interface .
Definition: compol_gather_vec_attachment.h:138
Layout::Interface Interface
Definition: compol_gather_vec_attachment.h:57
void set_attachment(Grid &grid, TAttachment &attachment)
The grid and the attachment from where the data shall be copied.
Definition: compol_gather_vec_attachment.h:117
Layout::Element Element
Definition: compol_gather_vec_attachment.h:56
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the data for the given interface to the buffer.
Definition: compol_gather_vec_attachment.h:125
Vector::value_type Value
Definition: compol_gather_vec_attachment.h:59
TAttachment::ValueType Vector
Definition: compol_gather_vec_attachment.h:58
ComPol_GatherVecAttachment()
Initialises the collector with an invalid grid.
Definition: compol_gather_vec_attachment.h:102
TLayout Layout
Definition: compol_gather_vec_attachment.h:54
Layout::Type GeomObj
Definition: compol_gather_vec_attachment.h:55
Grid::AttachmentAccessor< GeomObj, TAttachment > m_aaVec
Definition: compol_gather_vec_attachment.h:90
virtual ~ComPol_GatherVecAttachment()
Definition: compol_gather_vec_attachment.h:68
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
TValueType value_type
Definition: vector.h:57
the ug namespace
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