11using namespace viennacore;
19 while (begin != end) {
20 result += *begin * *begin;
23 return result * result;
30 while (begin != end) {
31 result += *begin * *begin;
34 return std::pow(result, 1.5);
40template <
class T, std::
size_t N>
45 return (d[3] * d[1] * d[1] - 2. * d[1] * d[0] * d[6] + d[4] * d[0] * d[0]) /
52template <
class T, std::
size_t N>
57 return (d[0] * d[0] * (d[4] + d[5]) + d[1] * d[1] * (d[3] + d[5]) +
58 d[2] * d[2] * (d[3] + d[4]) +
60 (d[0] * d[1] * d[6] + d[0] * d[2] * d[8] + d[1] * d[2] * d[7])) /
67template <
class T, std::
size_t N>
69 double norm =
squareSumSquare(funcValues.begin(), funcValues.begin() + 3);
72 return -(d[0] * d[0] * (d[7] * d[7] - d[4] * d[5]) +
73 d[1] * d[1] * (d[8] * d[8] - d[3] * d[5]) +
74 d[2] * d[2] * (d[6] * d[6] - d[3] * d[4]) +
75 2. * (d[0] * d[1] * (d[5] * d[6] - d[8] * d[7]) +
76 d[0] * d[2] * (d[4] * d[8] - d[6] * d[7]) +
77 d[1] * d[2] * (d[3] * d[7] - d[6] * d[8]))) /
84template <
class It,
class T =
typename It::DomainType::hrleValueType>
86 constexpr int D = It::DomainType::dimension;
88 for (
int i = 0; i <
D; i++) {
89 hrleVectorType<hrleIndexType, D> posUnit(0);
90 hrleVectorType<hrleIndexType, D> negUnit(0);
93 T phi_0 = it.getCenter().getValue();
94 T phi_px = it.getNeighbor(posUnit).getValue();
95 T phi_nx = it.getNeighbor(negUnit).getValue();
96 int second_pos = (i + 1) %
D;
97 posUnit[second_pos] = 1;
98 negUnit[second_pos] = 1;
99 T phi_pp = it.getNeighbor(posUnit).getValue();
100 T phi_np = it.getNeighbor(negUnit).getValue();
101 posUnit[second_pos] = -1;
102 negUnit[second_pos] = -1;
103 T phi_pn = it.getNeighbor(posUnit).getValue();
104 T phi_nn = it.getNeighbor(negUnit).getValue();
107 d[i] = (phi_px - phi_nx) / 2.;
108 d[i + 3] = (phi_px - 2. * phi_0 + phi_nx) / gridDelta;
109 d[i + 6] = (phi_pp - phi_pn - phi_np + phi_nn) / (4 * gridDelta);
117template <
class It,
class T =
typename It::DomainType::hrleValueType>
119 constexpr int D = It::DomainType::dimension;
121 const double gridDelta2 = gridDelta * gridDelta;
122 for (
int i = 0; i <
D; i++) {
123 hrleVectorType<hrleIndexType, D> posUnit(0);
124 hrleVectorType<hrleIndexType, D> negUnit(0);
126 int second_axis = (i + 1) %
D;
127 posUnit[first_axis] = 1;
128 negUnit[first_axis] = -1;
129 T phi_0 = it.getCenter().getValue();
130 T phi_px = it.getNeighbor(posUnit).getValue();
131 T phi_nx = it.getNeighbor(negUnit).getValue();
132 posUnit[second_axis] = 1;
133 negUnit[second_axis] = 1;
134 T phi_pp = it.getNeighbor(posUnit).getValue();
135 T phi_np = it.getNeighbor(negUnit).getValue();
136 posUnit[second_axis] = -1;
137 negUnit[second_axis] = -1;
138 T phi_pn = it.getNeighbor(posUnit).getValue();
139 T phi_nn = it.getNeighbor(negUnit).getValue();
140 posUnit[first_axis] = 0;
141 negUnit[first_axis] = 0;
142 posUnit[second_axis] = 1;
143 negUnit[second_axis] = -1;
144 T phi_py = it.getNeighbor(posUnit).getValue();
145 T phi_ny = it.getNeighbor(negUnit).getValue();
147 d[i] = (phi_pp - phi_np + phi_pn - phi_nn) / (4 * gridDelta);
148 d[i + 3] = (phi_pp - 2. * phi_py + phi_np + phi_px - 2. * phi_0 + phi_nx +
149 phi_pn - 2. * phi_ny + phi_nn) /
151 d[i + 6] = (phi_pp - phi_pn - phi_np + phi_nn) / (4 * gridDelta2);
160template <
class It,
class T =
typename It::DomainType::hrleValueType>
162 constexpr int D = It::DomainType::dimension;
163 auto gridDelta = it.getDomain().getGrid().getGridDelta();
169 if constexpr (
D == 2) {
180template <
class It,
class T =
typename It::DomainType::hrleValueType>
182 constexpr int D = It::DomainType::dimension;
183 auto gridDelta = it.getDomain().getGrid().getGridDelta();
189 if constexpr (
D == 2) {
190 Logger::getInstance()
192 "2D structures do not have a Gaussian Curvature, use "
193 "\"meanCurvature(IteratorType & neighborIterator)\" instead!")
Definition lsAdvect.hpp:37
double squareSumSquare(It begin, It end)
Returns the squared sum square for values in the range [start, end[.
Definition lsCurvatureFormulas.hpp:17
std::array< T, 9 > smallStencilFromIterator(It &it, const double gridDelta)
Fills an std::array with differential values calculated from neighbour values. This stencil only uses...
Definition lsCurvatureFormulas.hpp:85
double gaussianCurvature3D(std::array< T, N > funcValues)
Gaussian curvature formula for implicit surfaces in 3D, the passed array should contain the function ...
Definition lsCurvatureFormulas.hpp:68
double meanCurvature2D(std::array< T, N > funcValues)
Mean curvature formula for implicit surfaces in 2D, the passed array should contain the function valu...
Definition lsCurvatureFormulas.hpp:41
T gaussianCurvature(It &it, bool bigStencil=false)
Calculates the Gaussian Curvature of the level set function from a suitable hrle iterator....
Definition lsCurvatureFormulas.hpp:181
std::array< T, 9 > bigStencilFromIterator(It &it, const double gridDelta)
Fills an std::array with differential values calculated from neighbour values. This stencil also uses...
Definition lsCurvatureFormulas.hpp:118
T meanCurvature(It &it, bool bigStencil=false)
Calculates the Mean Curvature of the level set function from a suitable hrle iterator....
Definition lsCurvatureFormulas.hpp:161
double rootSumSquarePow3(It begin, It end)
Returns the root sum square to the 3rd power for values in the range [start, end[.
Definition lsCurvatureFormulas.hpp:28
double meanCurvature3D(std::array< T, N > funcValues)
Mean curvature formula for implicit surfaces in 3D, the passed array should contain the function valu...
Definition lsCurvatureFormulas.hpp:53
constexpr int D
Definition pyWrap.cpp:65
double T
Definition pyWrap.cpp:63