19 PetscReal
x = std::abs(r) / dr;
21 if (
x > 1.5)
return 0.0;
23 if (
x > 0.5 &&
x <= 1.5)
24 return (5 - 3 *
x - std::sqrt(-3 * (1 -
x) * (1 -
x) + 1)) / (6 * dr);
26 return (1 + std::sqrt(-3 *
x *
x + 1)) / (3 * dr);
32 PetscReal
x = std::abs(r) / dr;
34 if (
x >= 0.0 &&
x <= 1.0)
35 return (3 - 2 *
x + std::sqrt(1 + 4 *
x - 4 *
x *
x)) / (8 * dr);
36 else if (
x >= 1.0 &&
x <= 2.0)
37 return (5 - 2 *
x - std::sqrt(-7 + 12 *
x - 4 *
x *
x)) / (8 * dr);
45 PetscFunctionBeginUser;
47 if (name ==
"ROMA_ET_AL_1999")
52 else if (name ==
"PESKIN_2002")
58 SETERRQ1(PETSC_COMM_WORLD, PETSC_ERR_ARG_UNKNOWN_TYPE,
59 "No support for delta kernel `%s`.\n", name.c_str());
61 PetscFunctionReturn(0);
65PetscReal
delta(
const std::vector<PetscReal> &source,
66 const std::vector<PetscReal> &target,
67 const std::vector<PetscReal> &widths,
71 for (
unsigned int d = 0; d < widths.size(); ++d)
72 phi *= kernel(source[d] - target[d], widths[d]);
Prototype of Delta functions.
PetscReal delta(const std::vector< PetscReal > &source, const std::vector< PetscReal > &target, const std::vector< PetscReal > &widths, const DeltaKernel &kernel)
Discrete delta function.
PetscReal Roma_et_al_1999(const PetscReal &r, const PetscReal &dr)
Regularized delta function from Roma et al. (1999).
PetscReal Peskin_2002(const PetscReal &r, const PetscReal &dr)
Regularized delta function from Peskin (2002).
PetscErrorCode getKernel(const std::string &name, DeltaKernel &kernel, PetscInt &size)
Get the delta kernel and size providing the name.
std::function< PetscReal(const PetscReal &r, const PetscReal &dr)> DeltaKernel
Typedef to choose the regularized delta kernel to use.
A toolbox for building flow solvers.