Peano
Loading...
Searching...
No Matches
PatchUtils.h
Go to the documentation of this file.
1// This file is part of the ExaHyPE2 project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5
6#include <vector>
7
8#include "tarch/la/Vector.h"
10
13
14
15namespace exahype2 {
16 namespace fv {
26 int numberOfVolumesPerAxisInPatch
27 )
28 //InlineMethod
29 {
31
32 for (int d=0; d<2; d++) {
33 #if !defined(GPUOffloadingSYCL) and !defined(GPUOffloadingOMP)
34 assertion2( numberOfVolumesPerAxisInPatch>=1, h, numberOfVolumesPerAxisInPatch );
35 #endif
36 volumeSize(d) = h(d)/numberOfVolumesPerAxisInPatch;
37 }
38
39 return volumeSize;
40 }
41
42
45 int numberOfVolumesPerAxisInPatch
46 )
47 //InlineMethod
48 {
50
51 for (int d=0; d<3; d++) {
52 volumeSize(d) = h(d)/numberOfVolumesPerAxisInPatch;
53 }
54
55 return volumeSize;
56 }
57
58
61 int numberOfVolumesPerAxisInPatch
62 )
63 //InlineMethod
64 {
65 return getVolumeSize(h,numberOfVolumesPerAxisInPatch);
66 }
67
68
71 int numberOfVolumesPerAxisInPatch
72 )
73 //InlineMethod
74 {
75 return getVolumeSize(h,numberOfVolumesPerAxisInPatch);
76 }
77
78
97 int numberOfVolumesPerAxisInPatch,
98 const tarch::la::Vector<2,int>& index
99 )
100 //InlineMethod
101 {
102 tarch::la::Vector<2,double> volumeSize = getVolumeSize(h,numberOfVolumesPerAxisInPatch);
103 tarch::la::Vector<2,double> result = x - 0.5 * h + 0.5 * volumeSize;
104 for (int d=0; d<2; d++) {
105 result(d) += index(d) * volumeSize(d);
106 }
107 return result;
108 }
109
110
114 int numberOfVolumesPerAxisInPatch,
115 const tarch::la::Vector<3,int>& index
116 )
117 //InlineMethod
118 {
119 tarch::la::Vector<3,double> volumeSize = getVolumeSize(h,numberOfVolumesPerAxisInPatch);
120 tarch::la::Vector<3,double> result = x - 0.5 * h + 0.5 * volumeSize;
121 for (int d=0; d<3; d++) {
122 result(d) += index(d) * volumeSize(d);
123 }
124 return result;
125 }
126
127
131 int numberOfVolumesPerAxisInPatch,
132 int overlap,
133 int normal,
134 const tarch::la::Vector<2,int>& index
135 )
136 //InlineMethod
137 {
138 tarch::la::Vector<2,double> volumeSize = getFaceSize(h,numberOfVolumesPerAxisInPatch);
140
141 for (int d=0; d<2; d++) {
142 if (d==normal) {
143 result(d) = x(d) - overlap * volumeSize(d) + 0.5 * volumeSize(d);
144 }
145 else {
146 result(d) = x(d) - 0.5 * h(d) + 0.5 * volumeSize(d);
147 }
148 result(d) += index(d) * volumeSize(d);
149 }
150
151 return result;
152 }
153
154
158 int numberOfVolumesPerAxisInPatch,
159 int overlap,
160 int normal,
161 const tarch::la::Vector<3,int>& index
162 )
163 //InlineMethod
164 {
165 tarch::la::Vector<3,double> volumeSize = getVolumeSize(h,numberOfVolumesPerAxisInPatch);
166 tarch::la::Vector<3,double> result = x - 0.5 * h + 0.5 * volumeSize;
167
168 for (int d=0; d<3; d++) {
169 if (d==normal) {
170 result(d) = x(d) - overlap * volumeSize(d) + 0.5 * volumeSize(d);
171 }
172 else {
173 result(d) = x(d) - 0.5 * h(d) + 0.5 * volumeSize(d);
174 }
175 result(d) += index(d) * volumeSize(d);
176 }
177
178 return result;
179 }
180
181
191 int numberOfVolumesPerAxisInPatch
192 );
193
194
197 int numberOfVolumesPerAxisInPatch
198 );
199
200
225 const double* __restrict__ Q,
226 int unknownsPlusAuxiliaryVariables,
227 int numberOfVolumesPerAxisInPatch,
229 int normal,
230 bool isRight,
231 double volumeSize,
232 double* __restrict__ gradient
233 );
234
235
242 std::string plotVolume(
243 const double* __restrict__ Q,
244 int unknowns
245 );
246
247
262 const double* __restrict__ Q,
263 int unknowns,
264 int auxiliaryVariables,
265 int numberOfVolumesPerAxisInPatch,
266 int haloSize,
267 const std::string& location = "",
268 bool triggerNonCriticalAssertion = true,
269 double* minValues = nullptr,
270 double* maxValues = nullptr
271 );
272
273
281 std::string plotPatch(
282 const double* __restrict__ Q,
283 int unknowns,
284 int auxiliaryVariables,
285 int numberOfVolumesPerAxisInPatch,
286 int haloSize,
287 bool prettyPrint = false
288 );
289
290
291 std::string plotPatchOverlap(
292 const double* __restrict__ Q,
293 int unknowns,
294 int auxiliaryVariables,
295 int numberOfGridCellsPerPatchPerAxis,
296 int haloSize,
297 int normal,
298 bool prettyPrint = false
299 );
300
301
310 int unknownsPlusAuxiliaryVariables,
311 int numberOfGridCellsPerPatchPerAxis,
312 int haloSize, // same as overlap
313 int normal,
314 bool isRightLayer,
315 const double* __restrict__ srcQ,
316 double* __restrict__ destQ
317 );
318 }
319}
320
#define assertion2(expr, param0, param1)
static tarch::la::Vector< 2, double > getVolumeCentre(const tarch::la::Vector< 2, double > &x, const tarch::la::Vector< 2, double > &h, int numberOfVolumesPerAxisInPatch, const tarch::la::Vector< 2, int > &index)
In ExaHyPE's Finite Volume setup, a cell hosts a patch of Finite Volumes.
Definition PatchUtils.h:94
void validatePatch(const double *__restrict__ Q, int unknowns, int auxiliaryVariables, int numberOfVolumesPerAxisInPatch, int haloSize, const std::string &location="", bool triggerNonCriticalAssertion=true, double *minValues=nullptr, double *maxValues=nullptr)
Just runs over the patch and ensures that no entry is non or infinite.
static tarch::la::Vector< 2, double > getFaceCentre(const tarch::la::Vector< 2, double > &x, const tarch::la::Vector< 2, double > &h, int numberOfVolumesPerAxisInPatch, int overlap, int normal, const tarch::la::Vector< 2, int > &index)
Definition PatchUtils.h:128
std::string plotPatch(const double *__restrict__ Q, int unknowns, int auxiliaryVariables, int numberOfVolumesPerAxisInPatch, int haloSize, bool prettyPrint=false)
Plot patch.
double getVolumeLength(const tarch::la::Vector< 2, double > &h, int numberOfVolumesPerAxisInPatch)
With GCC 10, it was impossible to return/copy the vector class.
void copyHalfOfHalo(int unknownsPlusAuxiliaryVariables, int numberOfGridCellsPerPatchPerAxis, int haloSize, int normal, bool isRightLayer, const double *__restrict__ srcQ, double *__restrict__ destQ)
A face always holds a left and a right overlap.
static tarch::la::Vector< 2, double > getVolumeSize(const tarch::la::Vector< 2, double > &h, int numberOfVolumesPerAxisInPatch)
We need this routine within vectorised and GPUised code.
Definition PatchUtils.h:24
std::string plotPatchOverlap(const double *__restrict__ Q, int unknowns, int auxiliaryVariables, int numberOfGridCellsPerPatchPerAxis, int haloSize, int normal, bool prettyPrint=false)
static tarch::la::Vector< 2, double > getFaceSize(const tarch::la::Vector< 2, double > &h, int numberOfVolumesPerAxisInPatch)
Definition PatchUtils.h:59
void computeOneSidedGradient(const double *__restrict__ Q, int unknownsPlusAuxiliaryVariables, int numberOfVolumesPerAxisInPatch, const tarch::la::Vector< Dimensions, int > &volume, int normal, bool isRight, double volumeSize, double *__restrict__ gradient)
Compute a one-sided difference quotient of the solution within a patch.
std::string plotVolume(const double *__restrict__ Q, int unknowns)
Helper routine that I need in the log statements.
This file is part of the ExaHyPE 2 project within Peano 4.
Definition __init__.py:1
Simple vector class.
Definition Vector.h:159