53 std::pair<T, T>
operator()(
const viennahrle::Index<D> &indices,
55 auto &grid = levelSet->getGrid();
56 double gridDelta = grid.getGridDelta();
58 VectorType<T, 3> coordinate{0., 0., 0.};
59 for (
unsigned i = 0; i <
D; ++i) {
60 coordinate[i] = indices[i] * gridDelta;
64 neighborIterator.goToIndicesSequential(indices);
74 T stencil[2 * stencilRadius + 1];
76 for (
int i = 0; i <
D; i++) {
82 stencil[stencilRadius] = neighborIterator.getCenter().getValue();
84 for (
int k = 1; k <= stencilRadius; ++k) {
85 stencil[stencilRadius + k] =
86 neighborIterator.getNeighbor((k - 1) * 2 *
D + i).getValue();
87 stencil[stencilRadius - k] =
88 neighborIterator.getNeighbor((k - 1) * 2 *
D +
D + i).getValue();
101 gradPosTotal += pow2(std::max(wenoGradMinus[i],
T(0))) +
102 pow2(std::min(wenoGradPlus[i],
T(0)));
105 gradNegTotal += pow2(std::min(wenoGradMinus[i],
T(0))) +
106 pow2(std::max(wenoGradPlus[i],
T(0)));
112 Vec3D<T> normalVector{};
113 if (calculateNormalVectors) {
115 for (
int i = 0; i <
D; i++) {
118 T pos = neighborIterator.getNeighbor(i).getValue();
119 T neg = neighborIterator.getNeighbor(i +
D).getValue();
120 normalVector[i] = (pos - neg) * 0.5;
121 denominator += normalVector[i] * normalVector[i];
123 if (denominator > 0) {
124 denominator = 1. / std::sqrt(denominator);
125 for (
unsigned i = 0; i <
D; ++i) {
126 normalVector[i] *= denominator;
132 double scalarVelocity = velocities->getScalarVelocity(
133 coordinate, material, normalVector,
134 neighborIterator.getCenter().getPointId());
135 Vec3D<T> vectorVelocity = velocities->getVectorVelocity(
136 coordinate, material, normalVector,
137 neighborIterator.getCenter().getPointId());
142 if (scalarVelocity > 0) {
143 vel_grad += std::sqrt(gradPosTotal) * scalarVelocity;
145 vel_grad += std::sqrt(gradNegTotal) * scalarVelocity;
151 for (
int w = 0; w <
D; w++) {
152 if (vectorVelocity[w] > 0.) {
153 vel_grad += vectorVelocity[w] * wenoGradMinus[w];
155 vel_grad += vectorVelocity[w] * wenoGradPlus[w];
160 return {vel_grad, 0.};