Peano
Loading...
Searching...
No Matches
CellAccess.cpp
Go to the documentation of this file.
1#include "CellAccess.h"
2
3
5 const double* __restrict__ QIn,
6 int haloSize,
7 int unknowns,
8 int numberOfAuxiliaryVariables,
9 int numberOfDoFsPerAxisInPatch
10):
11 _QIn(QIn),
12 _haloSize(haloSize),
13 _unknowns(unknowns),
14 _numberOfAuxiliaryVariables(numberOfAuxiliaryVariables),
15 _numberOfDoFsPerAxisInPatch(numberOfDoFsPerAxisInPatch) {}
16
17
19 if constexpr (Dimensions == 2) {
20 return (_numberOfDoFsPerAxisInPatch + 2 * _haloSize) * (_numberOfDoFsPerAxisInPatch + 2 * _haloSize)
21 * (_unknowns + _numberOfAuxiliaryVariables);
22 } else {
23 return (_numberOfDoFsPerAxisInPatch + 2 * _haloSize) * (_numberOfDoFsPerAxisInPatch + 2 * _haloSize)
24 * (_numberOfDoFsPerAxisInPatch + 2 * _haloSize) * (_unknowns + _numberOfAuxiliaryVariables);
25 }
26}
27
28
29const double* __restrict__ exahype2::CellAccess::operator()(
30 const tarch::la::Vector<Dimensions, int>& relativeCellPosition
31) const {
32 if constexpr (Dimensions == 2) {
33 int voxelShift = relativeCellPosition(0)
34 + relativeCellPosition(1) * (_numberOfDoFsPerAxisInPatch + 2 * _haloSize);
35 return _QIn + voxelShift * (_unknowns + _numberOfAuxiliaryVariables);
36 } else {
37 int voxelShift = relativeCellPosition(0) + relativeCellPosition(1) * (_numberOfDoFsPerAxisInPatch + 2 * _haloSize)
38 + relativeCellPosition(2) * (_numberOfDoFsPerAxisInPatch + 2 * _haloSize)
39 * (_numberOfDoFsPerAxisInPatch + 2 * _haloSize);
40 return _QIn + voxelShift * (_unknowns + _numberOfAuxiliaryVariables);
41 }
42}
43
44
45double exahype2::CellAccess::operator()(const tarch::la::Vector<Dimensions, int>& relativeCellPosition, int unknown)
46 const {
47 return *((*this)(relativeCellPosition) + unknown);
48}
49
50
51const double* __restrict__ exahype2::CellAccess::left(int normal) const {
52 tarch::la::Vector<Dimensions, int> relativePosition(0);
53 relativePosition(normal) = -1;
54 return (*this)(relativePosition);
55}
56
57
58const double* __restrict__ exahype2::CellAccess::right(int normal) const {
59 tarch::la::Vector<Dimensions, int> relativePosition(0);
60 relativePosition(normal) = 1;
61 return (*this)(relativePosition);
62}
63
64
65double exahype2::CellAccess::left(int normal, int unknown) const {
66 tarch::la::Vector<Dimensions, int> relativePosition(0);
67 relativePosition(normal) = -1;
68 return (*this)(relativePosition, unknown);
69}
70
71
72double exahype2::CellAccess::right(int normal, int unknown) const {
73 tarch::la::Vector<Dimensions, int> relativePosition(0);
74 relativePosition(normal) = 1;
75 return (*this)(relativePosition, unknown);
76}
77
78
79double exahype2::CellAccess::centre(int unknown) const { return *(_QIn + unknown); }
double centre(int unknown) const
const double *__restrict__ operator()(const tarch::la::Vector< Dimensions, int > &relativeCellPosition) const
Get a pointer to another cell's data.
const double *__restrict__ left(int normal) const
Return access to the left neighbour.
CellAccess(const double *__restrict__ QIn, int haloSize, int unknowns, int numberOfAuxiliaryVariables, int numberOfDoFsPerAxisInPatch)
Definition CellAccess.cpp:4
const double *__restrict__ right(int normal) const
Simple vector class.
Definition Vector.h:134