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/geometry/MakeHeader | 41 +
src/geometry/blockGeometry2D.cpp | 38 +
src/geometry/blockGeometry2D.h | 121 +++
src/geometry/blockGeometry2D.hh | 288 ++++++
src/geometry/blockGeometry3D.cpp | 36 +
src/geometry/blockGeometry3D.h | 127 +++
src/geometry/blockGeometry3D.hh | 331 +++++++
src/geometry/blockGeometryStatistics2D.cpp | 34 +
src/geometry/blockGeometryStatistics2D.h | 142 +++
src/geometry/blockGeometryStatistics2D.hh | 517 ++++++++++
src/geometry/blockGeometryStatistics3D.cpp | 34 +
src/geometry/blockGeometryStatistics3D.h | 150 +++
src/geometry/blockGeometryStatistics3D.hh | 1471 ++++++++++++++++++++++++++++
src/geometry/blockGeometryStructure2D.cpp | 40 +
src/geometry/blockGeometryStructure2D.h | 171 ++++
src/geometry/blockGeometryStructure2D.hh | 534 ++++++++++
src/geometry/blockGeometryStructure3D.cpp | 35 +
src/geometry/blockGeometryStructure3D.h | 168 ++++
src/geometry/blockGeometryStructure3D.hh | 783 +++++++++++++++
src/geometry/blockGeometryView2D.cpp | 35 +
src/geometry/blockGeometryView2D.h | 109 +++
src/geometry/blockGeometryView2D.hh | 171 ++++
src/geometry/blockGeometryView3D.cpp | 35 +
src/geometry/blockGeometryView3D.h | 113 +++
src/geometry/blockGeometryView3D.hh | 185 ++++
src/geometry/cuboid2D.cpp | 35 +
src/geometry/cuboid2D.h | 166 ++++
src/geometry/cuboid2D.hh | 425 ++++++++
src/geometry/cuboid3D.cpp | 35 +
src/geometry/cuboid3D.h | 175 ++++
src/geometry/cuboid3D.hh | 758 ++++++++++++++
src/geometry/cuboidGeometry2D.cpp | 35 +
src/geometry/cuboidGeometry2D.h | 165 ++++
src/geometry/cuboidGeometry2D.hh | 677 +++++++++++++
src/geometry/cuboidGeometry3D.cpp | 35 +
src/geometry/cuboidGeometry3D.h | 273 ++++++
src/geometry/cuboidGeometry3D.hh | 1233 +++++++++++++++++++++++
src/geometry/geometry2D.h | 38 +
src/geometry/geometry2D.hh | 38 +
src/geometry/geometry3D.h | 38 +
src/geometry/geometry3D.hh | 40 +
src/geometry/module.mk | 27 +
src/geometry/superGeometry2D.cpp | 37 +
src/geometry/superGeometry2D.h | 198 ++++
src/geometry/superGeometry2D.hh | 504 ++++++++++
src/geometry/superGeometry3D.cpp | 37 +
src/geometry/superGeometry3D.h | 203 ++++
src/geometry/superGeometry3D.hh | 557 +++++++++++
src/geometry/superGeometryStatistics2D.cpp | 34 +
src/geometry/superGeometryStatistics2D.h | 128 +++
src/geometry/superGeometryStatistics2D.hh | 392 ++++++++
src/geometry/superGeometryStatistics3D.cpp | 34 +
src/geometry/superGeometryStatistics3D.h | 140 +++
src/geometry/superGeometryStatistics3D.hh | 467 +++++++++
54 files changed, 12633 insertions(+)
create mode 100644 src/geometry/MakeHeader
create mode 100644 src/geometry/blockGeometry2D.cpp
create mode 100644 src/geometry/blockGeometry2D.h
create mode 100644 src/geometry/blockGeometry2D.hh
create mode 100644 src/geometry/blockGeometry3D.cpp
create mode 100644 src/geometry/blockGeometry3D.h
create mode 100644 src/geometry/blockGeometry3D.hh
create mode 100644 src/geometry/blockGeometryStatistics2D.cpp
create mode 100644 src/geometry/blockGeometryStatistics2D.h
create mode 100644 src/geometry/blockGeometryStatistics2D.hh
create mode 100644 src/geometry/blockGeometryStatistics3D.cpp
create mode 100644 src/geometry/blockGeometryStatistics3D.h
create mode 100644 src/geometry/blockGeometryStatistics3D.hh
create mode 100644 src/geometry/blockGeometryStructure2D.cpp
create mode 100644 src/geometry/blockGeometryStructure2D.h
create mode 100644 src/geometry/blockGeometryStructure2D.hh
create mode 100644 src/geometry/blockGeometryStructure3D.cpp
create mode 100644 src/geometry/blockGeometryStructure3D.h
create mode 100644 src/geometry/blockGeometryStructure3D.hh
create mode 100644 src/geometry/blockGeometryView2D.cpp
create mode 100644 src/geometry/blockGeometryView2D.h
create mode 100644 src/geometry/blockGeometryView2D.hh
create mode 100644 src/geometry/blockGeometryView3D.cpp
create mode 100644 src/geometry/blockGeometryView3D.h
create mode 100644 src/geometry/blockGeometryView3D.hh
create mode 100644 src/geometry/cuboid2D.cpp
create mode 100644 src/geometry/cuboid2D.h
create mode 100644 src/geometry/cuboid2D.hh
create mode 100644 src/geometry/cuboid3D.cpp
create mode 100644 src/geometry/cuboid3D.h
create mode 100644 src/geometry/cuboid3D.hh
create mode 100644 src/geometry/cuboidGeometry2D.cpp
create mode 100644 src/geometry/cuboidGeometry2D.h
create mode 100644 src/geometry/cuboidGeometry2D.hh
create mode 100644 src/geometry/cuboidGeometry3D.cpp
create mode 100644 src/geometry/cuboidGeometry3D.h
create mode 100644 src/geometry/cuboidGeometry3D.hh
create mode 100644 src/geometry/geometry2D.h
create mode 100644 src/geometry/geometry2D.hh
create mode 100644 src/geometry/geometry3D.h
create mode 100644 src/geometry/geometry3D.hh
create mode 100644 src/geometry/module.mk
create mode 100644 src/geometry/superGeometry2D.cpp
create mode 100644 src/geometry/superGeometry2D.h
create mode 100644 src/geometry/superGeometry2D.hh
create mode 100644 src/geometry/superGeometry3D.cpp
create mode 100644 src/geometry/superGeometry3D.h
create mode 100644 src/geometry/superGeometry3D.hh
create mode 100644 src/geometry/superGeometryStatistics2D.cpp
create mode 100644 src/geometry/superGeometryStatistics2D.h
create mode 100644 src/geometry/superGeometryStatistics2D.hh
create mode 100644 src/geometry/superGeometryStatistics3D.cpp
create mode 100644 src/geometry/superGeometryStatistics3D.h
create mode 100644 src/geometry/superGeometryStatistics3D.hh
(limited to 'src/geometry')
diff --git a/src/geometry/MakeHeader b/src/geometry/MakeHeader
new file mode 100644
index 0000000..25442ca
--- /dev/null
+++ b/src/geometry/MakeHeader
@@ -0,0 +1,41 @@
+# This file is part of the OpenLB library
+#
+# Copyright (C) 2007 Mathias J. Krause
+# 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.
+
+
+generic :=
+
+precompiled := blockGeometry2D \
+ blockGeometry3D \
+ blockGeometryStatistics2D \
+ blockGeometryStatistics3D \
+ blockGeometryStructure2D \
+ blockGeometryStructure3D \
+ blockGeometryView2D \
+ blockGeometryView3D \
+ cuboid2D \
+ cuboid3D \
+ cuboidGeometry2D \
+ cuboidGeometry3D \
+ superGeometry2D \
+ superGeometry3D \
+ superGeometryStatistics2D \
+ superGeometryStatistics3D
diff --git a/src/geometry/blockGeometry2D.cpp b/src/geometry/blockGeometry2D.cpp
new file mode 100644
index 0000000..7bcadf3
--- /dev/null
+++ b/src/geometry/blockGeometry2D.cpp
@@ -0,0 +1,38 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2011 Mathias J. Krause, Simon Zimny
+ * 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.
+ */
+
+/** \file
+ * Representation of the 2D block geometry -- template instantiation.
+ */
+
+#include "dynamics/latticeDescriptors.h"
+
+#include "blockGeometry2D.h"
+#include "blockGeometry2D.hh"
+
+namespace olb {
+
+template class BlockGeometry2D;
+
+}
+
diff --git a/src/geometry/blockGeometry2D.h b/src/geometry/blockGeometry2D.h
new file mode 100644
index 0000000..fd94523
--- /dev/null
+++ b/src/geometry/blockGeometry2D.h
@@ -0,0 +1,121 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Mathias J. Krause
+ * 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.
+ */
+
+/** \file
+ * Representation of the 2D block geometry view -- header file.
+ */
+
+#ifndef BLOCK_GEOMETRY_2D_H
+#define BLOCK_GEOMETRY_2D_H
+
+#include
+#include
+#include "core/blockData2D.h"
+#include "geometry/blockGeometryStatistics2D.h"
+#include "geometry/blockGeometryStructure2D.h"
+#include "geometry/cuboid2D.h"
+
+/// All OpenLB code is contained in this namespace.
+namespace olb {
+
+/// Representation of a block geometry
+/** This class is derived from block geometry structure. It
+ * holds the actual data with the materials. It stores pointers
+ * to all dependent block geometry views.
+ * It presents a volume of voxels where different types are
+ * given my material numbers which is imporant e.g. to work
+ * with different boundaries (like for inflow/output regions).
+ *
+ */
+template
+class BlockGeometry2D final : public BlockData2D, public BlockGeometryStructure2D {
+
+private:
+ /// Cuboid which charaterizes the block geometry
+ Cuboid2D _cuboid;
+ /// List to all depending statistic status objects
+ std::list _statisticsUpdateNeeded;
+
+public:
+ /// Constructor
+ BlockGeometry2D(T x0, T y0, T h, int nX, int nY, int iCglob=-1);
+ /// Constructor
+ BlockGeometry2D(Cuboid2D& cuboid, int iCglob=-1);
+ /// Copy constructor
+ BlockGeometry2D(BlockGeometry2D const& rhs);
+ /// Copy assignment
+ BlockGeometry2D& operator=(BlockGeometry2D const& rhs);
+
+ /// Returns the underlying block structure
+ BlockStructure2D& getBlockStructure() override;
+
+ /// Write access to the associated block statistic
+ BlockGeometryStatistics2D& getStatistics(bool verbose=true) override;
+ /// Read only access to the associated block statistic
+ BlockGeometryStatistics2D const& getStatistics(bool verbose=true) const override;
+
+ /// Read only access to the origin position given in SI units (meter)
+ Vector getOrigin() const override;
+ /// Read only access to the voxel size given in SI units (meter)
+ const T getDeltaR() const override;
+ /// Returns the extend (number of voxels) in X-direction
+ int getNx() const override;
+ /// Returns the extend (number of voxels) in Y-direction
+ int getNy() const override;
+
+ /// Write access to a material number
+ int& get(int iX, int iY) override; // override BlockGeometryStructure2D::get() by linking to BlockData2D::get()
+ /// Read only access to a material number
+ int const& get(int iX, int iY) const override; // override BlockGeometryStructure2D::get() by linking to BlockData2D::get()
+ /// returns the (iX,iY) entry in the 2D scalar field
+ int getMaterial(int iX, int iY) const override; // TODO old
+
+ /// Transforms lattice to physical coordinates (wrapped from cuboid geometry)
+ void getPhysR(T physR[2], const int& iX, const int& iY) const override;
+
+ // returns the raw data field
+ // olb::ScalarField2D* getRawData();
+ // void resize(int X, int Y, int Z, int nX, int nY, int nZ);
+ // refine Mesh
+ // void refineMesh(int level = 2);
+
+ /// Adds a pointer to the list of dependent statistic classes
+ void addToStatisticsList(bool* statisticStatus) override;
+ /// Removes a pointer from the list of dependent statistic classes if existing
+ void removeFromStatisticsList(bool* statisticStatus) override;
+
+ /// Prints a chosen part of the block geometry
+ void printLayer(int x0, int x1, int y0, int y1, bool linenumber = false);
+ /// Prints a chosen part of the block geometry
+ void printLayer(int direction, int layer, bool linenumber = false);
+ /// Prints a chosen node and its neighbourhood
+ void printNode(int x0, int y0);
+
+private:
+ /// Resets all depending statistic flags
+ void resetStatistics();
+};
+
+} // namespace olb
+
+#endif
diff --git a/src/geometry/blockGeometry2D.hh b/src/geometry/blockGeometry2D.hh
new file mode 100644
index 0000000..9b46cdd
--- /dev/null
+++ b/src/geometry/blockGeometry2D.hh
@@ -0,0 +1,288 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2011, 2014 Mathias J. Krause, Simon Zimny
+ * 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.
+ */
+
+/** \file
+ * Representation of the 2D block geometry -- generic implementation.
+ */
+
+#ifndef BLOCK_GEOMETRY_2D_HH
+#define BLOCK_GEOMETRY_2D_HH
+
+
+#include "geometry/blockGeometry2D.h"
+
+namespace olb {
+
+template
+BlockGeometry2D::BlockGeometry2D(T x0, T y0, T h, int nX, int nY, int iCglob)
+ : BlockData2D(nX,nY), BlockGeometryStructure2D(iCglob), _cuboid(x0, y0, h, nX, nY)
+{
+ this->_statistics = BlockGeometryStatistics2D(this);
+ addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
+}
+
+template
+BlockGeometry2D::BlockGeometry2D(Cuboid2D& cuboid, int iCglob)
+ : BlockData2D(cuboid.getNx(),cuboid.getNy()), BlockGeometryStructure2D(iCglob),
+ _cuboid(cuboid)
+{
+ this->_statistics = BlockGeometryStatistics2D(this);
+ addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
+}
+
+template
+BlockGeometry2D::BlockGeometry2D(BlockGeometry2D const& rhs)
+ : BlockData2D(rhs.getNx(), rhs.getNy()), BlockGeometryStructure2D(rhs._iCglob),
+ _cuboid(rhs._cuboid)
+{
+ this->_statistics = BlockGeometryStatistics2D(this);
+ addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
+}
+
+template
+BlockGeometry2D& BlockGeometry2D::operator=(BlockGeometry2D const& rhs)
+{
+ this->_nx = rhs._nx;
+ this->_ny = rhs._ny;
+ this->_iCglob = rhs._iCglob;
+ _cuboid = rhs._cuboid;
+ this->_statistics = BlockGeometryStatistics2D(this);
+ addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
+ return *this;
+}
+
+template
+BlockStructure2D& BlockGeometry2D::getBlockStructure()
+{
+ return *this;
+}
+
+template
+BlockGeometryStatistics2D& BlockGeometry2D::getStatistics(bool verbose)
+{
+ return this->_statistics;
+}
+
+template
+BlockGeometryStatistics2D const& BlockGeometry2D::getStatistics(bool verbose) const
+{
+ return this->_statistics;
+}
+
+template
+Vector BlockGeometry2D::getOrigin() const
+{
+ return _cuboid.getOrigin();
+}
+
+template
+const T BlockGeometry2D::getDeltaR() const
+{
+ return _cuboid.getDeltaR();
+}
+
+template
+int BlockGeometry2D::getNx() const
+{
+ return _cuboid.getNx();
+}
+
+template
+int BlockGeometry2D::getNy() const
+{
+ return _cuboid.getNy();
+}
+
+
+template
+int& BlockGeometry2D::get(int iX, int iY)
+{
+ resetStatistics();
+ return BlockData2D::get(iX,iY);
+}
+
+template
+int const& BlockGeometry2D::get(int iX, int iY) const
+{
+ return BlockData2D::get(iX,iY);
+}
+
+template
+int BlockGeometry2D::getMaterial(int iX, int iY) const
+{
+ int material;
+ if (iX < 0 || iX + 1 > getNx() || iY < 0 || iY + 1 > getNy() ) {
+ material = 0;
+ } else {
+ material = BlockData2D::get(iX,iY);
+ }
+ return material;
+}
+
+template
+void BlockGeometry2D::getPhysR(T physR[2], const int& iX, const int& iY) const
+{
+ _cuboid.getPhysR(physR, iX, iY);
+ return;
+}
+
+///TODO up, DONE down
+/*
+template
+olb::ScalarField3D* BlockGeometry3D::getRawData() {
+ return &_geometryData;
+}*/
+/*
+template
+void BlockGeometry3D::resize(int X, int Y, int Z, int nX, int nY, int nZ) {
+ olb::ScalarField3D geometryDataTemp(nX, nY, nZ);
+ geometryDataTemp.construct();
+ geometryDataTemp.reset();
+ for(int iX=0; iX
+void BlockGeometry3D::refineMesh(int level) {
+
+ // new number of Voxels in X-,Y-,and Z-direction and new spacing
+
+ int _nXnew = level * getNx();
+ int _nYnew = level * getNy();
+ int _nZnew = level * getNz();
+ T _hnew = getDeltaR() / ((T) level);
+
+ olb::ScalarField3D _refinedGeometryData(_nXnew, _nYnew,
+ _nZnew);
+ _refinedGeometryData.construct();
+
+ for (int iX = 0; iX < getNx(); iX++) {
+ for (int iY = 0; iY < getNy(); iY++) {
+ for (int iZ = 0; iZ < getNz(); iZ++) {
+ for (int li = 0; li < level; li++) {
+ for (int lj = 0; lj < level; lj++) {
+ for (int lk = 0; lk < level; lk++) {
+
+ _refinedGeometryData.get(level * iX + li, level
+ * iY + lj, level * iZ + lk) = getMaterial(
+ iX, iY, iZ);
+
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (int iX = 0; iX < _nXnew; iX++) {
+ for (int iY = 0; iY < _nYnew; iY++) {
+ for (int iZ = 0; iZ < _nZnew; iZ++) {
+
+ if (iX == 0 || iY == 0 || iZ == 0 || iX == _nXnew - 1 || iY
+ == _nYnew - 1 || iZ == _nZnew - 1)
+ _refinedGeometryData.get(iX, iY, iZ) = 0;
+ }
+ }
+ }
+ reInit(getOrigin()[0], getOrigin()[1], getOrigin()[2], _hnew, _nXnew - 2, _nYnew - 2, _nZnew - 2, this->_iCglob,
+ &_refinedGeometryData);
+}*/
+
+
+template
+void BlockGeometry2D::addToStatisticsList(bool* statisticStatus)
+{
+ _statisticsUpdateNeeded.push_back(statisticStatus);
+}
+
+template
+void BlockGeometry2D::removeFromStatisticsList(bool* statisticStatus)
+{
+ _statisticsUpdateNeeded.remove(statisticStatus);
+}
+
+
+template
+void BlockGeometry2D::printLayer(int x0, int x1, int y0, int y1, bool linenumber)
+{
+ for (int x = x0; x <= x1; x++) {
+ if (linenumber) {
+ this->clout << x << ": ";
+ }
+ for (int y = y0; y <= y1; y++) {
+ this->clout << getMaterial(x, y) << " ";
+ }
+ if (x1 - x0 != 0) {
+ this->clout << std::endl;
+ }
+ }
+ this->clout << std::endl;
+}
+
+template
+void BlockGeometry2D::printLayer(int direction, int layer, bool linenumber)
+{
+ assert(direction >= 0 && direction <= 2);
+ switch (direction) {
+ case 0:
+ printLayer(layer, layer, 0, getNy() - 1, linenumber);
+ break;
+ case 1:
+ printLayer(0, getNx() - 1, layer, layer, linenumber);
+ break;
+ }
+}
+
+template
+void BlockGeometry2D::printNode(int x0, int y0)
+{
+ for (int x = x0 - 1; x <= x0 + 1; x++) {
+ this->clout << "x=" << x << std::endl;
+ for (int y = y0 - 1; y <= y0 + 1; y++) {
+ this->clout << getMaterial(x, y) << " ";
+ }
+ this->clout << std::endl;
+ }
+ this->clout << std::endl;
+}
+
+template
+void BlockGeometry2D::resetStatistics()
+{
+ for (std::list::iterator it = _statisticsUpdateNeeded.begin(); it != _statisticsUpdateNeeded.end(); it++) {
+ **it = true;
+ }
+}
+
+} // namespace olb
+
+#endif
diff --git a/src/geometry/blockGeometry3D.cpp b/src/geometry/blockGeometry3D.cpp
new file mode 100644
index 0000000..7f3ca2f
--- /dev/null
+++ b/src/geometry/blockGeometry3D.cpp
@@ -0,0 +1,36 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2011 Mathias J. Krause, Simon Zimny
+ * 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.
+ */
+
+/** \file
+ * Representation of the 3D block geometry -- template instantiation.
+ */
+
+#include "blockGeometry3D.h"
+#include "blockGeometry3D.hh"
+
+namespace olb {
+
+template class BlockGeometry3D;
+
+}
+
diff --git a/src/geometry/blockGeometry3D.h b/src/geometry/blockGeometry3D.h
new file mode 100644
index 0000000..3d0a401
--- /dev/null
+++ b/src/geometry/blockGeometry3D.h
@@ -0,0 +1,127 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2014 Mathias J. Krause
+ * 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.
+ */
+
+/** \file
+ * Representation of the 3D block geometry view -- header file.
+ */
+
+#ifndef BLOCK_GEOMETRY_3D_H
+#define BLOCK_GEOMETRY_3D_H
+
+#include
+#include
+#include "core/blockData3D.h"
+#include "geometry/blockGeometryStatistics3D.h"
+#include "geometry/blockGeometryStructure3D.h"
+#include "geometry/cuboid3D.h"
+
+/// All OpenLB code is contained in this namespace.
+namespace olb {
+
+/// Representation of a block geometry
+/** This class is derived from block geometry structure. It
+ * holds the actual data with the materials. It stores pointers
+ * to all dependent block geometry views.
+ * It presents a volume of voxels where different types are
+ * given by material numbers which is important e.g. to work
+ * with different boundaries (like for inflow/output regions).
+ *
+ * This class is not intended to be derived from.
+ */
+template
+class BlockGeometry3D final : public BlockData3D, public BlockGeometryStructure3D {
+
+private:
+ /// Cuboid which charaterizes the block geometry
+ Cuboid3D _cuboid;
+ /// List to all depending statistic status objects
+ std::list _statisticsUpdateNeeded;
+
+public:
+ /// Constructor
+ BlockGeometry3D(T x0, T y0, T z0, T h, int nX, int nY, int nZ, int iCglob=-1);
+ /// Constructor
+ BlockGeometry3D(Cuboid3D& cuboid, int iCglob=-1);
+ /// Copy constructor
+ BlockGeometry3D(BlockGeometry3D const& rhs);
+ /// Copy assignment
+ BlockGeometry3D& operator=(BlockGeometry3D const& rhs);
+
+ /// Returns the underlying block structure
+ BlockStructure3D& getBlockStructure() override;
+
+ /// Write access to the associated block statistic
+ BlockGeometryStatistics3D& getStatistics(bool verbose=true) override;
+ /// Read only access to the associated block statistic
+ BlockGeometryStatistics3D const& getStatistics(bool verbose=true) const override;
+
+ /// Read only access to the origin position given in SI units (meter)
+ Vector getOrigin() const override;
+ /// Read only access to the voxel size given in SI units (meter)
+ const T getDeltaR() const override;
+ /// Returns the extend (number of voxels) in X-direction
+ int getNx() const override;
+ /// Returns the extend (number of voxels) in Y-direction
+ int getNy() const override;
+ /// Returns the extend (number of voxels) in Z-direction
+ int getNz() const override;
+ /// Write access to a material number
+ int& get(int iX, int iY, int iZ) override; // override BlockGeometryStructure3D::get() by linking to BlockData3D::get()
+ /// Read only access to a material number
+ int const& get(int iX, int iY, int iZ) const override; // override BlockGeometryStructure3D::get() by linking to BlockData3D::get()
+ /// returns the (iX,iY,iZ) entry in the 3D scalar field
+ int getMaterial(int iX, int iY, int iZ) const override; // TODO old
+
+ /// Transforms lattice to physical coordinates (wrapped from cuboid geometry)
+ void getPhysR(T physR[3], const int& iX, const int& iY, const int& iZ) const override;
+
+ // returns the raw data field
+ // olb::ScalarField3D* getRawData();
+ // void resize(int X, int Y, int Z, int nX, int nY, int nZ);
+ // refine Mesh
+ // void refineMesh(int level = 2);
+
+ /// Adds a pointer to the list of dependent statistic classes
+ void addToStatisticsList(bool* statisticStatus) override;
+ /// Removes a pointer from the list of dependent statistic classes if existing
+ void removeFromStatisticsList(bool* statisticStatus) override;
+
+ /// Prints a chosen part of the block geometry
+ void printLayer(int x0, int x1, int y0, int y1, int z0, int z1, bool linenumber = false);
+ /// Prints a chosen part of the block geometry
+ void printLayer(int direction, int layer, bool linenumber = false);
+ /// Prints a chosen node and its neighbourhood
+ void printNode(int x0, int y0, int z0);
+
+private:
+
+ /// Re-initialization of the block geometry
+ /*void reInit(T originX, T originY, T originZ, T deltaR, int nX, int nY, int nZ, int iCglob = -1,
+ olb::ScalarField3D* geometryData = nullptr);*/
+ /// Resets all depending statistic flags
+ void resetStatistics();
+};
+
+} // namespace olb
+
+#endif
diff --git a/src/geometry/blockGeometry3D.hh b/src/geometry/blockGeometry3D.hh
new file mode 100644
index 0000000..6264c8b
--- /dev/null
+++ b/src/geometry/blockGeometry3D.hh
@@ -0,0 +1,331 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2011, 2014 Mathias J. Krause, Simon Zimny
+ * 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.
+ */
+
+/** \file
+ * Representation of the 3D block geometry -- generic implementation.
+ */
+
+#ifndef BLOCK_GEOMETRY_3D_HH
+#define BLOCK_GEOMETRY_3D_HH
+
+
+#include "geometry/blockGeometry3D.h"
+
+
+namespace olb {
+
+template
+BlockGeometry3D::BlockGeometry3D(T x0, T y0, T z0, T h, int nX, int nY, int nZ, int iCglob)
+ : BlockData3D(nX,nY,nZ), BlockGeometryStructure3D(iCglob),
+ _cuboid(x0, y0, z0, h, nX, nY, nZ)
+{
+ this->_statistics = BlockGeometryStatistics3D(this);
+ addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
+}
+
+template
+BlockGeometry3D::BlockGeometry3D(Cuboid3D& cuboid, int iCglob)
+ : BlockData3D(cuboid.getNx(),cuboid.getNy(),cuboid.getNz()),
+ BlockGeometryStructure3D(iCglob), _cuboid(cuboid)
+{
+ this->_statistics = BlockGeometryStatistics3D(this);
+ addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
+}
+
+template
+BlockGeometry3D::BlockGeometry3D(BlockGeometry3D const& rhs)
+ : BlockData3D(rhs.getNx(), rhs.getNy(), rhs.getNz()),
+ BlockGeometryStructure3D(rhs._iCglob), _cuboid(rhs._cuboid)
+{
+ this->_statistics = BlockGeometryStatistics3D(this);
+ addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
+}
+
+template
+BlockGeometry3D& BlockGeometry3D::operator=(BlockGeometry3D const& rhs)
+{
+ this->_nx = rhs._nx;
+ this->_ny = rhs._ny;
+ this->_nz = rhs._nz;
+ this->_iCglob = rhs._iCglob;
+ _cuboid = rhs._cuboid;
+ this->_statistics = BlockGeometryStatistics3D(this);
+ addToStatisticsList( &(this->_statistics.getStatisticsStatus()) );
+ return *this;
+}
+
+template
+BlockStructure3D& BlockGeometry3D::getBlockStructure()
+{
+ return *this;
+}
+
+template
+BlockGeometryStatistics3D& BlockGeometry3D::getStatistics(bool verbose)
+{
+ return this->_statistics;
+}
+
+template
+BlockGeometryStatistics3D const& BlockGeometry3D::getStatistics(bool verbose) const
+{
+ return this->_statistics;
+}
+
+template
+Vector BlockGeometry3D::getOrigin() const
+{
+ return _cuboid.getOrigin();
+}
+
+template
+const T BlockGeometry3D::getDeltaR() const
+{
+ return _cuboid.getDeltaR();
+}
+
+template
+int BlockGeometry3D::getNx() const
+{
+ return _cuboid.getNx();
+}
+
+template
+int BlockGeometry3D::getNy() const
+{
+ return _cuboid.getNy();
+}
+
+template
+int BlockGeometry3D::getNz() const
+{
+ return _cuboid.getNz();
+}
+
+
+template
+int& BlockGeometry3D::get(int iX, int iY, int iZ)
+{
+ resetStatistics();
+ return BlockData3D::get(iX,iY,iZ,0);
+}
+
+template
+int const& BlockGeometry3D::get(int iX, int iY, int iZ) const
+{
+ return BlockData3D::get(iX,iY,iZ,0);
+}
+
+template
+int BlockGeometry3D::getMaterial(int iX, int iY, int iZ) const
+{
+ int material;
+ if (iX < 0 || iX + 1 > getNx() || iY < 0 || iY
+ + 1 > getNy() || iZ < 0 || iZ + 1 > getNz()) {
+ material = 0;
+ } else {
+ material = BlockData3D::get(iX,iY,iZ,0);
+ }
+ return material;
+}
+
+template
+void BlockGeometry3D::getPhysR(T physR[3], const int& iX, const int& iY,
+ const int& iZ) const
+{
+ _cuboid.getPhysR(physR, iX, iY, iZ);
+ return;
+}
+
+
+///TODO up, DONE down
+/*
+template
+olb::ScalarField3D* BlockGeometry3D::getRawData() {
+ return &_geometryData;
+}*/
+/*
+template
+void BlockGeometry3D::resize(int X, int Y, int Z, int nX, int nY, int nZ) {
+ olb::ScalarField3D geometryDataTemp(nX, nY, nZ);
+ geometryDataTemp.construct();
+ geometryDataTemp.reset();
+ for(int iX=0; iX
+void BlockGeometry3D::refineMesh(int level) {
+
+ // new number of Voxels in X-,Y-,and Z-direction and new spacing
+
+ int _nXnew = level * getNx();
+ int _nYnew = level * getNy();
+ int _nZnew = level * getNz();
+ T _hnew = getDeltaR() / ((T) level);
+
+ olb::ScalarField3D _refinedGeometryData(_nXnew, _nYnew,
+ _nZnew);
+ _refinedGeometryData.construct();
+
+ for (int iX = 0; iX < getNx(); iX++) {
+ for (int iY = 0; iY < getNy(); iY++) {
+ for (int iZ = 0; iZ < getNz(); iZ++) {
+ for (int li = 0; li < level; li++) {
+ for (int lj = 0; lj < level; lj++) {
+ for (int lk = 0; lk < level; lk++) {
+
+ _refinedGeometryData.get(level * iX + li, level
+ * iY + lj, level * iZ + lk) = getMaterial(
+ iX, iY, iZ);
+
+ }
+ }
+ }
+ }
+ }
+ }
+
+ for (int iX = 0; iX < _nXnew; iX++) {
+ for (int iY = 0; iY < _nYnew; iY++) {
+ for (int iZ = 0; iZ < _nZnew; iZ++) {
+
+ if (iX == 0 || iY == 0 || iZ == 0 || iX == _nXnew - 1 || iY
+ == _nYnew - 1 || iZ == _nZnew - 1)
+ _refinedGeometryData.get(iX, iY, iZ) = 0;
+ }
+ }
+ }
+ reInit(getOrigin()[0], getOrigin()[1], getOrigin()[2], _hnew, _nXnew - 2, _nYnew - 2, _nZnew - 2, this->_iCglob,
+ &_refinedGeometryData);
+}*/
+
+
+template
+void BlockGeometry3D::addToStatisticsList(bool* statisticStatus)
+{
+ _statisticsUpdateNeeded.push_back(statisticStatus);
+}
+
+template
+void BlockGeometry3D::removeFromStatisticsList(bool* statisticStatus)
+{
+ _statisticsUpdateNeeded.remove(statisticStatus);
+}
+
+
+template
+void BlockGeometry3D::printLayer(int x0, int x1, int y0, int y1, int z0,
+ int z1, bool linenumber)
+{
+ for (int x = x0; x <= x1; x++) {
+ if (linenumber) {
+ this->clout << x << ": ";
+ }
+ for (int y = y0; y <= y1; y++) {
+ for (int z = z0; z <= z1; z++) {
+ this->clout << getMaterial(x, y, z) << " ";
+ }
+ if (y1 - y0 != 0 && z1 - z0 != 0) {
+ this->clout << std::endl;
+ }
+ }
+ if (x1 - x0 != 0) {
+ this->clout << std::endl;
+ }
+ }
+ this->clout << std::endl;
+}
+
+template
+void BlockGeometry3D::printLayer(int direction, int layer, bool linenumber)
+{
+ assert(direction >= 0 && direction <= 2);
+ switch (direction) {
+ case 0:
+ printLayer(layer, layer, 0, getNy() - 1, 0, getNz() - 1, linenumber);
+ break;
+ case 1:
+ printLayer(0, getNx() - 1, layer, layer, 0, getNz() - 1, linenumber);
+ break;
+ case 2:
+ printLayer(0, getNx() - 1, 0, getNy() - 1, layer, layer, linenumber);
+ break;
+ }
+}
+
+template
+void BlockGeometry3D::printNode(int x0, int y0, int z0)
+{
+ for (int x = x0 - 1; x <= x0 + 1; x++) {
+ this->clout << "x=" << x << std::endl;
+ for (int y = y0 - 1; y <= y0 + 1; y++) {
+ for (int z = z0 - 1; z <= z0 + 1; z++) {
+ this->clout << getMaterial(x, y, z) << " ";
+ }
+ this->clout << std::endl;
+ }
+ this->clout << std::endl;
+ }
+ this->clout << std::endl;
+}
+
+/*
+template
+void BlockGeometry3D::reInit(T x0, T y0, T z0, T h, int nX, int nY, int nZ,
+ int iCglob, olb::ScalarField3D* geometryData) {
+
+ _cuboid = Cuboid3D(x0, y0, z0, h, nX, nY, nZ);
+ if (geometryData != nullptr) {
+ _geometryData.swap(*geometryData);
+ }
+ else {
+ olb::ScalarField3D geometryDataTemp(nX, nY, nZ);
+ _geometryData.swap(geometryDataTemp);
+ _geometryData.construct();
+ _geometryData.reset();
+ geometryDataTemp.deConstruct();
+ }
+ this->_iCglob=iCglob;
+}*/
+
+template
+void BlockGeometry3D::resetStatistics()
+{
+ for (std::list::iterator it = _statisticsUpdateNeeded.begin(); it != _statisticsUpdateNeeded.end(); ++it) {
+ **it = true;
+ }
+}
+
+} // namespace olb
+
+#endif
diff --git a/src/geometry/blockGeometryStatistics2D.cpp b/src/geometry/blockGeometryStatistics2D.cpp
new file mode 100644
index 0000000..9d894d1
--- /dev/null
+++ b/src/geometry/blockGeometryStatistics2D.cpp
@@ -0,0 +1,34 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2011, 2014 Mathias J. Krause, Simon Zimny
+ * 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.
+ */
+
+/** \file
+ * Representation of a statistic for a 2D geometry -- template instantiation.
+ */
+
+#include "blockGeometryStatistics2D.h"
+#include "blockGeometryStatistics2D.hh"
+
+namespace olb {
+template class BlockGeometryStatistics2D;
+}
+
diff --git a/src/geometry/blockGeometryStatistics2D.h b/src/geometry/blockGeometryStatistics2D.h
new file mode 100644
index 0000000..8d682ac
--- /dev/null
+++ b/src/geometry/blockGeometryStatistics2D.h
@@ -0,0 +1,142 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2011, 2014 Mathias J. Krause, Simon Zimny
+ * 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.
+ */
+
+/** \file
+ * Representation of a statistic for a 2D geometry -- header file.
+ */
+
+#ifndef BLOCK_GEOMETRY_STATISTICS_2D_H
+#define BLOCK_GEOMETRY_STATISTICS_2D_H
+
+#include
+#include