From ef0cf6ea7882269f23963ffbfe98cab6a96de11f Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Thu, 27 Jun 2013 15:17:26 +0000 Subject: [PATCH] Allow to set all grid parameters at run-time In particular whether the grid is structured or not, and the bounding box and element numbers in the former case. [[Imported from SVN: r9272]] --- cosserat-continuum.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cosserat-continuum.cc b/cosserat-continuum.cc index 1eb2d265..f24134b1 100644 --- a/cosserat-continuum.cc +++ b/cosserat-continuum.cc @@ -15,6 +15,7 @@ #include <dune/grid/io/file/amirameshreader.hh> #include <dune/grid/io/file/amirameshwriter.hh> +#include <dune/grid/io/file/gmshreader.hh> #include <dune/fufem/boundarypatch.hh> @@ -134,14 +135,19 @@ int main (int argc, char *argv[]) try // Create the grid // /////////////////////////////////////// typedef std::conditional<dim==1,OneDGrid,UGGrid<dim> >::type GridType; - array<unsigned int,dim> elements; - elements.fill(1); - elements[0] = 10; - FieldVector<double,dim> upper(1); - upper[0] = 10; - shared_ptr<GridType> grid = StructuredGridFactory<GridType>::createCubeGrid(FieldVector<double,dim>(0), - upper, - elements); + + shared_ptr<GridType> grid; + + FieldVector<double,dim> lower = parameterSet.get<FieldVector<double,dim> >("lower"); + FieldVector<double,dim> upper = parameterSet.get<FieldVector<double,dim> >("upper"); + + if (parameterSet.get<bool>("structuredGrid")) { + + array<unsigned int,dim> elements = parameterSet.get<array<unsigned int,dim> >("elements"); + grid = StructuredGridFactory<GridType>::createCubeGrid(lower, upper, elements); + + } else + grid = shared_ptr<GridType>(GmshReader<GridType>::read(gridFile)); grid->globalRefine(numLevels-1); -- GitLab