@@ -249,6 +249,58 @@ int DiscreteGradient::setManifoldSize(
249249 return 0 ;
250250}
251251
252+ void DiscreteGradient::computeDerivatives (
253+ const SimplexId &x,
254+ const std::vector<SimplexId> &stencilIds,
255+ const std::array<float , 3 > &xCoords,
256+ const std::vector<std::array<float , 3 >> &stencilCoords,
257+ double (&grad)[3]) {
258+
259+ const double *scalars
260+ = static_cast <double const *>(this ->inputScalarField_ .first );
261+ if (stencilIds[0 ] != -1 && stencilIds[1 ] != -1 )
262+ grad[0 ] = -(scalars[stencilIds[0 ]] - scalars[stencilIds[1 ]])
263+ / std::abs (stencilCoords[0 ][0 ] - stencilCoords[1 ][0 ]);
264+ else if (stencilIds[0 ] != -1 && stencilIds[1 ] == -1 )
265+ grad[0 ] = -(scalars[stencilIds[0 ]] - scalars[x])
266+ / std::abs (stencilCoords[0 ][0 ] - xCoords[0 ]);
267+ else if (stencilIds[1 ] != -1 && stencilIds[0 ] == -1 )
268+ grad[0 ] = -(scalars[x] - scalars[stencilIds[1 ]])
269+ / std::abs (stencilCoords[1 ][0 ] - xCoords[0 ]);
270+ if (stencilIds[2 ] != -1 && stencilIds[3 ] != -1 )
271+ grad[1 ] = -(scalars[stencilIds[2 ]] - scalars[stencilIds[3 ]])
272+ / std::abs (stencilCoords[2 ][1 ] - stencilCoords[3 ][1 ]);
273+ else if (stencilIds[2 ] != -1 && stencilIds[3 ] == -1 )
274+ grad[1 ] = -(scalars[stencilIds[2 ]] - scalars[x])
275+ / std::abs (stencilCoords[2 ][1 ] - xCoords[1 ]);
276+ else if (stencilIds[3 ] != -1 && stencilIds[2 ] == -1 )
277+ grad[1 ] = -(scalars[x] - scalars[stencilIds[3 ]])
278+ / std::abs (stencilCoords[3 ][1 ] - xCoords[1 ]);
279+ if (stencilIds[4 ] != -1 && stencilIds[5 ] != -1 )
280+ grad[2 ] = -(scalars[stencilIds[4 ]] - scalars[stencilIds[5 ]])
281+ / std::abs (stencilCoords[4 ][2 ] - stencilCoords[5 ][2 ]);
282+ else if (stencilIds[4 ] != -1 && stencilIds[5 ] == -1 )
283+ grad[2 ] = -(scalars[stencilIds[4 ]] - scalars[x])
284+ / std::abs (stencilCoords[4 ][2 ] - xCoords[2 ]);
285+ else if (stencilIds[5 ] != -1 && stencilIds[4 ] == -1 )
286+ grad[2 ] = -(scalars[x] - scalars[stencilIds[5 ]])
287+ / std::abs (stencilCoords[5 ][2 ] - xCoords[2 ]);
288+ }
289+
290+ int DiscreteGradient::getCriticalPointMap (
291+ const vector<pair<SimplexId, char >> &criticalPoints, vector<char > &isPL) {
292+ isPL.resize (numberOfVertices_);
293+ std::fill (isPL.begin (), isPL.end (), 0 );
294+ for (pair<SimplexId, char > criticalPoint : criticalPoints) {
295+ const SimplexId criticalPointId = criticalPoint.first ;
296+ const char criticalPointType = criticalPoint.second ;
297+
298+ isPL[criticalPointId] = criticalPointType;
299+ }
300+
301+ return 0 ;
302+ }
303+
252304#ifdef TTK_ENABLE_MPI
253305void DiscreteGradient::setCellToGhost (const int cellDim,
254306 const SimplexId cellId) {
0 commit comments