Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
compol_boolmarker.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2015: G-CSC, Goethe University Frankfurt
3 * Author: Andreas Vogel
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#ifndef __H__UG__compol_boolmarker__
34#define __H__UG__compol_boolmarker__
35
38
39namespace ug
40{
41
43template <class TLayout>
45{
46 public:
47 typedef TLayout Layout;
48 typedef typename Layout::Type GeomObj;
49 typedef typename Layout::Element Element;
50 typedef typename Layout::Interface Interface;
51 typedef typename Interface::const_iterator InterfaceIter;
52
55 : m_rMarker(marker)
56 {}
57
58 virtual int
59 get_required_buffer_size(const Interface& interface) {return interface.size() * sizeof(byte);}
60
62 virtual bool
63 collect(ug::BinaryBuffer& buff, const Interface& interface)
64 {
65 // write the entry indices of marked elements.
66 for(InterfaceIter iter = interface.begin();
67 iter != interface.end(); ++iter)
68 {
69 Element elem = interface.get_element(iter);
70 bool isMarked = m_rMarker.is_marked(elem);
71 byte refMark = (isMarked ? 1 : 0);
72 buff.write((char*)&refMark, sizeof(byte));
73 }
74
75 return true;
76 }
77
79 virtual bool
80 extract(ug::BinaryBuffer& buff, const Interface& interface)
81 {
82 byte val;
83 for(InterfaceIter iter = interface.begin();
84 iter != interface.end(); ++iter)
85 {
86 Element elem = interface.get_element(iter);
87 buff.read((char*)&val, sizeof(byte));
88 if(val) m_rMarker.mark(elem);
89 }
90 return true;
91 }
92
93 protected:
95};
96
98template <class TLayout>
100{
101 public:
102 typedef TLayout Layout;
103 typedef typename Layout::Type GeomObj;
104 typedef typename Layout::Element Element;
105 typedef typename Layout::Interface Interface;
106 typedef typename Interface::const_iterator InterfaceIter;
107
112
113 virtual int
114 get_required_buffer_size(const Interface& interface) {return interface.size() * sizeof(byte);}
115
117 virtual bool
118 collect(ug::BinaryBuffer& buff, const Interface& interface)
119 {
120 // write the entry indices of marked elements.
121 for(InterfaceIter iter = interface.begin();
122 iter != interface.end(); ++iter)
123 {
124 Element elem = interface.get_element(iter);
125 bool isMarked = m_rMarker.is_marked(elem);
126 byte refMark = (isMarked ? 1 : 0);
127 buff.write((char*)&refMark, sizeof(byte));
128 }
129
130 return true;
131 }
132
134 virtual bool
135 extract(ug::BinaryBuffer& buff, const Interface& interface)
136 {
137 byte val;
138 for(InterfaceIter iter = interface.begin();
139 iter != interface.end(); ++iter)
140 {
141 Element elem = interface.get_element(iter);
142 buff.read((char*)&val, sizeof(byte));
143 if(!val) m_rMarker.unmark(elem);
144 }
145 return true;
146 }
147
148 protected:
150};
151
152}// end of namespace
153
154#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
void read(char *buf, size_t size)
reads data of the given size (in bytes)
Definition binary_buffer_impl.h:58
void write(const char *buf, size_t size)
writes data of the given size (in bytes)
Definition binary_buffer_impl.h:71
Allows to mark elements.
Definition bool_marker.h:64
bool is_marked(GridObject *e) const
Definition bool_marker.cpp:86
void unmark(Vertex *e)
Definition bool_marker.h:120
void mark(Vertex *e, bool mark=true)
Definition bool_marker.h:109
adds marking at extracting side
Definition compol_boolmarker.h:45
Interface::const_iterator InterfaceIter
Definition compol_boolmarker.h:51
BoolMarker & m_rMarker
Definition compol_boolmarker.h:94
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
reads marks from the given stream
Definition compol_boolmarker.h:80
virtual int get_required_buffer_size(const Interface &interface)
returns the size of the buffer in bytes, that will be required for interface-communication.
Definition compol_boolmarker.h:59
Layout::Element Element
Definition compol_boolmarker.h:49
Layout::Interface Interface
Definition compol_boolmarker.h:50
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes 1 for marked and 0 for unmarked interface entries
Definition compol_boolmarker.h:63
ComPol_BoolMarker_AddMarks(BoolMarker &marker)
Construct the communication policy with a ug::BoolMarker.
Definition compol_boolmarker.h:54
Layout::Type GeomObj
Definition compol_boolmarker.h:48
TLayout Layout
Definition compol_boolmarker.h:47
removes marks at extracting side, if no mark was received
Definition compol_boolmarker.h:100
TLayout Layout
Definition compol_boolmarker.h:102
BoolMarker & m_rMarker
Definition compol_boolmarker.h:149
ComPol_BoolMarker_RemoveMarks(BoolMarker &marker)
Construct the communication policy with a ug::BoolMarker.
Definition compol_boolmarker.h:109
Layout::Element Element
Definition compol_boolmarker.h:104
Layout::Interface Interface
Definition compol_boolmarker.h:105
Layout::Type GeomObj
Definition compol_boolmarker.h:103
virtual int get_required_buffer_size(const Interface &interface)
returns the size of the buffer in bytes, that will be required for interface-communication.
Definition compol_boolmarker.h:114
virtual bool extract(ug::BinaryBuffer &buff, const Interface &interface)
reads marks from the given stream
Definition compol_boolmarker.h:135
virtual bool collect(ug::BinaryBuffer &buff, const Interface &interface)
writes 1 for marked and 0 for unmarked interface entries
Definition compol_boolmarker.h:118
Interface::const_iterator InterfaceIter
Definition compol_boolmarker.h:106
unsigned char byte
Definition types.h:113
the ug namespace