3#include <hrleVectorType.hpp>
6#include <vcVectorUtil.hpp>
10using namespace viennacore;
23 virtual bool isInside(
const Vec3D<hrleCoordType> &initial,
24 const Vec3D<hrleCoordType> &candidate,
25 double eps = 0.)
const {
33 const Vec3D<hrleCoordType> &candidate,
34 unsigned long initialPointId)
const = 0;
37 virtual std::array<hrleCoordType, 6>
getBounds()
const = 0;
44template <
class T,
int D>
54 bool isInside(
const Vec3D<hrleCoordType> &initial,
55 const Vec3D<hrleCoordType> &candidate,
56 double eps = 0.)
const override {
57 hrleCoordType dot = 0.;
58 for (
unsigned i = 0; i <
D; ++i) {
59 double tmp = candidate[i] - initial[i];
63 if (std::sqrt(dot) <= std::abs(
radius) + eps)
70 const Vec3D<hrleCoordType> &candidate,
71 unsigned long )
const override {
72 T distance = std::numeric_limits<T>::max();
73 Vec3D<hrleCoordType> v{};
74 for (
unsigned i = 0; i <
D; ++i) {
75 v[i] = candidate[i] - initial[i];
80 std::max(std::max(std::abs(v[0]), std::abs(v[1])), std::abs(v[2])) -
83 for (
unsigned i = 0; i <
D; ++i) {
84 T y = (v[(i + 1) %
D]);
91 T dirRadius = std::abs(v[i]) - std::sqrt(x);
92 if (std::abs(dirRadius) < std::abs(distance))
104 std::array<hrleCoordType, 6>
getBounds()
const override {
105 std::array<hrleCoordType, 6> bounds = {};
106 for (
unsigned i = 0; i <
D; ++i) {
108 bounds[2 * i + 1] =
radius;
116template <
class T,
int D>
124 for (
unsigned i = 0; i <
D; ++i) {
126 Logger::getInstance()
127 .addWarning(
"One half-axis of BoxDistribution is smaller than "
128 "the grid Delta! This can lead to numerical errors "
129 "breaking the distribution!")
136 const Vec3D<hrleCoordType> &candidate,
137 double eps = 0.)
const override {
138 for (
unsigned i = 0; i <
D; ++i) {
139 if (std::abs(candidate[i] - initial[i]) >
148 const Vec3D<hrleCoordType> &candidate,
149 unsigned long )
const override {
150 T distance = std::numeric_limits<T>::lowest();
151 for (
unsigned i = 0; i <
D; ++i) {
152 T vector = std::abs(candidate[i] - initial[i]);
153 distance = std::max(vector - std::abs(
posExtent[i]), distance);
155 return (
posExtent[0] < 0) ? -distance : distance;
158 std::array<hrleCoordType, 6>
getBounds()
const override {
159 std::array<hrleCoordType, 6> bounds = {};
160 for (
unsigned i = 0; i <
D; ++i) {
Concrete implementation of GeometricAdvectDistribution for a rectangular box distribution.
Definition lsGeometricAdvectDistributions.hpp:117
const T gridDelta
Definition lsGeometricAdvectDistributions.hpp:120
T getSignedDistance(const Vec3D< hrleCoordType > &initial, const Vec3D< hrleCoordType > &candidate, unsigned long) const override
Returns the signed distance of a point relative to the distributions center. This is the signed manha...
Definition lsGeometricAdvectDistributions.hpp:147
std::array< hrleCoordType, 6 > getBounds() const override
Sets bounds to the bounding box of the distribution.
Definition lsGeometricAdvectDistributions.hpp:158
bool isInside(const Vec3D< hrleCoordType > &initial, const Vec3D< hrleCoordType > &candidate, double eps=0.) const override
Quick check whether a point relative to the distributions center is inside the distribution....
Definition lsGeometricAdvectDistributions.hpp:135
const hrleVectorType< T, 3 > posExtent
Definition lsGeometricAdvectDistributions.hpp:119
BoxDistribution(const std::array< T, 3 > &halfAxes, const T delta)
Definition lsGeometricAdvectDistributions.hpp:122
Base class for distributions used by lsGeometricAdvect. All functions are pure virtual and must be im...
Definition lsGeometricAdvectDistributions.hpp:15
virtual T getSignedDistance(const Vec3D< hrleCoordType > &initial, const Vec3D< hrleCoordType > &candidate, unsigned long initialPointId) const =0
Returns the signed distance of a point relative to the distributions center. This is the signed manha...
GeometricAdvectDistribution()
Definition lsGeometricAdvectDistributions.hpp:17
virtual ~GeometricAdvectDistribution()
Definition lsGeometricAdvectDistributions.hpp:39
virtual bool isInside(const Vec3D< hrleCoordType > &initial, const Vec3D< hrleCoordType > &candidate, double eps=0.) const
Quick check whether a point relative to the distributions center is inside the distribution....
Definition lsGeometricAdvectDistributions.hpp:23
virtual std::array< hrleCoordType, 6 > getBounds() const =0
Sets bounds to the bounding box of the distribution.
Concrete implementation of GeometricAdvectDistribution for a spherical advection distribution.
Definition lsGeometricAdvectDistributions.hpp:45
const T gridDelta
Definition lsGeometricAdvectDistributions.hpp:49
bool isInside(const Vec3D< hrleCoordType > &initial, const Vec3D< hrleCoordType > &candidate, double eps=0.) const override
Quick check whether a point relative to the distributions center is inside the distribution....
Definition lsGeometricAdvectDistributions.hpp:54
T getSignedDistance(const Vec3D< hrleCoordType > &initial, const Vec3D< hrleCoordType > &candidate, unsigned long) const override
Returns the signed distance of a point relative to the distributions center. This is the signed manha...
Definition lsGeometricAdvectDistributions.hpp:69
std::array< hrleCoordType, 6 > getBounds() const override
Sets bounds to the bounding box of the distribution.
Definition lsGeometricAdvectDistributions.hpp:104
const T radius2
Definition lsGeometricAdvectDistributions.hpp:48
const T radius
Definition lsGeometricAdvectDistributions.hpp:47
SphereDistribution(const T passedRadius, const T delta)
Definition lsGeometricAdvectDistributions.hpp:51
Definition lsAdvect.hpp:46
constexpr int D
Definition pyWrap.cpp:65
double T
Definition pyWrap.cpp:63