summaryrefslogtreecommitdiff
path: root/apps/adrian
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-01-08 09:58:11 +0100
committerAdrian Kummerlaender2019-06-24 15:14:50 +0200
commit4eb1efbc9fe9661762a097f03934a9bc52024f28 (patch)
treeaed0c2cae3991a6b0009afdb7e2c9f761d25f6b9 /apps/adrian
parentb5fd6d62b1ea3717f6196fc4322dbaf6fc19868b (diff)
downloadgrid_refinement_openlb-4eb1efbc9fe9661762a097f03934a9bc52024f28.tar
grid_refinement_openlb-4eb1efbc9fe9661762a097f03934a9bc52024f28.tar.gz
grid_refinement_openlb-4eb1efbc9fe9661762a097f03934a9bc52024f28.tar.bz2
grid_refinement_openlb-4eb1efbc9fe9661762a097f03934a9bc52024f28.tar.lz
grid_refinement_openlb-4eb1efbc9fe9661762a097f03934a9bc52024f28.tar.xz
grid_refinement_openlb-4eb1efbc9fe9661762a097f03934a9bc52024f28.tar.zst
grid_refinement_openlb-4eb1efbc9fe9661762a097f03934a9bc52024f28.zip
Tidy up grid coupler construction
Diffstat (limited to 'apps/adrian')
-rw-r--r--apps/adrian/poiseuille2d/poiseuille2d.cpp77
1 files changed, 45 insertions, 32 deletions
diff --git a/apps/adrian/poiseuille2d/poiseuille2d.cpp b/apps/adrian/poiseuille2d/poiseuille2d.cpp
index 9f92c2a..9ef1ce8 100644
--- a/apps/adrian/poiseuille2d/poiseuille2d.cpp
+++ b/apps/adrian/poiseuille2d/poiseuille2d.cpp
@@ -313,45 +313,58 @@ public:
}
}
- Grid<T,DESCRIPTOR>* refine(Vector<T,2> origin, Vector<T,2> extend)
+ FineCoupler<T,DESCRIPTOR>& addFineCoupling(
+ Grid<T,DESCRIPTOR>& fineGrid, Vector<T,2> origin, Vector<T,2> extend)
+ {
+ _fineCouplers.emplace_back(
+ new FineCoupler<T,DESCRIPTOR>(
+ *this, fineGrid, origin, extend));
+ return *_fineCouplers.back();
+ }
+
+ CoarseCoupler<T,DESCRIPTOR>& addCoarseCoupling(
+ Grid<T,DESCRIPTOR>& fineGrid, Vector<T,2> origin, Vector<T,2> extend)
+ {
+ _coarseCouplers.emplace_back(
+ new CoarseCoupler<T,DESCRIPTOR>(
+ *this, fineGrid, origin, extend));
+ return *_coarseCouplers.back();
+ }
+
+ Grid<T,DESCRIPTOR>& refine(IndicatorF2D<T>& domainF)
{
- IndicatorCuboid2D<T> fineCuboid(extend, origin);
_fineGrids.emplace_back(
new Grid<T,DESCRIPTOR>(
- fineCuboid,
+ domainF,
2*getConverter().getResolution(),
2.0*getConverter().getLatticeRelaxationTime() - 0.5,
getConverter().getReynoldsNumber()
));
- Grid<T,DESCRIPTOR>* const fineGrid = _fineGrids.back().get();
+ return *_fineGrids.back();
+ }
- const T coarseDeltaX = getConverter().getPhysDeltaX();
+ Grid<T,DESCRIPTOR>& refine(Vector<T,2> origin, Vector<T,2> extend)
+ {
+ IndicatorCuboid2D<T> fineCuboid(extend, origin);
+ auto& fineGrid = refine(fineCuboid);
- _fineCouplers.emplace_back(
- new FineCoupler<T,DESCRIPTOR>(
- *this, *fineGrid, origin, Vector<T,2> {0,extend[1]}));
- _fineCouplers.emplace_back(
- new FineCoupler<T,DESCRIPTOR>(
- *this, *fineGrid, origin + Vector<T,2> {extend[0],0}, Vector<T,2> {0,extend[1]}));
- _fineCouplers.emplace_back(
- new FineCoupler<T,DESCRIPTOR>(
- *this, *fineGrid, origin + Vector<T,2>(0,extend[1]), Vector<T,2> {extend[0],0}));
- _fineCouplers.emplace_back(
- new FineCoupler<T,DESCRIPTOR>(
- *this, *fineGrid, origin, Vector<T,2> {extend[0],0}));
+ const Vector<T,2> extendX = {extend[0],0};
+ const Vector<T,2> extendY = {0,extend[1]};
- _coarseCouplers.emplace_back(
- new CoarseCoupler<T,DESCRIPTOR>(
- *this, *fineGrid, origin + coarseDeltaX, Vector<T,2> {0,extend[1]-2*coarseDeltaX}));
- _coarseCouplers.emplace_back(
- new CoarseCoupler<T,DESCRIPTOR>(
- *this, *fineGrid, origin + Vector<T,2>(extend[0]-coarseDeltaX,coarseDeltaX), Vector<T,2> {0,extend[1]-2*coarseDeltaX}));
- _coarseCouplers.emplace_back(
- new CoarseCoupler<T,DESCRIPTOR>(
- *this, *fineGrid, origin + Vector<T,2> {coarseDeltaX,extend[1]-coarseDeltaX}, Vector<T,2> {extend[0]-2*coarseDeltaX,0}));
- _coarseCouplers.emplace_back(
- new CoarseCoupler<T,DESCRIPTOR>(
- *this, *fineGrid, origin + coarseDeltaX, Vector<T,2> {extend[0]-2*coarseDeltaX,0}));
+ addFineCoupling(fineGrid, origin, extendY);
+ addFineCoupling(fineGrid, origin + extendX, extendY);
+ addFineCoupling(fineGrid, origin + extendY, extendX);
+ addFineCoupling(fineGrid, origin, extendX);
+
+ const T coarseDeltaX = getConverter().getPhysDeltaX();
+ const Vector<T,2> innerOrigin = origin + coarseDeltaX;
+ const Vector<T,2> innerExtendX = extendX - Vector<T,2> {2*coarseDeltaX,0};
+ const Vector<T,2> innerExtendY = extendY - Vector<T,2> {0,2*coarseDeltaX};
+
+ addCoarseCoupling(fineGrid, innerOrigin, innerExtendY);
+ addCoarseCoupling(fineGrid, innerOrigin + innerExtendX, innerExtendY);
+ addCoarseCoupling(fineGrid, innerOrigin + innerExtendY, innerExtendX);
+ addCoarseCoupling(fineGrid, innerOrigin, innerExtendX);
return fineGrid;
}
@@ -684,8 +697,6 @@ int main(int argc, char* argv[])
singleton::directories().setOutputDir("./tmp/");
OstreamManager clout(std::cout,"main");
- const T coarseDeltaX = 1./N;
-
Vector<T,2> coarseOrigin { 0.0, 0.0 };
Vector<T,2> coarseExtend { lx, ly };
IndicatorCuboid2D<T> coarseCuboid(coarseExtend, coarseOrigin);
@@ -694,11 +705,13 @@ int main(int argc, char* argv[])
Vector<T,2> fineExtend { 0.6 * lx, 0.6 };
auto coarseGrid = Grid<T,DESCRIPTOR>::make(coarseCuboid, N, 0.8, Re);
- auto fineGrid = coarseGrid->refine(fineOrigin, fineExtend);
+ auto fineGrid = &coarseGrid->refine(fineOrigin, fineExtend);
prepareGeometry(coarseGrid->getConverter(), coarseGrid->getSuperGeometry());
prepareGeometry(fineGrid->getConverter(), fineGrid->getSuperGeometry());
+ const T coarseDeltaX = coarseGrid->getConverter().getPhysDeltaX();
+
fineGrid->getSuperGeometry().rename(2,1);
fineGrid->getSuperGeometry().rename(5,2);
IndicatorCuboid2D<T> overlapCuboid(fineExtend - 4*coarseDeltaX, fineOrigin + 2*coarseDeltaX);