From 418c08847da977f27a797cd6b3215b99534a53eb Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 3 Oct 2020 16:31:24 +0200 Subject: [PATCH] add extended constructors for gmsh4reader --- dune/gmsh4/gmsh4reader.hh | 24 +++++++++++-------- .../gridcreators/continuousgridcreator.hh | 11 ++++++--- dune/gmsh4/gridcreators/derivedgridcreator.hh | 8 ++++--- .../gridcreators/discontinuousgridcreator.hh | 10 +++++--- .../gmsh4/gridcreators/lagrangegridcreator.hh | 10 ++++---- .../gmsh4/gridcreators/parallelgridcreator.hh | 11 ++++++--- dune/gmsh4/gridcreators/serialgridcreator.hh | 11 ++++++--- 7 files changed, 56 insertions(+), 29 deletions(-) diff --git a/dune/gmsh4/gmsh4reader.hh b/dune/gmsh4/gmsh4reader.hh index 0e26395..7ff1bb4 100644 --- a/dune/gmsh4/gmsh4reader.hh +++ b/dune/gmsh4/gmsh4reader.hh @@ -43,11 +43,13 @@ namespace Dune using size_type = SizeType; /// Constructor. Creates a new GridCreator with the passed factory - explicit Gmsh4Reader (GridFactory& factory) - : creator_(std::make_shared(factory)) + template ::value,int> = 0> + explicit Gmsh4Reader (Args&&... args) + : creator_(std::make_shared(std::forward(args)...)) {} - /// Constructor. Stores a references to the passed creator + /// Constructor. Stores the references in a non-destroying shared_ptr explicit Gmsh4Reader (GridCreator& creator) : creator_(stackobject_to_shared_ptr(creator)) {} @@ -65,13 +67,6 @@ namespace Dune **/ void read (std::string const& filename, bool fillCreator = true); - /// Implementation of \ref FileReader interface - static void fillFactoryImpl (GridFactory& factory, std::string const& filename) - { - Gmsh4Reader reader{factory}; - reader.read(filename); - } - /// Advanced read methods /// @{ @@ -103,6 +98,15 @@ namespace Dune return pieces_; } +#ifndef DOXYGEN + /// Implementation of \ref FileReader interface + static void fillFactoryImpl (GridFactory& factory, std::string const& filename) + { + Gmsh4Reader reader{factory}; + reader.read(filename); + } +#endif + private: template void readValueBinary(std::ifstream& input, T &v); diff --git a/dune/gmsh4/gridcreators/continuousgridcreator.hh b/dune/gmsh4/gridcreators/continuousgridcreator.hh index cc48833..ed7be39 100644 --- a/dune/gmsh4/gridcreators/continuousgridcreator.hh +++ b/dune/gmsh4/gridcreators/continuousgridcreator.hh @@ -27,10 +27,9 @@ namespace Dune using GlobalCoordinate = typename Super::GlobalCoordinate; using Nodes = std::vector; - ContinuousGridCreator (GridFactory& factory) - : Super(factory) - {} + public: + using Super::Super; using Super::factory; template @@ -102,5 +101,11 @@ namespace Dune std::size_t vertexShift_ = 0; }; + // deduction guides + template + ContinuousGridCreator(GridFactory&) + -> ContinuousGridCreator; + + } // end namespace Gmsh4 } // end namespace Dune diff --git a/dune/gmsh4/gridcreators/derivedgridcreator.hh b/dune/gmsh4/gridcreators/derivedgridcreator.hh index 37b0ca9..77d551d 100644 --- a/dune/gmsh4/gridcreators/derivedgridcreator.hh +++ b/dune/gmsh4/gridcreators/derivedgridcreator.hh @@ -23,9 +23,11 @@ namespace Dune using Grid = typename GridCreator::Grid; using GlobalCoordinate = typename Super::GlobalCoordinate; - DerivedGridCreator (GridFactory& factory) - : Super(factory) - , gridCreator_(factory) + template = 0> + DerivedGridCreator (Args&&... args) + : Super(std::forward(args)...) + , gridCreator_(Super::factory()) {} template diff --git a/dune/gmsh4/gridcreators/discontinuousgridcreator.hh b/dune/gmsh4/gridcreators/discontinuousgridcreator.hh index 58ae02f..0772068 100644 --- a/dune/gmsh4/gridcreators/discontinuousgridcreator.hh +++ b/dune/gmsh4/gridcreators/discontinuousgridcreator.hh @@ -39,10 +39,9 @@ namespace Dune } }; - DiscontinuousGridCreator (GridFactory& factory) - : Super(factory) - {} + public: + using Super::Super; using Super::factory; template @@ -67,5 +66,10 @@ namespace Dune std::map uniquePoints_; }; + // deduction guides + template + DiscontinuousGridCreator(GridFactory&) + -> DiscontinuousGridCreator; + } // end namespace Gmsh4 } // end namespace Dune diff --git a/dune/gmsh4/gridcreators/lagrangegridcreator.hh b/dune/gmsh4/gridcreators/lagrangegridcreator.hh index 9c05cb6..4f82e93 100644 --- a/dune/gmsh4/gridcreators/lagrangegridcreator.hh +++ b/dune/gmsh4/gridcreators/lagrangegridcreator.hh @@ -59,12 +59,9 @@ namespace Dune class LocalFunction; public: + using Super::Super; using Super::factory; - LagrangeGridCreator (GridFactory& factory) - : Super(factory) - {} - /// Implementation of the interface function `insertVertices()` template void insertVerticesImpl (std::size_t numNodes, @@ -283,6 +280,11 @@ namespace Dune std::size_t vertexShift_ = 0; }; + // deduction guides + template + LagrangeGridCreator(GridFactory&) + -> LagrangeGridCreator; + template class LagrangeGridCreator::LocalParametrization diff --git a/dune/gmsh4/gridcreators/parallelgridcreator.hh b/dune/gmsh4/gridcreators/parallelgridcreator.hh index 0f8942b..22162fb 100644 --- a/dune/gmsh4/gridcreators/parallelgridcreator.hh +++ b/dune/gmsh4/gridcreators/parallelgridcreator.hh @@ -32,9 +32,8 @@ namespace Dune // The GridFactory must support insertion of global vertex IDs static_assert(Std::is_detected, GlobalCoordinate, VertexId>{}, ""); - ParallelGridCreator (GridFactory& factory) - : Super(factory) - {} + public: + using Super::Super; template void insertVerticesImpl (std::size_t numNodes, @@ -79,5 +78,11 @@ namespace Dune std::size_t vertexShift_ = 0; }; + // deduction guides + template + ParallelGridCreator(GridFactory&) + -> ParallelGridCreator; + + } // end namespace Gmsh4 } // end namespace Dune diff --git a/dune/gmsh4/gridcreators/serialgridcreator.hh b/dune/gmsh4/gridcreators/serialgridcreator.hh index 82c713b..c85f088 100644 --- a/dune/gmsh4/gridcreators/serialgridcreator.hh +++ b/dune/gmsh4/gridcreators/serialgridcreator.hh @@ -22,9 +22,8 @@ namespace Dune using Super = GridCreatorInterface; using GlobalCoordinate = typename Super::GlobalCoordinate; - SerialGridCreator (GridFactory& factory) - : Super(factory) - {} + public: + using Super::Super; template void insertVerticesImpl (std::size_t numNodes, @@ -56,5 +55,11 @@ namespace Dune std::vector shift_; }; + // deduction guides + template + SerialGridCreator(GridFactory&) + -> SerialGridCreator; + + } // end namespace Gmsh4 } // end namespace Dune -- GitLab