/* 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 * A helper for initialising 2D boundaries -- generic implementation. */ #ifndef BOUNDARY_CONDITION_2D_HH #define BOUNDARY_CONDITION_2D_HH #include "boundaryCondition2D.h" #include "boundaryInstantiator2D.h" namespace olb { template class RegularizedBoundaryManager2D { public: template static Momenta* getVelocityBoundaryMomenta(); template static Dynamics* getVelocityBoundaryDynamics(T omega, Momenta& momenta); template static PostProcessorGenerator2D* getVelocityBoundaryProcessor(int x0, int x1, int y0, int y1); template static Momenta* getPressureBoundaryMomenta(); template static Dynamics* getPressureBoundaryDynamics(T omega, Momenta& momenta); template static PostProcessorGenerator2D* getPressureBoundaryProcessor(int x0, int x1, int y0, int y1); template static PostProcessorGenerator2D* getConvectionBoundaryProcessor(int x0, int x1, int y0, int y1, T* uAv=NULL); template static Momenta* getExternalVelocityCornerMomenta(); template static Dynamics* getExternalVelocityCornerDynamics(T omega, Momenta& momenta); template static PostProcessorGenerator2D* getExternalVelocityCornerProcessor(int x, int y); template static Momenta* getInternalVelocityCornerMomenta(); template static Dynamics* getInternalVelocityCornerDynamics(T omega, Momenta& momenta); template static PostProcessorGenerator2D* getInternalVelocityCornerProcessor(int x, int y); }; template class InterpolationBoundaryManager2D { public: template static Momenta* getVelocityBoundaryMomenta(); template static Dynamics* getVelocityBoundaryDynamics(T omega, Momenta& momenta); template static PostProcessorGenerator2D* getVelocityBoundaryProcessor(int x0, int x1, int y0, int y1); template static Momenta* getPressureBoundaryMomenta(); template static Dynamics* getPressureBoundaryDynamics(T omega, Momenta& momenta); template static PostProcessorGenerator2D* getPressureBoundaryProcessor(int x0, int x1, int y0, int y1); template static PostProcessorGenerator2D* getConvectionBoundaryProcessor(int x0, int x1, int y0, int y1, T* uAv=NULL); template static Momenta* getExternalVelocityCornerMomenta(); template static Dynamics* getExternalVelocityCornerDynamics(T omega, Momenta& momenta); template static PostProcessorGenerator2D* getExternalVelocityCornerProcessor(int x, int y); template static Momenta* getInternalVelocityCornerMomenta(); template static Dynamics* getInternalVelocityCornerDynamics(T omega, Momenta& momenta); template static PostProcessorGenerator2D* getInternalVelocityCornerProcessor(int x, int y); }; ////////// RegularizedBoundaryManager2D ///////////////////////////////////////// template template Momenta* RegularizedBoundaryManager2D::getVelocityBoundaryMomenta() { return new RegularizedVelocityBM; } template template Dynamics* RegularizedBoundaryManager2D:: getVelocityBoundaryDynamics(T omega, Momenta& momenta) { return new CombinedRLBdynamics(omega, momenta); } template template PostProcessorGenerator2D* RegularizedBoundaryManager2D:: getVelocityBoundaryProcessor(int x0, int x1, int y0, int y1) { return nullptr; } template template Momenta* RegularizedBoundaryManager2D::getPressureBoundaryMomenta() { return new RegularizedPressureBM; } template template Dynamics* RegularizedBoundaryManager2D:: getPressureBoundaryDynamics(T omega, Momenta& momenta) { return new CombinedRLBdynamics(omega, momenta); } template template PostProcessorGenerator2D* RegularizedBoundaryManager2D:: getPressureBoundaryProcessor(int x0, int x1, int y0, int y1) { return nullptr; } template template PostProcessorGenerator2D* RegularizedBoundaryManager2D:: getConvectionBoundaryProcessor(int x0, int x1, int y0, int y1, T* uAv) { return nullptr; } template template Momenta* RegularizedBoundaryManager2D::getExternalVelocityCornerMomenta() { return new FixedVelocityBM; } template template Dynamics* RegularizedBoundaryManager2D:: getExternalVelocityCornerDynamics(T omega, Momenta& momenta) { return new MixinDynamics(omega, momenta); } template template PostProcessorGenerator2D* RegularizedBoundaryManager2D:: getExternalVelocityCornerProcessor(int x, int y) { return new OuterVelocityCornerProcessorGenerator2D (x,y); } template template Momenta* RegularizedBoundaryManager2D::getInternalVelocityCornerMomenta() { return new InnerCornerVelBM2D; } template template Dynamics* RegularizedBoundaryManager2D:: getInternalVelocityCornerDynamics(T omega, Momenta& momenta) { return new CombinedRLBdynamics(omega, momenta); } template template PostProcessorGenerator2D* RegularizedBoundaryManager2D::getInternalVelocityCornerProcessor (int x, int y) { return nullptr; } ////////// InterpolationBoundaryManager2D ///////////////////////////////////////// template template Momenta* InterpolationBoundaryManager2D::getVelocityBoundaryMomenta() { return new BasicDirichletBM; } template template Dynamics* InterpolationBoundaryManager2D:: getVelocityBoundaryDynamics(T omega, Momenta& momenta) { return new MixinDynamics(omega, momenta); } template template PostProcessorGenerator2D* InterpolationBoundaryManager2D:: getVelocityBoundaryProcessor(int x0, int x1, int y0, int y1) { return new StraightFdBoundaryProcessorGenerator2D < T,DESCRIPTOR,direction,orientation > (x0, x1, y0, y1); } template template Momenta* InterpolationBoundaryManager2D::getPressureBoundaryMomenta() { return new BasicDirichletBM; } template template Dynamics* InterpolationBoundaryManager2D:: getPressureBoundaryDynamics(T omega, Momenta& momenta) { return new MixinDynamics(omega, momenta); } template template PostProcessorGenerator2D* InterpolationBoundaryManager2D:: getPressureBoundaryProcessor(int x0, int x1, int y0, int y1) { return new StraightFdBoundaryProcessorGenerator2D < T,DESCRIPTOR,direction,orientation > (x0, x1, y0, y1); } template template PostProcessorGenerator2D* InterpolationBoundaryManager2D:: getConvectionBoundaryProcessor(int x0, int x1, int y0, int y1, T* uAv) { return new StraightConvectionBoundaryProcessorGenerator2D < T,DESCRIPTOR,direction,orientation > (x0, x1, y0, y1, uAv); } template template Momenta* InterpolationBoundaryManager2D::getExternalVelocityCornerMomenta() { return new FixedVelocityBM; } template template Dynamics* InterpolationBoundaryManager2D:: getExternalVelocityCornerDynamics(T omega, Momenta& momenta) { return new MixinDynamics(omega, momenta); } template template PostProcessorGenerator2D* InterpolationBoundaryManager2D::getExternalVelocityCornerProcessor(int x, int y) { return new OuterVelocityCornerProcessorGenerator2D (x,y); } template template Momenta* InterpolationBoundaryManager2D::getInternalVelocityCornerMomenta() { return new InnerCornerVelBM2D; } template template Dynamics* InterpolationBoundaryManager2D:: getInternalVelocityCornerDynamics(T omega, Momenta& momenta) { return new CombinedRLBdynamics(omega, momenta); } template template PostProcessorGenerator2D* InterpolationBoundaryManager2D::getInternalVelocityCornerProcessor (int x, int y) { return nullptr; } ////////// Convenience wrappers for boundary functions //////////////////////// template void OnLatticeBoundaryCondition2D::addVelocityBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1, T omega) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addVelocityBoundary(indicator, x0, x1, y0, y1, omega); } template void OnLatticeBoundaryCondition2D::addVelocityBoundary( BlockIndicatorF2D& indicator, T omega, bool includeOuterCells) { auto& blockGeometryStructure = indicator.getBlockGeometryStructure(); const int margin = includeOuterCells ? 0 : 1; addVelocityBoundary(indicator, margin, blockGeometryStructure.getNx()-1 -margin, margin, blockGeometryStructure.getNy()-1 -margin, omega); } template void OnLatticeBoundaryCondition2D::addVelocityBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, T omega, bool includeOuterCells) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addVelocityBoundary(indicator, omega, includeOuterCells); } template void OnLatticeBoundaryCondition2D::addSlipBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addSlipBoundary(indicator, x0, x1, y0, y1); } template void OnLatticeBoundaryCondition2D::addSlipBoundary( BlockIndicatorF2D& indicator, bool includeOuterCells) { auto& blockGeometryStructure = indicator.getBlockGeometryStructure(); const int margin = includeOuterCells ? 0 : 1; addSlipBoundary(indicator, margin, blockGeometryStructure.getNx()-1 -margin, margin, blockGeometryStructure.getNy()-1 -margin); } template void OnLatticeBoundaryCondition2D::addSlipBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, bool includeOuterCells) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addSlipBoundary(indicator, includeOuterCells); } template void OnLatticeBoundaryCondition2D::addPartialSlipBoundary( T tuner, BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addPartialSlipBoundary(tuner, indicator, x0, x1, y0, y1); } template void OnLatticeBoundaryCondition2D::addPartialSlipBoundary( T tuner, BlockIndicatorF2D& indicator, bool includeOuterCells) { auto& blockGeometryStructure = indicator.getBlockGeometryStructure(); const int margin = includeOuterCells ? 0 : 1; addPartialSlipBoundary(tuner, indicator, margin, blockGeometryStructure.getNx()-1 -margin, margin, blockGeometryStructure.getNy()-1 -margin); } template void OnLatticeBoundaryCondition2D::addPartialSlipBoundary( T tuner, BlockGeometryStructure2D& blockGeometryStructure, int material, bool includeOuterCells) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addPartialSlipBoundary(tuner, indicator, includeOuterCells); } template void OnLatticeBoundaryCondition2D::addPressureBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1, T omega) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addPressureBoundary(indicator, x0, x1, y0, y1, omega); } template void OnLatticeBoundaryCondition2D::addPressureBoundary( BlockIndicatorF2D& indicator, T omega, bool includeOuterCells) { auto& blockGeometryStructure = indicator.getBlockGeometryStructure(); const int margin = includeOuterCells ? 0 : 1; addPressureBoundary(indicator, margin, blockGeometryStructure.getNx()-1 -margin, margin, blockGeometryStructure.getNy()-1 -margin, omega); } template void OnLatticeBoundaryCondition2D::addPressureBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, T omega, bool includeOuterCells) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addPressureBoundary(indicator, omega, includeOuterCells); } template void OnLatticeBoundaryCondition2D::addConvectionBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1, T omega, T* uAv) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addConvectionBoundary(indicator, x0, x1, y0, y1, omega, uAv); } template void OnLatticeBoundaryCondition2D::addConvectionBoundary( BlockIndicatorF2D& indicator, T omega, T* uAv, bool includeOuterCells) { auto& blockGeometryStructure = indicator.getBlockGeometryStructure(); const int margin = includeOuterCells ? 0 : 1; addConvectionBoundary(indicator, margin, blockGeometryStructure.getNx()-1 -margin, margin, blockGeometryStructure.getNy()-1 -margin, omega, uAv); } template void OnLatticeBoundaryCondition2D::addConvectionBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, T omega, T* uAv, bool includeOuterCells) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addConvectionBoundary(indicator, omega, uAv, includeOuterCells); } template void OnLatticeBoundaryCondition2D::addFreeEnergyWallBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1, T addend, int latticeNumber) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addFreeEnergyWallBoundary(indicator, x0, x1, y0, y1, addend, latticeNumber); } template void OnLatticeBoundaryCondition2D::addFreeEnergyWallBoundary( BlockIndicatorF2D& indicator, T addend, int latticeNumber, bool includeOuterCells) { auto& blockGeometryStructure = indicator.getBlockGeometryStructure(); const int margin = includeOuterCells ? 0 : 1; addFreeEnergyWallBoundary(indicator, margin, blockGeometryStructure.getNx()-1 -margin, margin, blockGeometryStructure.getNy()-1 -margin, addend, latticeNumber); } template void OnLatticeBoundaryCondition2D::addFreeEnergyWallBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, T addend, int latticeNumber, bool includeOuterCells) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addFreeEnergyWallBoundary(indicator, addend, latticeNumber, includeOuterCells); } template void OnLatticeBoundaryCondition2D::addFreeEnergyInletBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1, T omega, std::string type, int latticeNumber) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addFreeEnergyInletBoundary(indicator, x0, x1, y0, y1, omega, type, latticeNumber); } template void OnLatticeBoundaryCondition2D::addFreeEnergyInletBoundary( BlockIndicatorF2D& indicator, T omega, std::string type, int latticeNumber, bool includeOuterCells) { auto& blockGeometryStructure = indicator.getBlockGeometryStructure(); const int margin = includeOuterCells ? 0 : 1; addFreeEnergyInletBoundary(indicator, margin, blockGeometryStructure.getNx()-1 -margin, margin, blockGeometryStructure.getNy()-1 -margin, omega, type, latticeNumber); } template void OnLatticeBoundaryCondition2D::addFreeEnergyInletBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, T omega, std::string type, int latticeNumber, bool includeOuterCells) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addFreeEnergyInletBoundary(indicator, omega, type, latticeNumber, includeOuterCells); } template void OnLatticeBoundaryCondition2D::addFreeEnergyOutletBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1, T omega, std::string type, int latticeNumber) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addFreeEnergyOutletBoundary(indicator, x0, x1, y0, y1, omega, type, latticeNumber); } template void OnLatticeBoundaryCondition2D::addFreeEnergyOutletBoundary( BlockIndicatorF2D& indicator, T omega, std::string type, int latticeNumber, bool includeOuterCells) { auto& blockGeometryStructure = indicator.getBlockGeometryStructure(); const int margin = includeOuterCells ? 0 : 1; addFreeEnergyOutletBoundary(indicator, margin, blockGeometryStructure.getNx()-1 -margin, margin, blockGeometryStructure.getNy()-1 -margin, omega, type, latticeNumber); } template void OnLatticeBoundaryCondition2D::addFreeEnergyOutletBoundary( BlockGeometryStructure2D& blockGeometryStructure, int material, T omega, std::string type, int latticeNumber, bool includeOuterCells) { BlockIndicatorMaterial2D indicator(blockGeometryStructure, material); addFreeEnergyOutletBoundary(indicator, omega, type, latticeNumber, includeOuterCells); } ////////// Factory functions ////////////////////////////////////////////////// template OnLatticeBoundaryCondition2D* createLocalBoundaryCondition2D(BlockLatticeStructure2D& block) { return new BoundaryConditionInstantiator2D < T, DESCRIPTOR, RegularizedBoundaryManager2D > (block); } template OnLatticeBoundaryCondition2D* createInterpBoundaryCondition2D(BlockLatticeStructure2D& block) { return new BoundaryConditionInstantiator2D < T, DESCRIPTOR, InterpolationBoundaryManager2D > (block); } } // namespace olb #endif