From 94d3e79a8617f88dc0219cfdeedfa3147833719d Mon Sep 17 00:00:00 2001
From: Adrian Kummerlaender
Date: Mon, 24 Jun 2019 14:43:36 +0200
Subject: Initialize at openlb-1-3
---
src/functors/analytical/analyticalF.h | 353 ++++++++++++++++++++++++++++++++++
1 file changed, 353 insertions(+)
create mode 100644 src/functors/analytical/analyticalF.h
(limited to 'src/functors/analytical/analyticalF.h')
diff --git a/src/functors/analytical/analyticalF.h b/src/functors/analytical/analyticalF.h
new file mode 100644
index 0000000..0abd70f
--- /dev/null
+++ b/src/functors/analytical/analyticalF.h
@@ -0,0 +1,353 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2012 Lukas Baron, Tim Dornieden, 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 ANALYTICAL_F_H
+#define ANALYTICAL_F_H
+
+#include
+
+#include "analyticalBaseF.h"
+#include "indicator/smoothIndicatorF2D.h"
+#include "indicator/smoothIndicatorF3D.h"
+
+
+/**
+ * The functor dimensions are given by F: S^m -> T^n (S=source, T=target)
+ * and are implemented via GenericF(n,m).
+ * Don't get confused by the flipped order of source and target.
+ */
+
+namespace olb {
+
+template class SmoothIndicatorSphere3D;
+template class RadiativeUnitConverter;
+
+////////////////////////////////////////////////////////////////////////////////
+////////implementation of several 1d,2d,3d functors (analyticalFXD)/////////////
+////////////////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////1D////////////////////////////////////////////
+
+/// AnalyticalConst1D: 1D -> XD, where XD is defined by value.size()
+template
+class AnalyticalConst1D : public AnalyticalF1D {
+private:
+ // is constant return value of operator()
+ std::vector _c;
+public:
+ AnalyticalConst1D(T value);
+ AnalyticalConst1D(const std::vector& value);
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalLinear1D: 1D -> 1D troughout given points (x0,v0) and (x1,v1)
+// Punktsteigungsform
+template
+class AnalyticalLinear1D : public AnalyticalF1D {
+private:
+ T _a;
+ T _b;
+public:
+ AnalyticalLinear1D(T a, T b);
+ AnalyticalLinear1D(S x0, T v0, S x1, T v1);
+ bool operator() (T output[], const S x[]) override; ///< returns line _a*x + _b
+};
+
+/// AnalyticalRandom1D: 1D -> 1D with random image in (0,1)
+template
+class AnalyticalRandom1D : public AnalyticalF1D {
+public:
+ AnalyticalRandom1D();
+ bool operator() (T output[], const S x[]) override;
+};
+
+
+/// represents an inverse parabola profile like it is used in Poiseuille inflow
+/// note: output depends only on first parameter, maps 1D,2D,3D->1D
+template
+class AnalyticalSquare1D : public AnalyticalF1D {
+private:
+ S _cp;
+ S _r;
+ T _maxi;
+public:
+ AnalyticalSquare1D(S cp, S r, T maxi);
+ bool operator() (T output[], const S x[]) override;
+};
+
+
+/// SinusStartScale: 1D -> 1D a start curve based on sinus for a continuous transition at 0 and 1
+template
+class SinusStartScale : public AnalyticalF1D {
+protected:
+ S _numTimeSteps;
+ T _maxValue;
+ T _pi;
+public:
+ SinusStartScale(int numTimeSteps=1, T maxValue=1);
+ bool operator() (T output[], const S x[]) override;
+};
+
+
+/// PolynomialStartScale: 1D -> 1D a start curve based on a polynomial fifth order for a continuous transition at 0 and 1: maxValue*(6*y^5-15*y^4+10*y^3)
+template
+class PolynomialStartScale : public AnalyticalF1D {
+protected:
+ S _numTimeSteps;
+ T _maxValue;
+public:
+ PolynomialStartScale(S numTimeSteps=S(1), T maxValue=T(1));
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// Derivative of a given 1D functor computed with a finite difference
+template
+class AnalyticalDiffFD1D : public AnalyticalF1D {
+protected:
+ AnalyticalF1D& _f;
+ T _eps;
+public:
+ AnalyticalDiffFD1D(AnalyticalF1D& f, T eps = 1.e-10);
+ bool operator() (T output[], const T input[]) override;
+};
+
+//////////////////////////////////2D////////////////////////////////////////////
+
+template
+class AnalyticalComposed2D final : public AnalyticalF2D {
+private:
+ AnalyticalF2D& _f0;
+ AnalyticalF2D& _f1;
+public:
+ AnalyticalComposed2D(AnalyticalF2D& f0, AnalyticalF2D& f1);
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalConst2D: 2D -> XD, where XD is defined by value.size()
+template
+class AnalyticalConst2D final : public AnalyticalF2D {
+private:
+ // is constant return value of operator()
+ std::vector _c;
+public:
+ AnalyticalConst2D(T value);
+ AnalyticalConst2D(T value0, T value1);
+ AnalyticalConst2D(T value0, T value1, T value2);
+ AnalyticalConst2D(const std::vector& value);
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalLinear2D: 2D -> 1D troughout given points (x0,y0,v0), (x1,y1,v1), (x2,y2,v2)
+template
+class AnalyticalLinear2D final : public AnalyticalF2D {
+protected:
+ T _a;
+ T _b;
+ T _c;
+public:
+ AnalyticalLinear2D(T a, T b, T c);
+ AnalyticalLinear2D(S x0, S y0, T v0, S x1, S y1, T v1, S x2, S y2, T v2);
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalRandom2D: 2D -> 1D with random image in (0,1)
+template
+class AnalyticalRandom2D final : public AnalyticalF2D {
+public:
+ AnalyticalRandom2D();
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalRandom2D: 2D -> 1D with maxValue in the center decreasing linearly with the distrance to the center to zero at the radius and zero outside
+template
+class AnalyticalParticleAdsorptionLinear2D final : public AnalyticalF2D {
+protected:
+ T _center[2];
+ T _radius;
+ T _maxValue;
+public:
+ AnalyticalParticleAdsorptionLinear2D(T center[], T radius, T maxValue);
+ bool operator() (T output[], const S x[]);
+};
+
+/** Computes resulting velocity of an object from translational and rotational velocity.
+ * \param indicator Class defining the object (needs to be a SmoothIndicatorF2D)
+ * \param u translational velocity of the object - expected in lattice units
+ * \param omega rotational velocity of the object - expected in lattice units
+ */
+template
+class ParticleU2D : public AnalyticalF2D {
+protected:
+ SmoothIndicatorF2D& _indicator;
+ UnitConverter const& _converter;
+public:
+ ParticleU2D(SmoothIndicatorF2D& indicator, UnitConverter const& converter);
+ bool operator()(T output[], const S input[]);
+};
+
+
+//////////////////////////////////3D////////////////////////////////////////////
+template
+class AnalyticalComposed3D final : public AnalyticalF3D {
+private:
+ AnalyticalF3D& _f0;
+ AnalyticalF3D& _f1;
+ AnalyticalF3D& _f2;
+public:
+ AnalyticalComposed3D(AnalyticalF3D& f0, AnalyticalF3D& f1, AnalyticalF3D& f2);
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalConst3D: 3D -> XD, where XD is defined by value.size()
+template
+class AnalyticalConst3D final : public AnalyticalF3D {
+private:
+ // is constant return value of operator()
+ std::vector _c;
+public:
+ AnalyticalConst3D(T value);
+ AnalyticalConst3D(T value0, T value1);
+ AnalyticalConst3D(T value0, T value1, T value2);
+ AnalyticalConst3D(const std::vector& value);
+ AnalyticalConst3D(const Vector& value);
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalLinear3D: 3D -> 1D troughout given points (x0,y0,z0,v0), (x1,y1,z1,v1), (x2,y2,z2,v2), (x3,y3,z3,v3)
+template
+class AnalyticalLinear3D final : public AnalyticalF3D {
+protected:
+ T _a;
+ T _b;
+ T _c;
+ T _d;
+public:
+ AnalyticalLinear3D(T a, T b, T c, T d);
+ AnalyticalLinear3D(S x0, S y0, S z0, T v0, S x1, S y1, S z1, T v1, S x2, S y2,
+ S z2, T v2, S x3, S y3, S z3, T v3);
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalRandom3D: 3D -> 1D with random image in (0,1)
+template
+class AnalyticalRandom3D final : public AnalyticalF3D {
+public:
+ AnalyticalRandom3D();
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// AnalyticalScaled3D: 3D -> Image(AnalyticalF) scales AnalyticalF by _scale
+template
+class AnalyticalScaled3D final : public AnalyticalF3D {
+private:
+ AnalyticalF3D& _f;
+ T _scale;
+public:
+ AnalyticalScaled3D(AnalyticalF3D& f, T scale);
+ bool operator() (T output[], const S x[]) override;
+};
+
+/// see Mink et al. 2016 in Sec.3.1.
+template
+class PLSsolution3D : public AnalyticalF3D {
+private:
+ T _physSigmaEff;
+ T _physDiffusionCoefficient;
+public:
+ PLSsolution3D(RadiativeUnitConverter const& converter);
+ bool operator()(T output[1], const S x[3]) override;
+};
+
+/// light source as a cylinder along z-axis
+template
+class LightSourceCylindrical3D : public AnalyticalF3D {
+private:
+ T _physSigmaEff;
+ T _physDiffusionCoefficient;
+ Vector _center;
+public:
+ LightSourceCylindrical3D(RadiativeUnitConverter const& converter, Vector center = {T(0), T(0), T(0)});
+ bool operator()(T output[1], const S x[3]) override;
+};
+
+/**
+* \param _position of light source
+* \param _orientation direction of light source (normalized)
+* \param _falloff is power of the cosine
+*/
+template
+class Spotlight : public AnalyticalF3D {
+private:
+ Vector const _position;
+ Vector const _orientation;
+ T const _falloff;
+public:
+ Spotlight(Vector position, Vector direction, T falloff);
+ bool operator()(T output[1], const S x[3]) override;
+};
+
+/// 8.6.1 Gauss Hill inital values
+template
+class GaussianHill2D : public AnalyticalF2D {
+private:
+ T _sigma;
+ Vector _x0;
+ T _c0;
+public:
+ GaussianHill2D(T sigma, Vector x0, T c0);
+ bool operator()(T output[1], const S x[2]) override;
+};
+
+/// 8.6.1 Gauss Hill time evolution
+template
+class GaussianHillTimeEvolution2D : public AnalyticalF2D {
+private:
+ T _sigma02;
+ T _D;
+ T _t;
+ Vector _x0;
+ Vector _u;
+ T _c0;
+public:
+ GaussianHillTimeEvolution2D(T sigma0, T D, T t, Vector x0, Vector u, T c0);
+ bool operator()(T output[1], const S x[2]) override;
+};
+
+/** Computes resulting velocity of an object from translational and rotational velocity.
+ * \param indicator Class defining the object (needs to be a SmoothIndicatorF3D)
+ * \param u translational velocity of the object - expected in lattice units
+ * \param omega rotational velocity of the object - expected in lattice units
+ */
+template
+class ParticleU3D : public AnalyticalF3D {
+protected:
+ SmoothIndicatorF3D& _indicator;
+ UnitConverter const& _converter;
+public:
+ ParticleU3D(SmoothIndicatorF3D& indicator, UnitConverter const& converter);
+ bool operator()(T output[], const S input[]);
+};
+
+} // end namespace olb
+#endif
--
cgit v1.2.3