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/utilities/hyperplaneLattice2D.h | 105 ++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/utilities/hyperplaneLattice2D.h (limited to 'src/utilities/hyperplaneLattice2D.h') diff --git a/src/utilities/hyperplaneLattice2D.h b/src/utilities/hyperplaneLattice2D.h new file mode 100644 index 0000000..9b8850d --- /dev/null +++ b/src/utilities/hyperplaneLattice2D.h @@ -0,0 +1,105 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2018 Adrian Kummerlaender + * 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 HYPERPLANE_LATTICE_2D_H +#define HYPERPLANE_LATTICE_2D_H + +#include "core/vector.h" +#include "geometry/cuboidGeometry2D.h" +#include "hyperplane2D.h" + +namespace olb { + +/// Parametrization of a hyperplane lattice (i.e. a line lattice). +/** + * This class provides a common interface for describing how to discretize the intersection + * of a hyperplane given by Hyperplane2D and the mother cuboid of CuboidGeometry2D. + **/ +template +class HyperplaneLattice2D { +private: + CuboidGeometry2D& _geometry; + + /// \return max possible distance + int computeMaxLatticeDistance() const; + /// Compute _hyperplane.origin, _n so that the cuboid is right inside the geometry + void constructCuboid(int maxLatticeDistance); + /// Update _h, _n _hyperplane.u so that the length matches the given resolution + void setToResolution(int resolution); + +protected: + const Hyperplane2D _hyperplane; + + /// Origin vector of the lattice + /** + * Note that this origin is set to a outermost point of the intersection between + * cuboid geometry and hyperplane. Thus it is different from the Hyperplane2D + * origin vector in the general case. + **/ + Vector _origin; + /// Direction vector of the lattice, normalized to grid width _h + Vector _u; + + /// Distance between discrete lattice points + T _h; + /// Number of lattice points in the direction of _u + int _n; + +public: + /// Constructor for automatic discretization. + /** + * i.e. the grid width is set to CuboidGeometry2D::getMinDeltaR. + **/ + HyperplaneLattice2D(CuboidGeometry2D& geometry, + Hyperplane2D hyperplane); + /// Constructor for discretization of a given resolution. + HyperplaneLattice2D(CuboidGeometry2D& geometry, + Hyperplane2D hyperplane, + int resolution); + /// Constructor for discretization of a given grid width. + HyperplaneLattice2D(CuboidGeometry2D& geometry, + Hyperplane2D hyperplane, + T h); + + HyperplaneLattice2D(const HyperplaneLattice2D&) = default; + + const Hyperplane2D& getHyperplane() const; + + /// Transform 1d lattice coordinates to their physical 2d location + Vector getPhysR(const int& n) const; + + /// \return _n + int getN() const; + /// \return _h + T getPhysSpacing() const; + + /// \return _origin + Vector getPhysOrigin() const; + /// \return _u + Vector getVectorU() const; + +}; + +} + +#endif -- cgit v1.2.3