From d12f3f9eb04a686e97d4625500a6f834ca7bde4b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 24 Jun 2019 15:39:36 +0200 Subject: Adapt refinement to meta-descriptor --- src/refinement/coupler2D.cpp | 7 +++-- src/refinement/coupler2D.h | 12 ++++----- src/refinement/coupler2D.hh | 64 ++++++++++++++++++++++---------------------- src/refinement/grid2D.cpp | 5 ++-- src/refinement/grid2D.h | 13 +++++---- src/refinement/grid2D.hh | 56 +++++++++++++++++++------------------- 6 files changed, 80 insertions(+), 77 deletions(-) diff --git a/src/refinement/coupler2D.cpp b/src/refinement/coupler2D.cpp index 37997f5..733d7c9 100644 --- a/src/refinement/coupler2D.cpp +++ b/src/refinement/coupler2D.cpp @@ -25,12 +25,11 @@ #include "coupler2D.hh" #include "dynamics/latticeDescriptors.h" -#include "dynamics/latticeDescriptors.hh" namespace olb { -template class Coupler2D; -template class FineCoupler2D; -template class CoarseCoupler2D; +template class Coupler2D>; +template class FineCoupler2D>; +template class CoarseCoupler2D>; } diff --git a/src/refinement/coupler2D.h b/src/refinement/coupler2D.h index d43a294..9b310b7 100644 --- a/src/refinement/coupler2D.h +++ b/src/refinement/coupler2D.h @@ -29,7 +29,7 @@ namespace olb { -template class DESCRIPTOR> +template class Coupler2D { protected: Grid2D& _coarse; @@ -57,12 +57,12 @@ public: }; -template class DESCRIPTOR> +template class FineCoupler2D : public Coupler2D { private: - std::vector> _c2f_rho; - std::vector::d>> _c2f_u; - std::vector::q>> _c2f_fneq; + std::vector> _c2f_rho; + std::vector> _c2f_u; + std::vector> _c2f_fneq; public: FineCoupler2D(Grid2D& coarse, Grid2D& fine, @@ -74,7 +74,7 @@ public: }; -template class DESCRIPTOR> +template class CoarseCoupler2D : public Coupler2D { public: CoarseCoupler2D(Grid2D& coarse, Grid2D& fine, diff --git a/src/refinement/coupler2D.hh b/src/refinement/coupler2D.hh index c2b27db..800986d 100644 --- a/src/refinement/coupler2D.hh +++ b/src/refinement/coupler2D.hh @@ -30,32 +30,32 @@ namespace olb { -template class DESCRIPTOR> +template T Coupler2D::getScalingFactor() const { const T coarseTau = _coarse.getConverter().getLatticeRelaxationTime(); return (coarseTau - 0.25) / coarseTau; } -template class DESCRIPTOR> +template T Coupler2D::getInvScalingFactor() const { return 1./getScalingFactor(); } -template class DESCRIPTOR> +template const Vector& Coupler2D::getFineLatticeR(int y) const { return _fineLatticeR[y]; } -template class DESCRIPTOR> +template const Vector& Coupler2D::getCoarseLatticeR(int y) const { return _coarseLatticeR[y]; } -template class DESCRIPTOR> +template Coupler2D::Coupler2D(Grid2D& coarse, Grid2D& fine, Vector origin, Vector extend): _coarse(coarse), @@ -86,13 +86,13 @@ Coupler2D::Coupler2D(Grid2D& coarse, Grid2D class DESCRIPTOR> +template FineCoupler2D::FineCoupler2D(Grid2D& coarse, Grid2D& fine, Vector origin, Vector extend): Coupler2D(coarse, fine, origin, extend), _c2f_rho(this->_coarseSize), _c2f_u(this->_coarseSize, Vector(T{})), - _c2f_fneq(this->_coarseSize, Vector::q>(T{})) + _c2f_fneq(this->_coarseSize, Vector(T{})) { OstreamManager clout(std::cout,"C2F"); @@ -104,7 +104,7 @@ FineCoupler2D::FineCoupler2D(Grid2D& coarse, Grid2D< clout << "fine size: " << this->_fineSize << std::endl; } -template class DESCRIPTOR> +template void FineCoupler2D::store() { auto& coarseLattice = this->_coarse.getSuperLattice(); @@ -114,7 +114,7 @@ void FineCoupler2D::store() const auto pos = this->getCoarseLatticeR(y); T rho{}; T u[2] {}; - T fNeq[DESCRIPTOR::q] {}; + T fNeq[DESCRIPTOR::q] {}; Cell coarseCell; coarseLattice.get(pos, coarseCell); lbHelpers::computeRhoU(coarseCell, rho, u); @@ -122,7 +122,7 @@ void FineCoupler2D::store() _c2f_rho[y] = Vector(rho); _c2f_u[y] = Vector(u); - _c2f_fneq[y] = Vector::q>(fNeq); + _c2f_fneq[y] = Vector(fNeq); } } @@ -156,7 +156,7 @@ Vector order4interpolation(const std::vector>& data, int y) } -template class DESCRIPTOR> +template void FineCoupler2D::interpolate() { auto& coarseLattice = this->_coarse.getSuperLattice(); @@ -173,14 +173,14 @@ void FineCoupler2D::interpolate() _c2f_rho[y] = order2interpolation(Vector(rho), _c2f_rho[y]); _c2f_u[y] = order2interpolation(Vector(u), _c2f_u[y]); - T fNeq[DESCRIPTOR::q] {}; + T fNeq[DESCRIPTOR::q] {}; lbHelpers::computeFneq(coarseCell, fNeq, rho, u); - _c2f_fneq[y] = order2interpolation(Vector::q>(fNeq), _c2f_fneq[y]); + _c2f_fneq[y] = order2interpolation(Vector(fNeq), _c2f_fneq[y]); } } -template class DESCRIPTOR> +template void FineCoupler2D::couple() { const auto& coarseLattice = this->_coarse.getSuperLattice(); @@ -191,14 +191,14 @@ void FineCoupler2D::couple() const auto& coarsePos = this->getCoarseLatticeR(y); const auto& finePos = this->getFineLatticeR(2*y); - T fEq[DESCRIPTOR::q] {}; + T fEq[DESCRIPTOR::q] {}; Cell coarseCell; coarseLattice.get(coarsePos, coarseCell); lbHelpers::computeFeq(coarseCell, fEq); Cell cell; fineLattice.get(finePos, cell); - for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { cell[iPop] = fEq[iPop] + this->getScalingFactor() * _c2f_fneq[y][iPop]; } fineLattice.set(finePos, cell); @@ -216,7 +216,7 @@ void FineCoupler2D::couple() Cell fineCell; fineLattice.get(finePos, fineCell); - for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { fineCell[iPop] = lbHelpers::equilibrium(iPop, rho[0], u.data, uSqr) + this->getScalingFactor() * fneq[iPop]; } @@ -235,7 +235,7 @@ void FineCoupler2D::couple() Cell fineCell; fineLattice.get(finePos, fineCell); - for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { fineCell[iPop] = lbHelpers::equilibrium(iPop, rho[0], u.data, uSqr) + this->getScalingFactor() * fneq[iPop]; } @@ -254,7 +254,7 @@ void FineCoupler2D::couple() Cell fineCell; fineLattice.get(finePos, fineCell); - for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { fineCell[iPop] = lbHelpers::equilibrium(iPop, rho[0], u.data, uSqr) + this->getScalingFactor() * fneq[iPop]; } @@ -264,30 +264,30 @@ void FineCoupler2D::couple() } -template class DESCRIPTOR> +template void computeRestrictedFneq(const SuperLattice2D& lattice, Vector latticeR, - T restrictedFneq[DESCRIPTOR::q]) + T restrictedFneq[DESCRIPTOR::q]) { - for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { - const auto neighbor = latticeR + Vector {0, DESCRIPTOR::c[iPop][0], DESCRIPTOR::c[iPop][1]}; + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + const auto neighbor = latticeR + Vector {0, descriptors::c(iPop,0), descriptors::c(iPop,1)}; Cell cell; lattice.get(neighbor, cell); - T fNeq[DESCRIPTOR::q] {}; + T fNeq[DESCRIPTOR::q] {}; lbHelpers::computeFneq(cell, fNeq); - for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) { + for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) { restrictedFneq[jPop] += fNeq[jPop]; } } - for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { - restrictedFneq[iPop] /= DESCRIPTOR::q; + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + restrictedFneq[iPop] /= DESCRIPTOR::q; } } -template class DESCRIPTOR> +template CoarseCoupler2D::CoarseCoupler2D( Grid2D& coarse, Grid2D& fine, Vector origin, Vector extend): @@ -303,7 +303,7 @@ CoarseCoupler2D::CoarseCoupler2D( clout << "coarse size: " << this->_coarseSize << std::endl; } -template class DESCRIPTOR> +template void CoarseCoupler2D::couple() { const auto& fineLattice = this->_fine.getSuperLattice(); @@ -314,18 +314,18 @@ void CoarseCoupler2D::couple() const auto& finePos = this->getFineLatticeR(2*y); const auto& coarsePos = this->getCoarseLatticeR(y); - T fEq[DESCRIPTOR::q] {}; + T fEq[DESCRIPTOR::q] {}; Cell fineCell; fineLattice.get(finePos, fineCell); lbHelpers::computeFeq(fineCell, fEq); - T fNeq[DESCRIPTOR::q] {}; + T fNeq[DESCRIPTOR::q] {}; computeRestrictedFneq(fineLattice, finePos, fNeq); Cell coarseCell; coarseLattice.get(coarsePos, coarseCell); - for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { coarseCell[iPop] = fEq[iPop] + this->getInvScalingFactor() * fNeq[iPop]; } diff --git a/src/refinement/grid2D.cpp b/src/refinement/grid2D.cpp index 86ca284..4472fc7 100644 --- a/src/refinement/grid2D.cpp +++ b/src/refinement/grid2D.cpp @@ -25,11 +25,10 @@ #include "grid2D.hh" #include "dynamics/latticeDescriptors.h" -#include "dynamics/latticeDescriptors.hh" namespace olb { -template class Grid2D; -template class RefiningGrid2D; +template class Grid2D>; +template class RefiningGrid2D>; } diff --git a/src/refinement/grid2D.h b/src/refinement/grid2D.h index 42937ca..51d19ce 100644 --- a/src/refinement/grid2D.h +++ b/src/refinement/grid2D.h @@ -42,9 +42,12 @@ namespace olb { -template class DESCRIPTOR> class FineCoupler2D; -template class DESCRIPTOR> class CoarseCoupler2D; -template class DESCRIPTOR> class RefiningGrid2D; +template class FineCoupler2D; +template class CoarseCoupler2D; +template class RefiningGrid2D; + +template class sOnLatticeBoundaryCondition2D; +template class sOffLatticeBoundaryCondition2D; template using RelaxationTime = utilities::NamedType; @@ -70,7 +73,7 @@ struct Characteristics { }; -template class DESCRIPTOR> +template class Grid2D { protected: FunctorPtr> _domainF; @@ -141,7 +144,7 @@ public: }; -template class DESCRIPTOR> +template class RefiningGrid2D : public Grid2D { private: const Vector _origin; diff --git a/src/refinement/grid2D.hh b/src/refinement/grid2D.hh index 4f76896..d4310e5 100644 --- a/src/refinement/grid2D.hh +++ b/src/refinement/grid2D.hh @@ -28,12 +28,14 @@ #include "coupler2D.hh" #include "utilities/vectorHelpers.h" +#include "boundary/superBoundaryCondition2D.h" +#include "boundary/superOffBoundaryCondition2D.h" #include "communication/heuristicLoadBalancer.h" namespace olb { -template class DESCRIPTOR> +template Grid2D::Grid2D(FunctorPtr>&& domainF, RelaxationTime tau, int resolution, @@ -68,7 +70,7 @@ Grid2D::Grid2D(FunctorPtr>&& domainF, _converter->print(); } -template class DESCRIPTOR> +template Grid2D::Grid2D(FunctorPtr>&& domainF, LatticeVelocity latticeVelocity, int resolution, @@ -103,7 +105,7 @@ Grid2D::Grid2D(FunctorPtr>&& domainF, _converter->print(); } -template class DESCRIPTOR> +template Grid2D::Grid2D( FunctorPtr>&& domainF, RelaxationTime tau, @@ -115,7 +117,7 @@ Grid2D::Grid2D( Characteristics(re)) { } -template class DESCRIPTOR> +template Grid2D::Grid2D( FunctorPtr>&& domainF, LatticeVelocity latticeVelocity, @@ -127,43 +129,43 @@ Grid2D::Grid2D( Characteristics(re)) { } -template class DESCRIPTOR> +template Characteristics Grid2D::getCharacteristics() const { return _characteristics; } -template class DESCRIPTOR> +template UnitConverter& Grid2D::getConverter() { return *_converter; } -template class DESCRIPTOR> +template CuboidGeometry2D& Grid2D::getCuboidGeometry() { return *_cuboids; } -template class DESCRIPTOR> +template LoadBalancer& Grid2D::getLoadBalancer() { return *_balancer; } -template class DESCRIPTOR> +template SuperGeometry2D& Grid2D::getSuperGeometry() { return *_geometry; } -template class DESCRIPTOR> +template SuperLattice2D& Grid2D::getSuperLattice() { return *_lattice; } -template class DESCRIPTOR> +template Dynamics& Grid2D::addDynamics( std::unique_ptr>&& dynamics) { @@ -172,7 +174,7 @@ Dynamics& Grid2D::addDynamics( return ref; } -template class DESCRIPTOR> +template sOnLatticeBoundaryCondition2D& Grid2D::getOnLatticeBoundaryCondition() { _onLatticeBoundaryConditions.emplace_back( @@ -180,7 +182,7 @@ sOnLatticeBoundaryCondition2D& Grid2D::getOnLatticeB return *_onLatticeBoundaryConditions.back(); } -template class DESCRIPTOR> +template sOffLatticeBoundaryCondition2D& Grid2D::getOffLatticeBoundaryCondition() { _offLatticeBoundaryConditions.emplace_back( @@ -188,7 +190,7 @@ sOffLatticeBoundaryCondition2D& Grid2D::getOffLattic return *_offLatticeBoundaryConditions.back(); } -template class DESCRIPTOR> +template void Grid2D::collideAndStream() { for ( auto& fineCoupler : _fineCouplers ) { @@ -220,7 +222,7 @@ void Grid2D::collideAndStream() } } -template class DESCRIPTOR> +template FineCoupler2D& Grid2D::addFineCoupling( Grid2D& fineGrid, Vector origin, Vector extend) { @@ -230,7 +232,7 @@ FineCoupler2D& Grid2D::addFineCoupling( return *_fineCouplers.back(); } -template class DESCRIPTOR> +template CoarseCoupler2D& Grid2D::addCoarseCoupling( Grid2D& fineGrid, Vector origin, Vector extend) { @@ -240,7 +242,7 @@ CoarseCoupler2D& Grid2D::addCoarseCoupling( return *_coarseCouplers.back(); } -template class DESCRIPTOR> +template Vector Grid2D::alignOriginToGrid(Vector physR) const { Vector latticeR{}; @@ -248,7 +250,7 @@ Vector Grid2D::alignOriginToGrid(Vector physR) const return _cuboids->getPhysR(latticeR.toStdVector()); } -template class DESCRIPTOR> +template Vector Grid2D::alignExtendToGrid(Vector extend) const { const T deltaX = _converter->getPhysDeltaX(); @@ -258,7 +260,7 @@ Vector Grid2D::alignExtendToGrid(Vector extend) const }; } -template class DESCRIPTOR> +template void Grid2D::forEachGrid(std::function&)>&& f) { f(*this); @@ -267,7 +269,7 @@ void Grid2D::forEachGrid(std::function&) } } -template class DESCRIPTOR> +template void Grid2D::forEachGrid( const std::string& id, std::function&,const std::string&)>&& f) @@ -280,7 +282,7 @@ void Grid2D::forEachGrid( } } -template class DESCRIPTOR> +template Grid2D& Grid2D::locate(Vector pos) { int iC; @@ -292,7 +294,7 @@ Grid2D& Grid2D::locate(Vector pos) return *this; } -template class DESCRIPTOR> +template std::size_t Grid2D::getActiveVoxelN() const { std::size_t n = _geometry->getStatistics().getNvoxel(); @@ -302,7 +304,7 @@ std::size_t Grid2D::getActiveVoxelN() const return n; } -template class DESCRIPTOR> +template RefiningGrid2D& Grid2D::refine( Vector wantedOrigin, Vector wantedExtend, bool addCouplers) { @@ -348,7 +350,7 @@ RefiningGrid2D& Grid2D::refine( } -template class DESCRIPTOR> +template RefiningGrid2D::RefiningGrid2D( Grid2D& parentGrid, Vector origin, Vector extend): Grid2D( @@ -360,19 +362,19 @@ RefiningGrid2D::RefiningGrid2D( _extend(extend), _parentGrid(parentGrid) { } -template class DESCRIPTOR> +template Vector RefiningGrid2D::getOrigin() const { return _origin; } -template class DESCRIPTOR> +template Vector RefiningGrid2D::getExtend() const { return _extend; } -template class DESCRIPTOR> +template std::unique_ptr> RefiningGrid2D::getRefinedOverlap() const { const T coarseDeltaX = _parentGrid.getConverter().getPhysDeltaX(); -- cgit v1.2.3