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 --- .../twoWayCouplings/twoWayHelperFunctionals.h | 232 +++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 src/particles/twoWayCouplings/twoWayHelperFunctionals.h (limited to 'src/particles/twoWayCouplings/twoWayHelperFunctionals.h') diff --git a/src/particles/twoWayCouplings/twoWayHelperFunctionals.h b/src/particles/twoWayCouplings/twoWayHelperFunctionals.h new file mode 100644 index 0000000..7e76138 --- /dev/null +++ b/src/particles/twoWayCouplings/twoWayHelperFunctionals.h @@ -0,0 +1,232 @@ +/* Lattice Boltzmann sample, written in C++, using the OpenLB + * library + * + * Copyright (C) 2019 Davide Dapelo + * 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. + */ + +/* Helper functionals for Lagrangian two-way coupling methods -- header file. + */ + +#ifndef LB_TWO_WAY_HELPER_FUNCTIONALS_H +#define LB_TWO_WAY_HELPER_FUNCTIONALS_H + +#include "functors/lattice/reductionF3D.h" + +namespace olb { + +/** Data structure for smoothing functionals. + * Stores the lattice position of a cell within smoothing kernel length + * and the related multiplicative weight. + */ +template +struct LatticePosAndWeight { + int globic = 0; + int latticePos[3] = {0, 0, 0}; + T weight = T(); +}; + +/** Abstract class for particle Reynolds number computation within drag model. + * Its raison d'etre consists of not being templetized in Lattice. + */ +template class Particle> +class ParticleReynoldsNumber { +public: + /// Returns the particle Reynolds number. globicFull = { globic, latticeRoundedP[0, ..., 2] } + virtual T operator() (Particle* p, T magU, int globicFull[])=0; + /// Destructor + virtual ~ParticleReynoldsNumber() {}; +protected: + T _RePmin = 0.01; +}; + +/** Abstract class for particle Reynolds number computation within drag model. + */ +template class Particle> +class ParticleReynoldsNumberBase : public ParticleReynoldsNumber { +public: + /// Destructor + virtual ~ParticleReynoldsNumberBase() {}; +protected: + /// Constructor + ParticleReynoldsNumberBase(UnitConverter& converter); + UnitConverter& _converter; // reference to a UnitConverter +}; + +/** Class class for Newtonian particle Reynolds number computation within drag model. + */ +template class Particle> +class NewtonianParticleReynoldsNumber: public ParticleReynoldsNumberBase { +public: + /// Constructor + NewtonianParticleReynoldsNumber(UnitConverter& converter); + /// Destructor + ~NewtonianParticleReynoldsNumber() {}; + /// Returns the particle Reynolds number. globicFull = { globic, latticeRoundedP[0, ..., 2] } + virtual T operator() (Particle* p, T magU, int globicFull[]) override; +}; + +/** Class class for power-law particle Reynolds number computation within drag model. + */ +template class Particle> +class PowerLawParticleReynoldsNumber: public ParticleReynoldsNumberBase { +public: + /// Constructor + PowerLawParticleReynoldsNumber ( + UnitConverter& converter, SuperLattice3D& sLattice ); + /// Destructor + ~PowerLawParticleReynoldsNumber() {}; + /// Returns the particle Reynolds number. globicFull = { globic, latticeRoundedP[0, ..., 2] } + virtual T operator() (Particle* p, T magU, int globicFull[]) override; +protected: + SuperLattice3D& _sLattice; // reference to a lattice +}; + +/** Abstact class for all the local forward-coupling models, + * viz., momentum coupling from fluid to particle. + * Input parameters in attice units. + */ +template +class TwoWayHelperFunctional { +public: + /// Computes the momentum transfer from fluid to particle. + virtual bool operator() ( T gF[], T latticeVelF[], T latticeVelP[], + T physPosP[], int latticeRoundedP[], + int globic )=0; + virtual ~TwoWayHelperFunctional(); +protected: + /// Constructor + TwoWayHelperFunctional ( UnitConverter& converter, + SuperLattice3D& sLattice ); + UnitConverter& _converter; // reference to a UnitConverter + SuperLattice3D& _sLattice; // reference to a lattice + std::shared_ptr > _interpLatticeDensity; + std::shared_ptr > _interpLatticeVelocity ; +}; + +/** Naive way + */ +template +class NaiveMomentumExchange : public TwoWayHelperFunctional { +public: + /// Constructor + NaiveMomentumExchange ( UnitConverter& converter, + SuperLattice3D& sLattice, + std::shared_ptr > interpLatticeDensity ); + /// Computes the momentum transfer from fluid to particle. + virtual bool operator() ( T gF[], T latticeVelF[], T latticeVelP[], + T physPosP[], int latticeRoundedP[], + int globic ) override; +}; + +/** Using Ladd mechanism + */ +template +class LaddMomentumExchange : public TwoWayHelperFunctional { +public: + /// Constructor + LaddMomentumExchange ( UnitConverter& converter, + SuperLattice3D& sLattice, + std::shared_ptr > interpLatticeDensity, + std::shared_ptr > interpLatticeVelocity ); + /// Computes the momentum transfer from fluid to particle. + virtual bool operator() ( T gF[], T latticeVelF[], T latticeVelP[], + T physPosP[], int latticeRoundedP[], + int globic ) override; +}; + +/** Abstact class for all the smoothing functionals. + */ +template +class SmoothingFunctional { +public: + // Returns the size of _latticePosAndWeight + int getSize(); + // Returns the lattice position of the i-th element of _latticePosAndWeight + void getLatticePos(int latticePos[], int i); + // Returns the globic of the i-th element of _latticePosAndWeight + int getGlobic(int i); + // Returns the weight relative to the i-th element of _latticePosAndWeight + T getWeight(int i); + // Rebuilds _latticePosAndWeight with the new cells within _kernelLength from the bubble's position + bool update(T physPosP[], int globic); +protected: + /// Constructor + SmoothingFunctional(T kernelLength, UnitConverter& converter, SuperLattice3D& sLattice); + /// The actual smoothing function + virtual T smoothingFunction(T delta)=0; + /// Returns the weight for smoothing. + virtual T compute(T physPosP[], T physPosL[])=0; + T _kernelLength; // Kernel's smoothing length. + UnitConverter& _converter; // reference to a UnitConverter + SuperLattice3D& _sLattice; // reference to a lattice + // positions and weights of the cells within _kernelLength from bubble's position + std::deque > _latticePosAndWeight; +}; + +/** Abstact class for all the linear-averaging smoothing functionals. + */ +template +class LinearAveragingSmoothingFunctional : public SmoothingFunctional { +protected: + /// Constructor + LinearAveragingSmoothingFunctional(T kernelLength, UnitConverter& converter, SuperLattice3D& sLattice); + /// Returns the weight for smoothing. + virtual T compute(T physPosP[], T physPosL[]) override; +}; + +/** Abstact class for all the volume-averaging smoothing functionals. + */ +template +class VolumeAveragingSmoothingFunctional : public SmoothingFunctional { +protected: + /// Constructor + VolumeAveragingSmoothingFunctional(T kernelLength, UnitConverter& converter, SuperLattice3D& sLattice); + /// Returns the weight for smoothing. + virtual T compute(T physPosP[], T physPosL[]) override; +}; + +/** Smoothing functional as in Deen et al (2004), Chem. Eng. Sci 59. + */ +template +class DeenSmoothingFunctional : public LinearAveragingSmoothingFunctional { +public: + /// Constructor + DeenSmoothingFunctional(T kernelLength, UnitConverter& converter, SuperLattice3D& sLattice); +protected: + /// The actual smoothing function + virtual T smoothingFunction(T delta) override; +}; + +/** Stepwise smoothing functional. + */ +template +class StepSmoothingFunctional : public VolumeAveragingSmoothingFunctional { +public: + /// Constructor + StepSmoothingFunctional(T kernelLength, UnitConverter& converter, SuperLattice3D& sLattice); +protected: + /// The actual smoothing function + virtual T smoothingFunction(T delta) override; +}; + +} + +#endif -- cgit v1.2.3