Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
compol_copy_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 "lib_grid/grid/grid.h" // for Grid::AttachmentAccessor
34#include "pcl/pcl_base.h"
35#include "pcl/pcl_communication_structs.h" // for ICommunicationPolicy
37
38#ifndef __H__PLG__COMPOL_COPY_ATTACHMENT__
39#define __H__PLG__COMPOL_COPY_ATTACHMENT__
40
41namespace ug
42{
43
46
49
52template <class TLayout, class TAttachment>
54{
55 public:
56 typedef TLayout Layout;
57 typedef typename Layout::Type GeomObj;
58 typedef typename Layout::Element Element;
59 typedef typename Layout::Interface Interface;
60 typedef typename TAttachment::ValueType Value;
61
63
65
67 ComPol_CopyAttachment(Grid& grid, TAttachment attachment);
68
70
72
74 void set_attachment(Grid& grid, TAttachment& attachment);
75
77
80 virtual bool
81 collect(ug::BinaryBuffer& buff, const Interface& interface);
82
84
87 virtual bool
88 extract(ug::BinaryBuffer& buff, const Interface& interface);
89
90 void extract_on_constrained_elems_only(bool enable);
91
92 protected:
95};
96
97
99
102// implementation of the methods of CollectorCopy
104template <class TNodeLayout, class TAttachment>
107 m_extractOnConstrainedElemsOnly(false)
108{
109}
110
112template <class TNodeLayout, class TAttachment>
114ComPol_CopyAttachment(Grid& grid, TAttachment attachment) :
115 m_extractOnConstrainedElemsOnly(false)
116{
117 set_attachment(grid, attachment);
118}
119
121template <class TNodeLayout, class TAttachment>
123set_attachment(Grid& grid, TAttachment& attachment)
124{
125 m_aaVal.access(grid, attachment);
126}
127
129template <class TNodeLayout, class TAttachment>
131collect(ug::BinaryBuffer& buff, const Interface& interface)
132{
133 for(typename Interface::const_iterator iter = interface.begin();
134 iter != interface.end(); ++iter)
135 {
136 Serialize(buff, m_aaVal[interface.get_element(iter)]);
137 }
138 return true;
139}
140
142template <class TNodeLayout, class TAttachment>
144extract(ug::BinaryBuffer& buff, const Interface& interface)
145{
146 if(m_extractOnConstrainedElemsOnly){
147 for(typename Interface::const_iterator iter = interface.begin();
148 iter != interface.end(); ++iter)
149 {
150 typename TAttachment::ValueType val;
151 Deserialize(buff, val);
152 if(interface.get_element(iter)->is_constrained())
153 m_aaVal[interface.get_element(iter)] = val;
154 }
155 }
156 else{
157 for(typename Interface::const_iterator iter = interface.begin();
158 iter != interface.end(); ++iter)
159 {
160 Deserialize(buff, m_aaVal[interface.get_element(iter)]);
161 }
162 }
163 return true;
164}
165
166template <class TNodeLayout, class TAttachment>
169{
170 m_extractOnConstrainedElemsOnly = enable;
171}
172
173};
174
175#endif
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
copies values from a specified attachment to a stream and back.
Definition compol_copy_attachment.h:54
Layout::Element Element
Definition compol_copy_attachment.h:58
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes the data for the given interface to the buffer.
Definition compol_copy_attachment.h:131
Grid::AttachmentAccessor< GeomObj, TAttachment > m_aaVal
Definition compol_copy_attachment.h:93
void set_attachment(Grid &grid, TAttachment &attachment)
The grid and the attachment from where the data shall be copied.
Definition compol_copy_attachment.h:123
virtual ~ComPol_CopyAttachment()
Definition compol_copy_attachment.h:69
void extract_on_constrained_elems_only(bool enable)
Definition compol_copy_attachment.h:168
TLayout Layout
Definition compol_copy_attachment.h:56
bool m_extractOnConstrainedElemsOnly
Definition compol_copy_attachment.h:94
Layout::Type GeomObj
Definition compol_copy_attachment.h:57
TAttachment::ValueType Value
Definition compol_copy_attachment.h:60
ComPol_CopyAttachment()
Initialises the collector with an invalid grid.
Definition compol_copy_attachment.h:106
Layout::Interface Interface
Definition compol_copy_attachment.h:59
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
reads the data from the buffer to the given interface .
Definition compol_copy_attachment.h:144
the generic attachment-accessor for access to grids attachment pipes.
Definition grid.h:182
Manages the elements of a grid and their interconnection.
Definition grid.h:132
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