From af47dd01f9e9305e72778ecbb4a89296c22f89ea Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Wed, 13 Mar 2024 19:10:04 +0100 Subject: [PATCH] yrange()/mrange(): add xpl version --- src/include/ranges/mrange.cc.h | 6 ++++++ src/include/ranges/mrange.h | 6 ++++++ src/include/ranges/yrange.h | 6 ++++++ src/lib/ranges/yrange.cc | 5 +++++ src/opt/mpi/include/rrange.cc.h | 2 +- 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/include/ranges/mrange.cc.h b/src/include/ranges/mrange.cc.h index 001a0a8..82d1d6f 100644 --- a/src/include/ranges/mrange.cc.h +++ b/src/include/ranges/mrange.cc.h @@ -807,6 +807,12 @@ namespace CNORXZ { return MRangeFactory(std::make_tuple(rs...)).create(); } + + template + Sptr> xplMrange(const Sptr&... rs) + { + return std::dynamic_pointer_cast>( mrange( rs... ) ); + } template Sptr> RangeCast>::func(const RangePtr& r) diff --git a/src/include/ranges/mrange.h b/src/include/ranges/mrange.h index 0cbda99..ec8f37d 100644 --- a/src/include/ranges/mrange.h +++ b/src/include/ranges/mrange.h @@ -405,6 +405,12 @@ namespace CNORXZ template RangePtr mrange(const Sptr&... rs); + /** Create MRange pointer. + @param rs Pointer to sub-ranges. + */ + template + Sptr> xplMrange(const Sptr&... rs); + /** **** Specialization of RangeCast for MRange. @see RangeCast. diff --git a/src/include/ranges/yrange.h b/src/include/ranges/yrange.h index ea86b6d..06cb273 100644 --- a/src/include/ranges/yrange.h +++ b/src/include/ranges/yrange.h @@ -343,6 +343,12 @@ namespace CNORXZ */ RangePtr yrange(const Vector& rs); + /** Create YRange from sub-ranges. + @param rs Vector of pointers to the sub-ranges used by the YRange. + @return A shared pointer to the created YRange. + */ + Sptr xplYrange(const Vector& rs); + /** **** Specialize RangeCast for casts to YRange. @see RangeCast diff --git a/src/lib/ranges/yrange.cc b/src/lib/ranges/yrange.cc index 4a4ac16..ed0e40f 100644 --- a/src/lib/ranges/yrange.cc +++ b/src/lib/ranges/yrange.cc @@ -668,6 +668,11 @@ namespace CNORXZ return YRangeFactory(rs).create(); } + Sptr xplYrange(const Vector& rs) + { + return std::dynamic_pointer_cast( yrange( rs ) ); + } + /*=================+ | Range Casts | +=================*/ diff --git a/src/opt/mpi/include/rrange.cc.h b/src/opt/mpi/include/rrange.cc.h index 7ace931..ed23b87 100644 --- a/src/opt/mpi/include/rrange.cc.h +++ b/src/opt/mpi/include/rrange.cc.h @@ -441,7 +441,7 @@ namespace CNORXZ auto mr = ifor<0,N>( [&](auto mu) { return split( global->space()[CSizeT{}], geom->space()[CSizeT{}] ); }, [](const auto&... r) { return xplMrange(r,...); } ); - typedef std::remove_reference::type RangeI; + typedef std::remove_reference::type RangeI; return RRangeFactory(mr, geom).create(); // explicit range type!!! } // other cases!!!