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.h | 184 +++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 src/boundary/momentaOnBoundaries.h (limited to 'src/boundary/momentaOnBoundaries.h') diff --git a/src/boundary/momentaOnBoundaries.h b/src/boundary/momentaOnBoundaries.h new file mode 100644 index 0000000..46e4035 --- /dev/null +++ b/src/boundary/momentaOnBoundaries.h @@ -0,0 +1,184 @@ +/* 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 -- header file. + */ +#ifndef MOMENTA_ON_BOUNDARIES_H +#define MOMENTA_ON_BOUNDARIES_H + +#include "dynamics/dynamics.h" + +namespace olb { + +template class Cell; + +/// Dirichlet condition on velocity and/or pressure +template +class DirichletBoundaryMomenta : public Momenta { +}; + +template +class EquilibriumBM : public DirichletBoundaryMomenta { +public: + EquilibriumBM(); + EquilibriumBM( T rho, const T u[DESCRIPTOR::d] ); + T computeRho( Cell const& cell ) const override; + void computeU( Cell const& cell, T u[DESCRIPTOR::d] ) const override; + void computeJ( Cell const& cell, T j[DESCRIPTOR::d] ) const override; + void computeStress( Cell const& cell, T rho, const T u[DESCRIPTOR::d], + T pi[util::TensorVal::n] ) const override; + void defineRho( Cell& cell, T rho) override; + void defineU( Cell& cell, const T u[DESCRIPTOR::d]) override; + void defineAllMomenta( Cell& cell, T rho, const T u[DESCRIPTOR::d], + const T pi[util::TensorVal::n] ) override; +private: + T _rho; + T _u[DESCRIPTOR::d]; ///< value of the velocity on the boundary +}; + +/// Computation of velocity momenta on a velocity boundary +template +class VelocityBM : virtual public DirichletBoundaryMomenta { +public: + /// Default Constructor: initialization to zero + VelocityBM(); + /// Constructor with boundary initialization + VelocityBM(const T u[DESCRIPTOR::d]); + + T computeRho(Cell const& cell) const override; + void computeU ( Cell const& cell, T u[DESCRIPTOR::d] ) const override; + void computeJ ( Cell const& cell, T j[DESCRIPTOR::d] ) const override; + void computeU(T u[DESCRIPTOR::d]) const; + void defineRho(Cell& cell, T rho) override ; + void defineU(Cell& cell, const T u[DESCRIPTOR::d]) override ; + void defineU(const T u[DESCRIPTOR::d]); + void defineAllMomenta( Cell& cell, T rho, const T u[DESCRIPTOR::d], + const T pi[util::TensorVal::n] ) override; +private: + T _u[DESCRIPTOR::d]; ///< value of the velocity on the boundary +}; + +/// Computation of velocity momenta on a velocity boundary +template +class PressureBM : virtual public DirichletBoundaryMomenta { +public: + /// Default Constructor: initialization to u=0, rho=1 + PressureBM(); + /// Constructor with boundary initialization + PressureBM(const T values_[DESCRIPTOR::d]); + + T computeRho(Cell const& cell) const override; + T computeRho() const; + void computeU( Cell const& cell, T u[DESCRIPTOR::d] ) const override; + void computeJ( Cell const& cell, T j[DESCRIPTOR::d] ) const override; + void defineRho(Cell& cell, T rho) override; + void defineRho(T rho); + void defineU(Cell& cell, const T u[DESCRIPTOR::d]) override; + void defineAllMomenta( Cell& cell, T rho, const T u[DESCRIPTOR::d], + const T pi[util::TensorVal::n] ) override; +private: + /// Velocity/Density on boundary. + /** Contains velocity on the boundary, except for values[direction] that + * contains a prescription for the density. + */ + T _values[DESCRIPTOR::d]; +}; + +/// Here, the stress is computed from the particle distribution functions +template +class FreeStressBM : virtual public DirichletBoundaryMomenta { +public: + void computeStress( Cell const& cell, T rho, const T u[DESCRIPTOR::d], + T pi[util::TensorVal::n] ) const override; +}; + +/// Use special trick to compute u resp. rho, but compute pi from part. distr. functions +template + class HydroBM, + int direction, int orientation> +class BasicDirichletBM : public FreeStressBM, public HydroBM { +}; + +/// Computation of the stress tensor for regularized boundary +template +class RegularizedBM : virtual public DirichletBoundaryMomenta { +public: + /// Stress tensor + void computeStress( Cell const& cell, T rho, const T u[DESCRIPTOR::d], + T pi[util::TensorVal::n] ) const override; +}; + +/// Regularized velocity boundary node +template +class RegularizedVelocityBM : public RegularizedBM, public VelocityBM { +public: + RegularizedVelocityBM() { } + RegularizedVelocityBM(const T u[DESCRIPTOR::d]) : VelocityBM(u) {} +}; + +/// Regularized pressure boundary node +template +class RegularizedPressureBM : public RegularizedBM, public PressureBM { +public: + RegularizedPressureBM() { } + RegularizedPressureBM(const T values[DESCRIPTOR::d]) : PressureBM(values) { } +}; + +/// In this class, the velocity is fixed +/** + * As opposed to VelocityBM, the pressure is however not + * computed from a special trick on the boundary, but the + * same way it would be in the bulk. + */ +template +class FixedVelocityBM : public Momenta { +public: + T computeRho(Cell const& cell) const override; + void computeU( Cell const& cell, T u[DESCRIPTOR::d] ) const override; + void computeJ( Cell const& cell, T j[DESCRIPTOR::d] ) const override; + void computeStress( Cell const& cell, T rho, const T u[DESCRIPTOR::d], + T pi[util::TensorVal::n] ) const override; + void computeRhoU( Cell const& cell, T& rho, T u[DESCRIPTOR::d]) const override; + void computeAllMomenta( Cell const& cell, T& rho, T u[DESCRIPTOR::d], + T pi[util::TensorVal::n] ) const override; + void defineRho(Cell& cell, T rho) override; + void defineU(Cell& cell, const T u[DESCRIPTOR::d]) override; + void defineRhoU( Cell& cell, T rho, const T u[DESCRIPTOR::d]) override; + void defineAllMomenta( Cell& cell, T rho, const T u[DESCRIPTOR::d], + const T pi[util::TensorVal::n] ) override; +private: + BulkMomenta _basicMomenta; + T _fixU[DESCRIPTOR::d]; +}; + +template +T velocityBMRho( Cell const& cell, const T* u ); + +} // namespace olb + + +#endif -- cgit v1.2.3