Commit 4ff6705f authored by Timo Koch's avatar Timo Koch
Browse files

[pnm] Improve parameter handling for Grid.NumPores and use same type

parent 01b9b2b4
Pipeline #7771 passed with stages
......@@ -28,6 +28,7 @@
#include <iostream>
#include <algorithm>
#include <vector>
#include <dune/common/classname.hh>
#include <dune/common/exceptions.hh>
......@@ -38,6 +39,7 @@
#include <dune/foamgrid/dgffoam.hh>
#include <dumux/common/parameters.hh>
#include <dumux/common/exceptions.hh>
#include "griddata.hh"
#include "structuredlatticegridcreator.hh"
......@@ -72,14 +74,18 @@ public:
}
else // no grid file found
{
try
{
createOneDGrid_();
}
catch(Dune::RangeError& e)
{
// create a structured grid (1D grid or lattice grid)
const auto numPores = getParamFromGroup<std::vector<unsigned int>>(paramGroup_, "Grid.NumPores");
if (numPores.size() == 1)
createOneDGrid_(numPores[0]);
else if (numPores.size() == dimWorld)
makeGridFromStructuredLattice();
}
else
DUNE_THROW(ParameterException,
"Grid.NumPores parameter has wrong size " << numPores.size()
<< ". Should be 1 (for 1D grid) or "
<< dimWorld << " (for structured lattice grid)."
);
loadBalance();
}
......@@ -383,11 +389,10 @@ protected:
private:
void createOneDGrid_()
void createOneDGrid_(unsigned int numPores)
{
const auto lowerLeft = getParamFromGroup<GlobalPosition>(paramGroup_, "Grid.LowerLeft", GlobalPosition(0.0));
const auto upperRight = getParamFromGroup<GlobalPosition>(paramGroup_, "Grid.UpperRight");
const auto numPores = getParamFromGroup<unsigned int>(paramGroup_, "Grid.NumPores");
const auto cells = numPores - 1;
// create a step vector
......
......@@ -44,6 +44,7 @@
#include <dumux/io/grid/gridmanager_yasp.hh>
#include <dumux/common/parameters.hh>
#include <dumux/common/exceptions.hh>
namespace Dumux::PoreNetwork {
......@@ -320,7 +321,7 @@ private:
directions[11] = "12: (-1, 1, 1)\n";
directions[12] = "13: (-1, -1, 1)\n";
}
DUNE_THROW(Dumux::ParameterException, "You must specifiy probabilities for all directions (" << numDirections_() << ") \n" << directions << "\nExample (3D):\n\n"
DUNE_THROW(ParameterException, "You must specifiy probabilities for all directions (" << numDirections_() << ") \n" << directions << "\nExample (3D):\n\n"
<< "DeletionProbability = 0.5 0.5 0 0 0 0 0 0 0 0 0 0 0 \n\n"
<< "deletes approximately 50% of all throats in x and y direction, while no deletion in any other direction takes place.\n" );
}
......@@ -381,7 +382,10 @@ private:
{
const auto lowerLeft = getParamFromGroup<GlobalPosition>(paramGroup_, "Grid.LowerLeft", GlobalPosition(0.0));
const auto upperRight = getParamFromGroup<GlobalPosition>(paramGroup_, "Grid.UpperRight");
const auto numPores = getParamFromGroup<std::array<unsigned int, dimWorld>>(paramGroup_, "Grid.NumPores");
const auto numPores = getParamFromGroup<std::vector<unsigned int>>(paramGroup_, "Grid.NumPores");
if (numPores.size() != dimWorld)
DUNE_THROW(ParameterException, "Grid.NumPores has to be a space-separated list of " << dimWorld << " integers!");
for (int i = 0; i < dimWorld; ++i)
{
positions[i].push_back(lowerLeft[i]);
......
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