Peano
Loading...
Searching...
No Matches
FaceMarker.cpp
Go to the documentation of this file.
1#include "FaceMarker.h"
2
3
4std::ostream& operator<<( std::ostream& out, const peano4::datamanagement::FaceMarker& marker ) {
5 out << marker.toString();
6 return out;
7}
8
9
12 int select
13):
14 _cellCentre(event.getX()),
15 _h(event.getH()),
16 _cellIsLocal(event.getIsCellLocal()),
17 _select(select),
18 _isLocal( event.getIsFaceLocal() ),
19 _isAdjacentToParallelBoundary(event.getIsFaceAdjacentToParallelDomainBoundary()),
20 _relativePositionOfCellWithinFatherCell(event.getRelativePositionToFather()) {
21 for (int faceNumber=0; faceNumber<2*Dimensions; faceNumber++) {
22 _hasBeenRefined[faceNumber] = false;
23 _willBeRefined[faceNumber] = false;
24
25 const int normal = faceNumber % Dimensions;
26 for (int i=0; i<TwoPowerD; i++) {
27 std::bitset<Dimensions> studiedVertex = i;
28 studiedVertex.set(normal,faceNumber>=Dimensions);
29 _hasBeenRefined.set( faceNumber, _hasBeenRefined[faceNumber] or event.getHasBeenRefined(studiedVertex.to_ulong()) );
30 _willBeRefined.set( faceNumber, _willBeRefined[faceNumber] or event.getWillBeRefined(studiedVertex.to_ulong()) );
31 }
32 }
33}
34
35
37 tarch::la::Vector<Dimensions,double> result( _cellCentre );
38 int normal = i % Dimensions;
39 result(normal) += i >= Dimensions ? _h(normal)/2.0 : -_h(normal)/2.0;
40 return result;
41}
42
43
47
48
51 int index = i % Dimensions;
52 result(index) += i<Dimensions ? -_h(index) : _h(index);
53 return result;
54}
55
56
60
61
64 int index = i % Dimensions;
65 bool negativeSign = i<Dimensions;
66 if ( not _cellIsLocal ) negativeSign = not negativeSign;
67 result(index) += negativeSign ? - _h(index) : _h(index);
68 return result;
69}
70
71
75
76
78 std::ostringstream msg;
79 msg << "(cell-centre=" << _cellCentre
80 << ",cell-h=" << _h
81 << ",select=" << _select
82 << ",is-cell-local=" << _cellIsLocal
83 << ",is-face-local=" << isLocal()
84 << ",has-face-been-refined=" << hasBeenRefined()
85 << ",will-face-be-refined=" << willBeRefined()
86 << ",rel-pos=" << _relativePositionOfCellWithinFatherCell
87 << ")";
88 return msg.str();
89}
90
91
95
96
98 _select = face;
99 return *this;
100}
101
102
106
107
109 return _hasBeenRefined[i];
110}
111
112
114 return hasBeenRefined(_select);
115}
116
117
119 return _willBeRefined[i];
120}
121
122
124 return willBeRefined(_select);
125}
126
127
129 return _isLocal[i];
130}
131
132
134 return isLocal(_select);
135}
136
138 return isAdjacentToParallelBoundary(_select);
139}
140
142 return _isAdjacentToParallelBoundary[i];
143}
144
145
147 assertion1( _select>=0, toString() );
148 return getRelativePositionWithinFatherCell(_select);
149}
150
151
153 assertion2( i>=0, i, toString() );
154 tarch::la::Vector<Dimensions,int> result = _relativePositionOfCellWithinFatherCell;
155 const int normal = i % Dimensions;
156 result(normal) += i>=Dimensions ? 1 : 0;
157 return result;
158}
159
160
162 tarch::la::Vector<Dimensions-1,int> result;
163 const int normal = getSelectedFaceNumber()%Dimensions;
164 int pos = 0;
165 for(int d=0; d<Dimensions; d++){
166 if(d!=normal){
167 result[pos] = _relativePositionOfCellWithinFatherCell[d];
168 pos++;
169 }
170 }
171 return result;
172}
173
174
176 int normal = getSelectedFaceNumber() % Dimensions;
177 return
178 getRelativePositionWithinFatherCell()(normal)==1
179 or
180 getRelativePositionWithinFatherCell()(normal)==2;
181}
#define assertion2(expr, param0, param1)
#define assertion1(expr, param)
std::ostream & operator<<(std::ostream &out, const peano4::datamanagement::FaceMarker &marker)
Definition FaceMarker.cpp:4
#define TwoPowerD
Definition Globals.h:19
std::string toString(Filter filter)
Definition convert.cpp:170
Provide information about selected face.
Definition FaceMarker.h:35
std::bitset< 2 *Dimensions > _willBeRefined
Definition FaceMarker.h:59
tarch::la::Vector< Dimensions, double > outerNormal() const
FaceMarker(const peano4::grid::GridTraversalEvent &event, int select=0)
The derivation of _isLocal and _isRefined is very similar to peano4::grid::Spacetree::getFaceType().
bool hasBeenRefined() const
Has a face been refined.
int getSelectedFaceNumber() const
Return the number of the face.
tarch::la::Vector< Dimensions, double > x() const
A marker is always tied to one particular face.
tarch::la::Vector< Dimensions, double > normal() const
FaceMarker & select(int face)
Selects a face within a cell, i.e.
tarch::la::Vector< Dimensions-1, int > getRelativePositionWithinFatherFace() const
Return relative position of a subface within its father face.
std::bitset< 2 *Dimensions > _hasBeenRefined
Definition FaceMarker.h:54
bool isInteriorFaceWithinPatch() const
The term patch here refers to a 3x3 or 3x3x3 refinement.
tarch::la::Vector< Dimensions, int > getRelativePositionWithinFatherCell() const
Return relative position within father cell.
tarch::la::Vector< Dimensions, double > h() const
Size of the underlying cell.
std::bitset< TwoPowerD > getHasBeenRefined() const
std::bitset< TwoPowerD > getWillBeRefined() const
Simple vector class.
Definition Vector.h:150