/* 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.
*/
/** \file
* A helper for initialising 2D boundaries -- generic implementation.
*/
#ifndef SUPER_BOUNDARY_CONDITION_2D_HH
#define SUPER_BOUNDARY_CONDITION_2D_HH
#include
#include "boundaryCondition2D.h"
#include "extendedFiniteDifferenceBoundary2D.h"
#include "superBoundaryCondition2D.h"
#include "core/superLattice2D.h"
#include "functors/lattice/indicator/superIndicatorF2D.h"
namespace olb {
///////// class superBoundaryCondition2D ///////////////////////////////
template
sOnLatticeBoundaryCondition2D::sOnLatticeBoundaryCondition2D(
SuperLattice2D& sLattice) :
clout(std::cout,"sOnLatticeBoundaryCondition2D"),
_sLattice(sLattice),
_output(false)
{
}
template
sOnLatticeBoundaryCondition2D::sOnLatticeBoundaryCondition2D(
sOnLatticeBoundaryCondition2D const& rhs) :
clout(std::cout,"sOnLatticeBoundaryCondition2D"),
_sLattice(rhs._sLattice),
_output(false)
{
_blockBCs = rhs._blockBCs;
_overlap = rhs._overlap;
}
template
sOnLatticeBoundaryCondition2D sOnLatticeBoundaryCondition2D::operator=(sOnLatticeBoundaryCondition2D rhs)
{
sOnLatticeBoundaryCondition2D tmp(rhs);
return tmp;
}
template
sOnLatticeBoundaryCondition2D::~sOnLatticeBoundaryCondition2D()
{
//for (unsigned iC = 0; iC < _blockBCs.size(); iC++) {
// delete _blockBCs[iC];
//}
}
template
void sOnLatticeBoundaryCondition2D::addVelocityBoundary(
FunctorPtr>&& indicator, T omega)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addVelocityBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), omega, includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addVelocityBoundary(
SuperGeometry2D& superGeometry, int material, T omega)
{
addVelocityBoundary(superGeometry.getMaterialIndicator(material), omega);
}
template
void sOnLatticeBoundaryCondition2D::addSlipBoundary(
FunctorPtr>&& indicator)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addSlipBoundary(indicator->getExtendedBlockIndicatorF(iCloc), includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addSlipBoundary(
SuperGeometry2D& superGeometry, int material)
{
addSlipBoundary(superGeometry.getMaterialIndicator(material));
}
template
void sOnLatticeBoundaryCondition2D::addPartialSlipBoundary(
T tuner, FunctorPtr>&& indicator)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addPartialSlipBoundary(
tuner, indicator->getExtendedBlockIndicatorF(iCloc), includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addPartialSlipBoundary(
T tuner, SuperGeometry2D& superGeometry, int material)
{
addPartialSlipBoundary(tuner, superGeometry.getMaterialIndicator(material));
}
template
void sOnLatticeBoundaryCondition2D::addTemperatureBoundary(
FunctorPtr>&& indicator, T omega)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_ADblockBCs[iCloc]->addTemperatureBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), omega, includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addTemperatureBoundary(
SuperGeometry2D& superGeometry, int material, T omega)
{
addTemperatureBoundary(superGeometry.getMaterialIndicator(material), omega);
}
template
void sOnLatticeBoundaryCondition2D::addRegularizedTemperatureBoundary(
FunctorPtr>&& indicator, T omega)
{
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_ADblockBCs[iCloc]->addRegularizedTemperatureBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), omega);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addRegularizedTemperatureBoundary(
SuperGeometry2D& superGeometry, int material, T omega)
{
addRegularizedTemperatureBoundary(superGeometry.getMaterialIndicator(material), omega);
}
template
void sOnLatticeBoundaryCondition2D::addRegularizedHeatFluxBoundary(
FunctorPtr>&& indicator, T omega, T *heatFlux)
{
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_ADblockBCs[iCloc]->addRegularizedHeatFluxBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), omega, heatFlux);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addRegularizedHeatFluxBoundary(
SuperGeometry2D& superGeometry, int material, T omega, T *heatFlux)
{
addRegularizedHeatFluxBoundary(superGeometry.getMaterialIndicator(material), omega, heatFlux);
}
template
void sOnLatticeBoundaryCondition2D::addPressureBoundary(
FunctorPtr>&& indicator, T omega)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addPressureBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), omega, includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addPressureBoundary(
SuperGeometry2D& superGeometry, int material, T omega)
{
addPressureBoundary(superGeometry.getMaterialIndicator(material), omega);
}
template
void sOnLatticeBoundaryCondition2D::addConvectionBoundary(
FunctorPtr>&& indicator, T omega, T* uAv)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addConvectionBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), omega, uAv, includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addConvectionBoundary(
SuperGeometry2D& superGeometry, int material, T omega, T* uAv)
{
addConvectionBoundary(superGeometry.getMaterialIndicator(material),
omega, uAv);
}
template
void sOnLatticeBoundaryCondition2D::addFreeEnergyWallBoundary(
FunctorPtr>&& indicator, T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
T addend = 0;
if(latticeNumber==1)
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) );
else if(latticeNumber==2)
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (-h2/kappa2) );
else if(latticeNumber==3)
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) );
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addFreeEnergyWallBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), addend, latticeNumber, includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addFreeEnergyWallBoundary(
SuperGeometry2D& superGeometry, int material, T alpha, T kappa1, T kappa2, T h1, T h2, int latticeNumber)
{
addFreeEnergyWallBoundary(superGeometry.getMaterialIndicator(material),
alpha, kappa1, kappa2, h1, h2, latticeNumber);
}
template
void sOnLatticeBoundaryCondition2D::addFreeEnergyWallBoundary(
FunctorPtr>&& indicator, T alpha,
T kappa1, T kappa2, T kappa3, T h1, T h2, T h3, int latticeNumber)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
T addend = 0;
if(latticeNumber==1)
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (h2/kappa2) + (h3/kappa3) );
else if(latticeNumber==2)
addend = 1./(alpha*alpha) * ( (h1/kappa1) + (-h2/kappa2) );
else if(latticeNumber==3)
addend = 1./(alpha*alpha) * ( (h3/kappa3) );
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addFreeEnergyWallBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), addend, latticeNumber, includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addFreeEnergyWallBoundary(
SuperGeometry2D& superGeometry, int material, T alpha,
T kappa1, T kappa2, T kappa3, T h1, T h2, T h3, int latticeNumber)
{
addFreeEnergyWallBoundary(superGeometry.getMaterialIndicator(material),
alpha, kappa1, kappa2, kappa3, h1, h2, h3, latticeNumber);
}
template
void sOnLatticeBoundaryCondition2D::addFreeEnergyInletBoundary(
FunctorPtr>&& indicator, T omega, std::string type, int latticeNumber)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addFreeEnergyInletBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), omega, type, latticeNumber, includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addFreeEnergyInletBoundary(
SuperGeometry2D& superGeometry, int material, T omega, std::string type, int latticeNumber)
{
addFreeEnergyInletBoundary(superGeometry.getMaterialIndicator(material), omega, type, latticeNumber);
}
template
void sOnLatticeBoundaryCondition2D::addFreeEnergyOutletBoundary(
FunctorPtr>&& indicator, T omega, std::string type, int latticeNumber)
{
bool includeOuterCells = false;
if (indicator->getSuperGeometry().getOverlap() == 1) {
includeOuterCells = true;
clout << "WARNING: overlap == 1, boundary conditions set on overlap despite unknown neighbor materials" << std::endl;
}
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
_blockBCs[iCloc]->addFreeEnergyOutletBoundary(
indicator->getExtendedBlockIndicatorF(iCloc), omega, type, latticeNumber, includeOuterCells);
}
addPoints2CommBC(std::forward(indicator));
}
template
void sOnLatticeBoundaryCondition2D::addFreeEnergyOutletBoundary(
SuperGeometry2D& superGeometry, int material, T omega, std::string type, int latticeNumber)
{
addFreeEnergyOutletBoundary(superGeometry.getMaterialIndicator(material), omega, type, latticeNumber);
}
template
void sOnLatticeBoundaryCondition2D::addPoints2CommBC(
FunctorPtr>&& indicator)
{
if (_overlap == 0) {
return;
}
SuperGeometry2D& superGeometry = indicator->getSuperGeometry();
for (int iCloc = 0; iCloc < _sLattice.getLoadBalancer().size(); ++iCloc) {
const int nX = superGeometry.getBlockGeometry(iCloc).getNx();
const int nY = superGeometry.getBlockGeometry(iCloc).getNy();
for (int iX = -_overlap; iX < nX+_overlap; ++iX) {
for (int iY = -_overlap; iY < nY+_overlap; ++iY) {
if (iX < 0 || iX > nX - 1 ||
iY < 0 || iY > nY - 1 ) { // if within overlap
if (superGeometry.getBlockGeometry(iCloc).getMaterial(iX,iY) != 0) {
bool found = false;
for (int iXo = -_overlap; iXo <= _overlap && !found; ++iXo) {
for (int iYo = -_overlap; iYo <= _overlap && !found; ++iYo) {
const int nextX = iXo + iX;
const int nextY = iYo + iY;
if (indicator->getBlockIndicatorF(iCloc)(nextX, nextY)) {
_sLattice.get_commBC().add_cell(iCloc, iX, iY);
found = true;
}
}
}
}
}
}
}
}
}
template
void sOnLatticeBoundaryCondition2D::addPoints2CommBC(
SuperGeometry2D& superGeometry, int material)
{
addPoints2CommBC(superGeometry.getMaterialIndicator(material));
}
////////////////// Factory functions //////////////////////////////////
template
void createLocalBoundaryCondition2D(
sOnLatticeBoundaryCondition2D& sBC)
{
int nC = sBC.getSuperLattice().getLoadBalancer().size();
sBC.setOverlap(0);
for (int iC = 0; iC < nC; iC++) {
OnLatticeBoundaryCondition2D* blockBC =
createLocalBoundaryCondition2D(
sBC.getSuperLattice().getExtendedBlockLattice(iC));
sBC.getBlockBCs().push_back(blockBC);
}
}
template
void createInterpBoundaryCondition2D(
sOnLatticeBoundaryCondition2D& sBC)
{
int nC = sBC.getSuperLattice().getLoadBalancer().size();
sBC.setOverlap(1);
for (int iC = 0; iC < nC; iC++) {
OnLatticeBoundaryCondition2D* blockBC =
createInterpBoundaryCondition2D(
sBC.getSuperLattice().getExtendedBlockLattice(iC));
sBC.getBlockBCs().push_back(blockBC);
}
}
template
void createExtFdBoundaryCondition2D(
sOnLatticeBoundaryCondition2D& sBC)
{
int nC = sBC.getSuperLattice().getLoadBalancer().size();
sBC.setOverlap(1);
for (int iC = 0; iC < nC; iC++) {
OnLatticeBoundaryCondition2D* blockBC =
createExtendedFdBoundaryCondition2D(
sBC.getSuperLattice().getExtendedBlockLattice(iC));
sBC.getBlockBCs().push_back(blockBC);
}
}
//////////////// Output functions //////////////////////////////////
template
void sOnLatticeBoundaryCondition2D::outputOn()
{
_output = true;
int nC = _sLattice.getLoadBalancer().size();
for (int iCloc = 0; iCloc < nC; iCloc++) {
_blockBCs[iCloc]->outputOn();
}
}
template
void sOnLatticeBoundaryCondition2D::outputOff()
{
_output = false;
int nC = _sLattice.getLoadBalancer().size();
for (int iCloc = 0; iCloc < nC; iCloc++) {
_blockBCs[iCloc]->outputOff();
}
}
} // namespace olb
#endif