49 std::pair<T, T>
operator()(
const viennahrle::Index<D> &indices,
51 auto &grid = levelSet->getGrid();
52 double gridDelta = grid.getGridDelta();
54 VectorType<T, 3> coordinate{0., 0., 0.};
55 for (
unsigned i = 0; i <
D; ++i) {
56 coordinate[i] = indices[i] * gridDelta;
60 neighborIterator.goToIndicesSequential(indices);
72 for (
int i = 0; i <
D; i++) {
78 stencil[3] = neighborIterator.getCenter().getValue();
81 stencil[4] = neighborIterator.getNeighbor(i).getValue();
82 stencil[2] = neighborIterator.getNeighbor(i +
D).getValue();
86 stencil[5] = neighborIterator.getNeighbor(
D * 2 + i).getValue();
87 stencil[1] = neighborIterator.getNeighbor(
D * 2 +
D + i).getValue();
90 stencil[6] = neighborIterator.getNeighbor(
D * 4 + i).getValue();
91 stencil[0] = neighborIterator.getNeighbor(
D * 4 +
D + i).getValue();
103 gradPosTotal += pow2(std::max(wenoGradMinus[i],
T(0))) +
104 pow2(std::min(wenoGradPlus[i],
T(0)));
107 gradNegTotal += pow2(std::min(wenoGradMinus[i],
T(0))) +
108 pow2(std::max(wenoGradPlus[i],
T(0)));
114 Vec3D<T> normalVector = {};
115 if (calculateNormalVectors) {
117 for (
int i = 0; i <
D; i++) {
120 T pos = neighborIterator.getNeighbor(i).getValue();
121 T neg = neighborIterator.getNeighbor(i +
D).getValue();
122 normalVector[i] = (pos - neg) * 0.5;
123 denominator += normalVector[i] * normalVector[i];
125 if (denominator > 0) {
126 denominator = 1. / std::sqrt(denominator);
127 for (
unsigned i = 0; i <
D; ++i) {
128 normalVector[i] *= denominator;
134 double scalarVelocity = velocities->getScalarVelocity(
135 coordinate, material, normalVector,
136 neighborIterator.getCenter().getPointId());
137 Vec3D<T> vectorVelocity = velocities->getVectorVelocity(
138 coordinate, material, normalVector,
139 neighborIterator.getCenter().getPointId());
144 if (scalarVelocity > 0) {
145 vel_grad += std::sqrt(gradPosTotal) * scalarVelocity;
147 vel_grad += std::sqrt(gradNegTotal) * scalarVelocity;
153 for (
int w = 0; w <
D; w++) {
154 if (vectorVelocity[w] > 0.) {
155 vel_grad += vectorVelocity[w] * wenoGradMinus[w];
157 vel_grad += vectorVelocity[w] * wenoGradPlus[w];
162 return {vel_grad, 0.};