/* This file is part of the OpenLB library
*
* Copyright (C) 2016 Thomas Henn, Cyril Masquelier, Jan Marquardt, Mathias J. Krause,
* Davide Dapelo
* 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_2D_H
#define INDICATOR_F_2D_H
#include
#include "indicatorBaseF2D.h"
#include "io/xmlReader.h"
#include "core/blockData2D.h"
#include "core/unitConverter.h"
#include "indicatorBaseF3D.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 :
- 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 {
/// indicator function for a 2D-cuboid, parallel to the planes x=0, y=0;
/// theta rotates cuboid around its center, theta in radian measure
template
class IndicatorF2DfromIndicatorF3D : public IndicatorF2D {
private:
IndicatorF3D& _indicator3D;
public:
IndicatorF2DfromIndicatorF3D(IndicatorF3D& indicator3D);
bool operator() (bool output[], const S input[]) override;
};
/// indicator function for a 2D-cuboid, parallel to the planes x=0, y=0;
/// theta rotates cuboid around its center, theta in radian measure
template
class IndicatorCuboid2D : public IndicatorF2D {
private:
Vector _center;
S _xLength;
S _yLength;
S _theta;
public:
/// constructs an cuboid with x axis dimension 0 to extend[0], ...
IndicatorCuboid2D(Vector extend, Vector origin, S theta=0);
/// constructs an cuboid with x axis dimension -xlength/2 to xlength/2
IndicatorCuboid2D(S xlength, S ylength, Vector center= {S(), S()}, S theta=0);
/// returns true if input is inside, otherwise false
bool operator() (bool output[], const S input[]) override;
};
/// indicator function for a 2D circle
template
class IndicatorCircle2D : public IndicatorF2D {
private:
Vector _center;
S _radius2;
public:
IndicatorCircle2D(Vector center, S radius);
bool operator() (bool output[], const S input[]) override;
bool distance(S& distance, const Vector& origin, const Vector& direction, int iC=-1) override;
bool normal(Vector& normal, const Vector& origin, const Vector& direction, int iC=-1) override;
};
/// Indicator function creating an layer around an input indicator (for positive \p layerSize) or
/// reducing the input indicator by a layer (for negative \p layerSize).
/// \param[in] indicatorF - some indicator (e.g. IndicatorCircle2D)
/// \param[in] layerSize - size of the layer (can be negative) [physical units]
template
class IndicatorLayer2D : public IndicatorF2D {
private:
IndicatorF2D& _indicatorF;
S _layerSize;
bool _isPositive;
public:
IndicatorLayer2D(IndicatorF2D& indicatorF, S layerSize);
bool operator() (bool output[], const S input[]) override;
};
/////////creatorFunctions//////////////////////
template
IndicatorCuboid2D* createIndicatorCuboid2D(XMLreader const& params, bool verbose=false);
template
IndicatorCircle2D* createIndicatorCircle2D(XMLreader const& params, bool verbose=false);
}
#endif