/* This file is part of the OpenLB library * * Copyright (C) 2012 Lukas Baron, Tim Dornieden, Mathias J. Krause, * Albert Mink * 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 SUPER_BASE_F_2D_HH #define SUPER_BASE_F_2D_HH #include "superBaseF2D.h" namespace olb { template SuperF2D::SuperF2D(SuperStructure2D& superStructure, int targetDim) : GenericF(targetDim,3), _superStructure(superStructure) { } template SuperStructure2D& SuperF2D::getSuperStructure() { return _superStructure; } template int SuperF2D::getBlockFSize() const { OLB_ASSERT(_blockF.size() < INT32_MAX, "it is safe to cast std::size_t to int"); return _blockF.size(); } template BlockF2D& SuperF2D::getBlockF(int iCloc) { OLB_ASSERT(size_t(iCloc) < _blockF.size() && iCloc >= 0, "block functor index within bounds"); return *(_blockF[iCloc]); } template SuperDataF2D::SuperDataF2D(SuperData2D& superData) : SuperF2D(superData, superData.getDataSize()), _superData(superData) { for (int iC = 0; iC < _superData.getLoadBalancer().size(); ++iC) { this->_blockF.emplace_back( new BlockDataViewF2D(_superData.get(iC), _superData.getOverlap()) ); } } template bool SuperDataF2D::operator() (BaseType output[], const int input[]) { const auto& load = _superData.getLoadBalancer(); if (load.rank(input[0]) == singleton::mpi().getRank()) { return this->getBlockF(load.loc(input[0]))(output, &input[1]); } else { return false; } } template SuperData2D& SuperDataF2D::getSuperData() { return _superData; } template SuperIdentity2D::SuperIdentity2D(FunctorPtr>&& f) : SuperF2D(f->getSuperStructure(), f->getTargetDim()), _f(std::move(f)) { this->getName() = "Id(" + _f->getName() + ")"; for (int iC = 0; iC < _f->getBlockFSize(); ++iC) { this->_blockF.emplace_back( new BlockIdentity2D(_f->getBlockF(iC))); } } template bool SuperIdentity2D::operator()(W output[], const int input[]) { return _f(output, input); } template SuperLatticeF2D::SuperLatticeF2D(SuperLattice2D& superLattice, int targetDim) : SuperF2D(superLattice, targetDim), _sLattice(superLattice) { } template SuperLattice2D& SuperLatticeF2D::getSuperLattice() { return _sLattice; } template SuperLatticePhysF2D::SuperLatticePhysF2D (SuperLattice2D& sLattice, const UnitConverter& converter, int targetDim) : SuperLatticeF2D(sLattice, targetDim), _converter(converter) { } template UnitConverter const& SuperLatticePhysF2D::getConverter() const { return this->_converter; } template SuperLatticeThermalPhysF2D::SuperLatticeThermalPhysF2D (SuperLattice2D& sLattice, const ThermalUnitConverter& converter, int targetDim) : SuperLatticeF2D(sLattice, targetDim), _converter(converter) { } template ThermalUnitConverter const& SuperLatticeThermalPhysF2D::getConverter() const { return this->_converter; } } // end namespace olb #endif