diff options
Move distribution scaling factor to Coupler2D
Scaling factor is specific to the refinement method implemented by the coupler.
Diffstat (limited to 'src')
-rw-r--r-- | src/refinement/coupler2D.h | 3 | ||||
-rw-r--r-- | src/refinement/coupler2D.hh | 30 | ||||
-rw-r--r-- | src/refinement/grid2D.h | 5 | ||||
-rw-r--r-- | src/refinement/grid2D.hh | 14 |
4 files changed, 26 insertions, 26 deletions
diff --git a/src/refinement/coupler2D.h b/src/refinement/coupler2D.h index e911575..60a5cab 100644 --- a/src/refinement/coupler2D.h +++ b/src/refinement/coupler2D.h @@ -44,6 +44,9 @@ protected: const Vector<int,3>& getFineLatticeR(int y) const; const Vector<int,3>& getCoarseLatticeR(int y) const; + T getScalingFactor() const; + T getInvScalingFactor() const; + private: std::vector<Vector<int,3>> _coarseLatticeR; std::vector<Vector<int,3>> _fineLatticeR; diff --git a/src/refinement/coupler2D.hh b/src/refinement/coupler2D.hh index d599728..1d773f3 100644 --- a/src/refinement/coupler2D.hh +++ b/src/refinement/coupler2D.hh @@ -30,6 +30,17 @@ namespace olb { +template <typename T, template<typename> class DESCRIPTOR> +T Coupler2D<T,DESCRIPTOR>::getScalingFactor() const +{ + return 4. - _coarse.getConverter().getLatticeRelaxationFrequency(); +} + +template <typename T, template<typename> class DESCRIPTOR> +T Coupler2D<T,DESCRIPTOR>::getInvScalingFactor() const +{ + return 1./getScalingFactor(); +} template <typename T, template<typename> class DESCRIPTOR> const Vector<int,3>& Coupler2D<T,DESCRIPTOR>::getFineLatticeR(int y) const @@ -175,7 +186,7 @@ void FineCoupler2D<T,DESCRIPTOR>::couple() Cell<T,DESCRIPTOR> cell; fineLattice.get(finePos, cell); for (int iPop=0; iPop < DESCRIPTOR<T>::q; ++iPop) { - cell[iPop] = fEq[iPop] + this->_coarse.getScalingFactor() * _c2f_fneq[y][iPop]; + cell[iPop] = fEq[iPop] + this->getScalingFactor() * _c2f_fneq[y][iPop]; } fineLattice.set(finePos, cell); } @@ -214,7 +225,7 @@ void FineCoupler2D<T,DESCRIPTOR>::couple() _c2f_fneq[y+2][iPop] ); - fineCell[iPop] = lbHelpers<T,DESCRIPTOR>::equilibrium(iPop, rho, u, uSqr) + this->_coarse.getScalingFactor() * fneq; + fineCell[iPop] = lbHelpers<T,DESCRIPTOR>::equilibrium(iPop, rho, u, uSqr) + this->getScalingFactor() * fneq; } fineLattice.set(finePos, fineCell); @@ -249,7 +260,7 @@ void FineCoupler2D<T,DESCRIPTOR>::couple() _c2f_fneq[1][iPop], _c2f_fneq[2][iPop] ); - fineCell[iPop] = lbHelpers<T,DESCRIPTOR>::equilibrium(iPop, rho, u, uSqr) + this->_coarse.getScalingFactor() * fneq; + fineCell[iPop] = lbHelpers<T,DESCRIPTOR>::equilibrium(iPop, rho, u, uSqr) + this->getScalingFactor() * fneq; } fineLattice.set(finePos, fineCell); @@ -284,7 +295,7 @@ void FineCoupler2D<T,DESCRIPTOR>::couple() _c2f_fneq[this->_coarseSize-2][iPop], _c2f_fneq[this->_coarseSize-3][iPop] ); - fineCell[iPop] = lbHelpers<T,DESCRIPTOR>::equilibrium(iPop, rho, u, uSqr) + this->_coarse.getScalingFactor() * fneq; + fineCell[iPop] = lbHelpers<T,DESCRIPTOR>::equilibrium(iPop, rho, u, uSqr) + this->getScalingFactor() * fneq; } fineLattice.set(finePos, fineCell); @@ -294,14 +305,15 @@ void FineCoupler2D<T,DESCRIPTOR>::couple() template <typename T, template<typename> class DESCRIPTOR> void computeRestrictedFneq(const SuperLattice2D<T,DESCRIPTOR>& lattice, - Vector<int,3> pos, + Vector<int,3> latticeR, T restrictedFneq[DESCRIPTOR<T>::q]) { for (int iPop=0; iPop < DESCRIPTOR<T>::q; ++iPop) { - T fNeq[DESCRIPTOR<T>::q] {}; + const auto neighbor = latticeR + Vector<int,3>{0, DESCRIPTOR<T>::c[iPop][0], DESCRIPTOR<T>::c[iPop][1]}; Cell<T,DESCRIPTOR> cell; - const Vector<int,3> neighborPos {pos[0], pos[1] + DESCRIPTOR<T>::c[iPop][0], pos[2] + DESCRIPTOR<T>::c[iPop][1]}; - lattice.get(neighborPos, cell); + lattice.get(neighbor, cell); + + T fNeq[DESCRIPTOR<T>::q] {}; lbHelpers<T,DESCRIPTOR>::computeFneq(cell, fNeq); for (int jPop=0; jPop < DESCRIPTOR<T>::q; ++jPop) { @@ -352,7 +364,7 @@ void CoarseCoupler2D<T,DESCRIPTOR>::couple() coarseLattice.get(coarsePos, coarseCell); for (int iPop=0; iPop < DESCRIPTOR<T>::q; ++iPop) { - coarseCell[iPop] = fEq[iPop] + this->_coarse.getInvScalingFactor() * fNeq[iPop]; + coarseCell[iPop] = fEq[iPop] + this->getInvScalingFactor() * fNeq[iPop]; } coarseLattice.set(coarsePos, coarseCell); diff --git a/src/refinement/grid2D.h b/src/refinement/grid2D.h index cc6bb62..1d15170 100644 --- a/src/refinement/grid2D.h +++ b/src/refinement/grid2D.h @@ -66,9 +66,6 @@ public: SuperGeometry2D<T>& getSuperGeometry(); SuperLattice2D<T,DESCRIPTOR>& getSuperLattice(); - T getScalingFactor(); - T getInvScalingFactor(); - void collideAndStream(); FineCoupler2D<T,DESCRIPTOR>& addFineCoupling( @@ -76,7 +73,7 @@ public: CoarseCoupler2D<T,DESCRIPTOR>& addCoarseCoupling( Grid2D<T,DESCRIPTOR>& fineGrid, Vector<T,2> origin, Vector<T,2> extend); - Vector<T,2> alignLocationToGrid(Vector<T,2> physR) const; + Vector<T,2> alignOriginToGrid(Vector<T,2> physR) const; Vector<T,2> alignExtendToGrid(Vector<T,2> physR) const; Grid2D<T,DESCRIPTOR>& refine(IndicatorF2D<T>& domainF); diff --git a/src/refinement/grid2D.hh b/src/refinement/grid2D.hh index 59e23ce..99a2563 100644 --- a/src/refinement/grid2D.hh +++ b/src/refinement/grid2D.hh @@ -104,18 +104,6 @@ SuperLattice2D<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::getSuperLattice() } template <typename T, template<typename> class DESCRIPTOR> -T Grid2D<T,DESCRIPTOR>::getScalingFactor() -{ - return 4. - _converter->getLatticeRelaxationFrequency(); -} - -template <typename T, template<typename> class DESCRIPTOR> -T Grid2D<T,DESCRIPTOR>::getInvScalingFactor() -{ - return 1./getScalingFactor(); -} - -template <typename T, template<typename> class DESCRIPTOR> void Grid2D<T,DESCRIPTOR>::collideAndStream() { for ( auto& fineCoupler : _fineCouplers ) { @@ -181,7 +169,7 @@ Grid2D<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::refine(IndicatorF2D<T>& domainF) } template <typename T, template<typename> class DESCRIPTOR> -Vector<T,2> Grid2D<T,DESCRIPTOR>::alignLocationToGrid(Vector<T,2> physR) const +Vector<T,2> Grid2D<T,DESCRIPTOR>::alignOriginToGrid(Vector<T,2> physR) const { Vector<int,3> latticeR{}; _cuboids->getLatticeR(physR, latticeR); |