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 --- src/core/blockLatticeView3D.hh | 346 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 346 insertions(+) create mode 100644 src/core/blockLatticeView3D.hh (limited to 'src/core/blockLatticeView3D.hh') diff --git a/src/core/blockLatticeView3D.hh b/src/core/blockLatticeView3D.hh new file mode 100644 index 0000000..b94563d --- /dev/null +++ b/src/core/blockLatticeView3D.hh @@ -0,0 +1,346 @@ +/* This file is part of the OpenLB library + * + * Copyright (C) 2006, 2007, 2008 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 + * Dynamics for a generic 3D block lattice view -- generic implementation. + */ +#ifndef BLOCK_LATTICE_VIEW_3D_HH +#define BLOCK_LATTICE_VIEW_3D_HH + +#include "blockLatticeView3D.h" +#include "cell.h" +#include "functors/lattice/indicator/blockIndicatorF3D.h" + +namespace olb { + +////////////////////// Class BlockLatticeView3D ///////////////////////// + +template +BlockLatticeView3D::BlockLatticeView3D(BlockLatticeStructure3D& originalLattice_) + : BlockLatticeStructure3D(originalLattice_.getNx(), + originalLattice_.getNy(), + originalLattice_.getNz()), + originalLattice(&originalLattice_), x0(0), y0(0), z0(0) +{ } + +template +BlockLatticeView3D::BlockLatticeView3D ( + BlockLatticeStructure3D& originalLattice_, + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_ ) + : BlockLatticeStructure3D(x1_-x0_+1, y1_-y0_+1, z1_-z0_+1), + originalLattice(&originalLattice_), x0(x0_), y0(y0_), z0(z0_) +{ + OLB_PRECONDITION(x0 < originalLattice->getNx()); + // OLB_PRECONDITION(nx >= 1); + OLB_PRECONDITION(y0 < originalLattice->getNy()); + // OLB_PRECONDITION(ny >= 1); + OLB_PRECONDITION(z0 < originalLattice->getNz()); + // OLB_PRECONDITION(nz >= 1); +} + +template +BlockLatticeView3D::~BlockLatticeView3D() +{ +} + +template +BlockLatticeView3D::BlockLatticeView3D(BlockLatticeView3D const& rhs) + : BlockLatticeStructure3D(rhs._nx,rhs._ny,rhs._nz), originalLattice(rhs.originalLattice), + x0(rhs.x0), y0(rhs.y0), z0(rhs.z0) +{ } + +template +BlockLatticeView3D& BlockLatticeView3D::operator= ( + BlockLatticeView3D const& rhs ) +{ + BlockLatticeView3D tmp(rhs); + swap(tmp); + return *this; +} + +template +void BlockLatticeView3D::swap ( + BlockLatticeView3D& rhs) +{ + std::swap(this->_nx, rhs._nx); + std::swap(this->_ny, rhs._ny); + std::swap(this->_nz, rhs._nz); + std::swap(x0, rhs.x0); + std::swap(y0, rhs.y0); + std::swap(z0, rhs.z0); + std::swap(originalLattice, rhs.originalLattice); +} + +template +Cell& BlockLatticeView3D::get(int iX, int iY, int iZ) +{ + OLB_PRECONDITION(iXgetNx()); + OLB_PRECONDITION(iYgetNy()); + OLB_PRECONDITION(iZgetNz()); + return originalLattice->get(iX+x0, iY+y0, iZ+z0); +} + +template +Cell& BlockLatticeView3D::get(const int latticeR[]) +{ + return get(latticeR[0], latticeR[1], latticeR[2]); +} + +template +Cell const& BlockLatticeView3D::get ( + int iX, int iY, int iZ ) const +{ + OLB_PRECONDITION(iXgetNx()); + OLB_PRECONDITION(iYgetNy()); + OLB_PRECONDITION(iZgetNz()); + return originalLattice->get(iX+x0, iY+y0, iZ+z0); +} + +template +void BlockLatticeView3D::initialize() +{ + originalLattice->initialize(); +} + +template +void BlockLatticeView3D::defineDynamics ( + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, + Dynamics* dynamics ) +{ + originalLattice->defineDynamics( x0_+x0, x1_+x0, + y0_+y0, y1_+y0, + z0_+z0, z1_+z0, + dynamics ); +} + +template +void BlockLatticeView3D::defineDynamics ( + int iX, int iY, int iZ, Dynamics* dynamics ) +{ + originalLattice->defineDynamics(iX+x0, iY+y0, iZ+z0, dynamics); +} + +template +void BlockLatticeView3D::defineDynamics ( + BlockIndicatorF3D& indicator, Dynamics* dynamics) +{ + for (int iX = 0; iX < this->_nx; ++iX) { + for (int iY = 0; iY < this->_ny; ++iY) { + for (int iZ = 0; iZ < this->_nz; ++iZ) { + if (indicator(iX, iY, iZ)) { + defineDynamics(iX, iY, iZ, dynamics); + } + } + } + } +} + +template +void BlockLatticeView3D::defineDynamics ( + BlockGeometryStructure3D& blockGeometry, int material, Dynamics* dynamics) +{ + BlockIndicatorMaterial3D indicator(blockGeometry, std::vector(1, material)); + defineDynamics(indicator, dynamics); +} + +template +Dynamics* BlockLatticeView3D::getDynamics ( + int iX, int iY, int iZ) +{ + return originalLattice->getDynamics(iX+x0, iY+y0, iZ+z0); +} + +template +void BlockLatticeView3D::collide ( + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_ ) +{ + originalLattice->collide( x0_+x0, x1_+x0, + y0_+y0, y1_+y0, + z0_+z0, z1_+z0 ); + +} + +template +void BlockLatticeView3D::collide() +{ + originalLattice->collide( x0, x0+this->_nx-1, y0, y0+this->_ny-1, z0, z0+this->_nz-1); +} + +template +void BlockLatticeView3D::stream(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) +{ + originalLattice->stream( x0_+x0, x1_+x0, + y0_+y0, y1_+y0, + z0_+z0, z1_+z0 ); +} + +template +void BlockLatticeView3D::stream(bool periodic) +{ + OLB_PRECONDITION(!periodic); + originalLattice->stream( x0, x0+this->_nx-1, y0, y0+this->_ny-1, z0, z0+this->_nz-1); + postProcess(); +} + +template +void BlockLatticeView3D::collideAndStream ( + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_ ) +{ + originalLattice->collideAndStream( x0_+x0, x1_+x0, + y0_+y0, y1_+y0, + z0_+z0, z1_+z0 ); +} + +template +void BlockLatticeView3D::collideAndStream(bool periodic) +{ + OLB_PRECONDITION(!periodic); + originalLattice->collideAndStream(x0, x0+this->_nx-1, y0, y0+this->_ny-1, z0, z0+this->_nz-1); + postProcess(); +} + +template +T BlockLatticeView3D::computeAverageDensity ( + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_ ) const +{ + return originalLattice->computeAverageDensity( x0_+x0, x1_+x0, + y0_+y0, y1_+y0, + z0_+z0, z1_+z0 ); +} + +template +T BlockLatticeView3D::computeAverageDensity() const +{ + return originalLattice->computeAverageDensity ( + x0, x0+this->_nx-1, y0, y0+this->_ny-1, z0, z0+this->_nz-1 ); +} + +template +void BlockLatticeView3D::computeStress(int iX, int iY, int iZ, + T pi[util::TensorVal::n]) +{ + originalLattice->computeStress(iX + x0, iY + y0, iZ + z0, pi); +} + +template +void BlockLatticeView3D::stripeOffDensityOffset ( + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, T offset ) +{ + originalLattice->stripeOffDensityOffset( x0_+x0, x1_+x0, + y0_+y0, y1_+y0, + z0_+z0, z1_+z0, offset); +} + +template +void BlockLatticeView3D::stripeOffDensityOffset(T offset) +{ + originalLattice->stripeOffDensityOffset ( + x0, x0+this->_nx-1, y0, y0+this->_ny-1, z0, z0+this->_nz-1, offset); +} + +template +void BlockLatticeView3D::forAll ( + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, + WriteCellFunctional const& application ) +{ + originalLattice->forAll( x0_+x0, x1_+x0, + y0_+y0, y1_+y0, + z0_+z0, z1_+z0, application); +} + +template +void BlockLatticeView3D::forAll(WriteCellFunctional const& application) +{ + originalLattice->forAll ( + x0, x0+this->_nx-1, y0, y0+this->_ny-1, z0, z0+this->_nz-1, application ); +} + +template +void BlockLatticeView3D::addPostProcessor ( + PostProcessorGenerator3D const& ppGen ) +{ + PostProcessorGenerator3D* shiftedGen = ppGen.clone(); + shiftedGen->shift(x0,y0,z0); + originalLattice->addPostProcessor(*shiftedGen); + delete shiftedGen; +} + +template +void BlockLatticeView3D::resetPostProcessors() +{ + originalLattice->resetPostProcessors(); +} + +template +void BlockLatticeView3D::postProcess() +{ + originalLattice -> postProcess(x0, x0+this->_nx-1, y0, y0+this->_ny-1, z0, z0+this->_nz-1); +} + +template +void BlockLatticeView3D::postProcess( + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) +{ + originalLattice -> postProcess( x0_+x0, x1_+x0, y0_+y0, y1_+y0, z0_+z0, z1_+z0 ); +} + +template +void BlockLatticeView3D::addLatticeCoupling ( + LatticeCouplingGenerator3D const& lcGen, + std::vector partners ) +{ + LatticeCouplingGenerator3D* shiftedGen = lcGen.clone(); + shiftedGen->shift(x0,y0,z0); + originalLattice->addLatticeCoupling(*shiftedGen, partners); + delete shiftedGen; +} + +template +void BlockLatticeView3D::executeCoupling() +{ + originalLattice -> executeCoupling(x0, x0+this->_nx-1, y0, y0+this->_ny-1, z0, z0+this->_nz-1); +} + +template +void BlockLatticeView3D::executeCoupling( + int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) +{ + originalLattice -> executeCoupling( x0_+x0, x1_+x0, y0_+y0, y1_+y0, z0_+z0, z1_+z0 ); +} + +template +LatticeStatistics& BlockLatticeView3D:: +getStatistics() +{ + return originalLattice->getStatistics(); +} + +template +LatticeStatistics const& BlockLatticeView3D::getStatistics() const +{ + return originalLattice->getStatistics(); +} + +} // namespace olb + +#endif -- cgit v1.2.3