summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-01-10 21:55:43 +0100
committerAdrian Kummerlaender2019-06-24 15:17:09 +0200
commit946cb3702e6baacec1faaeab9ad66dfd99320b55 (patch)
treeca2b1b131c0aaade1703c38c378a44b1fad0e312
parente415cc0cc2baedaade019693f69b6e1ed0dd4c2b (diff)
downloadgrid_refinement_openlb-946cb3702e6baacec1faaeab9ad66dfd99320b55.tar
grid_refinement_openlb-946cb3702e6baacec1faaeab9ad66dfd99320b55.tar.gz
grid_refinement_openlb-946cb3702e6baacec1faaeab9ad66dfd99320b55.tar.bz2
grid_refinement_openlb-946cb3702e6baacec1faaeab9ad66dfd99320b55.tar.lz
grid_refinement_openlb-946cb3702e6baacec1faaeab9ad66dfd99320b55.tar.xz
grid_refinement_openlb-946cb3702e6baacec1faaeab9ad66dfd99320b55.tar.zst
grid_refinement_openlb-946cb3702e6baacec1faaeab9ad66dfd99320b55.zip
Fix grid alignment of refinement area
-rw-r--r--apps/adrian/poiseuille2d/poiseuille2d.cpp14
-rw-r--r--src/refinement/coupler2D.hh4
-rw-r--r--src/refinement/grid2D.h3
-rw-r--r--src/refinement/grid2D.hh9
4 files changed, 19 insertions, 11 deletions
diff --git a/apps/adrian/poiseuille2d/poiseuille2d.cpp b/apps/adrian/poiseuille2d/poiseuille2d.cpp
index df166e1..b16a19b 100644
--- a/apps/adrian/poiseuille2d/poiseuille2d.cpp
+++ b/apps/adrian/poiseuille2d/poiseuille2d.cpp
@@ -37,9 +37,9 @@ typedef double T;
const T lx = 8.0; // length of the channel
const T ly = 2.0; // height of the channel
-const int N = 64; // resolution of the model
-const T Re = 500.; // Reynolds number
-const T baseTau = 0.57; // Relaxation time of coarsest grid
+const int N = 50; // resolution of the model
+const T Re = 200.; // Reynolds number
+const T baseTau = 0.8; // Relaxation time of coarsest grid
const T maxPhysT = 60.; // max. simulation time in s, SI unit
const T physInterval = 0.25; // interval for the convergence check in s
const T residuum = 1e-5; // residuum for the convergence check
@@ -188,8 +188,8 @@ int main(int argc, char* argv[])
prepareGeometry(coarseGrid->getConverter(), coarseGrid->getSuperGeometry());
const Vector<T,2> wantedFineExtend {3.0, 1.5};
- const Vector<T,2> fineOrigin = coarseGrid->alignToGrid({0.8, (ly-wantedFineExtend[1])/2});
- const Vector<T,2> fineExtend = coarseGrid->alignToGrid(fineOrigin + wantedFineExtend) - fineOrigin;
+ const Vector<T,2> fineOrigin = coarseGrid->alignLocationToGrid({0.8, (ly-wantedFineExtend[1])/2});
+ const Vector<T,2> fineExtend = coarseGrid->alignExtendToGrid(wantedFineExtend);
auto fineGrid = &coarseGrid->refine(fineOrigin, fineExtend);
prepareGeometry(fineGrid->getConverter(), fineGrid->getSuperGeometry());
@@ -222,8 +222,8 @@ int main(int argc, char* argv[])
createLocalBoundaryCondition2D<T, DESCRIPTOR>(fineSBoundaryCondition);
const Vector<T,2> wantedFineExtend2 {0.6, 0.4};
- const Vector<T,2> fineOrigin2 = fineGrid->alignToGrid({1.05, (ly-wantedFineExtend2[1])/2});
- const Vector<T,2> fineExtend2 = fineGrid->alignToGrid(fineOrigin2 + wantedFineExtend2) - fineOrigin2;
+ const Vector<T,2> fineOrigin2 = fineGrid->alignLocationToGrid({1.05, (ly-wantedFineExtend2[1])/2});
+ const Vector<T,2> fineExtend2 = fineGrid->alignExtendToGrid(wantedFineExtend2);
auto fineGrid2 = &fineGrid->refine(fineOrigin2, fineExtend2);
prepareGeometry(fineGrid2->getConverter(), fineGrid2->getSuperGeometry());
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<T,DESCRIPTOR>::interpolate()
template <typename T, template<typename> class DESCRIPTOR>
void FineCoupler2D<T,DESCRIPTOR>::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<T,DESCRIPTOR>::CoarseCoupler2D(
template <typename T, template<typename> class DESCRIPTOR>
void CoarseCoupler2D<T,DESCRIPTOR>::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<T,DESCRIPTOR>& addCoarseCoupling(
Grid2D<T,DESCRIPTOR>& fineGrid, Vector<T,2> origin, Vector<T,2> extend);
- Vector<T,2> alignToGrid(Vector<T,2> physR) const;
+ Vector<T,2> alignLocationToGrid(Vector<T,2> physR) const;
+ Vector<T,2> alignExtendToGrid(Vector<T,2> physR) const;
Grid2D<T,DESCRIPTOR>& refine(IndicatorF2D<T>& domainF);
Grid2D<T,DESCRIPTOR>& refine(Vector<T,2> origin, Vector<T,2> 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,7 +181,7 @@ Grid2D<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::refine(IndicatorF2D<T>& domainF)
}
template <typename T, template<typename> class DESCRIPTOR>
-Vector<T,2> Grid2D<T,DESCRIPTOR>::alignToGrid(Vector<T,2> physR) const
+Vector<T,2> Grid2D<T,DESCRIPTOR>::alignLocationToGrid(Vector<T,2> physR) const
{
Vector<int,3> latticeR{};
_cuboids->getLatticeR(physR, latticeR);
@@ -189,6 +189,13 @@ Vector<T,2> Grid2D<T,DESCRIPTOR>::alignToGrid(Vector<T,2> physR) const
}
template <typename T, template<typename> class DESCRIPTOR>
+Vector<T,2> Grid2D<T,DESCRIPTOR>::alignExtendToGrid(Vector<T,2> extend) const
+{
+ const T deltaX = _converter->getPhysDeltaX();
+ return floor(extend / deltaX) * deltaX;
+}
+
+template <typename T, template<typename> class DESCRIPTOR>
Grid2D<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::refine(Vector<T,2> origin, Vector<T,2> extend)
{
IndicatorCuboid2D<T> fineCuboid(extend, origin);