/* This file is part of the OpenLB library
*
* Copyright (C) 2012 Jonas Kratzke, 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.
*/
#ifndef OFF_BOUNDARY_POST_PROCESSORS_2D_HH
#define OFF_BOUNDARY_POST_PROCESSORS_2D_HH
#include "offBoundaryPostProcessors2D.h"
#include "core/blockLattice2D.h"
#include "core/util.h"
#include "core/cell.h"
namespace olb {
/////////// LinearBouzidiPostProcessor2D /////////////////////////////////////
/* Bouzidi Interpolation scheme of first order
*
* fluid nodes wall solid node
* --o-------<-o->-----<-o->--|----x----
* xB x xN
* directions: --> iPop
* <-- opp
*
*/
template
ZeroVelocityBouzidiLinearPostProcessor2D::
ZeroVelocityBouzidiLinearPostProcessor2D(int x_, int y_, int iPop_, T dist_)
: x(x_), y(y_), iPop(iPop_), dist(dist_)
{
#ifndef QUIET
if (dist < 0 || dist > 1)
std::cout << "WARNING: Bogus distance at (" << x << "," << y << "): "
<< dist << std::endl;
#endif
typedef DESCRIPTOR L;
opp = util::opposite(iPop);
xN = x + descriptors::c(iPop,0);
yN = y + descriptors::c(iPop,1);
if (dist >= 0.5) {
xB = x - descriptors::c(iPop,0);
yB = y - descriptors::c(iPop,1);
q = 1/(2*dist);
iPop2 = opp;
} else {
xB = x;
yB = y;
q = 2*dist;
iPop2 = iPop;
}
/*
std::cout << "ZeroVelocityLinear (" << x << "," << y << "," <<
"), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
"), opp: " << opp << ", bP: (" << xB << "," << yB << "," <<
"), dist: " << dist << ", q: " << q << std::endl;
*/
}
template
void ZeroVelocityBouzidiLinearPostProcessor2D::
processSubDomain(BlockLattice2D& blockLattice, int x0_, int x1_, int y0_, int y1_)
{
if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
process(blockLattice);
}
}
template
void ZeroVelocityBouzidiLinearPostProcessor2D::
process(BlockLattice2D& blockLattice)
{
blockLattice.get(x, y)[opp] = q*blockLattice.get(xN, yN)[iPop] +
(1-q)*blockLattice.get(xB, yB)[iPop2];
}
template
VelocityBouzidiLinearPostProcessor2D::
VelocityBouzidiLinearPostProcessor2D(int x_, int y_, int iPop_, T dist_)
: x(x_), y(y_), iPop(iPop_), dist(dist_)
{
#ifndef QUIET
if (dist < 0 || dist > 1)
std::cout << "WARNING: Bogus distance at (" << x << "," << y << "," << "): "
<< dist << std::endl;
#endif
typedef DESCRIPTOR L;
opp = util::opposite(iPop);
xN = x + descriptors::c(iPop,0);
yN = y + descriptors::c(iPop,1);
if (dist >= 0.5) {
xB = x - descriptors::c(iPop,0);
yB = y - descriptors::c(iPop,1);
q = 1/(2*dist);
ufrac = q;
iPop2 = opp;
} else {
xB = x;
yB = y;
q = 2*dist;
iPop2 = iPop;
ufrac = 1;
}
/*
std::cout << "VelocityLinear (" << x << "," << y << "," <<
"), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
"), opp: " << opp << ", bP: (" << xB << "," << yB << "," <<
"), dist: " << dist << ", q: " << q << std::endl;
*/
}
template
void VelocityBouzidiLinearPostProcessor2D::
processSubDomain(BlockLattice2D& blockLattice, int x0_, int x1_, int y0_, int y1_)
{
if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
process(blockLattice);
}
}
template
void VelocityBouzidiLinearPostProcessor2D::
process(BlockLattice2D& blockLattice)
{
Dynamics* dynamics = blockLattice.getDynamics(xN, yN);
T velCoeff = ufrac*dynamics->getVelocityCoefficient(iPop);
dynamics->defineRho( blockLattice.get(xN, yN), blockLattice.get(x, y).computeRho() );
blockLattice.get(x, y)[opp] = q*blockLattice.get(xN, yN)[iPop] +
(1-q)*blockLattice.get(xB, yB)[iPop2] + velCoeff;
}
//////// CornerBouzidiPostProcessor2D ///////////////////
template
ZeroVelocityBounceBackPostProcessor2D::
ZeroVelocityBounceBackPostProcessor2D(int x_, int y_, int iPop_, T dist_)
: x(x_), y(y_), iPop(iPop_), dist(dist_)
{
#ifndef QUIET
if (dist < 0 || dist > 1)
std::cout << "WARNING: Bogus distance at (" << x << "," << y << "," << "): "
<< dist << std::endl;
#endif
typedef DESCRIPTOR L;
opp = util::opposite(iPop);
xN = x + descriptors::c(iPop,0);
yN = y + descriptors::c(iPop,1);
/*
std::cout << "Corner (" << x << "," << y << "," <<
"), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
"), dist: " << dist << std::endl;
*/
}
template
void ZeroVelocityBounceBackPostProcessor2D::
processSubDomain(BlockLattice2D& blockLattice, int x0_, int x1_, int y0_, int y1_)
{
if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
process(blockLattice);
}
}
template
void ZeroVelocityBounceBackPostProcessor2D::
process(BlockLattice2D& blockLattice)
{
blockLattice.get(x, y)[opp] = blockLattice.get(xN, yN)[iPop];
}
template
VelocityBounceBackPostProcessor2D::
VelocityBounceBackPostProcessor2D(int x_, int y_, int iPop_, T dist_)
: x(x_), y(y_), iPop(iPop_), dist(dist_)
{
#ifndef QUIET
if (dist < 0 || dist > 1)
std::cout << "WARNING: Bogus distance at (" << x << "," << y << "," << "): "
<< dist << std::endl;
#endif
typedef DESCRIPTOR L;
opp = util::opposite(iPop);
xN = x + descriptors::c(iPop,0);
yN = y + descriptors::c(iPop,1);
/*
std::cout << "Corner (" << x << "," << y << "," <<
"), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
"), dist: " << dist << std::endl;
*/
}
template
void VelocityBounceBackPostProcessor2D::
processSubDomain(BlockLattice2D& blockLattice, int x0_, int x1_, int y0_, int y1_)
{
if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
process(blockLattice);
}
}
template
void VelocityBounceBackPostProcessor2D::
process(BlockLattice2D& blockLattice)
{
Dynamics* dynamics = blockLattice.getDynamics(xN, yN);
T velCoeff = dynamics->getVelocityCoefficient(iPop);
dynamics->defineRho( blockLattice.get(xN, yN), blockLattice.get(x, y).computeRho() );
blockLattice.get(x, y)[opp] = blockLattice.get(xN, yN)[iPop] + velCoeff;
}
template
AntiBounceBackPostProcessor2D::
AntiBounceBackPostProcessor2D(int x_, int y_, int iPop_)
: x(x_), y(y_), iPop(iPop_)
{
typedef DESCRIPTOR L;
opp = util::opposite(iPop);
xN = x + descriptors::c(iPop,0);
yN = y + descriptors::c(iPop,1);
/*
std::cout << "Corner (" << x << "," << y << "," <<
"), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
"), dist: " << dist << std::endl;
*/
}
template
void AntiBounceBackPostProcessor2D::
processSubDomain(BlockLattice2D& blockLattice, int x0_, int x1_, int y0_, int y1_)
{
if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
process(blockLattice);
}
}
template
void AntiBounceBackPostProcessor2D::
process(BlockLattice2D& blockLattice)
{
/*Dynamics* dynamics = blockLattice.getDynamics(xN, yN);
T velCoeff = dynamics->getVelocityCoefficient(iPop);
dynamics->defineRho( blockLattice.get(xN, yN), blockLattice.get(x, y).computeRho() );*/
if (descriptors::c(iPop,1)==0) {
blockLattice.get(x, y)[opp] = -blockLattice.get(xN, yN)[iPop]; // + velCoeff;
}
//std::cout << "here" << std::endl;
}
template
BoundaryStreamPostProcessor2D::
BoundaryStreamPostProcessor2D(int x_, int y_, const bool streamDirection[DESCRIPTOR::q])
: x(x_), y(y_)
{
for (int iPop = 0; iPop < DESCRIPTOR::q ; ++iPop) {
this->_streamDirections[iPop] = streamDirection[iPop];
}
}
template
void BoundaryStreamPostProcessor2D::
processSubDomain(BlockLattice2D& blockLattice, int x0_, int x1_, int y0_, int y1_)
{
if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
process(blockLattice);
}
}
template
void BoundaryStreamPostProcessor2D::
process(BlockLattice2D& blockLattice)
{
for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
if (_streamDirections[iPop]) {
blockLattice.get(x + descriptors::c(iPop,0), y + descriptors::c(iPop,1))[iPop] = blockLattice.get(x, y)[iPop];
}
}
}
//////// LinearBouzidiBoundaryPostProcessorGenerator ////////////////////////////////
template
ZeroVelocityBouzidiLinearPostProcessorGenerator2D::
ZeroVelocityBouzidiLinearPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
: PostProcessorGenerator2D(x_, x_, y_, y_),
x(x_), y(y_), iPop(iPop_), dist(dist_)
{ }
template
PostProcessor2D*
ZeroVelocityBouzidiLinearPostProcessorGenerator2D::generate() const
{
return new ZeroVelocityBouzidiLinearPostProcessor2D
( this->x, this->y, this->iPop, this->dist);
}
template
PostProcessorGenerator2D*
ZeroVelocityBouzidiLinearPostProcessorGenerator2D::clone() const
{
return new ZeroVelocityBouzidiLinearPostProcessorGenerator2D
(this->x, this->y, this->iPop, this->dist);
}
template
VelocityBouzidiLinearPostProcessorGenerator2D::
VelocityBouzidiLinearPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
: PostProcessorGenerator2D(x_, x_, y_, y_),
x(x_), y(y_), iPop(iPop_), dist(dist_)
{ }
template
PostProcessor2D*
VelocityBouzidiLinearPostProcessorGenerator2D::generate() const
{
return new VelocityBouzidiLinearPostProcessor2D
( this->x, this->y, this->iPop, this->dist);
}
template
PostProcessorGenerator2D*
VelocityBouzidiLinearPostProcessorGenerator2D::clone() const
{
return new VelocityBouzidiLinearPostProcessorGenerator2D
(this->x, this->y, this->iPop, this->dist);
}
/////////// CornerBouzidiBoundaryPostProcessorGenerator /////////////////////////////////////
template
ZeroVelocityBounceBackPostProcessorGenerator2D::
ZeroVelocityBounceBackPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
: PostProcessorGenerator2D(x_, x_, y_, y_),
x(x_), y(y_), iPop(iPop_), dist(dist_)
{ }
template
PostProcessor2D*
ZeroVelocityBounceBackPostProcessorGenerator2D::generate() const
{
return new ZeroVelocityBounceBackPostProcessor2D
( this->x, this->y, this->iPop, this->dist);
}
template
PostProcessorGenerator2D*
ZeroVelocityBounceBackPostProcessorGenerator2D::clone() const
{
return new ZeroVelocityBounceBackPostProcessorGenerator2D
(this->x, this->y, this->iPop, this->dist);
}
template
VelocityBounceBackPostProcessorGenerator2D::
VelocityBounceBackPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
: PostProcessorGenerator2D(x_, x_, y_, y_),
x(x_), y(y_), iPop(iPop_), dist(dist_)
{ }
template
PostProcessor2D*
VelocityBounceBackPostProcessorGenerator2D::generate() const
{
return new VelocityBounceBackPostProcessor2D
( this->x, this->y, this->iPop, this->dist);
}
template
PostProcessorGenerator2D*
VelocityBounceBackPostProcessorGenerator2D::clone() const
{
return new VelocityBounceBackPostProcessorGenerator2D
(this->x, this->y, this->iPop, this->dist);
}
template
AntiBounceBackPostProcessorGenerator2D::
AntiBounceBackPostProcessorGenerator2D(int x_, int y_, int iPop_)
: PostProcessorGenerator2D(x_, x_, y_, y_),
x(x_), y(y_), iPop(iPop_)
{ }
template
PostProcessor2D*
AntiBounceBackPostProcessorGenerator2D::generate() const
{
return new AntiBounceBackPostProcessor2D
( this->x, this->y, this->iPop);
}
template
PostProcessorGenerator2D*
AntiBounceBackPostProcessorGenerator2D::clone() const
{
return new AntiBounceBackPostProcessorGenerator2D
(this->x, this->y, this->iPop);
}
template
BoundaryStreamPostProcessorGenerator2D::
BoundaryStreamPostProcessorGenerator2D(int x_, int y_, const bool streamDirections[DESCRIPTOR::q])
: PostProcessorGenerator2D(x_, x_, y_, y_),
x(x_), y(y_)
{
for (int iPop = 0; iPop < DESCRIPTOR::q ; ++iPop) {
this->_streamDirections[iPop] = streamDirections[iPop];
}
}
template
PostProcessor2D*
BoundaryStreamPostProcessorGenerator2D::generate() const
{
return new BoundaryStreamPostProcessor2D
( this->x, this->y, this->_streamDirections);
}
template
PostProcessorGenerator2D*
BoundaryStreamPostProcessorGenerator2D::clone() const
{
return new BoundaryStreamPostProcessorGenerator2D
(this->x, this->y, this->_streamDirections);
}
} // namespace olb
#endif