24#ifndef INDICATOR_BASE_F_3D_H
25#define INDICATOR_BASE_F_3D_H
66 virtual bool operator() (
bool output[1],
const S input[3]);
82 throw std::runtime_error(
"Indicator doesn't support random sampling");
98 _indicatorF(indicatorF),
100 _cacheCuboid(indicatorF.
getMin()[0], indicatorF.
getMin()[1], indicatorF.
getMin()[2], deltaR,
101 (int)((indicatorF.
getMax()[0] - indicatorF.
getMin()[0]) / deltaR + 1.5),
102 (int)((indicatorF.
getMax()[1] - indicatorF.
getMin()[1]) / deltaR + 1.5),
103 (int)((indicatorF.
getMax()[2] - indicatorF.
getMin()[2]) / deltaR + 1.5)),
104 _cacheBlock(_cacheCuboid.getExtent(), 0),
105 _cache(_cacheBlock.getNcells())
108 bool operator() (
bool output[1],
const S input[3])
override {
111 std::size_t iCell = _cacheBlock.
getCellId(latticeR);
112 if (_cache[iCell] == 0) {
114 _indicatorF(&result, input);
115 _cache[iCell] = result ? 1 : 2;
119 output[0] = _cache[iCell] == 1;
123 return _indicatorF(output, input);
127 bool save(std::string fileName) {
128 return _cache.
save(fileName);
130 bool load(std::string fileName) {
131 return _cache.
load(fileName);
135 return _indicatorF.
getMin();
138 return _indicatorF.
getMax();
156 return _indicatorF.
normal(
normal, origin, direction, iC);
159 return _indicatorF.
rotOnAxis(vec_rot, vec, axis, theta);
174 std::shared_ptr<IndicatorF3D<S>>
_f;
177 bool operator() (
bool output[1],
const S input[3]);
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
bool getLatticeR(Vector< T, 3 > physR, Vector< int, 3 > &latticeR, T eps=1e-5)
GenericF is a base class, that can represent continuous as well as discrete functions.
IndicatorF3D is an application from .
virtual bool operator()(bool output[1], const S input[3])
Returns true if input is inside the indicator.
virtual bool distance(S &distance, const Vector< S, 3 > &origin, S precision, const Vector< S, 3 > &direction)
virtual Vector< S, 3 > & getMax()
virtual Vector< S, 3 > & getMin()
virtual bool normal(Vector< S, 3 > &normal, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1)
returns true and the normal if there was one found for an given origin and direction
bool isInsideBox(Vector< S, 3 > point)
Returns true if point is inside a cube with corners _myMin and _myMax
virtual S signedDistance(const Vector< S, 3 > &input)
Returns signed distance to the nearest point on the indicator surface.
virtual Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize)
Return surface normal.
virtual Vector< S, 3 > getSample(const std::function< S()> &randomness) const
virtual bool rotOnAxis(Vector< S, 3 > &vec_rot, const Vector< S, 3 > &vec, const Vector< S, 3 > &axis, S &theta)
Rotate vector around axis by angle theta.
IndicatorIdentity3D(std::shared_ptr< IndicatorF3D< S > > f)
bool operator()(bool output[1], const S input[3])
Returns true if input is inside the indicator.
std::shared_ptr< IndicatorF3D< S > > _f
bool distance(S &distance, const S input[]) override
Vector< S, 3 > & getMin() override
bool distance(S &distance, const Vector< S, 3 > &origin) override
Vector< S, 3 > surfaceNormal(const Vector< S, 3 > &pos, const S meshSize) override
Return surface normal.
bool rotOnAxis(Vector< S, 3 > &vec_rot, const Vector< S, 3 > &vec, const Vector< S, 3 > &axis, S &theta) override
Rotate vector around axis by angle theta.
bool load(std::string fileName)
bool operator()(bool output[1], const S input[3]) override
Returns true if input is inside the indicator.
RegularCachedIndicatorF3D(IndicatorF3D< S > &indicatorF, S deltaR)
S signedDistance(const Vector< S, 3 > &input) override
Returns signed distance to the nearest point on the indicator surface.
bool save(std::string fileName)
bool distance(S &distance, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1) override
bool distance(S &distance, const Vector< S, 3 > &origin, S precision, const Vector< S, 3 > &direction) override
bool normal(Vector< S, 3 > &normal, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, int iC=-1) override
returns true and the normal if there was one found for an given origin and direction
bool distance(S &distance, const Vector< S, 3 > &origin, const Vector< S, 3 > &direction, S precision, S pitch) override
Vector< S, 3 > & getMax() override
bool save(std::string fileName="", const bool enforceUint=false)
Save Serializable into file fileName
bool load(std::string fileName="", const bool enforceUint=false)
Load Serializable from file fileName
Plain column for SISD CPU targets (default)
The description of a generic interface for all functor classes – header file.
Top level namespace for all of OpenLB.
efficient implementation of a vector class