summaryrefslogtreecommitdiff
path: root/src/refinement
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-01-17 13:37:26 +0100
committerAdrian Kummerlaender2019-06-24 15:17:09 +0200
commitd900d8c794bb9d50f528bc8e72ceb594fbc292c8 (patch)
tree3e5852e239daae4086c3b9c1c7b70dbaf0cf5c53 /src/refinement
parentac6ac9383dfcc3a688579dc1fb56874bc6ff392e (diff)
downloadgrid_refinement_openlb-d900d8c794bb9d50f528bc8e72ceb594fbc292c8.tar
grid_refinement_openlb-d900d8c794bb9d50f528bc8e72ceb594fbc292c8.tar.gz
grid_refinement_openlb-d900d8c794bb9d50f528bc8e72ceb594fbc292c8.tar.bz2
grid_refinement_openlb-d900d8c794bb9d50f528bc8e72ceb594fbc292c8.tar.lz
grid_refinement_openlb-d900d8c794bb9d50f528bc8e72ceb594fbc292c8.tar.xz
grid_refinement_openlb-d900d8c794bb9d50f528bc8e72ceb594fbc292c8.tar.zst
grid_refinement_openlb-d900d8c794bb9d50f528bc8e72ceb594fbc292c8.zip
Add named types to Grid2D constructor
This allows for readable differentiation between constructor overloads.
Diffstat (limited to 'src/refinement')
-rw-r--r--src/refinement/grid2D.h26
-rw-r--r--src/refinement/grid2D.hh44
2 files changed, 67 insertions, 3 deletions
diff --git a/src/refinement/grid2D.h b/src/refinement/grid2D.h
index 9a20544..f58a4ea 100644
--- a/src/refinement/grid2D.h
+++ b/src/refinement/grid2D.h
@@ -43,6 +43,29 @@ template <typename T, template<typename> class DESCRIPTOR> class FineCoupler2D;
template <typename T, template<typename> class DESCRIPTOR> class CoarseCoupler2D;
template <typename T, template<typename> class DESCRIPTOR> class RefiningGrid2D;
+template <typename T, typename Identificator>
+class NamedType {
+private:
+ T _value;
+
+public:
+ explicit NamedType(const T& value):
+ _value(value) {}
+ explicit NamedType(T&& value):
+ _value(std::move(value)) {}
+
+ operator T() const
+ {
+ return _value;
+ }
+};
+
+template <typename T>
+using RelaxationTime = NamedType<T,struct NamedRelaxationTime>;
+
+template <typename T>
+using LatticeVelocity = NamedType<T,struct NamedLatticeVelocity>;
+
template <typename T, template<typename> class DESCRIPTOR>
class Grid2D {
protected:
@@ -60,7 +83,8 @@ protected:
std::vector<std::unique_ptr<CoarseCoupler2D<T,DESCRIPTOR>>> _coarseCouplers;
public:
- Grid2D(FunctorPtr<IndicatorF2D<T>>&& domainF, int resolution, T tau, int re);
+ Grid2D(FunctorPtr<IndicatorF2D<T>>&& domainF, int resolution, RelaxationTime<T> tau, int re);
+ Grid2D(FunctorPtr<IndicatorF2D<T>>&& domainF, int resolution, LatticeVelocity<T> uMax, int re);
UnitConverter<T,DESCRIPTOR>& getConverter();
CuboidGeometry2D<T>& getCuboidGeometry();
diff --git a/src/refinement/grid2D.hh b/src/refinement/grid2D.hh
index 02fe351..2bf2f7f 100644
--- a/src/refinement/grid2D.hh
+++ b/src/refinement/grid2D.hh
@@ -34,7 +34,11 @@ namespace olb {
template <typename T, template<typename> class DESCRIPTOR>
-Grid2D<T,DESCRIPTOR>::Grid2D(FunctorPtr<IndicatorF2D<T>>&& domainF, int resolution, T tau, int re):
+Grid2D<T,DESCRIPTOR>::Grid2D(
+ FunctorPtr<IndicatorF2D<T>>&& domainF,
+ int resolution,
+ RelaxationTime<T> tau,
+ int re):
_domainF(std::move(domainF)),
_converter(new UnitConverterFromResolutionAndRelaxationTime<T,DESCRIPTOR>(
resolution, // resolution: number of voxels per charPhysL
@@ -66,6 +70,42 @@ Grid2D<T,DESCRIPTOR>::Grid2D(FunctorPtr<IndicatorF2D<T>>&& domainF, int resoluti
}
template <typename T, template<typename> class DESCRIPTOR>
+Grid2D<T,DESCRIPTOR>::Grid2D(
+ FunctorPtr<IndicatorF2D<T>>&& domainF,
+ int resolution,
+ LatticeVelocity<T> velocity,
+ int re):
+ _domainF(std::move(domainF)),
+ _converter(new UnitConverterFromResolutionAndLatticeVelocity<T,DESCRIPTOR>(
+ resolution, // resolution: number of voxels per charPhysL
+ velocity, // maxLatticeVelocity
+ T{1}, // charPhysLength: reference length of simulation geometry
+ T{1}, // charPhysVelocity: maximal/highest expected velocity during simulation in __m / s__
+ T{1./re}, // physViscosity: physical kinematic viscosity in __m^2 / s__
+ T{1}, // physDensity: physical density in __kg / m^3__
+ T{1})),
+ _cuboids(new CuboidGeometry2D<T>(
+ *_domainF,
+ _converter->getConversionFactorLength(),
+#ifdef PARALLEL_MODE_MPI
+ singleton::mpi().getSize()
+#else
+ 1
+#endif
+ )),
+ _balancer(new HeuristicLoadBalancer<T>(
+ *_cuboids)),
+ _geometry(new SuperGeometry2D<T>(
+ *_cuboids,
+ *_balancer,
+ 2)),
+ _lattice(new SuperLattice2D<T,DESCRIPTOR>(
+ *_geometry))
+{
+ _converter->print();
+}
+
+template <typename T, template<typename> class DESCRIPTOR>
UnitConverter<T,DESCRIPTOR>& Grid2D<T,DESCRIPTOR>::getConverter()
{
return *_converter;
@@ -209,7 +249,7 @@ RefiningGrid2D<T,DESCRIPTOR>::RefiningGrid2D(
Grid2D<T,DESCRIPTOR>(
std::unique_ptr<IndicatorF2D<T>>(new IndicatorCuboid2D<T>(extend, origin)),
2*parentGrid.getConverter().getResolution(),
- 2*parentGrid.getConverter().getLatticeRelaxationTime() - 0.5,
+ RelaxationTime<T>(2*parentGrid.getConverter().getLatticeRelaxationTime() - 0.5),
parentGrid.getConverter().getReynoldsNumber()),
_origin(origin),
_extend(extend),