37 template<alsfvm::boundary::Type BoundaryType,
class Function>
41 int i,
int j,
int k,
int h,
int nx,
int ny,
int nz,
42 int ngx,
int ngy,
int ngz,
int dimensions) {
43 const auto u = input.
at(i + ngx, j + ngy, k + ngz);
45 const auto numberOfCellsWithoutGhostCells =
ivec3{
nx,
ny, nz};
48 for (
int d = 0; d < dimensions; d++) {
50 for (
int side = 0; side < 2; side++) {
51 const bool zDir = (d == 2);
52 const bool yDir = (d == 1);
53 const bool xDir = (d == 0);
55 const int zStart = zDir ?
56 (side == 0 ? k - h : k + h) : (dimensions > 2 ? k - h : 0);
58 const int zEnd = zDir ?
59 (zStart + 1) : (dimensions > 2 ? k + h + 1 : 1);
62 (side == 0 ? j - h : j + h) : (dimensions == 2 ? j - h + 1 :
63 (dimensions == 3 ? j - h + 1 : 0));
66 (yStart + 1) : (dimensions == 2 ? j + h : (dimensions == 3 ? j + h : 1));
69 (side == 0 ? i - h : i + h) : i - h;
72 (xStart + 1) : i + h + 1;
82 for (
int z = zStart; z < zEnd; z++) {
83 for (
int y = yStart; y < yEnd; y++) {
84 for (
int x = xStart; x < xEnd; x++) {
85 const auto discretePosition =
ivec3{i, j, k};
86 const auto discretePositionPlusH =
ivec3{x, y, z};
92 discretePositionPlusH,
93 numberOfCellsWithoutGhostCells,
105 template<alsfvm::boundary::Type BoundaryType,
class PowerClass>
110 int i,
int j,
int k,
int h,
int nx,
int ny,
int nz,
111 int ngx,
int ngy,
int ngz,
int dimensions,
real p) {
113 forEachPointInComputeStructureCube<BoundaryType>([&](
double u,
double u_h) {
114 output.
at(h) += PowerClass::power(fabs(u - u_h), p) / (nx * ny *
nz);
115 }, input, i, j, k, h,
nx,
ny,
nz, ngx, ngy, ngz, dimensions);
121 template<alsfvm::boundary::Type BoundaryType,
class PowerClass>
125 auto inputView = input[var]->getView();
126 auto outputView = output[var]->getView();
136 for (
int k = 0; k <
nz; ++k) {
137 for (
int j = 0; j <
ny; ++j) {
138 for (
int i = 0; i <
nx; ++i) {
139 for (
int h = 1; h < numberOfH; ++h) {
141 computeStructureCube<BoundaryType, PowerClass>(outputView, inputView, i, j, k,
156 template<alsfvm::boundary::Type BoundaryType>
160 computeStructureCubeCPU <BoundaryType, alsutils::math::FastPower<1>>
161 (output, input, numberOfH,
p);
162 }
else if (p == 2.0) {
163 computeStructureCubeCPU <BoundaryType, alsutils::math::FastPower<2>>
164 (output, input, numberOfH,
p);
168 computeStructureCubeCPU <BoundaryType, alsutils::math::FastPower<3>>
169 (output, input, numberOfH,
p);
170 }
else if (p == 4.0) {
171 computeStructureCubeCPU <BoundaryType, alsutils::math::FastPower<4>>
172 (output, input, numberOfH,
p);
173 }
else if (p == 5.0) {
174 computeStructureCubeCPU <BoundaryType, alsutils::math::FastPower<5>>
175 (output, input, numberOfH,
p);
177 computeStructureCubeCPU <BoundaryType, alsutils::math::PowPower>
178 (output, input, numberOfH,
p);
void computeStructureCubeCPU(alsfvm::volume::Volume &output, const alsfvm::volume::Volume &input, int numberOfH, double p)
Definition: structure_common.hpp:122
void dispatchComputeStructureCubeCPU(alsfvm::volume::Volume &output, const alsfvm::volume::Volume &input, int numberOfH, double p)
Definition: structure_common.hpp:157
__device__ __host__ void forEachPointInComputeStructureCube(Function f, const alsfvm::memory::View< const real > &input, int i, int j, int k, int h, int nx, int ny, int nz, int ngx, int ngy, int ngz, int dimensions)
Definition: structure_common.hpp:38
virtual size_t getNumberOfYCells() const
Definition: Volume.cpp:208
The Volume class represents a volume (a collection of cells with values for each cell (eg...
Definition: Volume.hpp:30
virtual size_t getNumberOfVariables() const
getNumberOfVariables gets the number of variables used
Definition: Volume.cpp:83
#define __host__
Definition: types.hpp:46
__device__ __host__ T & at(size_t x, size_t y, size_t z)
at returns a reference to the element at the given location
Definition: View.hpp:65
size_t nx
Definition: VolumeFactory.cpp:87
double real
Definition: types.hpp:65
virtual size_t getNumberOfZCells() const
Definition: Volume.cpp:215
virtual size_t getNumberOfXGhostCells() const
Definition: Volume.cpp:238
virtual size_t getNumberOfZGhostCells() const
Definition: Volume.cpp:254
__device__ __host__ void computeStructureCube(alsfvm::memory::View< real > &output, const alsfvm::memory::View< const real > &input, int i, int j, int k, int h, int nx, int ny, int nz, int ngx, int ngy, int ngz, int dimensions, real p)
Definition: structure_common.hpp:106
size_t ny
Definition: VolumeFactory.cpp:88
virtual size_t getNumberOfYGhostCells() const
Definition: Volume.cpp:246
__device__ __host__ int makePositive(int position, int N)
Definition: structure_common.hpp:27
virtual size_t getNumberOfXCells() const
Definition: Volume.cpp:201
Simple templated class to get the value at the boundary.
Definition: ValueAtBoundary.hpp:14
size_t numberOfGhostCells
Definition: VolumeFactory.cpp:90
virtual size_t getDimensions() const
Gets the number of space dimensions.
Definition: Volume.cpp:279
#define __device__
Definition: types.hpp:45
size_t nz
Definition: VolumeFactory.cpp:89
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
float p
Definition: sodshocktube.py:5
functional
Definition: FunctionalStatistics.cpp:76