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/boundary/momentaOnBoundaries.hh | 427 ++++++++++++++++++++++++++++++++++++
1 file changed, 427 insertions(+)
create mode 100644 src/boundary/momentaOnBoundaries.hh
(limited to 'src/boundary/momentaOnBoundaries.hh')
diff --git a/src/boundary/momentaOnBoundaries.hh b/src/boundary/momentaOnBoundaries.hh
new file mode 100644
index 0000000..3ec9f94
--- /dev/null
+++ b/src/boundary/momentaOnBoundaries.hh
@@ -0,0 +1,427 @@
+/* This file is part of the OpenLB library
+ *
+ * Copyright (C) 2006, 2007 Jonas Latt
+ * 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
+ * Implementation of boundary cell dynamics -- generic implementation.
+ */
+#ifndef MOMENTA_ON_BOUNDARIES_HH
+#define MOMENTA_ON_BOUNDARIES_HH
+
+#include "momentaOnBoundaries.h"
+#include "core/util.h"
+#include "dynamics/lbHelpers.h"
+
+namespace olb {
+
+////////////////////// Class EquilibriumBM //////////////////////
+
+template
+EquilibriumBM::EquilibriumBM()
+{
+ _rho = (T)1;
+ for (int iD=0; iD
+EquilibriumBM::EquilibriumBM(T rho, const T u[DESCRIPTOR::d])
+{
+ _rho = rho;
+ for (int iD=0; iD
+T EquilibriumBM::computeRho( Cell const& cell ) const
+{
+ return _rho;
+}
+
+template
+void EquilibriumBM::computeU(
+ Cell const& cell, T u[DESCRIPTOR::d]) const
+{
+ for (int iD=0; iD
+void EquilibriumBM::computeJ (
+ Cell const& cell, T j[DESCRIPTOR::d]) const
+{
+ for (int iD=0; iD
+void EquilibriumBM::computeStress( Cell const& cell,
+ T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal::n] ) const
+{
+ for (int iPi=0; iPi::n; ++iPi) {
+ pi[iPi] = T();
+ }
+}
+
+
+template
+void EquilibriumBM::defineRho( Cell& cell, T rho )
+{
+ _rho = rho;
+}
+
+template
+void EquilibriumBM::defineU(
+ Cell& cell, const T u[DESCRIPTOR::d])
+{
+ for (int iD=0; iD
+void EquilibriumBM::defineAllMomenta( Cell& cell,
+ T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal::n] )
+{
+ defineRho(cell, rho);
+ defineU(cell, u);
+}
+
+
+
+////////////////////// Class VelocityBM //////////////////////
+
+template
+VelocityBM::VelocityBM()
+{
+ for (int iD=0; iD
+VelocityBM::VelocityBM(const T u[DESCRIPTOR::d])
+{
+ for (int iD=0; iD
+T VelocityBM::computeRho( Cell const& cell ) const
+{
+ return velocityBMRho(cell, _u);
+}
+
+template
+void VelocityBM::computeU (
+ Cell const& cell, T u[DESCRIPTOR::d]) const
+{
+ computeU(u);
+}
+
+template
+void VelocityBM::computeJ (
+ Cell const& cell, T j[DESCRIPTOR::d]) const
+{
+ T rho = computeRho(cell);
+ for (int iD=0; iD
+void VelocityBM::computeU( T u[DESCRIPTOR::d] ) const
+{
+ for (int iD=0; iD
+void VelocityBM::defineRho(Cell& cell, T rho )
+{
+}
+
+template
+void VelocityBM::defineU (
+ Cell& cell, const T u[DESCRIPTOR::d])
+{
+ defineU(u);
+}
+
+template
+void VelocityBM::defineU(const T u[DESCRIPTOR::d])
+{
+ for (int iD=0; iD
+void VelocityBM::defineAllMomenta (
+ Cell& cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal::n] )
+{
+ this->defineRhoU(cell, rho, u);
+}
+
+
+////////////////////// Class PressureBM //////////////////////
+
+template
+PressureBM::PressureBM()
+{
+ for (int iD=0; iD
+PressureBM::PressureBM(const T values[DESCRIPTOR::d])
+{
+ for (int iD=0; iD
+T PressureBM::computeRho( Cell const& cell ) const
+{
+ return computeRho();
+}
+
+template
+T PressureBM::computeRho() const
+{
+ return _values[direction];
+}
+
+template
+void PressureBM::computeU (
+ Cell const& cell, T u[DESCRIPTOR::d]) const
+{
+ for (int iD=0; iD const& onWallIndices
+ = util::subIndex();
+
+ std::vector const& normalIndices
+ = util::subIndex();
+
+ T rhoOnWall = T();
+ for (auto & e : onWallIndices) {
+ rhoOnWall += cell[e];
+ }
+
+ T rhoNormal = T();
+ for (auto & e : normalIndices) {
+ rhoNormal += cell[e];
+ }
+
+ u[direction] = (T)orientation*( ((T)2*rhoNormal+rhoOnWall+(T)1 ) / rho-(T)1 );
+}
+
+template
+void PressureBM::computeJ (
+ Cell const& cell, T j[DESCRIPTOR::d]) const
+{
+ computeU(cell, j);
+ T rho = computeRho(cell);
+ for (int iD=0; iD
+void PressureBM::defineRho(Cell& cell, T rho)
+{
+ defineRho(rho);
+}
+
+template
+void PressureBM::defineRho(T rho )
+{
+ _values[direction] = rho;
+}
+
+template
+void PressureBM::defineU(Cell& cell, const T u[DESCRIPTOR::d])
+{
+ for (int iD=0; iD
+void PressureBM::defineAllMomenta(
+ Cell& cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal::n] )
+{
+ this->defineRhoU(cell, rho, u);
+}
+
+
+//////// FreeStressBM //////////////////////////////////////////////
+
+template
+void FreeStressBM::computeStress (
+ Cell const& cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal::n] ) const
+{
+ lbHelpers::computeStress(cell, rho, u, pi);
+}
+
+
+
+////////////////////// Class RegularizedBM //////////////////////
+
+template
+void RegularizedBM::computeStress (
+ Cell const& cell, T rho, const T u[DESCRIPTOR::d],
+ T pi[util::TensorVal::n] ) const
+{
+ BoundaryHelpers::computeStress(cell, rho, u, pi);
+}
+
+////////////////////// Class FixedVelocityBM //////////////////////////
+
+template
+T FixedVelocityBM::computeRho(Cell const& cell) const
+{
+ return _basicMomenta.computeRho(cell);
+}
+
+template
+void FixedVelocityBM::computeU(Cell const& cell, T u[DESCRIPTOR::d]) const
+{
+ for (int iD=0; iD
+void FixedVelocityBM::computeJ(Cell const& cell, T j[DESCRIPTOR::d]) const
+{
+ T rho = computeRho(cell);
+ for (int iD=0; iD
+void FixedVelocityBM::computeStress (
+ Cell const& cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal::n] ) const
+{
+ _basicMomenta.computeStress(cell, rho, u, pi);
+}
+
+template
+void FixedVelocityBM::computeRhoU (
+ Cell const& cell, T& rho, T u[DESCRIPTOR::d] ) const
+{
+ rho = computeRho(cell);
+ computeU(cell,u);
+}
+
+template
+void FixedVelocityBM::computeAllMomenta (
+ Cell const& cell, T& rho, T u[DESCRIPTOR::d], T pi[util::TensorVal::n] ) const
+{
+ _basicMomenta.computeAllMomenta(cell, rho, u, pi);
+ computeU(cell, u);
+}
+
+template
+void FixedVelocityBM::defineRho(Cell& cell, T rho)
+{
+ _basicMomenta.defineRho(cell, rho);
+}
+
+template
+void FixedVelocityBM::defineU(Cell& cell, const T u[DESCRIPTOR::d])
+{
+ for (int iD=0; iD
+void FixedVelocityBM::defineRhoU(Cell& cell, T rho, const T u[DESCRIPTOR::d])
+{
+ defineRho(cell,rho);
+ defineU(cell,u);
+}
+
+template
+void FixedVelocityBM::defineAllMomenta( Cell& cell, T rho, const T u[DESCRIPTOR::d],
+ const T pi[util::TensorVal::n] )
+{
+ _basicMomenta.defineAllMomenta(cell, rho, u, pi);
+ defineU(cell,u);
+}
+
+////////////////////// Extracted helper functions //////////////////////////
+
+template
+T velocityBMRho( Cell const& cell, const T* u )
+{
+ std::vector const& onWallIndices
+ = util::subIndex();
+
+ std::vector const& normalIndices
+ = util::subIndex();
+
+ T rhoOnWall = T();
+ for (auto & e : onWallIndices) {
+ rhoOnWall += cell[e];
+ }
+
+ T rhoNormal = T();
+ for (auto & e : normalIndices) {
+ rhoNormal += cell[e];
+ }
+
+ T rho =((T)2*rhoNormal+rhoOnWall+(T)1) /
+ ((T)1+(T)orientation*u[direction]);
+
+ return rho;
+}
+
+
+
+} // namespace olb
+
+#endif
--
cgit v1.2.3