/* This file is part of the OpenLB library
*
* Copyright (C) 2014-2016 Cyril Masquelier, Mathias J. Krause, Albert Mink
* E-mail contact: info@openlb.net
* The most recent release of OpenLB can be downloaded at
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef INDICATOR_F_3D_H
#define INDICATOR_F_3D_H
#include
#include "indicatorBaseF3D.h"
#include "io/xmlReader.h"
/** \file
* This file contains indicator functions. These return 1 if the given
* coordinates are inside, and 0 if they are outside of the defined set.
* Implemented are :
- Sphere
- Cylinder
- Cone
- Pipe (not yet)
- Cube (not yet)
- Cuboid
- Circle
* The smoothIndicator functors return values in [0,1]. In particular there is
* an epsilon enclosure of the set, wherein the return values are smooth and do
* not jump from 0 to 1.
Boolean operators allow to create unions and intersections. They can be used
for example for initialization of a SuperGeometry.
*/
namespace olb {
template
class IndicatorTranslate3D : public IndicatorF3D {
private:
std::array _translate;
IndicatorF3D& _indicator;
public:
IndicatorTranslate3D(std::array translate, IndicatorF3D& indicator);
bool operator() (bool output[], const S input[]) override;
};
/// indicator function for a 3D circle
template
class IndicatorCircle3D : public IndicatorF3D {
private:
Vector _center;
Vector _normal;
S _radius2;
public:
IndicatorCircle3D(Vector center, Vector normal, S radius);
IndicatorCircle3D(S center0, S center1, S center2, S normal0, S normal1,
S normal2, S radius);
bool operator() (bool output[], const S input[]) override;
Vector const& getCenter() const;
Vector const& getNormal() const;
S getRadius() const;
//virtual bool distance(S& distance, Vector origin, Vector direction, int iC=-1);
};
/// indicator function for a 3D-sphere
template
class IndicatorSphere3D : public IndicatorF3D {
private:
Vector _center;
S _radius2;
public:
IndicatorSphere3D(Vector center, S radius);
IndicatorSphere3D(const IndicatorSphere3D&);
bool operator() (bool output[], const S input[]) override;
bool distance(S& distance, const Vector& origin,
const Vector& direction, int iC=-1) override;
bool distance(S& distance, const Vector& origin);
};
/// indicator function for a layer
template
class IndicatorLayer3D : public IndicatorF3D {
private:
IndicatorF3D& _indicatorF;
S _layerSize;
public:
IndicatorLayer3D(IndicatorF3D& indicatorF, S layerSize);
bool operator() (bool output[], const S input[]) override;
};
/// indicator function for the internal part of an input indicator
template
class IndicatorInternal3D : public IndicatorF3D {
private:
IndicatorF3D& _indicatorF;
S _layerSize;
public:
IndicatorInternal3D(IndicatorF3D& indicatorF, S layerSize);
bool operator() (bool output[], const S input[]) override;
};
/// indicator function for a 3d-cylinder
template
class IndicatorCylinder3D : public IndicatorF3D {
private:
Vector _center1;
Vector _center2;
Vector _I;
Vector _J;
Vector _K;
S _length;
S _radius2;
void init();
public:
IndicatorCylinder3D(Vector center1, Vector center2, S radius);
// eps is length of cylinder
IndicatorCylinder3D(Vector center1, Vector normal, S radius, S eps);
IndicatorCylinder3D(IndicatorCircle3D const& circleF, S eps);
bool operator() (bool output[], const S input[]) override;
Vector const& getCenter1() const;
Vector const& getCenter2() const;
S getRadius() const;
};
/// indicator function for a 3d frustum
template
class IndicatorCone3D : public IndicatorF3D {
private:
Vector _center1;
Vector _center2;
Vector _I;
Vector _J;
Vector _K;
S _length;
S _radius1;
S _radius2; // The 2nd radius is optional: if not defined, _center2 is the vertex of the cone
public:
IndicatorCone3D(Vector center1, Vector center2, S radius1, S radius2=0);
bool operator() (bool output[], const S input[]) override;
};
/** indicator function for a 3d-cuboid, parallel to the planes x=0, y=0, z=0.
* \param extend must have only positive elements
* \param xLength must be positive
*/
template
class IndicatorCuboid3D : public IndicatorF3D {
private:
const Vector _center;
const S _xLength;
const S _yLength;
const S _zLength;
public:
/// constructs an cuboid with x axis dimension 0 to extend[0], ...
IndicatorCuboid3D(Vector extend, Vector origin);
/// constructs an cuboid with x axis dimension -xlength/2 to xlength/2
IndicatorCuboid3D(S xlength, S ylength, S zlength, Vector center);
/// returns true if input is inside, otherwise false
bool operator() (bool output[], const S input[]) override;
};
/** \brief indicator function for a 3d-cuboid, turned by an angle theta around an axis of rotation
*
* The cuboid is turned along the axis going through the point "centerRotation" and being orthogonal to either x=0 or y=0 or z=0 respectively
* \param theta angle (rad) by which the cuboid is turned
* \param plane the axis of rotation is orthogonal to the plane i=0, where 0 corresponds to the plane x=0, 1 to the plane y=0, and 2 to z=0
* \param centerRotation vector of coordinates which defines, with "plane", the axis of rotation; centerRotation is a point on th axis of rotation
*
*/
template
class IndicatorCuboidRotate3D : public IndicatorCuboid3D {
private:
S _theta;
int _plane;
Vector _centerRotation;
public:
// constructs an cuboid turned by some angle theta around a given center of rotation
IndicatorCuboidRotate3D(Vector extend, Vector origin, S theta, int plane, Vector centerRotation);
IndicatorCuboidRotate3D(S xlength, S ylength, S zlength, Vector origin, S theta, int plane, Vector centerRotation);
bool operator() (bool output[], const S input[]);
};
/////////creatorFunctions//////////////////////
// creator function for geometric primitives
template
std::shared_ptr> createIndicatorCircle3D(XMLreader const& params, bool verbose=false);
template
std::shared_ptr> createIndicatorSphere3D(XMLreader const& params, bool verbose=false);
template
std::shared_ptr> createIndicatorCylinder3D(XMLreader const& params, bool verbose=false);
template
std::shared_ptr> createIndicatorCone3D(XMLreader const& params, bool verbose=false);
template
std::shared_ptr> createIndicatorCuboid3D(XMLreader const& params, bool verbose=false);
// arithmetic creator functions
template
std::shared_ptr> createIndicatorUnion3D(XMLreader const& params, bool verbose=false);
template
std::shared_ptr> createIndicatorWithout3D(XMLreader const& params, bool verbose=false);
template
std::shared_ptr> createIndicatorIntersection3D(XMLreader const¶ms, bool verbose=false);
// godfather
template
std::shared_ptr> createIndicatorF3D(XMLreader const& params, bool verbose=false);
}
#endif