summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-01-07 19:22:13 +0100
committerAdrian Kummerlaender2019-06-24 15:14:50 +0200
commit41ceb9219e2415c02974895c4114250a0b6bcb41 (patch)
tree2d1377dc6057cc4834ab4f1849741e0cc961d7ff
parent531c88ab94a11087f41dd07be5fc6c16b7ddad2d (diff)
downloadgrid_refinement_openlb-41ceb9219e2415c02974895c4114250a0b6bcb41.tar
grid_refinement_openlb-41ceb9219e2415c02974895c4114250a0b6bcb41.tar.gz
grid_refinement_openlb-41ceb9219e2415c02974895c4114250a0b6bcb41.tar.bz2
grid_refinement_openlb-41ceb9219e2415c02974895c4114250a0b6bcb41.tar.lz
grid_refinement_openlb-41ceb9219e2415c02974895c4114250a0b6bcb41.tar.xz
grid_refinement_openlb-41ceb9219e2415c02974895c4114250a0b6bcb41.tar.zst
grid_refinement_openlb-41ceb9219e2415c02974895c4114250a0b6bcb41.zip
Fix alignment of physical and lattice coupling lines
-rw-r--r--apps/adrian/poiseuille2d/poiseuille2d.cpp49
1 files changed, 27 insertions, 22 deletions
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<T,DESCRIPTOR> const& converter,
IndicatorCuboid2D<T> outflow(extend, origin);
superGeometry.rename(1,4,1,outflow);
- IndicatorCuboid2D<T> obstacle(Vector<T,2>{0.2,0.1}, Vector<T,2>{1.25,0.45});
+ IndicatorCuboid2D<T> obstacle(Vector<T,2> {0.2,0.1}, Vector<T,2> {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<T,DESCRIPTOR>& _coarse;
Grid<T,DESCRIPTOR>& _fine;
- const Vector<T,2> _origin;
- const Vector<T,2> _extend;
- const int _coarseSize;
+
+ const int _coarseSize;
+ const int _fineSize;
const bool _vertical;
+
+ Vector<T,2> _physOrigin;
Vector<int,3> _coarseOrigin;
Vector<int,3> _fineOrigin;
@@ -358,18 +360,21 @@ public:
Coupler(Grid<T,DESCRIPTOR>& coarse, Grid<T,DESCRIPTOR>& fine, Vector<T,2> origin, Vector<T,2> 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<int> 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<int,3> 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<T>::q; ++iPop) {
const T fneq = order3interpolation(
@@ -670,15 +675,15 @@ int main(int argc, char* argv[])
residuum);
timer.start();
- FineCoupler<T,DESCRIPTOR> fineCoupler0(*coarseGrid, *fineGrid, fineOrigin, Vector<T,2>{0,fineExtend[1]+coarseDeltaX});
- FineCoupler<T,DESCRIPTOR> fineCoupler1(*coarseGrid, *fineGrid, fineOrigin + Vector<T,2>{fineExtend[0],0}, Vector<T,2>{0,fineExtend[1]+coarseDeltaX});
- FineCoupler<T,DESCRIPTOR> fineCoupler2(*coarseGrid, *fineGrid, fineOrigin + Vector<T,2>(0,fineExtend[1]), Vector<T,2>{fineExtend[0]+coarseDeltaX,0});
- FineCoupler<T,DESCRIPTOR> fineCoupler3(*coarseGrid, *fineGrid, fineOrigin, Vector<T,2>{fineExtend[0]+coarseDeltaX,0});
+ FineCoupler<T,DESCRIPTOR> fineCoupler0(*coarseGrid, *fineGrid, fineOrigin, Vector<T,2> {0,fineExtend[1]});
+ FineCoupler<T,DESCRIPTOR> fineCoupler1(*coarseGrid, *fineGrid, fineOrigin + Vector<T,2> {fineExtend[0],0}, Vector<T,2> {0,fineExtend[1]});
+ FineCoupler<T,DESCRIPTOR> fineCoupler2(*coarseGrid, *fineGrid, fineOrigin + Vector<T,2>(0,fineExtend[1]), Vector<T,2> {fineExtend[0],0});
+ FineCoupler<T,DESCRIPTOR> fineCoupler3(*coarseGrid, *fineGrid, fineOrigin, Vector<T,2> {fineExtend[0],0});
- CoarseCoupler<T,DESCRIPTOR> coarseCoupler0(*coarseGrid, *fineGrid, fineOrigin + coarseDeltaX, Vector<T,2>{0,fineExtend[1]-2*coarseDeltaX});
- CoarseCoupler<T,DESCRIPTOR> coarseCoupler1(*coarseGrid, *fineGrid, fineOrigin + Vector<T,2>(fineExtend[0]-coarseDeltaX,coarseDeltaX), Vector<T,2>{0,fineExtend[1]-2*coarseDeltaX});
- CoarseCoupler<T,DESCRIPTOR> coarseCoupler2(*coarseGrid, *fineGrid, fineOrigin + Vector<T,2>{coarseDeltaX,fineExtend[1]-coarseDeltaX}, Vector<T,2>{fineExtend[0]-2*coarseDeltaX,0});
- CoarseCoupler<T,DESCRIPTOR> coarseCoupler3(*coarseGrid, *fineGrid, fineOrigin + coarseDeltaX, Vector<T,2>{fineExtend[0]-2*coarseDeltaX,0});
+ CoarseCoupler<T,DESCRIPTOR> coarseCoupler0(*coarseGrid, *fineGrid, fineOrigin + coarseDeltaX, Vector<T,2> {0,fineExtend[1]-2*coarseDeltaX});
+ CoarseCoupler<T,DESCRIPTOR> coarseCoupler1(*coarseGrid, *fineGrid, fineOrigin + Vector<T,2>(fineExtend[0]-coarseDeltaX,coarseDeltaX), Vector<T,2> {0,fineExtend[1]-2*coarseDeltaX});
+ CoarseCoupler<T,DESCRIPTOR> coarseCoupler2(*coarseGrid, *fineGrid, fineOrigin + Vector<T,2> {coarseDeltaX,fineExtend[1]-coarseDeltaX}, Vector<T,2> {fineExtend[0]-2*coarseDeltaX,0});
+ CoarseCoupler<T,DESCRIPTOR> coarseCoupler3(*coarseGrid, *fineGrid, fineOrigin + coarseDeltaX, Vector<T,2> {fineExtend[0]-2*coarseDeltaX,0});
for (int iT = 0; iT < coarseGrid->getConverter().getLatticeTime(maxPhysT); ++iT) {
if (converge.hasConverged()) {