Commit 391fa3dd authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Merge branch 'feature/gmsh4reader_constructors' into 'master'

add extended constructors for gmsh4reader

See merge request !7
parents 66232845 418c0884
Pipeline #5000 failed with stage
in 10 minutes and 9 seconds
......@@ -43,11 +43,13 @@ namespace Dune
using size_type = SizeType;
/// Constructor. Creates a new GridCreator with the passed factory
explicit Gmsh4Reader (GridFactory<Grid>& factory)
: creator_(std::make_shared<GridCreator>(factory))
template <class... Args,
std::enable_if_t<std::is_constructible<GridCreator, Args...>::value,int> = 0>
explicit Gmsh4Reader (Args&&... args)
: creator_(std::make_shared<GridCreator>(std::forward<Args>(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<Grid>& 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<Grid>& factory, std::string const& filename)
{
Gmsh4Reader reader{factory};
reader.read(filename);
}
#endif
private:
template<class T>
void readValueBinary(std::ifstream& input, T &v);
......
......@@ -27,10 +27,9 @@ namespace Dune
using GlobalCoordinate = typename Super::GlobalCoordinate;
using Nodes = std::vector<GlobalCoordinate>;
ContinuousGridCreator (GridFactory<Grid>& factory)
: Super(factory)
{}
public:
using Super::Super;
using Super::factory;
template <class NodeAttributes>
......@@ -102,5 +101,11 @@ namespace Dune
std::size_t vertexShift_ = 0;
};
// deduction guides
template <class Grid>
ContinuousGridCreator(GridFactory<Grid>&)
-> ContinuousGridCreator<Grid>;
} // end namespace Gmsh4
} // end namespace Dune
......@@ -23,9 +23,11 @@ namespace Dune
using Grid = typename GridCreator::Grid;
using GlobalCoordinate = typename Super::GlobalCoordinate;
DerivedGridCreator (GridFactory<Grid>& factory)
: Super(factory)
, gridCreator_(factory)
template <class... Args,
disableCopyMove<DerivedGridCreator, Args...> = 0>
DerivedGridCreator (Args&&... args)
: Super(std::forward<Args>(args)...)
, gridCreator_(Super::factory())
{}
template <class NodeAttributes>
......
......@@ -39,10 +39,9 @@ namespace Dune
}
};
DiscontinuousGridCreator (GridFactory<Grid>& factory)
: Super(factory)
{}
public:
using Super::Super;
using Super::factory;
template <class NodeAttributes>
......@@ -67,5 +66,10 @@ namespace Dune
std::map<GlobalCoordinate, std::size_t, CoordLess> uniquePoints_;
};
// deduction guides
template <class Grid>
DiscontinuousGridCreator(GridFactory<Grid>&)
-> DiscontinuousGridCreator<Grid>;
} // end namespace Gmsh4
} // end namespace Dune
......@@ -59,12 +59,9 @@ namespace Dune
class LocalFunction;
public:
using Super::Super;
using Super::factory;
LagrangeGridCreator (GridFactory<GridType>& factory)
: Super(factory)
{}
/// Implementation of the interface function `insertVertices()`
template <class NodeAttributes>
void insertVerticesImpl (std::size_t numNodes,
......@@ -283,6 +280,11 @@ namespace Dune
std::size_t vertexShift_ = 0;
};
// deduction guides
template <class Grid>
LagrangeGridCreator(GridFactory<Grid>&)
-> LagrangeGridCreator<Grid>;
template <class Grid>
class LagrangeGridCreator<Grid>::LocalParametrization
......
......@@ -32,9 +32,8 @@ namespace Dune
// The GridFactory must support insertion of global vertex IDs
static_assert(Std::is_detected<Gmsh4::HasInsertVertex, GridFactory<Grid>, GlobalCoordinate, VertexId>{}, "");
ParallelGridCreator (GridFactory<Grid>& factory)
: Super(factory)
{}
public:
using Super::Super;
template <class NodeAttributes>
void insertVerticesImpl (std::size_t numNodes,
......@@ -79,5 +78,11 @@ namespace Dune
std::size_t vertexShift_ = 0;
};
// deduction guides
template <class Grid>
ParallelGridCreator(GridFactory<Grid>&)
-> ParallelGridCreator<Grid>;
} // end namespace Gmsh4
} // end namespace Dune
......@@ -22,9 +22,8 @@ namespace Dune
using Super = GridCreatorInterface<Grid, Self>;
using GlobalCoordinate = typename Super::GlobalCoordinate;
SerialGridCreator (GridFactory<Grid>& factory)
: Super(factory)
{}
public:
using Super::Super;
template <class NodeAttributes>
void insertVerticesImpl (std::size_t numNodes,
......@@ -56,5 +55,11 @@ namespace Dune
std::vector<std::int64_t> shift_;
};
// deduction guides
template <class Grid>
SerialGridCreator(GridFactory<Grid>&)
-> SerialGridCreator<Grid>;
} // end namespace Gmsh4
} // end namespace Dune
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment