Peano
Loading...
Searching...
No Matches
DGUtils.cpp
Go to the documentation of this file.
2
3
5 int unknownsPlusAuxiliaryVariables,
6 int order,
7 int numberOfProjectedQuantities,
8 int normal,
9 int isRightFaceHalf,
10 const double* __restrict__ srcQ,
11 double* __restrict__ destQ
12) {
14 unknownsPlusAuxiliaryVariables,
15 order+1,
16 numberOfProjectedQuantities,
17 normal,
18 isRightFaceHalf,
19 srcQ,
20 destQ
21 );
22}
23
24
26 const tarch::la::Vector<3,double>& cellSize,
27 const tarch::la::Vector<3,int>& index,
28 const double* __restrict__ quadratureWeights
29) {
30 double result = 1.0;
31 for (int d=0; d<Dimensions; d++) {
32 result *= cellSize(d) * quadratureWeights[ index(d) ];
33 }
34 return result;
35}
36
37
38
39int exahype2::dg::getNodesPerCell(int nodesPerAxis){
40 int nodesPerCell=nodesPerAxis;
41 for(int d=1; d<Dimensions; d++) {
42 nodesPerCell *= nodesPerAxis;
43 }
44 return nodesPerCell;
45}
46
49 for(int i=1; i<Dimensions; i++){
50 strides[i] = strides[i-1]*nodesPerAxis;
51 }
52 return strides;
53}
54
56 int node,
58){
59
61 int tmp = 0;
62 for(int d=Dimensions-1; d>=0; d--){
63 index[d] = (node - tmp) / strides[d];
64 tmp += strides[d]*index[d];
65 }
66 return index;
67
68}
69
70
72 const tarch::la::Vector<Dimensions,int>& indexCell,
73 const int direction,
74 const int orientation,
75 const int nodesPerAxis
76 ){
77
78 /*
79 * Imagine a 3d cell of order 2, so there are 9 nodes
80 * for a node [i,j,k], we want face element [j,k] if in
81 * direction i, [i,k] in direction j and [i,j] if in
82 * direction k.
83 * Element [a,b] of a face is element a*strides[0]+b
84 * (concept is same in other dimensions but with
85 * additional terms and greater strides)
86 *
87 * However since the Hull is one array, we need to skip
88 * the previous faces, so ignore nodesPerFace*dimensions
89 * indexes (nodesPerFace*dimensions+1) if right.
90 */
91
92 int HullIndex = 0;
93 int stride = 1;
94
95 for(int dim=0; dim<Dimensions; dim++){
96 if(dim!=direction){
97 HullIndex += indexCell[dim]*stride;
98 stride *= nodesPerAxis;
99 }
100 }
101
102 /* if left face need to skip left and right faces for each previous dimension
103 * if right face, need to skip those plus the left face
104 */
105 return HullIndex + stride*(2*direction+orientation); //stride is nodesPerAxis^(d)
106
107}
108
109
111 const double* __restrict__ const QCell,
112 const double* __restrict__ const derivativeOperator,
113 const double invDx,
114 const int nodesPerAxis,
115 const int strideQ,
116 const int scalarIndex,
117 double* __restrict__ gradQ
118 ){
119
120 tarch::la::Vector<Dimensions,int> strides = getStrides(nodesPerAxis);
121 tarch::la::Vector<Dimensions,int> index = getIndex(scalarIndex, strides);
122
123 for(int dim=0; dim<Dimensions; dim++){
124
125 for(int var=0; var<strideQ; var++){
126 gradQ[dim*strideQ+var] = 0.0;
127 }//var
128
129 for(int node=0; node<nodesPerAxis; node++){
130// const double coeff = invDx * derivativeOperator[node+nodesPerAxis*index[dim]];
131 const double coeff = invDx * derivativeOperator[node+nodesPerAxis*index[dim]];
132 for(int var=0; var<strideQ; var++){
133 gradQ[dim*strideQ+var] += coeff*QCell[(scalarIndex + (node-index[dim])*strides[dim])*strideQ + var];
134 }//var
135 }//node
136 }//dim
137
138}
139
140
142 double* __restrict__ QOut,
143 const double* __restrict__ Qsubstract,
144 const int order,
145 const int unknowns,
146 const int auxiliaryVariables
147) {
148 const int nodesPerAxis = order+1;
149 const int nodesPerCell = getNodesPerCell(nodesPerAxis);
150 const int strideQ = unknowns+auxiliaryVariables;
151
152 for(int node=0; node<nodesPerCell; node++){
153 for(int var=0; var<strideQ; var++){
154 QOut[node*strideQ+var] -= Qsubstract[node*strideQ+var];
155 }
156 }
157}
158
159
161 const double* __restrict__ Q,
162 const int order,
163 const int unknowns,
164 const int auxiliaryVariables
165) {
166 return ::exahype2::fv::plotPatch(
167 Q,
168 order+1,
169 unknowns,
170 auxiliaryVariables,
171 Dimensions==2
172 );
173}
174
175
177 const double* __restrict__ Q,
178 const int order,
179 const int unknowns,
180 const int auxiliaryVariables,
181 int normal,
182 int numberOfQuantitiesProjectedOntoFace
183) {
184 return ::exahype2::fv::plotPatchOverlap(
185 Q,
186 unknowns,
187 auxiliaryVariables,
188 order+1,
189 numberOfQuantitiesProjectedOntoFace,
190 normal,
191 Dimensions==2
192 );
193}
std::string plotFace(const double *__restrict__ Q, const int order, const int unknowns, const int auxiliaryVariables, int normal, int numberOfQuantitiesProjectedOntoFace)
Definition DGUtils.cpp:176
tarch::la::Vector< Dimensions, int > getStrides(int nodesPerAxis)
Definition DGUtils.cpp:47
void computeGradient(const double *__restrict__ const QCell, const double *__restrict__ const derivativeOperator, const double invDx, const int nodesPerAxis, const int strideQ, const int scalarIndex, double *__restrict__ gradQ)
Definition DGUtils.cpp:110
double getQuadratureWeight(const tarch::la::Vector< 3, double > &cellSize, const tarch::la::Vector< 3, int > &index, const double *__restrict__ quadratureWeights)
Compute integral over shape function over cell defined by index.
Definition DGUtils.cpp:25
tarch::la::Vector< Dimensions, int > getIndex(int node, tarch::la::Vector< Dimensions, int > strides)
Definition DGUtils.cpp:55
int getNodesPerCell(int nodesPerAxis)
The number of nodes in a cell is basically the input to the power of d.
Definition DGUtils.cpp:39
void subtractCell(double *__restrict__ QOut, const double *__restrict__ Qsubstract, const int order, const int unknowns, const int auxiliaryVariables)
Definition DGUtils.cpp:141
void copyOneSideOfFaceProjection(int unknownsPlusAuxiliaryVariables, int order, int numberOfProjectedQuantities, int normal, int isRightFaceHalf, const double *__restrict__ srcQ, double *__restrict__ destQ)
Delegate to PatchUtils of the Finite Volume scheme.
Definition DGUtils.cpp:4
std::string plotCell(const double *__restrict__ Q, const int order, const int unknowns, const int auxiliaryVariables)
Definition DGUtils.cpp:160
int cellIndexToHullIndex(const tarch::la::Vector< Dimensions, int > &indexCell, const int direction, const int orientation, const int nodesPerAxis)
Definition DGUtils.cpp:71
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.
Simple vector class.
Definition Vector.h:134