Peano
Loading...
Searching...
No Matches
DGUtils.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/la.h"
9#include "tarch/la/Vector.h"
11#include "tarch/Assertions.h"
12
16#include "peano4/utils/Loop.h"
17
18#include "Functors.h"
19
21
22
23
24namespace exahype2 {
25 namespace dg {
46 template<typename T>
51 int polynomialOrder,
52 const T* __restrict__ quadraturePoints
53 );
54
55 template<typename T>
60 int polynomialOrder,
61 int faceOrientation,
62 const T* __restrict__ quadraturePoints,
64 );
65
80 const tarch::la::Vector<3,double>& cellSize,
81 const tarch::la::Vector<3,int>& index,
82 const double* __restrict__ quadratureWeights
83 );
84
85
93 int getNodesPerCell(int nodesPerAxis);
94
95
96 /* returns a vector with the powers of nodesPerAxis up to the Dimensions - 1
97 ** e.g. for dims = 2, nodesPerAxis = 2 will return (1, 2)
98 ** for dims = 3, nodesPerAxis = 4 will return (1, 4, 16)
99 **
100 ** This is used to iterate over the nodes of a cell in a given dimension,
101 ** since the cells are all in the same array one after another advancing by
102 ** n*strides[i] will move you to the cell which is n steps in direction i
103 ** from the current cell.
104 ** i.e. node+1 would be the "right" neighbour, node+nodesPerAxis would be the
105 ** "upper" neighbour, and so on.
106 */
108
109
110 /*for a given linear node number, returns the index of that node
111 **in cartesian coordinate system.
112 **e.g. for dims = 2, nodesPerAxis = 4, there will be 16 total nodes
113 ** so node 0 is [0,0], 1 is [1,0] and so on until 15 which is [3,3]
114 ** for dims = 3, nodesPerAxis = 4, there will be 16*4 = 64 total nodes
115 ** ranging from 0 which is [0,0,0] to 63 which is [3,3,3]
116 */
118 int node,
120 );
121
122 /*
123 * for a given node index within the cell, returns the index of the neighbouring
124 * node on the surface in a given direction with a given orientation.
125 *
126 * Ordering on the surface is the same as for the previous functions, but only
127 * considering one "side" on each face
128 *
129 * So with the same notation as the previous function, if given a 2*2 cell
130 * in 2 dimensions, there are a total of 4 faces (left,right,down,up), each
131 * with 2 nodes.
132 * If given index which corresponds to [0,1],
133 * direction 0, orientation 0 would return node 1 on the left face
134 * direction 1, orientation 1 would return node 0 on the upper face
135 * 6 7
136 * 1 [ o o ] 3
137 * 0 [ o o ] 2
138 * 4 5
139 */
141 const tarch::la::Vector<Dimensions,int>& indexCell,
142 const int direction,
143 const int orientation,
144 const int nodesPerAxis
145 );
146
147 /*
148 * Computes the gradient of Q in a given direction for a given node
149 *
150 * Mostly used for the non-conservative product.
151 *
152 * Since the solution is represented by the sum of basis functions, its
153 * derivative at a given node is the sum of the derivatives of the basis
154 * functions evaluated at that node.
155 * The derivative operator contains the value of the derivatives evaluated
156 * at the quadrature nodes, therefore it only needs to be multiplied by
157 * their coefficients.
158 *
159 *
160 * u(x) = \sum_i \phi_i(x) * u_i => du(x)/dx = d\phi_i(x_i)/dx * u_i
161 *
162 * @param invDx: the inverse of the size of the cell in any one dimension, this
163 * assumes that the cells are cubic
164 *
165 * @param derivativeOperator: array containing the value of the derivatives of
166 * the n base functions of the dg polynomial evaluated at the n quadrature points
167 * (in 1 dimension)
168 *
169 * @param scalarIndex: index of the node at which the gradient should be evaluated
170 *
171 * @param gradQ: where the gradient values should be placed, has size unknowns*Dimensions
172 * since there is a gradient in each direction and the gradient is only nonzero for the
173 * unknowns
174 *
175 * @param strideQ: total number of variables over which the gradient should be computed
176 */
178 const double* __restrict__ const QCell,
179 const double* __restrict__ const derivativeOperator,
180 const double invDx,
181 const int nodesPerAxis,
182 const int strideQ,
183 const int scalarIndex,
184 double* __restrict__ gradQ
185 );
186
187 /*
188 * Substracts contents of one cell array from another.
189 */
191 double* __restrict__ QOut,
192 const double* __restrict__ Qsubstract,
193 const int order,
194 const int unknowns,
195 const int auxiliaryVariables
196 );
197
198
199 /*
200 * Plot patch
201 *
202 * usually used for debugging
203 */
204
205 std::string plotCell(
206 const double* __restrict__ Q,
207 const int order,
208 const int unknowns,
209 const int auxiliaryVariables
210 );
211
212 /*
213 * Plot Face
214 *
215 * Usually used for debugging. We plot all unknowns, i.e. both the unknowns
216 * form the left and the right adjacent side. The order is linear, i.e. you
217 * have to take the normal into account when you want to find out how the
218 * unknowns are spatially arranged.
219 *
220 * See the discussion around ExaHyPE's lexicographic ordering.
221 */
222 std::string plotFace(
223 const double* __restrict__ Q,
224 const int order,
225 const int unknowns,
226 const int auxiliaryVariables,
227 int normal,
228 int numberOfQuantitiesProjectedOntoFace
229 );
230
268 template<typename QStoreType>
271 int order,
272 const double* __restrict__ QuadratureNodes1d,
273 int unknownsPerDoF,
274 const QStoreType* __restrict__ Q,
276 int unknown
277 );
278
283 int unknownsPlusAuxiliaryVariables,
284 int order,
285 int numberOfProjectedQuantities,
286 int normal,
287 int isRightFaceHalf,
288 const double* __restrict__ srcQ,
289 double* __restrict__ destQ
290 );
291 }
292}
293
294
295#include "DGUtils.cpph"
Definition dg.py:1
std::string plotFace(const double *__restrict__ Q, const int order, const int unknowns, const int auxiliaryVariables, int normal, int numberOfQuantitiesProjectedOntoFace)
tarch::la::Vector< Dimensions, int > getStrides(int nodesPerAxis)
tarch::la::Vector< Dimensions, double > getQuadraturePoint(const tarch::la::Vector< Dimensions, double > &cellCentre, const tarch::la::Vector< Dimensions, double > &cellSize, const tarch::la::Vector< Dimensions, int > &index, int polynomialOrder, const T *__restrict__ quadraturePoints)
Construct location of a quadrature point.
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)
void getQuadraturePointInFace(const tarch::la::Vector< Dimensions, double > &faceCentre, const tarch::la::Vector< Dimensions, double > &cellSize, const tarch::la::Vector< Dimensions, int > &index, int polynomialOrder, int faceOrientation, const T *__restrict__ quadraturePoints, tarch::la::Vector< Dimensions, double > *output)
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.
tarch::la::Vector< Dimensions, int > getIndex(int node, tarch::la::Vector< Dimensions, int > strides)
int getNodesPerCell(int nodesPerAxis)
The number of nodes in a cell is basically the input to the power of d.
void subtractCell(double *__restrict__ QOut, const double *__restrict__ Qsubstract, const int order, const int unknowns, const int auxiliaryVariables)
QStoreType evaluatePolynomial(const peano4::datamanagement::CellMarker &marker, int order, const double *__restrict__ QuadratureNodes1d, int unknownsPerDoF, const QStoreType *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &x, int unknown)
Evaluate the DG polynomial.
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.
std::string plotCell(const double *__restrict__ Q, const int order, const int unknowns, const int auxiliaryVariables)
int cellIndexToHullIndex(const tarch::la::Vector< Dimensions, int > &indexCell, const int direction, const int orientation, const int nodesPerAxis)
This file is part of the multigrid project within Peano 4.
Definition __init__.py:1
Simple vector class.
Definition Vector.h:159