/* This file is part of the OpenLB library
*
* Copyright (C) 2008 Orestis Malaspinas, Andrea Parmigiani
* 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 -- header file.
*/
#ifndef ADVECTION_DIFFUSION_BOUNDARY_INSTANTIATOR_2D_H
#define ADVECTION_DIFFUSION_BOUNDARY_INSTANTIATOR_2D_H
#include "advectionDiffusionBoundaryCondition2D.h"
#include "advectionDiffusionBoundaryCondition2D.hh"
#include "functors/lattice/indicator/blockIndicatorF2D.h"
namespace olb {
template
class AdvectionDiffusionBoundaryConditionInstantiator2D : public OnLatticeAdvectionDiffusionBoundaryCondition2D {
public:
AdvectionDiffusionBoundaryConditionInstantiator2D( BlockLatticeStructure2D& block_ );
~AdvectionDiffusionBoundaryConditionInstantiator2D() override;
void addTemperatureBoundary0N(int x0, int x1, int y0, int y1, T omega) override;
void addTemperatureBoundary0P(int x0, int x1, int y0, int y1, T omega) override;
void addTemperatureBoundary1N(int x0, int x1, int y0, int y1, T omega) override;
void addTemperatureBoundary1P(int x0, int x1, int y0, int y1, T omega) override;
void addTemperatureCornerNN(int x, int y, T omega) override;
void addTemperatureCornerNP(int x, int y, T omega) override;
void addTemperatureCornerPN(int x, int y, T omega) override;
void addTemperatureCornerPP(int x, int y, T omega) override;
virtual BlockLatticeStructure2D& getBlock();
virtual BlockLatticeStructure2D const& getBlock() const;
void addTemperatureBoundary(BlockIndicatorF2D& indicator, int x0, int x1, int y0, int y1, T omega) override;
void addRegularizedTemperatureBoundary(BlockIndicatorF2D& indicator, int x0, int x1, int y0, int y1, T omega) override;
void addRegularizedTemperatureBoundary(BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1, T omega) override;
void addRegularizedTemperatureBoundary(BlockIndicatorF2D& indicator, T omega) override;
void addRegularizedTemperatureBoundary(BlockGeometryStructure2D& blockGeometryStructure, int material, T omega) override;
void addRegularizedHeatFluxBoundary(BlockIndicatorF2D& indicator, int x0, int x1, int y0, int y1, T omega, T *heatFlux) override;
void addRegularizedHeatFluxBoundary(BlockGeometryStructure2D& blockGeometryStructure, int material, int x0, int x1, int y0, int y1, T omega, T *heatFlux) override;
void addRegularizedHeatFluxBoundary(BlockIndicatorF2D& indicator, T omega, T *heatFlux) override;
void addRegularizedHeatFluxBoundary(BlockGeometryStructure2D& blockGeometryStructure, int material, T omega, T *heatFlux) override;
private:
template
void addTemperatureBoundary(int x0, int x1, int y0, int y1, T omega);
template
void addTemperatureCorner(int x, int y, T omega);
template
void addRegularizedTemperatureBoundary(int x0, int x1, int y0, int y1, T omega);
template
void addRegularizedTemperatureCorner(int x, int y, T omega);
template
void addRegularizedHeatFluxBoundary(int x0, int x1, int y0, int y1, T omega, T *heatFlux);
template
void addRegularizedHeatFluxCorner(int x, int y, T omega);
BlockLatticeStructure2D& block;
std::vector*> momentaVector;
std::vector*> dynamicsVector;
};
///////// class AdvectionDiffusionBoundaryConditionInstantiator2D ////////////////////////
template
AdvectionDiffusionBoundaryConditionInstantiator2D::AdvectionDiffusionBoundaryConditionInstantiator2D (
BlockLatticeStructure2D& block_)
: block(block_)
{ }
template
AdvectionDiffusionBoundaryConditionInstantiator2D::~AdvectionDiffusionBoundaryConditionInstantiator2D()
{
for (unsigned iDynamics=0; iDynamics
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureBoundary(int x0, int x1, int y0, int y1, T omega)
{
OLB_PRECONDITION(x0==x1 || y0==y1);
for (int iX=x0; iX<=x1; ++iX) {
for (int iY=y0; iY<=y1; ++iY) {
Momenta* momenta
= BoundaryManager::template getTemperatureBoundaryMomenta();
Dynamics* dynamics
= BoundaryManager::template getTemperatureBoundaryDynamics(omega, *momenta);
this->getBlock().defineDynamics(iX,iX,iY,iY, dynamics);
momentaVector.push_back(momenta);
dynamicsVector.push_back(dynamics);
}
}
PostProcessorGenerator2D* postProcessor
= BoundaryManager::template getTemperatureBoundaryProcessor(x0,x1, y0,y1);
if (postProcessor) {
this->getBlock().addPostProcessor(*postProcessor);
}
}
template
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureCorner(int x, int y, T omega)
{
Momenta* momenta
= BoundaryManager::template getTemperatureCornerMomenta();
Dynamics* dynamics
= BoundaryManager::template getTemperatureCornerDynamics(omega, *momenta);
this->getBlock().defineDynamics(x,x,y,y, dynamics);
PostProcessorGenerator2D* postProcessor
= BoundaryManager::template getTemperatureCornerProcessor(x, y);
if (postProcessor) {
this->getBlock().addPostProcessor(*postProcessor);
}
}
template
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedTemperatureBoundary(int x0, int x1, int y0, int y1, T omega)
{
OLB_PRECONDITION(x0==x1 || y0==y1);
for (int iX=x0; iX<=x1; ++iX) {
for (int iY=y0; iY<=y1; ++iY) {
Momenta* momenta
= BoundaryManager::template getRegularizedTemperatureBoundaryMomenta();
Dynamics* dynamics
= BoundaryManager::template getRegularizedTemperatureBoundaryDynamics(omega, *momenta);
this->getBlock().defineDynamics(iX,iX,iY,iY, dynamics);
momentaVector.push_back(momenta);
dynamicsVector.push_back(dynamics);
}
}
PostProcessorGenerator2D* postProcessor
= BoundaryManager::template getRegularizedTemperatureBoundaryProcessor(x0,x1, y0,y1);
if (postProcessor) {
this->getBlock().addPostProcessor(*postProcessor);
}
}
template
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedTemperatureCorner(int x, int y, T omega)
{
Momenta* momenta
= BoundaryManager::template getRegularizedTemperatureCornerMomenta();
Dynamics* dynamics
= BoundaryManager::template getRegularizedTemperatureCornerDynamics(omega, *momenta);
this->getBlock().defineDynamics(x,x,y,y, dynamics);
PostProcessorGenerator2D* postProcessor
= BoundaryManager::template getRegularizedTemperatureCornerProcessor(x, y);
if (postProcessor) {
this->getBlock().addPostProcessor(*postProcessor);
}
}
template
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedHeatFluxBoundary(int x0, int x1, int y0, int y1, T omega, T *heatFlux)
{
OLB_PRECONDITION(x0==x1 || y0==y1);
for (int iX=x0; iX<=x1; ++iX) {
for (int iY=y0; iY<=y1; ++iY) {
Momenta* momenta
= BoundaryManager::template getRegularizedHeatFluxBoundaryMomenta(heatFlux);
Dynamics* dynamics
= BoundaryManager::template getRegularizedHeatFluxBoundaryDynamics(omega, *momenta);
this->getBlock().defineDynamics(iX,iX,iY,iY, dynamics);
momentaVector.push_back(momenta);
dynamicsVector.push_back(dynamics);
}
}
PostProcessorGenerator2D* postProcessor
= BoundaryManager::template getRegularizedHeatFluxBoundaryProcessor(x0,x1, y0,y1);
if (postProcessor) {
this->getBlock().addPostProcessor(*postProcessor);
}
}
template
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedHeatFluxCorner(int x, int y, T omega)
{
Momenta* momenta
= BoundaryManager::template getRegularizedHeatFluxCornerMomenta();
Dynamics* dynamics
= BoundaryManager::template getRegularizedHeatFluxCornerDynamics(omega, *momenta);
this->getBlock().defineDynamics(x,x,y,y, dynamics);
PostProcessorGenerator2D* postProcessor
= BoundaryManager::template getRegularizedHeatFluxCornerProcessor(x, y);
if (postProcessor) {
this->getBlock().addPostProcessor(*postProcessor);
}
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureBoundary(BlockIndicatorF2D& indicator,
int x0, int x1, int y0, int y1, T omega)
{
std::vector discreteNormal(3,0);
for (int iX = x0; iX <= x1; ++iX) {
for (int iY = y0; iY <= y1; ++iY) {
if (indicator(iX, iY)) {
discreteNormal = indicator.getBlockGeometryStructure().getStatistics().getType(iX,iY);
if (discreteNormal[0] == 0) {
if (discreteNormal[1] == 1) {
addTemperatureBoundary<0,1>(iX,iX,iY,iY, omega);
}
else if (discreteNormal[1] == -1) {
addTemperatureBoundary<0,-1>(iX,iX,iY,iY, omega);
}
else if (discreteNormal[2] == 1) {
addTemperatureBoundary<1,1>(iX,iX,iY,iY, omega);
}
else if (discreteNormal[2] == -1) {
addTemperatureBoundary<1,-1>(iX,iX,iY,iY, omega);
}
}
else if (discreteNormal[0] == 1) {
if (discreteNormal[1] == 1 && discreteNormal[2] == 1) {
addTemperatureCorner<1,1>(iX,iY, omega);
}
else if (discreteNormal[1] == 1 && discreteNormal[2] == -1) {
addTemperatureCorner<1,-1>(iX,iY, omega);
}
else if (discreteNormal[1] == -1 && discreteNormal[2] == 1) {
addTemperatureCorner<-1,1>(iX,iY, omega);
}
else if (discreteNormal[1] == -1 && discreteNormal[2] == -1) {
addTemperatureCorner<-1,-1>(iX,iY, omega);
}
}
}
}
}
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedTemperatureBoundary(BlockIndicatorF2D& indicator,
int x0, int x1, int y0, int y1, T omega)
{
std::vector discreteNormal(3,0);
for (int iX = x0; iX <= x1; ++iX) {
for (int iY = y0; iY <= y1; ++iY) {
if (indicator(iX, iY)) {
discreteNormal = indicator.getBlockGeometryStructure().getStatistics().getType(iX,iY);
// cout << discreteNormal[0] << " " << discreteNormal[1] << " " << discreteNormal[2] << endl;
if (discreteNormal[0] == 0) {
if (discreteNormal[1] == 1) {
addRegularizedTemperatureBoundary<0,1>(iX,iX,iY,iY, omega);
}
else if (discreteNormal[1] == -1) {
addRegularizedTemperatureBoundary<0,-1>(iX,iX,iY,iY, omega);
}
else if (discreteNormal[2] == 1) {
addRegularizedTemperatureBoundary<1,1>(iX,iX,iY,iY, omega);
}
else if (discreteNormal[2] == -1) {
addRegularizedTemperatureBoundary<1,-1>(iX,iX,iY,iY, omega);
}
}
else if (discreteNormal[0] == 1) {
if (discreteNormal[1] == 1 && discreteNormal[2] == 1) {
addRegularizedTemperatureCorner<1,1>(iX,iY, omega);
}
else if (discreteNormal[1] == 1 && discreteNormal[2] == -1) {
addRegularizedTemperatureCorner<1,-1>(iX,iY, omega);
}
else if (discreteNormal[1] == -1 && discreteNormal[2] == 1) {
addRegularizedTemperatureCorner<-1,1>(iX,iY, omega);
}
else if (discreteNormal[1] == -1 && discreteNormal[2] == -1) {
addRegularizedTemperatureCorner<-1,-1>(iX,iY, omega);
}
}
}
}
}
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedTemperatureBoundary(BlockGeometryStructure2D& blockGeometryStructure, int material,
int x0, int x1, int y0, int y1, T omega)
{
BlockIndicatorMaterial2D indicator(blockGeometryStructure, material);
addRegularizedTemperatureBoundary(indicator, x0, x1, y0, y1, omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedTemperatureBoundary(BlockIndicatorF2D& indicator, T omega)
{
auto& blockGeometryStructure = indicator.getBlockGeometryStructure();
addRegularizedTemperatureBoundary(indicator,
0, blockGeometryStructure.getNx()-1,
0, blockGeometryStructure.getNy()-1,
omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedTemperatureBoundary(BlockGeometryStructure2D& blockGeometryStructure, int material, T omega)
{
BlockIndicatorMaterial2D indicator(blockGeometryStructure, material);
addRegularizedTemperatureBoundary(indicator,
0, blockGeometryStructure.getNx()-1,
0, blockGeometryStructure.getNy()-1,
omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedHeatFluxBoundary(BlockIndicatorF2D& indicator,
int x0, int x1, int y0, int y1, T omega, T *heatFlux)
{
std::vector discreteNormal(3,0);
for (int iX = x0; iX <= x1; ++iX) {
for (int iY = y0; iY <= y1; ++iY) {
if (indicator(iX, iY)) {
discreteNormal = indicator.getBlockGeometryStructure().getStatistics().getType(iX,iY);
// cout << discreteNormal[0] << " " << discreteNormal[1] << " " << discreteNormal[2] << endl;
if (discreteNormal[0] == 0) {
if (discreteNormal[1] == 1) {
addRegularizedHeatFluxBoundary<0,1>(iX,iX,iY,iY, omega, heatFlux);
}
else if (discreteNormal[1] == -1) {
addRegularizedHeatFluxBoundary<0,-1>(iX,iX,iY,iY, omega, heatFlux);
}
else if (discreteNormal[2] == 1) {
addRegularizedHeatFluxBoundary<1,1>(iX,iX,iY,iY, omega, heatFlux);
}
else if (discreteNormal[2] == -1) {
addRegularizedHeatFluxBoundary<1,-1>(iX,iX,iY,iY, omega, heatFlux);
}
}
else if (discreteNormal[0] == 1) {
if (discreteNormal[1] == 1 && discreteNormal[2] == 1) {
addRegularizedHeatFluxCorner<1,1>(iX,iY, omega);
}
else if (discreteNormal[1] == 1 && discreteNormal[2] == -1) {
addRegularizedHeatFluxCorner<1,-1>(iX,iY, omega);
}
else if (discreteNormal[1] == -1 && discreteNormal[2] == 1) {
addRegularizedHeatFluxCorner<-1,1>(iX,iY, omega);
}
else if (discreteNormal[1] == -1 && discreteNormal[2] == -1) {
addRegularizedHeatFluxCorner<-1,-1>(iX,iY, omega);
}
}
}
}
}
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedHeatFluxBoundary(BlockGeometryStructure2D& blockGeometryStructure, int material,
int x0, int x1, int y0, int y1, T omega, T *heatFlux)
{
BlockIndicatorMaterial2D indicator(blockGeometryStructure, material);
addRegularizedHeatFluxBoundary(indicator, x0, x1, y0, y1, omega, heatFlux);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedHeatFluxBoundary(BlockIndicatorF2D& indicator, T omega, T *heatFlux)
{
auto& blockGeometryStructure = indicator.getBlockGeometryStructure();
addRegularizedHeatFluxBoundary(indicator,
0, blockGeometryStructure.getNx()-1,
0, blockGeometryStructure.getNy()-1,
omega, heatFlux);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addRegularizedHeatFluxBoundary(BlockGeometryStructure2D& blockGeometryStructure, int material, T omega, T *heatFlux)
{
BlockIndicatorMaterial2D indicator(blockGeometryStructure, material);
addRegularizedHeatFluxBoundary(indicator,
0, blockGeometryStructure.getNx()-1,
0, blockGeometryStructure.getNy()-1,
omega, heatFlux);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureBoundary0N(int x0, int x1, int y0, int y1, T omega)
{
addTemperatureBoundary<0,-1>(x0,x1,y0,y1, omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureBoundary0P(int x0, int x1, int y0, int y1, T omega)
{
addTemperatureBoundary<0,1>(x0,x1,y0,y1, omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureBoundary1N(int x0, int x1, int y0, int y1, T omega)
{
addTemperatureBoundary<1,-1>(x0,x1,y0,y1, omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureBoundary1P(int x0, int x1, int y0, int y1, T omega)
{
addTemperatureBoundary<1,1>(x0,x1,y0,y1, omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureCornerNN(int x, int y, T omega)
{
addTemperatureCorner<-1,-1>(x,y, omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureCornerNP(int x, int y, T omega)
{
addTemperatureCorner<-1,1>(x,y, omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureCornerPN(int x, int y, T omega)
{
addTemperatureCorner<1,-1>(x,y, omega);
}
template
void AdvectionDiffusionBoundaryConditionInstantiator2D::
addTemperatureCornerPP(int x, int y, T omega)
{
addTemperatureCorner<1,1>(x,y, omega);
}
template
BlockLatticeStructure2D& AdvectionDiffusionBoundaryConditionInstantiator2D::getBlock()
{
return block;
}
template
BlockLatticeStructure2D const& AdvectionDiffusionBoundaryConditionInstantiator2D::getBlock() const
{
return block;
}
}
#endif