Peano
Loading...
Searching...
No Matches
Projection.cpp
Go to the documentation of this file.
1#include "Projection.h"
2
3#include "peano4/utils/Loop.h"
5
6#include <iostream>
7
9 int numberOfVolumesPerAxisInPatch,
10 int haloSize,
11 int unknowns,
12 int auxiliaryVariables,
13 const double* __restrict__ Q,
14 double* __restrict__ leftFace,
15 double* __restrict__ bottomFace,
16 double* __restrict__ rightFace,
17 double* __restrict__ topFace
18) {
19 assertionEquals( Dimensions, 2 );
20 double* faces[4] = { leftFace, bottomFace, rightFace, topFace };
22 numberOfVolumesPerAxisInPatch,
23 haloSize,
24 unknowns,
25 auxiliaryVariables,
26 Q,
27 faces
28 );
29}
30
31
33 int numberOfVolumesPerAxisInPatch,
34 int haloSize,
35 int unknowns,
36 int auxiliaryVariables,
37 const double* __restrict__ Q,
38 double* __restrict__ leftFace,
39 double* __restrict__ bottomFace,
40 double* __restrict__ frontFace,
41 double* __restrict__ rightFace,
42 double* __restrict__ topFace,
43 double* __restrict__ backFace
44) {
45 assertionEquals( Dimensions, 3 );
46 double* faces[6] = { leftFace, bottomFace, frontFace, rightFace, topFace, backFace};
48 numberOfVolumesPerAxisInPatch,
49 haloSize,
50 unknowns,
51 auxiliaryVariables,
52 Q,
53 faces
54 );
55}
56
57
59 int numberOfVolumesPerAxisInPatch,
60 int haloSize,
61 int unknowns,
62 int auxiliaryVariables,
63 const double* __restrict__ Q,
64 double* faces[2*Dimensions]
65) {
66 for(int d=0; d<Dimensions; d++) {
72 dfore(k,numberOfVolumesPerAxisInPatch,d,0) {
73 for (int i=0; i<haloSize; i++) {
76 patchCell(d) = i;
77 overlapCell(d) = i+haloSize;
78
79 int patchCellSerialised = peano4::utils::dLinearised(patchCell,numberOfVolumesPerAxisInPatch);
80 int overlapCellSerialised = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,numberOfVolumesPerAxisInPatch,haloSize,d);
81 for (int j=0; j<unknowns+auxiliaryVariables; j++) {
82 faces[d][overlapCellSerialised*(unknowns+auxiliaryVariables)+j] =
83 Q[patchCellSerialised*(unknowns+auxiliaryVariables)+j];
84 if (Q[patchCellSerialised*(unknowns+auxiliaryVariables)+j]!=17.0) std::cerr << "not good";
85 }
86
87 patchCell(d) = i+numberOfVolumesPerAxisInPatch-haloSize;
88 overlapCell(d) = i;
89
90 patchCellSerialised = peano4::utils::dLinearised(patchCell,12);
91 overlapCellSerialised = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,numberOfVolumesPerAxisInPatch,haloSize,d);
92 for (int j=0; j<unknowns+auxiliaryVariables; j++) {
93 faces[d+Dimensions][overlapCellSerialised*(unknowns+auxiliaryVariables)+j] =
94 Q[patchCellSerialised*(unknowns+auxiliaryVariables)+j];
95 }
96 }
97 }
98 }
99}
100
101
103 int numberOfVolumesPerAxisInPatch,
104 int haloSize,
105 int unknowns,
106 int auxiliaryVariables,
107 const double* __restrict__ Q,
108 double* __restrict__ leftFace,
109 double* __restrict__ bottomFace,
110 double* __restrict__ rightFace,
111 double* __restrict__ topFace
112) {
113 assertionEquals( Dimensions, 2 );
114 double* faces[4] = { leftFace, bottomFace, rightFace, topFace };
116 numberOfVolumesPerAxisInPatch,
117 haloSize,
118 unknowns,
119 auxiliaryVariables,
120 Q,
121 faces
122 );
123}
124
125
127 int numberOfVolumesPerAxisInPatch,
128 int haloSize,
129 int unknowns,
130 int auxiliaryVariables,
131 const double* __restrict__ Q,
132 double* __restrict__ leftFace,
133 double* __restrict__ bottomFace,
134 double* __restrict__ frontFace,
135 double* __restrict__ rightFace,
136 double* __restrict__ topFace,
137 double* __restrict__ backFace
138) {
139 assertionEquals( Dimensions, 3 );
140 double* faces[6] = { leftFace, bottomFace, frontFace, rightFace, topFace, backFace};
142 numberOfVolumesPerAxisInPatch,
143 haloSize,
144 unknowns,
145 auxiliaryVariables,
146 Q,
147 faces
148 );
149}
150
151
153 int numberOfVolumesPerAxisInPatch,
154 int haloSize,
155 int unknowns,
156 int auxiliaryVariables,
157 const double* __restrict__ Q,
158 double* faces[2*Dimensions]
159) {
160 for(int d=0; d<Dimensions; d++) {
166 dfore(k,numberOfVolumesPerAxisInPatch,d,0) {
167 for (int i=0; i<haloSize; i++) {
169 tarch::la::Vector<Dimensions,int> overlapCell = k;
170 patchCell(d) = i;
171 overlapCell(d) = i; // this is correct
172
173 int patchCellSerialised = peano4::utils::dLinearised(patchCell,numberOfVolumesPerAxisInPatch+2*haloSize);
174 int overlapCellSerialised = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,numberOfVolumesPerAxisInPatch,haloSize,d);
175
176 for (int j=0; j<unknowns+auxiliaryVariables; j++) {
177 faces[d][overlapCellSerialised*(unknowns+auxiliaryVariables)+j] =
178 Q[patchCellSerialised*(unknowns+auxiliaryVariables)+j];
179 }
180
181 patchCell(d) = i+numberOfVolumesPerAxisInPatch+haloSize;
182 overlapCell(d) = i+haloSize;
183
184 patchCellSerialised = peano4::utils::dLinearised(patchCell,numberOfVolumesPerAxisInPatch+2*haloSize);
185 overlapCellSerialised = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,numberOfVolumesPerAxisInPatch,haloSize,d);
186 for (int j=0; j<unknowns+auxiliaryVariables; j++) {
187 faces[d+Dimensions][overlapCellSerialised*(unknowns+auxiliaryVariables)+j] =
188 Q[patchCellSerialised*(unknowns+auxiliaryVariables)+j];
189 }
190 }
191 }
192 }
193}
194
195
197 int numberOfVolumesPerAxisInPatch,
198 int haloSize,
199 int unknowns,
200 int auxiliaryVariables,
201 const double* __restrict__ Q,
202 double* __restrict__ leftFace,
203 double* __restrict__ bottomFace,
204 double* __restrict__ rightFace,
205 double* __restrict__ topFace
206) {
207 assertionEquals( Dimensions, 2 );
208 double* faces[4] = { leftFace, bottomFace, rightFace, topFace };
210 numberOfVolumesPerAxisInPatch,
211 haloSize,
212 unknowns,
213 auxiliaryVariables,
214 Q,
215 faces
216 );
217}
218
219
221 int numberOfVolumesPerAxisInPatch,
222 int haloSize,
223 int unknowns,
224 int auxiliaryVariables,
225 const double* __restrict__ Q,
226 double* __restrict__ leftFace,
227 double* __restrict__ bottomFace,
228 double* __restrict__ frontFace,
229 double* __restrict__ rightFace,
230 double* __restrict__ topFace,
231 double* __restrict__ backFace
232) {
233 assertionEquals( Dimensions, 3 );
234 double* faces[6] = { leftFace, bottomFace, frontFace, rightFace, topFace, backFace};
236 numberOfVolumesPerAxisInPatch,
237 haloSize,
238 unknowns,
239 auxiliaryVariables,
240 Q,
241 faces
242 );
243}
244
245
247 int numberOfVolumesPerAxisInPatch,
248 int haloSize,
249 int unknowns,
250 int auxiliaryVariables,
251 const double* __restrict__ Q,
252 double* faces[2*Dimensions]
253) {
254 assertion(false);
255 for(int d=0; d<Dimensions; d++) {
261 dfore(k,numberOfVolumesPerAxisInPatch,d,0) {
262 for (int i=0; i<haloSize; i++) {
264 tarch::la::Vector<Dimensions,int> overlapCell = k;
265 patchCell(d) = i;
266 overlapCell(d) = i; // this is correct
267
268 int patchCellSerialised = peano4::utils::dLinearised(patchCell,numberOfVolumesPerAxisInPatch+2*haloSize);
269 int overlapCellSerialised = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,numberOfVolumesPerAxisInPatch,haloSize,d);
270
271 for (int j=0; j<unknowns+auxiliaryVariables; j++) {
272 faces[d][overlapCellSerialised*(unknowns+auxiliaryVariables)+j] =
273 Q[patchCellSerialised*(unknowns+auxiliaryVariables)+j];
274 }
275
276 patchCell(d) = i+numberOfVolumesPerAxisInPatch+haloSize;
277 overlapCell(d) = i+haloSize;
278
279 patchCellSerialised = peano4::utils::dLinearised(patchCell,numberOfVolumesPerAxisInPatch+2*haloSize);
280 overlapCellSerialised = toolbox::blockstructured::serialiseVoxelIndexInOverlap(overlapCell,numberOfVolumesPerAxisInPatch,haloSize,d);
281 for (int j=0; j<unknowns+auxiliaryVariables; j++) {
282 faces[d+Dimensions][overlapCellSerialised*(unknowns+auxiliaryVariables)+j] =
283 Q[patchCellSerialised*(unknowns+auxiliaryVariables)+j];
284 }
285 }
286 }
287 }
288}
#define assertionEquals(lhs, rhs)
#define assertion(expr)
#define dfore(counter, max, dim, value)
This is an exclusive d-dimensional for loop.
Definition Loop.h:942
CPUGPUMethod int dLinearised(const tarch::la::Vector< Dimensions, int > &counter, int max)
Map d-dimensional vector onto integer index.
Definition Loop.cpp:106
int serialiseVoxelIndexInOverlap(const tarch::la::Vector< Dimensions, int > &overlapCell, int numberOfDoFsPerAxisInPatch, int overlap, int normal)
The volumes or elements within an overlap are always enumerated lexicographically.
void extrapolatePatchSolutionAndProjectExtrapolatedHaloOntoFaces(int numberOfVolumesPerAxisInPatch, int haloSize, int unknowns, int auxiliaryVariables, const double *__restrict__ Q, double *__restrict__ leftFace, double *__restrict__ bottomFace, double *__restrict__ rightFace, double *__restrict__ topFace)
void projectPatchHaloOntoFaces(int numberOfVolumesPerAxisInPatch, int haloSize, int unknowns, int auxiliaryVariables, const double *__restrict__ Q, double *__restrict__ leftFace, double *__restrict__ bottomFace, double *__restrict__ rightFace, double *__restrict__ topFace)
Take elements from the halo and project them onto the face.
void projectPatchSolutionOntoFaces(int numberOfVolumesPerAxisInPatch, int haloSize, int unknowns, int auxiliaryVariables, const double *__restrict__ Q, double *__restrict__ leftFace, double *__restrict__ bottomFace, double *__restrict__ rightFace, double *__restrict__ topFace)
Project data from patch onto adjacent faces.
Definition Projection.cpp:8
Simple vector class.
Definition Vector.h:134