6 #include "exahype2/fv/BoundaryConditions.h"
7 #include "peano4/utils/Linearised.h"
8 #include "peano4/utils/Loop.h"
16 const tarch::la::Vector<DIMENSIONS, int>& cellIndex,
17 const tarch::la::Vector<DIMENSIONS, double>&
cellSize
19 const double ratio = DomainSize[0] /
cellSize[0];
20 const int depth =
static_cast<int>(std::round(std::log(ratio) / std::log(3.0)));
24 for (
int i = 0; i < DIMENSIONS; ++i) {
25 index += cellIndex[i] * stride;
27 int dimSize = (i == 0) ? (std::pow(3,
depth) + 1) : std::pow(3,
depth);
34 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
35 const tarch::la::Vector<DIMENSIONS, double>&
cellSize
37 tarch::la::Vector<DIMENSIONS, int> faceIndices;
38 tarch::la::Vector<DIMENSIONS, double> cellCentreOffset = cellCentre - DomainOffset;
39 tarch::la::Vector<DIMENSIONS, int> cellIndex = tarch::la::convertScalar<int>(
40 tarch::la::floor(tarch::la::divideComponents(cellCentreOffset,
cellSize))
43 faceIndices[0] = linearise(cellIndex,
cellSize);
45 std::swap(cellIndex[0], cellIndex[1]);
46 faceIndices[1] = linearise(cellIndex,
cellSize);
49 std::swap(cellIndex[0], cellIndex[2]);
50 faceIndices[2] = linearise(cellIndex,
cellSize);
56 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
57 const tarch::la::Vector<DIMENSIONS, double>&
cellSize,
60 tarch::la::Vector<DIMENSIONS, double> cellCentreOffset = cellCentre - DomainOffset;
61 tarch::la::Vector<DIMENSIONS, int> cellIndex = tarch::la::convertScalar<int>(
62 tarch::la::floor(tarch::la::divideComponents(cellCentreOffset,
cellSize))
65 for (
int i = 1; i <= axis % DIMENSIONS; ++i) {
66 std::swap(cellIndex[0], cellIndex[i]);
68 int faceIndex = linearise(cellIndex,
cellSize);
69 return axis >= DIMENSIONS ? faceIndex + 1 : faceIndex;
73 int cellCount = std::pow(GridLength, DIMENSIONS);
74 int faceCount = std::pow(GridLength, DIMENSIONS - 1) * (GridLength + 1);
76 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
80 tarch::MemoryLocation::Pinned
85 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
104 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
105 const tarch::la::Vector<DIMENSIONS, double>&
cellSize
107 tarch::la::Vector<DIMENSIONS, double> cellCentreOffset = cellCentre - DomainOffset;
108 tarch::la::Vector<DIMENSIONS, int> cellIndex = tarch::la::convertScalar<int>(
109 tarch::la::floor(tarch::la::divideComponents(cellCentreOffset,
cellSize))
111 int index = peano4::utils::dLinearised(cellIndex, GridLength);
117 if (axis >= DIMENSIONS) {
119 return faceData[index + 1].data();
122 return faceData[index].data();
127 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
128 const tarch::la::Vector<DIMENSIONS, double>&
cellSize,
136 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
137 const tarch::la::Vector<DIMENSIONS, double>&
cellSize,
145 int faceCount = std::pow(GridLength, DIMENSIONS - 1) * (GridLength + 1);
146 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
147 tarch::copyTo<double, double>(
151 tarch::MemoryLocation::Pinned
157 int faceCount = std::pow(GridLength, DIMENSIONS - 1) * (GridLength + 1);
158 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
159 tarch::copyFrom<double, double>(
163 tarch::MemoryLocation::Pinned
const tarch::la::Vector< DIMENSIONS, double > cellSize
A singleton repository to manage and provide access to grid cell and face data.
int getCellQReconstructedCardinality()
double * getFaceQNew(int index, int axis)
void copyFacesFromDevice()
double * getFaceQNewDevice(const tarch::la::Vector< DIMENSIONS, double > &cellCentre, const tarch::la::Vector< DIMENSIONS, double > &cellSize, int axis)
int getCellQCardinality()
static DataRepository & getInstance()
double * getCellQ(int index)
std::array< double *, DIMENSIONS > facesDevice
std::array< std::vector< FaceQNew >, DIMENSIONS > faces
static tarch::la::Vector< DIMENSIONS, int > getFaceIndices(const tarch::la::Vector< DIMENSIONS, double > &cellCentre, const tarch::la::Vector< DIMENSIONS, double > &cellSize)
Calculates the indices of the lower faces of a cell along along all axis for x axis: x_1 + x_2 * (3^D...
static int linearise(const tarch::la::Vector< DIMENSIONS, int > &cellCentre, const tarch::la::Vector< DIMENSIONS, double > &cellSize)
Calculates the linearised index of the lower face of a cell along one axis (along one axis means the ...
static int getFaceIndex(const tarch::la::Vector< DIMENSIONS, double > &cellCentre, const tarch::la::Vector< DIMENSIONS, double > &cellSize, int axis)