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))
45 std::swap(cellIndex[0], cellIndex[1]);
49 std::swap(cellIndex[0], cellIndex[2]);
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]);
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) {
78 _depthLevel.facesDevice[axis] = tarch::allocateMemory<double>(
80 tarch::MemoryLocation::Pinned
86 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
87 tarch::freeMemory(
_depthLevel.facesDevice[axis], tarch::MemoryLocation::Pinned);
105 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
106 const tarch::la::Vector<DIMENSIONS, double>&
cellSize
108 tarch::la::Vector<DIMENSIONS, double> cellCentreOffset = cellCentre - DomainOffset;
109 tarch::la::Vector<DIMENSIONS, int> cellIndex = tarch::la::convertScalar<int>(
110 tarch::la::floor(tarch::la::divideComponents(cellCentreOffset,
cellSize))
112 int index = peano4::utils::dLinearised(cellIndex, GridLength);
117 auto& faceData =
_depthLevel.faces[axis % DIMENSIONS];
118 if (axis >= DIMENSIONS) {
120 return faceData[index + 1].data();
123 return faceData[index].data();
128 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
129 const tarch::la::Vector<DIMENSIONS, double>&
cellSize,
133 return _depthLevel.faces[axis % DIMENSIONS][index].data();
137 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
138 const tarch::la::Vector<DIMENSIONS, double>&
cellSize,
146 int faceCount = std::pow(GridLength, DIMENSIONS - 1) * (GridLength + 1);
147 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
148 tarch::copyTo<double, double>(
152 tarch::MemoryLocation::Pinned
158 int faceCount = std::pow(GridLength, DIMENSIONS - 1) * (GridLength + 1);
159 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
160 tarch::copyFrom<double, double>(
164 tarch::MemoryLocation::Pinned
const tarch::la::Vector< DIMENSIONS, double > cellSize
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)
DataRepository(const DataRepository &)=delete
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)