Commit 20698125 authored by Timo Koch's avatar Timo Koch
Browse files

[io][bugfix] Enable parallel grids from cake grid creator

Fill the factory on rank 0 and then distribute to the other ranks.
This uses the same method used for Dune::GmshReader.

Add some parallel test to make sure this works
parent 964fdb85
Pipeline #7260 passed with stages
......@@ -14,6 +14,8 @@ Differences Between DuMu<sup>x</sup> 3.5 and DuMu<sup>x</sup> 3.4
- __Construction and update of GridGeometries changed__: Grid geometries are fully updated after construction.
Additional call of update functions are therefore only needed after grid adaption. Calling the update functions after construction now leads to a performance penalty.
- __Cake grid creator__: The cake grid creator can now be used in parallel simulations
### Immediate interface changes not allowing/requiring a deprecation period:
- __Virtual interface of GridDataTransfer__: The `GridDataTransfer` abstract base class now required the Grid type as a template argument. Furthermore, the `store` and `reconstruct` interface functions do now expect the grid as a function argument. This allows to correctly update grid geometries and corresponding mapper (see "Construction and update of GridGeometries changed" above in the changelog)
......@@ -276,6 +276,12 @@ public:
const std::string& modelParamGroup,
bool verbose = false)
GridFactory gridFactory;
// create grid on rank 0, return empty grid on all other ranks
if (gridFactory.comm().rank() != 0)
return std::unique_ptr<Grid>(gridFactory.createGrid());
const auto& dR = polarCoordinates[0];
const auto& dA = polarCoordinates[1];
......@@ -19,6 +19,19 @@ dumux_add_test(NAME test_gridmanager_cake_360_ug
--relative 1e-6)
dumux_add_test(NAME test_gridmanager_cake_360_ug_parallel
TARGET test_gridmanager_cake_ug
LABELS unit io
CMD_ARGS --script fuzzy --zeroThreshold {"process rank":100}
--command "${MPIEXEC} -np 3 ${CMAKE_CURRENT_BINARY_DIR}/test_gridmanager_cake_ug -Grid.Name ug-360"
--files ${CMAKE_SOURCE_DIR}/test/references/test_gridmanager_cake_3d_360-reference.vtu
--relative 1e-6)
dumux_add_test(NAME test_gridmanager_cake_360_alu
TARGET test_gridmanager_cake_alu
LABELS unit io
......@@ -32,6 +45,19 @@ dumux_add_test(NAME test_gridmanager_cake_360_alu
--relative 1e-6)
dumux_add_test(NAME test_gridmanager_cake_360_alu_parallel
TARGET test_gridmanager_cake_alu
LABELS unit io
CMD_ARGS --script fuzzy --zeroThreshold {"process rank":100}
--command "${MPIEXEC} -np 3 ${CMAKE_CURRENT_BINARY_DIR}/test_gridmanager_cake_alu -Grid.Name alu-360"
--files ${CMAKE_SOURCE_DIR}/test/references/test_gridmanager_cake_3d_360-reference.vtu
--relative 1e-6)
dumux_add_test(NAME test_gridmanager_cake_210_ug
TARGET test_gridmanager_cake_ug
LABELS unit io
......@@ -20,13 +20,15 @@
* \brief Test for the cake grid manager
#include "config.h"
#include <string>
#include <iostream>
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/timer.hh>
#include <dune/grid/io/file/vtk.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
#include <dumux/io/grid/gridmanager.hh>
......@@ -63,10 +65,14 @@ void testCakeGridManager(const std::string& name)
// make the grid
Dune::Timer timer;
std::cout << "Constructing " << dim << "-d cake grid with " << gridManager.grid().leafGridView().size(0) << " elements took "
<< timer.elapsed() << " seconds.\n";
// construct a vtk output writer and attach the boundaryMakers
Dune::VTKWriter<typename Grid<dim>::LeafGridView> vtkWriter(gridManager.grid().leafGridView());
const auto& gridView = gridManager.grid().leafGridView();
if (gridView.comm().rank() == 0)
std::cout << "Constructing " << dim << "-d cake grid with " << gridView.size(0) << " elements took "
<< timer.elapsed() << " seconds.\n";
// write the grid to a .vtk file
Dune::VTKWriter<typename Grid<dim>::LeafGridView> vtkWriter(gridView);
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