From 41ceb9219e2415c02974895c4114250a0b6bcb41 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 7 Jan 2019 19:22:13 +0100 Subject: Fix alignment of physical and lattice coupling lines --- apps/adrian/poiseuille2d/poiseuille2d.cpp | 49 +++++++++++++++++-------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'apps/adrian/poiseuille2d') diff --git a/apps/adrian/poiseuille2d/poiseuille2d.cpp b/apps/adrian/poiseuille2d/poiseuille2d.cpp index f160135..f551820 100644 --- a/apps/adrian/poiseuille2d/poiseuille2d.cpp +++ b/apps/adrian/poiseuille2d/poiseuille2d.cpp @@ -68,7 +68,7 @@ void prepareGeometry(UnitConverter const& converter, IndicatorCuboid2D outflow(extend, origin); superGeometry.rename(1,4,1,outflow); - IndicatorCuboid2D obstacle(Vector{0.2,0.1}, Vector{1.25,0.45}); + IndicatorCuboid2D obstacle(Vector {0.2,0.1}, Vector {1.25,0.45}); superGeometry.rename(1,5,obstacle); // Removes all not needed boundary voxels outside the surface @@ -327,10 +327,12 @@ class Coupler { protected: Grid& _coarse; Grid& _fine; - const Vector _origin; - const Vector _extend; - const int _coarseSize; + + const int _coarseSize; + const int _fineSize; const bool _vertical; + + Vector _physOrigin; Vector _coarseOrigin; Vector _fineOrigin; @@ -358,18 +360,21 @@ public: Coupler(Grid& coarse, Grid& fine, Vector origin, Vector extend): _coarse(coarse), _fine(fine), - _origin(origin), - _extend(extend), - _coarseSize(extend.norm() / coarse.getConverter().getPhysDeltaX()), + _coarseSize(floor(extend.norm() / coarse.getConverter().getPhysDeltaX() + 0.5)+1), + _fineSize(2*_coarseSize-1), _vertical(util::nearZero(extend[0])) { OLB_ASSERT(util::nearZero(extend[0]) || util::nearZero(extend[1]), "Coupling is only implemented alongside unit vectors"); - std::vector tmp(3,0); - _coarse.getCuboidGeometry().getLatticeR(_origin.toStdVector(), tmp); - _coarseOrigin = tmp; - _fine.getCuboidGeometry().getLatticeR(_origin.toStdVector(), tmp); - _fineOrigin = tmp; + const auto& coarseGeometry = _coarse.getCuboidGeometry(); + const auto& fineGeometry = _fine.getCuboidGeometry(); + + Vector tmpLatticeOrigin{}; + coarseGeometry.getLatticeR(origin, tmpLatticeOrigin); + _physOrigin = coarseGeometry.getPhysR(tmpLatticeOrigin.toStdVector()); + + coarseGeometry.getLatticeR(_physOrigin, _coarseOrigin); + fineGeometry.getLatticeR(_physOrigin, _fineOrigin); } }; @@ -390,7 +395,7 @@ public: OstreamManager clout(std::cout,"C2F"); clout << "coarse origin: " << this->_coarseOrigin[0] << " " << this->_coarseOrigin[1] << " " << this->_coarseOrigin[2] << std::endl; clout << "fine origin: " << this->_fineOrigin[0] << " " << this->_fineOrigin[1] << " " << this->_fineOrigin[2] << std::endl; - clout << "fine size: " << 2*this->_coarseSize-1 << std::endl; + clout << "fine size: " << this->_fineSize << std::endl; } void store() @@ -537,7 +542,7 @@ public: ); const T uSqr = u[0]*u[0] + u[1]*u[1]; - const auto finePos = this->getFineLatticeR(2*(this->_coarseSize-1)-1); + const auto finePos = this->getFineLatticeR(this->_fineSize-2); for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { const T fneq = order3interpolation( @@ -670,15 +675,15 @@ int main(int argc, char* argv[]) residuum); timer.start(); - FineCoupler fineCoupler0(*coarseGrid, *fineGrid, fineOrigin, Vector{0,fineExtend[1]+coarseDeltaX}); - FineCoupler fineCoupler1(*coarseGrid, *fineGrid, fineOrigin + Vector{fineExtend[0],0}, Vector{0,fineExtend[1]+coarseDeltaX}); - FineCoupler fineCoupler2(*coarseGrid, *fineGrid, fineOrigin + Vector(0,fineExtend[1]), Vector{fineExtend[0]+coarseDeltaX,0}); - FineCoupler fineCoupler3(*coarseGrid, *fineGrid, fineOrigin, Vector{fineExtend[0]+coarseDeltaX,0}); + FineCoupler fineCoupler0(*coarseGrid, *fineGrid, fineOrigin, Vector {0,fineExtend[1]}); + FineCoupler fineCoupler1(*coarseGrid, *fineGrid, fineOrigin + Vector {fineExtend[0],0}, Vector {0,fineExtend[1]}); + FineCoupler fineCoupler2(*coarseGrid, *fineGrid, fineOrigin + Vector(0,fineExtend[1]), Vector {fineExtend[0],0}); + FineCoupler fineCoupler3(*coarseGrid, *fineGrid, fineOrigin, Vector {fineExtend[0],0}); - CoarseCoupler coarseCoupler0(*coarseGrid, *fineGrid, fineOrigin + coarseDeltaX, Vector{0,fineExtend[1]-2*coarseDeltaX}); - CoarseCoupler coarseCoupler1(*coarseGrid, *fineGrid, fineOrigin + Vector(fineExtend[0]-coarseDeltaX,coarseDeltaX), Vector{0,fineExtend[1]-2*coarseDeltaX}); - CoarseCoupler coarseCoupler2(*coarseGrid, *fineGrid, fineOrigin + Vector{coarseDeltaX,fineExtend[1]-coarseDeltaX}, Vector{fineExtend[0]-2*coarseDeltaX,0}); - CoarseCoupler coarseCoupler3(*coarseGrid, *fineGrid, fineOrigin + coarseDeltaX, Vector{fineExtend[0]-2*coarseDeltaX,0}); + CoarseCoupler coarseCoupler0(*coarseGrid, *fineGrid, fineOrigin + coarseDeltaX, Vector {0,fineExtend[1]-2*coarseDeltaX}); + CoarseCoupler coarseCoupler1(*coarseGrid, *fineGrid, fineOrigin + Vector(fineExtend[0]-coarseDeltaX,coarseDeltaX), Vector {0,fineExtend[1]-2*coarseDeltaX}); + CoarseCoupler coarseCoupler2(*coarseGrid, *fineGrid, fineOrigin + Vector {coarseDeltaX,fineExtend[1]-coarseDeltaX}, Vector {fineExtend[0]-2*coarseDeltaX,0}); + CoarseCoupler coarseCoupler3(*coarseGrid, *fineGrid, fineOrigin + coarseDeltaX, Vector {fineExtend[0]-2*coarseDeltaX,0}); for (int iT = 0; iT < coarseGrid->getConverter().getLatticeTime(maxPhysT); ++iT) { if (converge.hasConverged()) { -- cgit v1.2.3