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
189 double getVolumeLength(
191 int numberOfVolumesPerAxisInPatch
192 );
193
194
195 double getVolumeLength(
197 int numberOfVolumesPerAxisInPatch
198 );
199
200
207 std::string plotVolume(
208 const double* __restrict__ Q,
209 int unknowns
210 );
211
212
226 void validatePatch(
227 const double* __restrict__ Q,
228 int unknowns,
229 int auxiliaryVariables,
230 int numberOfVolumesPerAxisInPatch,
231 int haloSize,
232 const std::string& location = "",
233 bool triggerNonCriticalAssertion = true,
234 double* minValues = nullptr,
235 double* maxValues = nullptr
236 );
237
238
246 std::string plotPatch(
247 const double* __restrict__ Q,
248 int unknowns,
249 int auxiliaryVariables,
250 int numberOfVolumesPerAxisInPatch,
251 int haloSize,
252 bool prettyPrint = false
253 );
254
255
256 std::string plotPatchOverlap(
257 const double* __restrict__ Q,
258 int unknowns,
259 int auxiliaryVariables,
260 int numberOfGridCellsPerPatchPerAxis,
261 int haloSize,
262 int normal,
263 bool prettyPrint = false
264 );
265
266
274 void copyHalfOfHalo(
275 int unknownsPlusAuxiliaryVariables,
276 int numberOfGridCellsPerPatchPerAxis,
277 int haloSize, // same as overlap
278 int normal,
279 bool isRightLayer,
280 const double* __restrict__ srcQ,
281 double* __restrict__ destQ
282 );
283 }
284}
285
#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
std::string plotVolume(const double *__restrict__ Q, int unknowns)
Helper routine that I need in the log statements.
For the generic kernels that I use here most of the time.
Definition CellAccess.h:13
Definition fv.py:1
Simple vector class.
Definition Vector.h:150