Peano 4
Loading...
Searching...
No Matches
VertexMarker.cpp
Go to the documentation of this file.
1#include "VertexMarker.h"
2
3#include "peano4/utils/Loop.h"
5
6
7std::ostream& operator<<( std::ostream& out, const peano4::datamanagement::VertexMarker& marker ) {
8 out << marker.toString();
9 return out;
10}
11
12
14 const VertexMarker& marker,
15 const std::bitset<Dimensions>& parentVertexPositionWithinParentCell
16) {
17 return marker.x()
19 tarch::la::convertScalar<double>(marker.getRelativePositionWithinFatherCell()),
20 marker.h()
21 )
23 tarch::la::Vector<Dimensions,double>( parentVertexPositionWithinParentCell ),
24 3.0*marker.h()
25 );
26}
27
28
31 int select
32):
33 _cellCentre(event.getX()),
34 _h(event.getH()),
35 _select(select) {
36 _hasBeenRefined = event.getHasBeenRefined();
37 _willBeRefined = event.getWillBeRefined();
38 _isLocal = event.getIsVertexLocal();
39 _isParentCellLocal = event.getIsParentCellLocal();
40 _relativePositionOfCellWithinFatherCell = event.getRelativePositionToFather();
41 _isAdjacentToParallelDomainBoundary = event.getIsVertexAdjacentToParallelDomainBoundary();
42 _isAdjacentCellLocal = event.getIsAdjacentCellLocal();
43 _isParentOfSubtree = event.getIsVertexParentOfSubtree();
44
45 _isHanging = 0;
46 for (int i=0; i<TwoPowerD; i++) {
47 if (
49 ) {
50 int position = event.getVertexDataFrom(i);
51 assertion( not _isHanging[position] );
52 _isHanging[position] = true;
53 }
54 if (
56 ) {
57 int position = event.getVertexDataTo(i);
58 assertion( not _isHanging[position] );
59 _isHanging[position] = true;
60 }
61 }
62
63 _isParentVertexLocal = event.getIsParentVertexLocal();
64}
65
66
68 return _isParentOfSubtree[i];
69}
70
71
73 return isParentOfSubtree(_select);
74}
75
76
80
81
83 tarch::la::Vector<Dimensions,int> result = _relativePositionOfCellWithinFatherCell;
84 std::bitset<Dimensions> index = i;
85 for (int d=0; d<Dimensions; d++) {
86 result(d) += index[d] ? 1 : 0;
87 }
88 return result;
89}
90
91
93 assertion(i>=0);
95 return _isParentVertexLocal[i];
96}
97
98
100 bool result = true;
101 for (int d=0; d<Dimensions; d++) {
102 result &= getRelativePositionWithinFatherCell()(d) != 1;
103 result &= getRelativePositionWithinFatherCell()(d) != 2;
104 }
105 return result;
106}
107
109 tarch::la::Vector<Dimensions,double> result( _cellCentre );
110 std::bitset<Dimensions> myset(i);
111 for (int d=0; d<Dimensions; d++) {
112 result(d) -= 0.5 * _h(d);
113 result(d) += static_cast<double>(myset[d]) * _h(d);
114 }
115 return result;
116}
117
118
122
123
125 std::ostringstream msg;
126 msg << "(cell-centre=" << _cellCentre <<
127 ",cell-h=" << _h <<
128 ",local=" << _isLocal <<
129 ",hanging=" << _isHanging <<
130 ",select=" << _select <<
131 ",has-been-refined=" << _hasBeenRefined <<
132 ",will-be-refined=" << _willBeRefined <<
133 ",is-parent-vertex-local=" << _isParentVertexLocal <<
134 ",is-parent-cell-local=" << _isParentCellLocal <<
135 ",rel-pos-within-father=" << _relativePositionOfCellWithinFatherCell <<
136 ",is-adjacent-cell-local=" << _isAdjacentCellLocal <<
137 ",x(selected)=" << x() <<
138 ")";
139 return msg.str();
140}
141
142
146
147
149 assertion2(vertexNumber>=0,vertexNumber,toString());
150 assertion2(vertexNumber<TwoPowerD,vertexNumber,toString());
151 _select = vertexNumber;
152 return *this;
153}
154
155
159
160
162 return hasBeenRefined(_select);
163}
164
165
167 return _hasBeenRefined[i];
168}
169
170
172 return willBeRefined(_select);
173}
174
175
177 return _willBeRefined[i];
178}
179
180
182 return isLocal(_select);
183}
184
185
187 return _isParentCellLocal;
188}
189
190
192 return _isLocal[i];
193}
194
195
196bool peano4::datamanagement::VertexMarker::isContainedInAdjacentCells( const tarch::la::Vector<Dimensions,double>& x, double scaleAdjacentCells, double tolerance ) const {
197 bool result = true;
198 for (int d=0; d<Dimensions; d++) {
199 result &= tarch::la::smallerEquals( std::abs(x(d) - (this->x())(d)), scaleAdjacentCells * _h(d), tolerance);
200 }
201 return result;
202}
203
204
207 for (int d=0; d<Dimensions; d++) {
208 result(d) = x(d) <= (this->x())(d) ? 0 : 1;
209 }
210 return result;
211}
212
213
215 return isHanging( _select );
216}
217
218
220 return _isHanging[i];
221}
222
223
225 return isAdjacentToParallelDomainBoundary( _select );
226}
227
228
230 return _isAdjacentToParallelDomainBoundary[i];
231}
232
233
237
238
240 tarch::la::Vector<Dimensions, double> result = _cellCentre;
241 for (int d=0; d<Dimensions; d++) {
242 assertion1( _relativePositionOfCellWithinFatherCell(d)>=0, toString() );
243 assertion1( _relativePositionOfCellWithinFatherCell(d)<=2, toString() );
244 if (_relativePositionOfCellWithinFatherCell(d)==0) {
245 result(d) += _h(d);
246 }
247 if (_relativePositionOfCellWithinFatherCell(d)==2) {
248 result(d) -= _h(d);
249 }
250 }
251 return result;
252}
253
254
256 std::bitset<TwoPowerD> result = 0;
257
258 std::bitset<Dimensions> selectedVertexAsBitset = _select;
259 tarch::la::Vector<Dimensions,int> selectedVertex( selectedVertexAsBitset );
260 dfor2(j) {
261 tarch::la::Vector<Dimensions,int> entryIn3x3Patch = selectedVertex + j;
262 result[ jScalar ] = _isAdjacentCellLocal[ peano4::utils::dLinearised(entryIn3x3Patch,3) ];
263 } enddforx
264
265 return result;
266}
267
#define assertion2(expr, param0, param1)
#define assertion1(expr, param)
#define assertion(expr)
And from this we can write down f$ nabla phi_i nabla phi_i dx but since we are constructing matrix let s investigate the f$ j
#define TwoPowerD
Definition Globals.h:19
#define dfor2(counter)
Shortcut For dfor(counter,2)
Definition Loop.h:906
#define enddforx
I prefer to use this macro for dforx instead of a closing bracket as many syntax parser fail otherwis...
Definition Loop.h:928
std::ostream & operator<<(std::ostream &out, const peano4::datamanagement::VertexMarker &marker)
static constexpr int CreateOrDestroyHangingGridEntity
Implies that the data will then be local or had been local.
std::string toString(Filter filter)
Definition convert.cpp:170
tarch::la::Vector< Dimensions, double > reconstructXOfParentVertex(const VertexMarker &marker, const std::bitset< Dimensions > &parentVertexPositionWithinParentCell)
Reconstruct parent vertex position.
CPUGPUMethod int dLinearised(const tarch::la::Vector< Dimensions, int > &counter, int max)
Map d-dimensional vector onto integer index.
Definition Loop.cpp:106
bool smallerEquals(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
Matrix< Rows, Cols, Scalar > multiplyComponents(const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs)
Vertex marker to provide information about selected vertex.
VertexMarker()=default
Some unit tests prefer to construct a marker manually, so I offer a dummy default constructor.
tarch::la::Vector< Dimensions, double > h() const
bool coincidesWithCoarseGridVertex() const
Does vertex spatially coincide with coarser level's vertex.
bool isContainedInAdjacentCells(const tarch::la::Vector< Dimensions, double > &x, double scaleAdjacentCells=1.0, double tolerance=tarch::la::NUMERICAL_ZERO_DIFFERENCE) const
Will return true if x is contained within the adjacent cells.
VertexMarker & select(int number)
Picks a vertex within a cell.
tarch::la::Vector< Dimensions, int > getRelativeAdjacentCell(const tarch::la::Vector< Dimensions, double > &x) const
Each vertex is surrounded by cells.
tarch::la::Vector< Dimensions, double > x() const
tarch::la::Vector< Dimensions, double > getInvokingParentCellsCentre() const
See getInvokingCellCentre().
bool isAdjacentToParallelDomainBoundary() const
Is currently selected/analysed vertex adjacent to parallel domain boundary.
std::bitset< TwoPowerD > areAdjacentCellsLocal() const
Are adjacent cells of selected vertex local.
bool isParentCellLocal() const
Whenever we touch a vertex the first or the last time, we touch it from a cell: If we touch a vertex ...
bool hasBeenRefined() const
A vertex is refined iff it is surrounded by cells which are refined.
int getSelectedVertexNumber() const
Information about selected vertex.
tarch::la::Vector< Dimensions, double > getInvokingCellCentre() const
Return centre of cell from which this vertex marker is constructed.
bool isParentVertexLocal(int i) const
Is the parent vertex local.
tarch::la::Vector< Dimensions, int > getRelativePositionWithinFatherCell() const
Relative position within parent cell.
tarch::la::Vector< TwoPowerD, int > getVertexDataFrom() const
tarch::la::Vector< TwoPowerD, int > getVertexDataTo() const
Simple vector class.
Definition Vector.h:134