1 #ifndef ABLATELIBRARY_RBF_HPP
2 #define ABLATELIBRARY_RBF_HPP
4 #include <petsc/private/hashmapi.h>
5 #include "domain/range.hpp"
6 #include "domain/subDomain.hpp"
8 #define __RBF_DEFAULT_POLYORDER 3
10 namespace ablate::domain::rbf {
14 std::shared_ptr<ablate::domain::SubDomain> subDomain =
nullptr;
17 const int polyOrder = 4;
20 PetscInt minNumberCells = -1;
21 PetscBool useCells = PETSC_FALSE;
22 const bool returnNeighborVertices;
25 PetscInt cStart = 0, cEnd = 0;
29 const bool hasDerivatives;
31 PetscInt *dxyz =
nullptr;
32 PetscHMapI hash =
nullptr;
33 PetscInt *nStencil =
nullptr;
34 PetscInt **stencilList =
nullptr;
35 PetscReal **stencilWeights =
nullptr;
36 PetscReal **stencilXLocs =
nullptr;
39 PetscInt derivativeKey(PetscInt dx, PetscInt dy, PetscInt dz)
const {
return (100 * dx + 10 * dy + dz); };
44 const bool hasInterpolation;
45 Mat *RBFMatrix =
nullptr;
48 void Matrix(
const PetscInt c);
52 void FreeStencilData();
55 PetscReal DistanceSquared(PetscInt dim, PetscReal x[], PetscReal y[]);
56 PetscReal DistanceSquared(PetscInt dim, PetscReal x[]);
57 void Loc3D(PetscInt dim, PetscReal xIn[], PetscReal x[3]);
60 explicit RBF(
int polyOrder = 4,
bool hasDerivatives =
true,
bool hasInterpolation =
true,
bool returnNeighborVertices =
false);
66 void Setup(std::shared_ptr<ablate::domain::SubDomain> subDomain);
75 void SetDerivatives(PetscInt nDer, PetscInt dx[], PetscInt dy[], PetscInt dz[], PetscBool useCellsLocal);
82 void SetDerivatives(PetscInt nDer, PetscInt dx[], PetscInt dy[], PetscInt dz[]);
105 PetscReal
EvalDer(DM dm, Vec vec,
const PetscInt fid, PetscInt c, PetscInt dx, PetscInt dy, PetscInt dz);
140 virtual PetscReal
RBFVal(PetscInt dim, PetscReal x[], PetscReal y[]) = 0;
148 virtual PetscReal
RBFDer(PetscInt dim, PetscReal x[], PetscInt dx, PetscInt dy, PetscInt dz) = 0;
153 virtual std::string_view
type()
const = 0;
158 inline PetscInt GetDimensions() {
return RBF::subDomain->GetDimensions(); }
void Initialize()
Definition: rbf.cpp:701
void SetDerivatives(PetscInt nDer, PetscInt dx[], PetscInt dy[], PetscInt dz[], PetscBool useCellsLocal)
Definition: rbf.cpp:264
virtual std::string_view type() const =0
PetscReal Interpolate(const ablate::domain::Field *field, Vec f, const PetscInt c, PetscReal xEval[3])
Definition: rbf.cpp:465
PetscReal EvalDer(const ablate::domain::Field *field, PetscInt c, PetscInt dx, PetscInt dy, PetscInt dz)
Definition: rbf.cpp:405
virtual PetscReal RBFVal(PetscInt dim, PetscReal x[], PetscReal y[])=0
PetscReal Interpolate(const ablate::domain::Field *field, PetscReal xEval[3])
Definition: rbf.hpp:131
virtual PetscReal RBFDer(PetscInt dim, PetscReal x[], PetscInt dx, PetscInt dy, PetscInt dz)=0
void SetupDerivativeStencils()
Definition: rbf.cpp:399