Commit 3817890e authored by Lukas Riedel's avatar Lukas Riedel

falling back to default YaspGrid constructor if YaspGrid is used

parent 9ba8a6df
......@@ -4,6 +4,41 @@
namespace Dune {
namespace Dorie {
/// Specialized constructor for parallel YaspGrid construction
/** \param extensions Extensions of the grid
* \param elements Number of elements in each direction
* \return Shared pointer to the grid
*/
template<typename GridType, int dim>
std::enable_if_t<
std::is_same<YaspGrid<dim>,GridType>::value,
std::shared_ptr<YaspGrid<dim>> >
grid_cube_construction (const Dune::FieldVector<double,dim>& extensions,
const std::array<unsigned int,dim>& elements)
{
std::array<int,dim> elements_;
std::copy(elements.cbegin(),elements.cend(),elements_.begin());
return std::make_shared<YaspGrid<dim>>(extensions,elements_);
}
/// Default rectangular grid constructor. Call StructuredGridFactory
/** \param extensions Extensions of the grid
* \param elements Number of elements in each direction
* \return Shared pointer to the grid
*/
template<typename GridType, int dim>
std::enable_if_t<
!std::is_same<YaspGrid<dim>,GridType>::value,
std::shared_ptr<GridType> >
grid_cube_construction (const Dune::FieldVector<double,dim>& extensions,
const std::array<unsigned int,dim>& elements)
{
const Dune::FieldVector<double,dim> origin(.0);
return Dune::StructuredGridFactory<GridType>::createCubeGrid(origin,extensions,elements);
}
/// Read simplex Gmsh file in 2D or 3D, create a grid, and return a shared pointer to the grid
/** Refine the grid globally and call default load balancing for multi-processing support.
* \tparam GridType Type of the grid. Must be supported by Dune::GridFactory
......@@ -66,10 +101,9 @@ std::shared_ptr<GridType> build_grid_cube (const Dune::ParameterTree& inifile, c
const int level = inifile.get<int>("grid.initialLevel");
const Dune::FieldVector<double,dim> lowerLeft(0.);
const Dune::FieldVector<double,dim> upperRight = inifile.get<Dune::FieldVector<double,dim>>("grid.extensions");
const Dune::array<int,dim> elements = inifile.get<Dune::array<int,dim>>("grid.cells");
const Dune::array<unsigned int,dim> elements = inifile.get<Dune::array<unsigned int,dim>>("grid.cells");
//auto grid = Dune::StructuredGridFactory<GridType>::createCubeGrid(lowerLeft,upperRight,elements);
auto grid = std::make_shared<GridType>(upperRight,elements);
auto grid = grid_cube_construction<GridType,dim>(upperRight,elements);
grid->globalRefine(level);
grid->loadBalance();
......
Markdown is supported
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