summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-01-14 15:51:54 +0100
committerAdrian Kummerlaender2019-06-24 15:17:09 +0200
commit6403bbf816f6256ade8569114441386ece29d4a5 (patch)
treeb8301e322f322f20ee0e78eefd3d7adfc4cdc80c
parent9546a228faa725df3a1956995f5c247ac8c79f51 (diff)
downloadgrid_refinement_openlb-6403bbf816f6256ade8569114441386ece29d4a5.tar
grid_refinement_openlb-6403bbf816f6256ade8569114441386ece29d4a5.tar.gz
grid_refinement_openlb-6403bbf816f6256ade8569114441386ece29d4a5.tar.bz2
grid_refinement_openlb-6403bbf816f6256ade8569114441386ece29d4a5.tar.xz
grid_refinement_openlb-6403bbf816f6256ade8569114441386ece29d4a5.zip
Tidy up function parameters by accepting Grid2D
-rw-r--r--apps/adrian/poiseuille2d/poiseuille2d.cpp117
1 files changed, 51 insertions, 66 deletions
diff --git a/apps/adrian/poiseuille2d/poiseuille2d.cpp b/apps/adrian/poiseuille2d/poiseuille2d.cpp
index 8b8640e..7112f58 100644
--- a/apps/adrian/poiseuille2d/poiseuille2d.cpp
+++ b/apps/adrian/poiseuille2d/poiseuille2d.cpp
@@ -47,14 +47,15 @@ const T physInterval = 0.25; // interval for the convergence check in s
const T residuum = 1e-5; // residuum for the convergence check
-void prepareGeometry(UnitConverter<T,DESCRIPTOR> const& converter,
- SuperGeometry2D<T>& superGeometry)
+void prepareGeometry(Grid2D<T,DESCRIPTOR>& grid)
{
-
OstreamManager clout(std::cout,"prepareGeometry");
clout << "Prepare Geometry ..." << std::endl;
- superGeometry.rename(0,1);
+ auto& converter = grid.getConverter();
+ auto& sGeometry = grid.getSuperGeometry();
+
+ sGeometry.rename(0,1);
const T physSpacing = converter.getPhysDeltaX();
@@ -64,10 +65,10 @@ void prepareGeometry(UnitConverter<T,DESCRIPTOR> const& converter,
const Vector<T,2> wallOrigin {-physSpacing/4, -physSpacing/4};
IndicatorCuboid2D<T> lowerWall(wallExtend, wallOrigin);
- superGeometry.rename(1,2,lowerWall);
+ sGeometry.rename(1,2,lowerWall);
IndicatorCuboid2D<T> upperWall(wallExtend, wallOrigin + Vector<T,2> {0,ly});
- superGeometry.rename(1,2,upperWall);
+ sGeometry.rename(1,2,upperWall);
}
// Set material number for inflow and outflow
@@ -76,46 +77,48 @@ void prepareGeometry(UnitConverter<T,DESCRIPTOR> const& converter,
const Vector<T,2> origin {-physSpacing/4, -physSpacing/4};
IndicatorCuboid2D<T> inflow(extend, origin);
- superGeometry.rename(1,3,inflow);
+ sGeometry.rename(1,3,inflow);
IndicatorCuboid2D<T> outflow(extend, origin + Vector<T,2> {lx,0});
- superGeometry.rename(1,4,outflow);
+ sGeometry.rename(1,4,outflow);
}
// Set material number for vertically centered obstacle
{
const Vector<T,2> origin {1.25, ly/2};
IndicatorCircle2D<T> obstacle(origin, 0.1);
- superGeometry.rename(1,2,obstacle);
+ sGeometry.rename(1,2,obstacle);
}
- superGeometry.clean();
- superGeometry.innerClean();
- superGeometry.checkForErrors();
- superGeometry.print();
+ sGeometry.clean();
+ sGeometry.innerClean();
+ sGeometry.checkForErrors();
+ sGeometry.print();
clout << "Prepare Geometry ... OK" << std::endl;
}
-void prepareLattice(UnitConverter<T,DESCRIPTOR> const& converter,
- SuperLattice2D<T, DESCRIPTOR>& sLattice,
+void prepareLattice(Grid2D<T,DESCRIPTOR>& grid,
Dynamics<T, DESCRIPTOR>& bulkDynamics,
- sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>& sBoundaryCondition,
- SuperGeometry2D<T>& superGeometry)
+ sOnLatticeBoundaryCondition2D<T,DESCRIPTOR>& sBoundaryCondition)
{
OstreamManager clout(std::cout,"prepareLattice");
clout << "Prepare lattice ..." << std::endl;
+ auto& converter = grid.getConverter();
+ auto& sGeometry = grid.getSuperGeometry();
+ auto& sLattice = grid.getSuperLattice();
+
const T omega = converter.getLatticeRelaxationFrequency();
- sLattice.defineDynamics(superGeometry, 0, &instances::getNoDynamics<T, DESCRIPTOR>());
- sLattice.defineDynamics(superGeometry, 1, &bulkDynamics); // bulk
- sLattice.defineDynamics(superGeometry, 2, &instances::getBounceBack<T, DESCRIPTOR>());
- sLattice.defineDynamics(superGeometry, 3, &bulkDynamics); // inflow
- sLattice.defineDynamics(superGeometry, 4, &bulkDynamics); // outflow
+ sLattice.defineDynamics(sGeometry, 0, &instances::getNoDynamics<T, DESCRIPTOR>());
+ sLattice.defineDynamics(sGeometry, 1, &bulkDynamics); // bulk
+ sLattice.defineDynamics(sGeometry, 2, &instances::getBounceBack<T, DESCRIPTOR>());
+ sLattice.defineDynamics(sGeometry, 3, &bulkDynamics); // inflow
+ sLattice.defineDynamics(sGeometry, 4, &bulkDynamics); // outflow
- sBoundaryCondition.addVelocityBoundary(superGeometry, 3, omega);
- sBoundaryCondition.addVelocityBoundary(superGeometry, 4, omega);
+ sBoundaryCondition.addVelocityBoundary(sGeometry, 3, omega);
+ sBoundaryCondition.addVelocityBoundary(sGeometry, 4, omega);
const T Lx = converter.getLatticeLength(lx);
const T Ly = converter.getLatticeLength(ly);
@@ -128,15 +131,15 @@ void prepareLattice(UnitConverter<T,DESCRIPTOR> const& converter,
std::vector<T> axisDirection{1, 0};
Poiseuille2D<T> u(axisPoint, axisDirection, maxVelocity, radius);
- sLattice.defineRhoU(superGeometry, 1, rho, u);
- sLattice.iniEquilibrium(superGeometry, 1, rho, u);
- sLattice.defineRhoU(superGeometry, 2, rho, u);
- sLattice.iniEquilibrium(superGeometry, 2, rho, u);
+ sLattice.defineRhoU(sGeometry, 1, rho, u);
+ sLattice.iniEquilibrium(sGeometry, 1, rho, u);
+ sLattice.defineRhoU(sGeometry, 2, rho, u);
+ sLattice.iniEquilibrium(sGeometry, 2, rho, u);
- sLattice.defineRhoU(superGeometry, 3, rho, u);
- sLattice.iniEquilibrium(superGeometry, 3, rho, u);
- sLattice.defineRhoU(superGeometry, 4, rho, u);
- sLattice.iniEquilibrium(superGeometry, 4, rho, u);
+ sLattice.defineRhoU(sGeometry, 3, rho, u);
+ sLattice.iniEquilibrium(sGeometry, 3, rho, u);
+ sLattice.defineRhoU(sGeometry, 4, rho, u);
+ sLattice.iniEquilibrium(sGeometry, 4, rho, u);
sLattice.initialize();
@@ -144,16 +147,19 @@ void prepareLattice(UnitConverter<T,DESCRIPTOR> const& converter,
}
void getResults(const std::string& prefix,
- SuperLattice2D<T,DESCRIPTOR>& sLattice,
- UnitConverter<T,DESCRIPTOR> const& converter, int iT,
- SuperGeometry2D<T>& superGeometry, Timer<T>& timer, bool hasConverged)
+ Grid2D<T,DESCRIPTOR>& grid,
+ int iT, Timer<T>& timer, bool hasConverged)
{
OstreamManager clout(std::cout,"getResults");
+ auto& converter = grid.getConverter();
+ auto& sLattice = grid.getSuperLattice();
+ auto& sGeometry = grid.getSuperGeometry();
+
SuperVTMwriter2D<T> vtmWriter(prefix + "poiseuille2d");
SuperLatticePhysVelocity2D<T, DESCRIPTOR> velocity(sLattice, converter);
SuperLatticePhysPressure2D<T, DESCRIPTOR> pressure(sLattice, converter);
- SuperLatticeGeometry2D<T, DESCRIPTOR> geometry( sLattice, superGeometry );
+ SuperLatticeGeometry2D<T, DESCRIPTOR> geometry(sLattice, sGeometry);
vtmWriter.addFunctor(geometry);
vtmWriter.addFunctor(velocity);
vtmWriter.addFunctor(pressure);
@@ -187,13 +193,13 @@ int main(int argc, char* argv[])
IndicatorCuboid2D<T> coarseCuboid(coarseExtend, coarseOrigin);
Grid2D<T,DESCRIPTOR> coarseGrid(coarseCuboid, N, baseTau, Re);
- prepareGeometry(coarseGrid.getConverter(), coarseGrid.getSuperGeometry());
+ prepareGeometry(coarseGrid);
const Vector<T,2> fineExtend {3.0, 1.5};
const Vector<T,2> fineOrigin {0.8, (ly-fineExtend[1])/2};
auto& fineGrid = coarseGrid.refine(fineOrigin, fineExtend);
- prepareGeometry(fineGrid.getConverter(), fineGrid.getSuperGeometry());
+ prepareGeometry(fineGrid);
auto refinedOverlap = fineGrid.getRefinedOverlap();
coarseGrid.getSuperGeometry().rename(1,0,*refinedOverlap);
@@ -206,12 +212,7 @@ int main(int argc, char* argv[])
sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> coarseSBoundaryCondition(coarseGrid.getSuperLattice());
createLocalBoundaryCondition2D<T, DESCRIPTOR>(coarseSBoundaryCondition);
- prepareLattice(
- coarseGrid.getConverter(),
- coarseGrid.getSuperLattice(),
- coarseBulkDynamics,
- coarseSBoundaryCondition,
- coarseGrid.getSuperGeometry());
+ prepareLattice(coarseGrid, coarseBulkDynamics, coarseSBoundaryCondition);
BGKdynamics<T, DESCRIPTOR> fineBulkDynamics(
fineGrid.getConverter().getLatticeRelaxationFrequency(),
@@ -224,18 +225,13 @@ int main(int argc, char* argv[])
const Vector<T,2> fineOrigin2 {1.05, (ly-fineExtend2[1])/2};
auto& fineGrid2 = fineGrid.refine(fineOrigin2, fineExtend2);
- prepareGeometry(fineGrid2.getConverter(), fineGrid2.getSuperGeometry());
+ prepareGeometry(fineGrid2);
auto refinedOverlap2 = fineGrid2.getRefinedOverlap();
fineGrid.getSuperGeometry().rename(1,0,*refinedOverlap2);
fineGrid.getSuperGeometry().rename(2,0,*refinedOverlap2);
- prepareLattice(
- fineGrid.getConverter(),
- fineGrid.getSuperLattice(),
- fineBulkDynamics,
- fineSBoundaryCondition,
- fineGrid.getSuperGeometry());
+ prepareLattice(fineGrid, fineBulkDynamics, fineSBoundaryCondition);
BGKdynamics<T, DESCRIPTOR> fineBulkDynamics2(
fineGrid2.getConverter().getLatticeRelaxationFrequency(),
@@ -244,12 +240,7 @@ int main(int argc, char* argv[])
sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> fineSBoundaryCondition2(fineGrid2.getSuperLattice());
createLocalBoundaryCondition2D<T, DESCRIPTOR>(fineSBoundaryCondition2);
- prepareLattice(
- fineGrid2.getConverter(),
- fineGrid2.getSuperLattice(),
- fineBulkDynamics2,
- fineSBoundaryCondition2,
- fineGrid2.getSuperGeometry());
+ prepareLattice(fineGrid2, fineBulkDynamics2, fineSBoundaryCondition2);
clout << "starting simulation..." << endl;
Timer<T> timer(
@@ -270,26 +261,20 @@ int main(int argc, char* argv[])
getResults(
"coarse_",
- coarseGrid.getSuperLattice(),
- coarseGrid.getConverter(),
+ coarseGrid,
iT,
- coarseGrid.getSuperGeometry(),
timer,
converge.hasConverged());
getResults(
"fine_",
- fineGrid.getSuperLattice(),
- fineGrid.getConverter(),
+ fineGrid,
iT,
- fineGrid.getSuperGeometry(),
timer,
converge.hasConverged());
getResults(
"fine2_",
- fineGrid2.getSuperLattice(),
- fineGrid2.getConverter(),
+ fineGrid2,
iT,
- fineGrid2.getSuperGeometry(),
timer,
converge.hasConverged());