diff options
Remove unnecessary managed pointers
-rw-r--r-- | apps/adrian/poiseuille2d/poiseuille2d.cpp | 84 | ||||
-rw-r--r-- | src/refinement/coupler2D.hh | 6 | ||||
-rw-r--r-- | src/refinement/grid2D.h | 2 | ||||
-rw-r--r-- | src/refinement/grid2D.hh | 16 |
4 files changed, 48 insertions, 60 deletions
diff --git a/apps/adrian/poiseuille2d/poiseuille2d.cpp b/apps/adrian/poiseuille2d/poiseuille2d.cpp index 3d263fa..8b8640e 100644 --- a/apps/adrian/poiseuille2d/poiseuille2d.cpp +++ b/apps/adrian/poiseuille2d/poiseuille2d.cpp @@ -186,114 +186,114 @@ int main(int argc, char* argv[]) const Vector<T,2> coarseExtend {lx, ly}; IndicatorCuboid2D<T> coarseCuboid(coarseExtend, coarseOrigin); - auto coarseGrid = Grid2D<T,DESCRIPTOR>::make(coarseCuboid, N, baseTau, Re); - prepareGeometry(coarseGrid->getConverter(), coarseGrid->getSuperGeometry()); + Grid2D<T,DESCRIPTOR> coarseGrid(coarseCuboid, N, baseTau, Re); + prepareGeometry(coarseGrid.getConverter(), coarseGrid.getSuperGeometry()); 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()); + auto& fineGrid = coarseGrid.refine(fineOrigin, fineExtend); + prepareGeometry(fineGrid.getConverter(), fineGrid.getSuperGeometry()); - auto refinedOverlap = fineGrid->getRefinedOverlap(); - coarseGrid->getSuperGeometry().rename(1,0,*refinedOverlap); - coarseGrid->getSuperGeometry().rename(2,0,*refinedOverlap); + auto refinedOverlap = fineGrid.getRefinedOverlap(); + coarseGrid.getSuperGeometry().rename(1,0,*refinedOverlap); + coarseGrid.getSuperGeometry().rename(2,0,*refinedOverlap); BGKdynamics<T, DESCRIPTOR> coarseBulkDynamics( - coarseGrid->getConverter().getLatticeRelaxationFrequency(), + coarseGrid.getConverter().getLatticeRelaxationFrequency(), instances::getBulkMomenta<T, DESCRIPTOR>()); - sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> coarseSBoundaryCondition(coarseGrid->getSuperLattice()); + sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> coarseSBoundaryCondition(coarseGrid.getSuperLattice()); createLocalBoundaryCondition2D<T, DESCRIPTOR>(coarseSBoundaryCondition); prepareLattice( - coarseGrid->getConverter(), - coarseGrid->getSuperLattice(), + coarseGrid.getConverter(), + coarseGrid.getSuperLattice(), coarseBulkDynamics, coarseSBoundaryCondition, - coarseGrid->getSuperGeometry()); + coarseGrid.getSuperGeometry()); BGKdynamics<T, DESCRIPTOR> fineBulkDynamics( - fineGrid->getConverter().getLatticeRelaxationFrequency(), + fineGrid.getConverter().getLatticeRelaxationFrequency(), instances::getBulkMomenta<T, DESCRIPTOR>()); - sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> fineSBoundaryCondition(fineGrid->getSuperLattice()); + sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> fineSBoundaryCondition(fineGrid.getSuperLattice()); createLocalBoundaryCondition2D<T, DESCRIPTOR>(fineSBoundaryCondition); const Vector<T,2> fineExtend2 {0.6, 0.4}; const Vector<T,2> fineOrigin2 {1.05, (ly-fineExtend2[1])/2}; - auto fineGrid2 = &fineGrid->refine(fineOrigin2, fineExtend2); - prepareGeometry(fineGrid2->getConverter(), fineGrid2->getSuperGeometry()); + auto& fineGrid2 = fineGrid.refine(fineOrigin2, fineExtend2); + prepareGeometry(fineGrid2.getConverter(), fineGrid2.getSuperGeometry()); - auto refinedOverlap2 = fineGrid2->getRefinedOverlap(); - fineGrid->getSuperGeometry().rename(1,0,*refinedOverlap2); - fineGrid->getSuperGeometry().rename(2,0,*refinedOverlap2); + auto refinedOverlap2 = fineGrid2.getRefinedOverlap(); + fineGrid.getSuperGeometry().rename(1,0,*refinedOverlap2); + fineGrid.getSuperGeometry().rename(2,0,*refinedOverlap2); prepareLattice( - fineGrid->getConverter(), - fineGrid->getSuperLattice(), + fineGrid.getConverter(), + fineGrid.getSuperLattice(), fineBulkDynamics, fineSBoundaryCondition, - fineGrid->getSuperGeometry()); + fineGrid.getSuperGeometry()); BGKdynamics<T, DESCRIPTOR> fineBulkDynamics2( - fineGrid2->getConverter().getLatticeRelaxationFrequency(), + fineGrid2.getConverter().getLatticeRelaxationFrequency(), instances::getBulkMomenta<T, DESCRIPTOR>()); - sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> fineSBoundaryCondition2(fineGrid2->getSuperLattice()); + sOnLatticeBoundaryCondition2D<T, DESCRIPTOR> fineSBoundaryCondition2(fineGrid2.getSuperLattice()); createLocalBoundaryCondition2D<T, DESCRIPTOR>(fineSBoundaryCondition2); prepareLattice( - fineGrid2->getConverter(), - fineGrid2->getSuperLattice(), + fineGrid2.getConverter(), + fineGrid2.getSuperLattice(), fineBulkDynamics2, fineSBoundaryCondition2, - fineGrid2->getSuperGeometry()); + fineGrid2.getSuperGeometry()); clout << "starting simulation..." << endl; Timer<T> timer( - coarseGrid->getConverter().getLatticeTime(maxPhysT), - coarseGrid->getSuperGeometry().getStatistics().getNvoxel()); + coarseGrid.getConverter().getLatticeTime(maxPhysT), + coarseGrid.getSuperGeometry().getStatistics().getNvoxel()); util::ValueTracer<T> converge( - fineGrid2->getConverter().getLatticeTime(physInterval), + fineGrid2.getConverter().getLatticeTime(physInterval), residuum); timer.start(); - for (int iT = 0; iT < coarseGrid->getConverter().getLatticeTime(maxPhysT); ++iT) { + for (int iT = 0; iT < coarseGrid.getConverter().getLatticeTime(maxPhysT); ++iT) { if (converge.hasConverged()) { clout << "Simulation converged." << endl; break; } - coarseGrid->collideAndStream(); + coarseGrid.collideAndStream(); getResults( "coarse_", - coarseGrid->getSuperLattice(), - coarseGrid->getConverter(), + coarseGrid.getSuperLattice(), + coarseGrid.getConverter(), iT, - coarseGrid->getSuperGeometry(), + coarseGrid.getSuperGeometry(), timer, converge.hasConverged()); getResults( "fine_", - fineGrid->getSuperLattice(), - fineGrid->getConverter(), + fineGrid.getSuperLattice(), + fineGrid.getConverter(), iT, - fineGrid->getSuperGeometry(), + fineGrid.getSuperGeometry(), timer, converge.hasConverged()); getResults( "fine2_", - fineGrid2->getSuperLattice(), - fineGrid2->getConverter(), + fineGrid2.getSuperLattice(), + fineGrid2.getConverter(), iT, - fineGrid2->getSuperGeometry(), + fineGrid2.getSuperGeometry(), timer, converge.hasConverged()); - converge.takeValue(fineGrid2->getSuperLattice().getStatistics().getAverageEnergy(), true); + converge.takeValue(fineGrid2.getSuperLattice().getStatistics().getAverageEnergy(), true); } timer.stop(); diff --git a/src/refinement/coupler2D.hh b/src/refinement/coupler2D.hh index 1d773f3..3bd2b2f 100644 --- a/src/refinement/coupler2D.hh +++ b/src/refinement/coupler2D.hh @@ -75,7 +75,7 @@ Coupler2D<T,DESCRIPTOR>::Coupler2D(Grid2D<T,DESCRIPTOR>& coarse, Grid2D<T,DESCRI _physOrigin = coarseGeometry.getPhysR(tmpLatticeOrigin.toStdVector()); const T deltaX = _fine.getConverter().getPhysDeltaX(); - const Vector<T,2> stepPhysR = _vertical ? Vector<T,2>{0, deltaX} : Vector<T,2>{deltaX, 0}; + const Vector<T,2> stepPhysR = _vertical ? Vector<T,2> {0, deltaX} : Vector<T,2> {deltaX, 0}; for (int i=0; i < _fineSize; ++i) { if (i % 2 == 0) { @@ -186,7 +186,7 @@ void FineCoupler2D<T,DESCRIPTOR>::couple() Cell<T,DESCRIPTOR> cell; fineLattice.get(finePos, cell); for (int iPop=0; iPop < DESCRIPTOR<T>::q; ++iPop) { - cell[iPop] = fEq[iPop] + this->getScalingFactor() * _c2f_fneq[y][iPop]; + cell[iPop] = fEq[iPop] + this->getScalingFactor() * _c2f_fneq[y][iPop]; } fineLattice.set(finePos, cell); } @@ -309,7 +309,7 @@ void computeRestrictedFneq(const SuperLattice2D<T,DESCRIPTOR>& lattice, T restrictedFneq[DESCRIPTOR<T>::q]) { for (int iPop=0; iPop < DESCRIPTOR<T>::q; ++iPop) { - const auto neighbor = latticeR + Vector<int,3>{0, DESCRIPTOR<T>::c[iPop][0], DESCRIPTOR<T>::c[iPop][1]}; + const auto neighbor = latticeR + Vector<int,3> {0, DESCRIPTOR<T>::c[iPop][0], DESCRIPTOR<T>::c[iPop][1]}; Cell<T,DESCRIPTOR> cell; lattice.get(neighbor, cell); diff --git a/src/refinement/grid2D.h b/src/refinement/grid2D.h index d782651..9a20544 100644 --- a/src/refinement/grid2D.h +++ b/src/refinement/grid2D.h @@ -60,8 +60,6 @@ protected: std::vector<std::unique_ptr<CoarseCoupler2D<T,DESCRIPTOR>>> _coarseCouplers; public: - static std::unique_ptr<Grid2D<T,DESCRIPTOR>> make(IndicatorF2D<T>& domainF, int resolution, T tau, int re); - Grid2D(FunctorPtr<IndicatorF2D<T>>&& domainF, int resolution, T tau, int re); UnitConverter<T,DESCRIPTOR>& getConverter(); diff --git a/src/refinement/grid2D.hh b/src/refinement/grid2D.hh index aa82240..02fe351 100644 --- a/src/refinement/grid2D.hh +++ b/src/refinement/grid2D.hh @@ -34,16 +34,6 @@ namespace olb { template <typename T, template<typename> class DESCRIPTOR> -std::unique_ptr<Grid2D<T,DESCRIPTOR>> Grid2D<T,DESCRIPTOR>::make( - IndicatorF2D<T>& domainF, - int resolution, T tau, int re) -{ - return std::unique_ptr<Grid2D<T,DESCRIPTOR>>( - new Grid2D<T,DESCRIPTOR>(domainF, resolution, tau, re) - ); -} - -template <typename T, template<typename> class DESCRIPTOR> Grid2D<T,DESCRIPTOR>::Grid2D(FunctorPtr<IndicatorF2D<T>>&& domainF, int resolution, T tau, int re): _domainF(std::move(domainF)), _converter(new UnitConverterFromResolutionAndRelaxationTime<T,DESCRIPTOR>( @@ -62,7 +52,7 @@ Grid2D<T,DESCRIPTOR>::Grid2D(FunctorPtr<IndicatorF2D<T>>&& domainF, int resoluti #else 1 #endif - )), + )), _balancer(new HeuristicLoadBalancer<T>( *_cuboids)), _geometry(new SuperGeometry2D<T>( @@ -191,7 +181,7 @@ RefiningGrid2D<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::refine( addFineCoupling(fineGrid, origin, extendX); const T coarseDeltaX = getConverter().getPhysDeltaX(); - const Vector<T,2> innerOrigin = origin + coarseDeltaX; + 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}; @@ -244,7 +234,7 @@ std::unique_ptr<IndicatorF2D<T>> RefiningGrid2D<T,DESCRIPTOR>::getRefinedOverlap const T coarseDeltaX = _parentGrid.getConverter().getPhysDeltaX(); return std::unique_ptr<IndicatorF2D<T>>( - new IndicatorCuboid2D<T>(_extend - 4*coarseDeltaX, _origin + 2*coarseDeltaX)); + new IndicatorCuboid2D<T>(_extend - 4*coarseDeltaX, _origin + 2*coarseDeltaX)); } } |