13 template<Type BoundaryType>
25 ivec3 discretePosition,
26 ivec3 numberOfCellsWithoutGhostCells,
27 ivec3 numberGhostCells) {
29 const auto positivePosition =
makePositive(discretePosition,
30 numberOfCellsWithoutGhostCells);
32 const auto moduloPosition =
ivec3{positivePosition.
x % numberOfCellsWithoutGhostCells.
x,
33 positivePosition.y % numberOfCellsWithoutGhostCells.
y,
34 positivePosition.z % numberOfCellsWithoutGhostCells.
z};
36 const auto positionPeriodic = moduloPosition + numberGhostCells;
38 return view.
at(view.
index(positionPeriodic.x, positionPeriodic.y,
44 while (position < 0) {
52 ivec3 numberOfCells) {
68 ivec3 discretePosition,
69 ivec3 numberOfCellsWithoutGhostCells,
70 ivec3 numberGhostCells) {
74 const auto innerPosition =
ivec3{
75 max(0, min(discretePosition.
x, numberOfCellsWithoutGhostCells.
x - 1)),
76 max(0, min(discretePosition.
y, numberOfCellsWithoutGhostCells.
y - 1)),
77 max(0, min(discretePosition.
z, numberOfCellsWithoutGhostCells.
z - 1))
80 const auto positionWithGhostCells = innerPosition + numberGhostCells;
82 printf(
"N: %02d, gc: %02d, given: %02d, wo gc: %02d, inner: %02d, index: %02d, value: %f\n",
83 numberOfCellsWithoutGhostCells.
x, numberGhostCells.x,
85 discretePosition.
x - numberGhostCells.x,
86 innerPosition.x, view.
index(positionWithGhostCells.x, positionWithGhostCells.y,
87 positionWithGhostCells.z), view.
at(view.
index(positionWithGhostCells.x,
88 positionWithGhostCells.y,
90 positionWithGhostCells.z)));
92 return view.
at(view.
index(positionWithGhostCells.x, positionWithGhostCells.y,
93 positionWithGhostCells.z));
T z
Definition: vec3.hpp:28
__device__ static __host__ T getValueAtBoundary(const memory::View< T > &view, ivec3 discretePosition, ivec3 numberOfCellsWithoutGhostCells, ivec3 numberGhostCells)
Definition: ValueAtBoundary.hpp:66
__device__ __host__ size_t index(size_t x, size_t y, size_t z) const
index computes the linear index of the given cell
Definition: View.hpp:116
#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
Neumann boundary.
Definition: Type.hpp:27
__device__ static __host__ T getValueAtBoundary(const memory::View< T > &view, ivec3 discretePosition, ivec3 numberOfCellsWithoutGhostCells, ivec3 numberGhostCells)
Definition: ValueAtBoundary.hpp:23
Periodic boundary conditions.
Definition: Type.hpp:24
__device__ __host__ int makePositive(int position, int N)
Definition: structure_common.hpp:27
Simple templated class to get the value at the boundary.
Definition: ValueAtBoundary.hpp:14
#define __device__
Definition: types.hpp:45
T y
Definition: vec3.hpp:27
Various utility functions to implement the tecno flux.
Definition: types.hpp:30
T x
Definition: vec3.hpp:26