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 const auto cellCount = std::pow(GridLength, DIMENSIONS);
74 const auto faceCount = std::pow(GridLength, DIMENSIONS - 1) * (GridLength + 1);
75 const int depth =
static_cast<int>(std::round(std::log(GridLength) / std::log(3.0)));
78 _depthLevels[depth - 1].QReconstructed.resize(cellCount);
79 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
84 const auto cellCountAMR = std::pow(GridLength * 3, DIMENSIONS);
85 const auto faceCountAMR = std::pow(GridLength * 3, DIMENSIONS - 1) * (GridLength * 3 + 1);
88 for (
int axis = 0; axis < DIMENSIONS; ++axis) {
106 const auto cellCount = std::pow(GridLength, DIMENSIONS);
107 const auto faceCount = std::pow(GridLength, DIMENSIONS - 1) * (GridLength + 1);
108 const auto volumeCount = cellCount * std::pow(AbstractFVSolver::NumberOfFiniteVolumesPerAxisPerPatch, DIMENSIONS);
109 const auto volumeReconstructedCount = cellCount
111 pow(AbstractFVSolver::NumberOfFiniteVolumesPerAxisPerPatch + 2, DIMENSIONS);
112 const auto facesVolumesCount = faceCount
113 * std::pow(AbstractFVSolver::NumberOfFiniteVolumesPerAxisPerPatch, DIMENSIONS - 1) * 2;
114 std::size_t totalStorageSize = (volumeCount + volumeReconstructedCount + facesVolumesCount)
115 * (AbstractFVSolver::NumberOfUnknowns + AbstractFVSolver::NumberOfAuxiliaryVariables)
117 return totalStorageSize;
121 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
122 const tarch::la::Vector<DIMENSIONS, double>&
cellSize
124 const double ratio = DomainSize[0] /
cellSize[0];
125 const int depth =
static_cast<int>(std::round(std::log(ratio) / std::log(3.0)));
126 tarch::la::Vector<DIMENSIONS, double> cellCentreOffset = cellCentre - DomainOffset;
127 tarch::la::Vector<DIMENSIONS, int> cellIndex = tarch::la::convertScalar<int>(
128 tarch::la::floor(tarch::la::divideComponents(cellCentreOffset,
cellSize))
130 int index = peano4::utils::dLinearised(cellIndex, std::pow(3, depth));
135 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
136 const tarch::la::Vector<DIMENSIONS, double>&
cellSize
138 const double ratio = DomainSize[0] /
cellSize[0];
139 const int depth =
static_cast<int>(std::round(std::log(ratio) / std::log(3.0)));
140 tarch::la::Vector<DIMENSIONS, double> cellCentreOffset = cellCentre - DomainOffset;
141 tarch::la::Vector<DIMENSIONS, int> cellIndex = tarch::la::convertScalar<int>(
142 tarch::la::floor(tarch::la::divideComponents(cellCentreOffset,
cellSize))
144 int index = peano4::utils::dLinearised(cellIndex, std::pow(3, depth));
145 return _depthLevels[depth - 1].QReconstructed[index].data();
149 auto& faceData =
_depthLevels[depth - 1].faces[axis % DIMENSIONS];
150 if (axis >= DIMENSIONS) {
152 return faceData[index + 1].data();
155 return faceData[index].data();
160 const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
161 const tarch::la::Vector<DIMENSIONS, double>&
cellSize,
164 const double ratio = DomainSize[0] /
cellSize[0];
165 const int depth =
static_cast<int>(std::round(std::log(ratio) / std::log(3.0)));
167 return _depthLevels[depth - 1].faces[axis % DIMENSIONS][index].data();
const tarch::la::Vector< DIMENSIONS, double > cellSize
A singleton repository to manage and provide access to grid cell and face data.
double * getFaceQNew(int index, int depth, int axis)
int getCellQCardinality() const
int getFaceCardinality() const
std::vector< DepthLevel > _depthLevels
double * getCellQReconstructed(const tarch::la::Vector< DIMENSIONS, double > &cellCentre, const tarch::la::Vector< DIMENSIONS, double > &cellSize)
static DataRepository & getInstance()
std::size_t getMemoryUsageInBytes() const
int getCellQReconstructedCardinality() const
double * getCellQ(const tarch::la::Vector< DIMENSIONS, double > &cellCentre, const tarch::la::Vector< DIMENSIONS, double > &cellSize)
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)