From 946cb3702e6baacec1faaeab9ad66dfd99320b55 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 10 Jan 2019 21:55:43 +0100 Subject: Fix grid alignment of refinement area --- src/refinement/coupler2D.hh | 4 ++-- src/refinement/grid2D.h | 3 ++- src/refinement/grid2D.hh | 9 ++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/refinement') diff --git a/src/refinement/coupler2D.hh b/src/refinement/coupler2D.hh index 5614d16..d599728 100644 --- a/src/refinement/coupler2D.hh +++ b/src/refinement/coupler2D.hh @@ -160,7 +160,7 @@ void FineCoupler2D::interpolate() template class DESCRIPTOR> void FineCoupler2D::couple() { - auto& coarseLattice = this->_coarse.getSuperLattice(); + const auto& coarseLattice = this->_coarse.getSuperLattice(); auto& fineLattice = this->_fine.getSuperLattice(); for (int y=0; y < this->_coarseSize; ++y) { @@ -333,7 +333,7 @@ CoarseCoupler2D::CoarseCoupler2D( template class DESCRIPTOR> void CoarseCoupler2D::couple() { - auto& fineLattice = this->_fine.getSuperLattice(); + const auto& fineLattice = this->_fine.getSuperLattice(); auto& coarseLattice = this->_coarse.getSuperLattice(); for (int y=0; y < this->_coarseSize; ++y) { diff --git a/src/refinement/grid2D.h b/src/refinement/grid2D.h index 6d3579c..cc6bb62 100644 --- a/src/refinement/grid2D.h +++ b/src/refinement/grid2D.h @@ -76,7 +76,8 @@ public: CoarseCoupler2D& addCoarseCoupling( Grid2D& fineGrid, Vector origin, Vector extend); - Vector alignToGrid(Vector physR) const; + Vector alignLocationToGrid(Vector physR) const; + Vector alignExtendToGrid(Vector physR) const; Grid2D& refine(IndicatorF2D& domainF); Grid2D& refine(Vector origin, Vector extend); diff --git a/src/refinement/grid2D.hh b/src/refinement/grid2D.hh index 65dd84d..59e23ce 100644 --- a/src/refinement/grid2D.hh +++ b/src/refinement/grid2D.hh @@ -181,13 +181,20 @@ Grid2D& Grid2D::refine(IndicatorF2D& domainF) } template class DESCRIPTOR> -Vector Grid2D::alignToGrid(Vector physR) const +Vector Grid2D::alignLocationToGrid(Vector physR) const { Vector latticeR{}; _cuboids->getLatticeR(physR, latticeR); return _cuboids->getPhysR(latticeR.toStdVector()); } +template class DESCRIPTOR> +Vector Grid2D::alignExtendToGrid(Vector extend) const +{ + const T deltaX = _converter->getPhysDeltaX(); + return floor(extend / deltaX) * deltaX; +} + template class DESCRIPTOR> Grid2D& Grid2D::refine(Vector origin, Vector extend) { -- cgit v1.2.3