/* This file is part of the OpenLB library
*
* Copyright (C) 2013 Albert Mink, Lukas Baron, 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 BLOCK_BASE_F_2D_HH
#define BLOCK_BASE_F_2D_HH
#include "blockBaseF2D.h"
namespace olb {
// BlockF2D
template
BlockF2D::BlockF2D(BlockStructure2D& blockStructure, int targetDim)
: GenericF(targetDim,2), _blockStructure(&blockStructure) { }
template
BlockF2D::BlockF2D(int targetDim)
: GenericF(targetDim,2), _blockStructure(nullptr) { }
template
BlockStructure2D& BlockF2D::getBlockStructure()
{
return *_blockStructure;
}
template
void BlockF2D::setBlockStructure(BlockStructure2D* blockStructure)
{
_blockStructure = blockStructure;
}
//template
//std::vector BlockF2D::getMinValue()
//{
// T min[this->getTargetDim()];
// T minTmp[this->getTargetDim()];
// this->operator()(min,0,0);
// for (int iX = 1; iX < _blockStructure.getNx(); ++iX) {
// for (int iY = 1; iY < _blockStructure.getNy(); ++iY) {
// this->operator()(minTmp,iX,iY);
// for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
// if (min[iDim] > minTmp[iDim] ) {
// min[iDim] = minTmp[iDim];
// }
// }
// }
// }
// std::vector minV(min,min+this->getTargetDim());
// return minV;
//}
//template
//std::vector BlockF2D::getMaxValue()
//{
// T max[this->getTargetDim()];
// T maxTmp[this->getTargetDim()];
// this->operator()(max,0,0);
// for (int iX = 1; iX < _blockStructure.getNx(); ++iX) {
// for (int iY = 1; iY < _blockStructure.getNy(); ++iY) {
// this->operator()(maxTmp,iX,iY);
// for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
// if (max[iDim] > maxTmp[iDim] ) {
// max[iDim] = maxTmp[iDim];
// }
// }
// }
// }
// std::vector maxV(max,max+this->getTargetDim());
// return maxV;
//}
template
BlockDataF2D::BlockDataF2D(BlockData2D& blockData)
: BlockF2D(blockData, blockData.getSize()),
_blockData(blockData)
{ }
template
BlockDataF2D::BlockDataF2D(BlockF2D& f)
: BlockF2D(f.getBlockStructure(), f.getTargetDim()),
_blockDataStorage(new BlockData2D(f)),
_blockData(*_blockDataStorage)
{ }
template
BlockDataF2D::BlockDataF2D(int nx, int ny, int size)
// hacky solution to both managing BlockData2D using std::unique_ptr and
// passing it down the line to the base class
: BlockF2D(*(new BlockData2D(nx, ny, size)), size),
_blockDataStorage(static_cast*>(&(this->getBlockStructure()))),
_blockData(*_blockDataStorage)
{ }
template
BlockData2D& BlockDataF2D::getBlockData()
{
return _blockData;
}
template
bool BlockDataF2D::operator()(T output[], const int input[])
{
for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
output[iDim] = static_cast(_blockData.get(input[0], input[1], iDim));
}
return true;
}
template
BlockDataViewF2D::BlockDataViewF2D(BlockData2D& blockData, int overlap)
: BlockDataF2D(blockData),
_overlap(overlap)
{ }
template
bool BlockDataViewF2D::operator() (T output[], const int input[])
{
for (int iDim = 0; iDim < this->getTargetDim(); ++iDim) {
output[iDim] = this->_blockData.get(input[0] + _overlap,
input[1] + _overlap,
iDim);
}
return true;
}
// BlockIdendity2D
template
BlockIdentity2D::BlockIdentity2D(BlockF2D& f)
: BlockF2D(f.getBlockStructure() ,f.getTargetDim() ), _f(f)
{
this->getName() = _f.getName();
std::swap( _f._ptrCalcC, this->_ptrCalcC );
}
template
bool BlockIdentity2D::operator()(T output[], const int input[])
{
_f(output,input);
return true;
}
// BlockLatticeF2D
template
BlockLatticeF2D::BlockLatticeF2D
(BlockLatticeStructure2D& blockStructure, int targetDim)
: BlockF2D(blockStructure, targetDim), _blockLattice(blockStructure) { }
template
BlockLatticeStructure2D& BlockLatticeF2D::getBlockLattice()
{
return _blockLattice;
}
template
BlockLatticePhysF2D::BlockLatticePhysF2D
(BlockLatticeStructure2D& blockLattice, const UnitConverter& converter, int targetDim)
: BlockLatticeF2D(blockLattice, targetDim), _converter(converter)
{ }
template
BlockLatticeThermalPhysF2D::BlockLatticeThermalPhysF2D
(BlockLatticeStructure2D& blockLattice, const ThermalUnitConverter& converter, int targetDim)
: BlockLatticeF2D(blockLattice, targetDim), _converter(converter)
{ }
} // end namespace olb
#endif