Commit dd2b9f3e authored by Andreas Nüßing's avatar Andreas Nüßing
Browse files

add the configuration to the datatree

in order to reproduce computation results, we want to output the config
that was used to produce that result. This output should include also
default values that where used and one should be able to use it directly
to redo a certain computation.

This commit adds a function template `get_and_set` which wraps the
behavior of `ParameterTree::get`. Besides retrieving the value from the
`ParameterTree`, it also writes the value to the given `DataTree`.
parent be557a16
......@@ -67,14 +67,14 @@ namespace duneuro
, dirichletExtension_(volumeConductor->gridView(), problem_)
, boundaryCondition_(volumeConductor->gridView(), problem_)
, functionSpace_(volumeConductor->grid(), boundaryCondition_)
, localOperator_(problem_, config.get<unsigned int>("intorderadd", 0))
, localOperator_(problem_, get_and_set<unsigned int>(config, dataTree, "intorderadd", 0))
, assembler_(functionSpace_, localOperator_, elementType == ElementType::hexahedron ?
(1 << VC::dim) + 1 :
Dune::StaticPower<3, VC::dim>::power)
, solverBackend_(config.get<unsigned int>("max_iterations", 5000),
config.get<unsigned int>("verbose", 0), true, true)
, solverBackend_(get_and_set<unsigned int>(config, dataTree, "max_iterations", 5000),
get_and_set<unsigned int>(config, dataTree, "verbose", 0), true, true)
, linearSolverMutex_()
, linearSolver_(linearSolverMutex_, assembler_.getGO(), config)
, linearSolver_(linearSolverMutex_, assembler_.getGO(), config, dataTree)
{
dataTree.set("degree", degree);
dataTree.set("element_type", to_string(elementType));
......
......@@ -74,25 +74,27 @@ namespace duneuro
: volumeConductor_(volumeConductor)
, problem_(problem)
, functionSpace_(volumeConductor_->gridView())
, edgeNormProvider_(config.get<std::string>("edge_norm_type"), 1.0)
, localOperator_(
*problem_, edgeNormProvider_,
ConvectionDiffusion_DG_Scheme::fromString(config.get<std::string>("scheme")),
config.get<bool>("weights") ? ConvectionDiffusion_DG_Weights::weightsOn :
ConvectionDiffusion_DG_Weights::weightsOff,
config.get<DF>("penalty"), false, config.get<unsigned int>("intorderadd", 0))
, edgeNormProvider_(get_and_set<std::string>(config, dataTree, "edge_norm_type"), 1.0)
, localOperator_(*problem_, edgeNormProvider_,
ConvectionDiffusion_DG_Scheme::fromString(
get_and_set<std::string>(config, dataTree, "scheme")),
get_and_set<bool>(config, dataTree, "weights") ?
ConvectionDiffusion_DG_Weights::weightsOn :
ConvectionDiffusion_DG_Weights::weightsOff,
get_and_set<DF>(config, dataTree, "penalty"), false,
get_and_set<unsigned int>(config, dataTree, "intorderadd", 0))
, assembler_(functionSpace_, localOperator_, 2 * VC::dim + 1)
, firstOrderSpace_(volumeConductor_->grid(), volumeConductor_->gridView())
, solverBackend_(*assembler_, firstOrderSpace_.getGFS(), config)
, solverBackend_(*assembler_, firstOrderSpace_.getGFS(),
get_and_set<unsigned int>(config, dataTree, "max_iterations", 5000),
get_and_set<int>(config, dataTree, "verbose", 1), true,
get_and_set<bool>(config, dataTree, "use_superlu", true))
, linearSolverMutex_()
, linearSolver_(linearSolverMutex_, *assembler_, config)
, pdeLabLinearSolver_(*assembler_, solverBackend_, config)
, pdeLabMatrixComputed_(false)
, linearSolver_(linearSolverMutex_, *assembler_, config, dataTree)
{
assert(volumeConductor_);
dataTree.set("degree", degree);
dataTree.set("element_type", to_string(elementType));
solverBackend_.setReuse(true);
}
DGSolver(std::shared_ptr<VC> volumeConductor, const Dune::ParameterTree& config,
......
......@@ -17,8 +17,8 @@
#include <dune/subgrid/subgrid.hh>
#endif
#include <duneuro/common/volume_conductor.hh>
#include <duneuro/common/fitted_driver_data.hh>
#include <duneuro/common/volume_conductor.hh>
#if HAVE_NIFTI
#include <duneuro/io/nifti_image_reader.hh>
#endif
......@@ -204,7 +204,7 @@ namespace duneuro
template <class GV, class L>
std::shared_ptr<std::vector<Dune::FieldVector<typename GV::ctype, GV::dimension>>>
compute_deformed_positions(const GV& gridView, const std::vector<L>& elementLabels,
const Dune::ParameterTree& config)
const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
auto deformedPositions =
std::make_shared<std::vector<Dune::FieldVector<typename GV::ctype, GV::dimension>>>(
......@@ -212,8 +212,8 @@ namespace duneuro
VertexToElementsMap<GV> vertexToElements(gridView);
ElementCenters<GV> centers(gridView);
auto shift = config.get<typename GV::ctype>("shift");
auto minority = config.get<unsigned int>("minority", 3);
auto shift = get_and_set<typename GV::ctype>(config, dataTree, "shift");
auto minority = get_and_set<unsigned int>(config, dataTree, "minority", 3);
for (const auto& vertex : Dune::vertices(gridView)) {
// extract neighboring elements along with their labels
const auto& elements = vertexToElements.elements(vertex);
......@@ -233,19 +233,20 @@ namespace duneuro
return deformedPositions;
}
template <class HostGrid, class L = char>
template <class HostGrid, class L>
std::unique_ptr<Dune::GeometryGrid<HostGrid,
DeformationFunction<typename HostGrid::LeafGridView>>>
create_geometry_adapted_grid(std::unique_ptr<HostGrid> hostGrid,
const std::vector<L>& elementLabels,
const Dune::ParameterTree& config)
const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
using HostGridView = typename HostGrid::LeafGridView;
using CoordFunction = DeformationFunction<HostGridView>;
using ctype = typename HostGrid::ctype;
auto hostGridView = hostGrid->leafGridView();
auto deformedPosition = compute_deformed_positions(hostGridView, elementLabels, config);
auto deformedPosition =
compute_deformed_positions(hostGridView, elementLabels, config, dataTree);
using GridType = Dune::GeometryGrid<HostGrid, CoordFunction>;
return Dune::Std::make_unique<GridType>(hostGrid.release(),
......@@ -278,19 +279,21 @@ namespace duneuro
template <int dim>
GeometryAdaptedGrid<dim> make_geometry_adapted_grid(const FittedDriverData<dim>& data,
const Dune::ParameterTree& config)
const Dune::ParameterTree& config,
DataTree dataTree = DataTree())
{
auto ygrid = Dune::Std::make_unique<typename GeometryAdaptedGrid<dim>::StructuredGrid>(
config.get<Dune::FieldVector<double, dim>>("lower_left"),
config.get<Dune::FieldVector<double, dim>>("upper_right"),
config.get<std::array<int, dim>>("cells"));
auto geometryGrid = create_geometry_adapted_grid(std::move(ygrid), data.labels, config);
auto ggGv = geometryGrid->leafGridView();
if (data.labels.size() != static_cast<std::size_t>(ggGv.size(0))) {
get_and_set<Dune::FieldVector<double, dim>>(config, dataTree, "lower_left"),
get_and_set<Dune::FieldVector<double, dim>>(config, dataTree, "upper_right"),
get_and_set<std::array<int, dim>>(config, dataTree, "cells"));
if (data.labels.size() != static_cast<std::size_t>(ygrid->size(0))) {
DUNE_THROW(Dune::Exception, "number of labels (" << data.labels.size()
<< ") does not match number of cells ("
<< ggGv.size(0) << ")");
<< ygrid->size(0) << ")");
}
auto geometryGrid =
create_geometry_adapted_grid(std::move(ygrid), data.labels, config, dataTree);
auto ggGv = geometryGrid->leafGridView();
// subgrid creation
auto grid = Dune::Std::make_unique<typename GeometryAdaptedGrid<dim>::GridType>(*geometryGrid);
grid->createBegin();
......@@ -314,7 +317,7 @@ namespace duneuro
make_geometry_adapted_volume_conductor(
std::unique_ptr<typename GeometryAdaptedGrid<dim>::GridType> grid,
std::unique_ptr<std::vector<char>> labels, const std::vector<double>& conductivities,
const Dune::ParameterTree& config)
const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
using VC = VolumeConductor<typename GeometryAdaptedGrid<dim>::GridType>;
using Tensor = typename VC::TensorType;
......@@ -339,17 +342,18 @@ namespace duneuro
#if HAVE_NIFTI
template <int dim>
struct GeometryAdaptedGridReader {
static GeometryAdaptedGrid<dim> read(const Dune::ParameterTree& config)
static GeometryAdaptedGrid<dim> read(const Dune::ParameterTree& config,
DataTree dataTree = DataTree())
{
std::vector<char> labels;
std::array<unsigned int, dim> cells;
NiftiImageReader::read<dim>(config.get<std::string>("filename"), std::back_inserter(labels),
cells);
NiftiImageReader::read<dim>(get_and_set<std::string>(config, dataTree, "filename"),
std::back_inserter(labels), cells);
std::array<int, dim> s;
std::copy(cells.begin(), cells.end(), s.begin());
auto ygrid = Dune::Std::make_unique<typename GeometryAdaptedGrid<dim>::StructuredGrid>(
config.get<Dune::FieldVector<double, dim>>("lower_left"),
config.get<Dune::FieldVector<double, dim>>("upper_right"), s);
get_and_set<Dune::FieldVector<double, dim>>(config, dataTree, "lower_left"),
get_and_set<Dune::FieldVector<double, dim>>(config, dataTree, "upper_right"), s);
// geometry adaption
auto geometryGrid = create_geometry_adapted_grid(std::move(ygrid), labels, config);
auto ggGv = geometryGrid->leafGridView();
......
......@@ -35,8 +35,10 @@ namespace duneuro
using IndexCache = Dune::PDELab::LFSIndexCache<LFS>;
using FESwitch = Dune::FiniteElementInterfaceSwitch<typename LFS::Traits::FiniteElementType>;
GridFunctionMean(std::shared_ptr<const GFS> gfs, const Dune::ParameterTree& config)
: gridFunctionSpace_(gfs), superIntegrationOrder_(config.get("superIntegrationOrder", 0))
GridFunctionMean(std::shared_ptr<const GFS> gfs, const Dune::ParameterTree& config,
DataTree dataTree = DataTree())
: gridFunctionSpace_(gfs)
, superIntegrationOrder_(get_and_set(config, dataTree, "superIntegrationOrder", 0))
{
assert(gridFunctionSpace_);
}
......
......@@ -12,6 +12,8 @@
#include <dune/common/fvector.hh>
#include <dune/common/parametertree.hh>
#include <duneuro/io/data_tree.hh>
namespace duneuro
{
// compute force from b to a
......@@ -165,28 +167,31 @@ namespace duneuro
// generate more or less evenly distributed electrodes on a sphere
template <class ctype, int dim>
void generate_points_on_sphere(const Dune::ParameterTree& config,
std::vector<Dune::FieldVector<ctype, dim>>& points)
std::vector<Dune::FieldVector<ctype, dim>>& points,
DataTree dataTree = DataTree())
{
using Coordinate = Dune::FieldVector<ctype, dim>;
generate_points_on_sphere(config.get<unsigned int>("count"), points,
config.get<Coordinate>("center", Coordinate(0.0)),
config.get<ctype>("radius", 1.0),
config.get<unsigned int>("iterations", 500),
config.get<ctype>("distance", 1e-3), config.get<ctype>("dt", 0.1));
generate_points_on_sphere(get_and_set<unsigned int>(config, dataTree, "count"), points,
get_and_set<Coordinate>(config, dataTree, "center", Coordinate(0.0)),
get_and_set<ctype>(config, dataTree, "radius", 1.0),
get_and_set<unsigned int>(config, dataTree, "iterations", 500),
get_and_set<ctype>(config, dataTree, "distance", 1e-3),
get_and_set<ctype>(config, dataTree, "dt", 0.1));
}
// generate more or less evenly distributed electrodes on a sphere
template <class ctype, int dim>
std::vector<Dune::FieldVector<ctype, dim>>
generate_points_on_sphere(const Dune::ParameterTree& config)
generate_points_on_sphere(const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
using Coordinate = Dune::FieldVector<ctype, dim>;
std::vector<Coordinate> points;
generate_points_on_sphere(config.get<unsigned int>("count"), points,
config.get<Coordinate>("center", Coordinate(0.0)),
config.get<ctype>("radius", 1.0),
config.get<unsigned int>("iterations", 500),
config.get<ctype>("distance", 1e-3), config.get<ctype>("dt", 0.1));
generate_points_on_sphere(get_and_set<unsigned int>(config, dataTree, "count"), points,
get_and_set<Coordinate>(config, dataTree, "center", Coordinate(0.0)),
get_and_set<ctype>(config, dataTree, "radius", 1.0),
get_and_set<unsigned int>(config, dataTree, "iterations", 500),
get_and_set<ctype>(config, dataTree, "distance", 1e-3),
get_and_set<ctype>(config, dataTree, "dt", 0.1));
return points;
}
}
......
......@@ -6,19 +6,21 @@
#include <dune/grid/yaspgrid.hh>
#include <duneuro/io/data_tree.hh>
namespace duneuro
{
template <int dim>
std::unique_ptr<Dune::YaspGrid<dim, Dune::EquidistantOffsetCoordinates<double, dim>>>
make_structured_grid(const Dune::ParameterTree& config)
make_structured_grid(const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
auto grid =
Dune::Std::make_unique<Dune::YaspGrid<dim,
Dune::EquidistantOffsetCoordinates<double, dim>>>(
config.get<Dune::FieldVector<double, dim>>("lower_left"),
config.get<Dune::FieldVector<double, dim>>("upper_right"),
config.get<std::array<int, dim>>("cells"));
grid->globalRefine(config.get<unsigned int>("refinements"));
get_and_set<Dune::FieldVector<double, dim>>(config, dataTree, "lower_left"),
get_and_set<Dune::FieldVector<double, dim>>(config, dataTree, "upper_right"),
get_and_set<std::array<int, dim>>(config, dataTree, "cells"));
grid->globalRefine(get_and_set<unsigned int>(config, dataTree, "refinements"));
return std::move(grid);
}
}
......
......@@ -177,13 +177,15 @@ namespace duneuro
* where start defect is the norm of the residual of x.
*/
ThreadSafeStationaryLinearProblemSolver(std::mutex& mutex, const GO& go,
const Dune::ParameterTree& params)
const Dune::ParameterTree& config,
DataTree dataTree = DataTree())
: _mutex(mutex)
, _go(go)
, _fixFirstDOF(params.get<bool>("fixDOF", true))
, _fixedDOFEntry(params.get<typename M::field_type>("fixedDOFEntry", 1.0))
, _verbose(params.get<int>("verbosity", 1))
, _debug(params.get<bool>("debug", false))
, _fixFirstDOF(get_and_set<bool>(config, dataTree, "fixDOF", true))
, _fixedDOFEntry(
get_and_set<typename M::field_type>(config, dataTree, "fixedDOFEntry", 1.0))
, _verbose(get_and_set<int>(config, dataTree, "verbose", 1))
, _debug(get_and_set<bool>(config, dataTree, "debug", false))
{
}
......@@ -234,7 +236,8 @@ namespace duneuro
Dune::Timer solutionTimer;
timer.start();
DV z(_go.trialGridFunctionSpace(), 0.0);
ls.apply(*_jacobian, z, r, config.get<typename RV::ElementType>(
ls.apply(*_jacobian, z, r, get_and_set<typename RV::ElementType>(
config, dataTree,
"reduction")); // solver makes right hand side consistent
timer.stop();
dataTree.set("iterations", ls.result().iterations);
......
......@@ -53,29 +53,33 @@ namespace duneuro
using Traits = UDGSolverTraits<ST, compartments, degree, P, DF, RF, JF>;
UDGSolver(std::shared_ptr<typename Traits::SubTriangulation> subTriangulation,
const Dune::ParameterTree& config)
: UDGSolver(subTriangulation, std::make_shared<typename Traits::Problem>(
config.get<std::vector<double>>("conductivities")),
const Dune::ParameterTree& config, DataTree dataTree = DataTree())
: UDGSolver(subTriangulation,
std::make_shared<typename Traits::Problem>(
get_and_set<std::vector<double>>(config, dataTree, "conductivities")),
config)
{
}
UDGSolver(std::shared_ptr<typename Traits::SubTriangulation> subTriangulation,
std::shared_ptr<typename Traits::Problem> problem, const Dune::ParameterTree& config)
std::shared_ptr<typename Traits::Problem> problem, const Dune::ParameterTree& config,
DataTree dataTree = DataTree())
: subTriangulation_(subTriangulation)
, problem_(problem)
, functionSpace_(subTriangulation_->gridView(), subTriangulation_)
, edgeNormProvider_(config.get<std::string>("edge_norm_type"), 1.0)
, localOperator_(*problem_, edgeNormProvider_, ConvectionDiffusion_DG_Scheme::fromString(
config.get<std::string>("scheme")),
ConvectionDiffusion_DG_Weights::weightsOn, config.get<RF>("penalty"))
, edgeNormProvider_(get_and_set<std::string>(config, dataTree, "edge_norm_type"), 1.0)
, localOperator_(*problem_, edgeNormProvider_,
ConvectionDiffusion_DG_Scheme::fromString(
get_and_set<std::string>(config, dataTree, "scheme")),
ConvectionDiffusion_DG_Weights::weightsOn,
get_and_set<RF>(config, dataTree, "penalty"))
, wrappedLocalOperator_(localOperator_)
, unfittedSubTriangulation_(subTriangulation_->gridView(), *subTriangulation_)
, gridOperator_(functionSpace_.getGFS(), functionSpace_.getGFS(), unfittedSubTriangulation_,
wrappedLocalOperator_,
typename Traits::MatrixBackend(2 * Traits::dimension + 1))
, solverBackend_(config.get<unsigned int>("max_iterations", 5000),
config.get<unsigned int>("verbose", 0))
, solverBackend_(get_and_set<unsigned int>(config, dataTree, "max_iterations", 5000),
get_and_set<unsigned int>(config, dataTree, "verbose", 0))
, linearSolver_(linearSolverMutex_, gridOperator_, config)
, pdeLabLinearSolver_(gridOperator_, solverBackend_, config)
, pdeLabMatrixComputed_(false)
......
......@@ -7,9 +7,10 @@ namespace duneuro
{
enum class VectorDensity { dense, sparse };
static inline VectorDensity source_model_default_density(const Dune::ParameterTree& config)
static inline VectorDensity source_model_default_density(const Dune::ParameterTree& config,
DataTree dataTree = DataTree())
{
const auto t = config.get<std::string>("type");
const auto t = get_and_set<std::string>(config, dataTree, "type");
if (t == "partial_integration") {
return VectorDensity::sparse;
}
......
......@@ -51,10 +51,10 @@ namespace duneuro
explicit VolumeConductorStorage(const FittedDriverData<3>& data,
const Dune::ParameterTree& config,
DataTree dataTree = DataTree())
: adaptedGrid_(make_geometry_adapted_grid(data, config.sub("grid")))
, volumeConductor_(make_geometry_adapted_volume_conductor<3>(std::move(adaptedGrid_.grid),
std::move(adaptedGrid_.labels),
data.conductivities, config))
: adaptedGrid_(make_geometry_adapted_grid(data, config.sub("grid"), dataTree.sub("grid")))
, volumeConductor_(make_geometry_adapted_volume_conductor<3>(
std::move(adaptedGrid_.grid), std::move(adaptedGrid_.labels), data.conductivities,
config, dataTree))
{
}
......
......@@ -16,9 +16,9 @@ namespace duneuro
static std::shared_ptr<SourceModelInterface<typename VC::ctype, VC::dim, Vector>>
createDense(std::shared_ptr<VC> volumeConductor, const Solver& solver,
std::shared_ptr<KDTreeElementSearch<typename VC::GridView>> search,
const Dune::ParameterTree& config)
const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
const auto type = config.get<std::string>("type");
const auto type = get_and_set<std::string>(config, dataTree, "type");
if (type == "partial_integration") {
return std::make_shared<PartialIntegrationSourceModel<
typename Solver::Traits::FunctionSpace::GFS, Vector>>(solver.functionSpace().getGFS(),
......@@ -26,12 +26,12 @@ namespace duneuro
} else if (type == "venant") {
return std::make_shared<VenantSourceModel<VC, typename Solver::Traits::FunctionSpace::GFS,
Vector>>(
volumeConductor, solver.functionSpace().getGFS(), search, config);
volumeConductor, solver.functionSpace().getGFS(), search, config, dataTree);
} else if (type == "subtraction") {
return std::make_shared<SubtractionSourceModel<typename Solver::Traits::VolumeConductor,
typename Solver::Traits::FunctionSpace,
Vector>>(
volumeConductor, solver.functionSpace(), search, config);
volumeConductor, solver.functionSpace(), search, config, dataTree);
} else {
DUNE_THROW(duneuro::SourceModelException, "unknown source model of type \"" << type
<< "\"");
......@@ -42,9 +42,9 @@ namespace duneuro
static std::shared_ptr<SourceModelInterface<typename VC::ctype, VC::dim, Vector>>
createSparse(std::shared_ptr<VC> volumeConductor, const Solver& solver,
std::shared_ptr<KDTreeElementSearch<typename VC::GridView>> search,
const Dune::ParameterTree& config)
const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
const auto type = config.get<std::string>("type");
const auto type = get_and_set<std::string>(config, dataTree, "type");
if (type == "partial_integration") {
return std::make_shared<PartialIntegrationSourceModel<
typename Solver::Traits::FunctionSpace::GFS, Vector>>(solver.functionSpace().getGFS(),
......@@ -52,7 +52,7 @@ namespace duneuro
} else if (type == "venant") {
return std::make_shared<VenantSourceModel<VC, typename Solver::Traits::FunctionSpace::GFS,
Vector>>(
volumeConductor, solver.functionSpace().getGFS(), search, config);
volumeConductor, solver.functionSpace().getGFS(), search, config, dataTree);
} else {
DUNE_THROW(duneuro::SourceModelException, "unknown source model of type \"" << type
<< "\"");
......
......@@ -52,7 +52,7 @@ namespace duneuro
void setSourceModel(const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
denseSourceModel_ = SMF::template createDense<typename Traits::RangeDOFVector>(
volumeConductor_, *solver_, search_, config);
volumeConductor_, *solver_, search_, config, dataTree);
}
void solve(typename Traits::DomainDOFVector& solution, const Dune::ParameterTree& config,
......@@ -69,8 +69,7 @@ namespace duneuro
dataTree.set("time_rhs_assembly", timer.lastElapsed());
timer.start();
// solve system
solver_->solve(*rightHandSideVector_, solution, config.sub("solver"),
dataTree.sub("linear_system_solver"));
solver_->solve(*rightHandSideVector_, solution, config.sub("solver"), dataTree.sub("solver"));
timer.stop();
dataTree.set("time_solve", timer.lastElapsed());
dataTree.set("time", timer.elapsed());
......
......@@ -66,7 +66,7 @@ namespace duneuro
dataTree.set("time_rhs_assembly", timer.lastElapsed());
timer.start();
// solve system
solver_->solve(*rightHandSideVector_, solution, config, dataTree.sub("linear_system_solver"));
solver_->solve(*rightHandSideVector_, solution, config, dataTree);
timer.stop();
dataTree.set("time_solution", timer.lastElapsed());
dataTree.set("time", timer.elapsed());
......
......@@ -48,13 +48,13 @@ namespace duneuro
{
sparseSourceModel_.reset();
denseSourceModel_.reset();
density_ = source_model_default_density(config);
density_ = source_model_default_density(config, dataTree);
if (density_ == VectorDensity::sparse) {
sparseSourceModel_ = SMF::template createSparse<typename Traits::SparseRHSVector>(
volumeConductor_, *solver_, search_, config);
volumeConductor_, *solver_, search_, config, dataTree);
} else {
denseSourceModel_ = SMF::template createDense<typename Traits::DenseRHSVector>(
volumeConductor_, *solver_, search_, config);
volumeConductor_, *solver_, search_, config, dataTree);
}
}
......
......@@ -15,9 +15,9 @@ namespace duneuro
static std::shared_ptr<SourceModelInterface<typename VC::ctype, VC::dim, V>>
createDense(std::shared_ptr<VC> volumeConductor, const Solver& solver,
std::shared_ptr<KDTreeElementSearch<typename VC::GridView>> search,
const Dune::ParameterTree& config)
const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
const auto type = config.get<std::string>("type");
const auto type = get_and_set<std::string>(config, dataTree, "type");
if (type == "partial_integration") {
return std::make_shared<PartialIntegrationSourceModel<
typename Solver::Traits::FunctionSpace::GFS, V>>(solver.functionSpace().getGFS(),
......@@ -25,7 +25,7 @@ namespace duneuro
} else if (type == "subtraction") {
return std::make_shared<SubtractionSourceModel<typename Solver::Traits::VolumeConductor,
typename Solver::Traits::FunctionSpace, V>>(
volumeConductor, solver.functionSpace(), search, config);
volumeConductor, solver.functionSpace(), search, config, dataTree);
} else {
DUNE_THROW(duneuro::SourceModelException, "unknown source model of type \"" << type
<< "\"");
......@@ -36,9 +36,9 @@ namespace duneuro
static std::shared_ptr<SourceModelInterface<typename VC::ctype, VC::dim, V>>
createSparse(std::shared_ptr<VC> volumeConductor, const Solver& solver,
std::shared_ptr<KDTreeElementSearch<typename VC::GridView>> search,
const Dune::ParameterTree& config)
const Dune::ParameterTree& config, DataTree dataTree = DataTree())
{
const auto type = config.get<std::string>("type");
const auto type = get_and_set<std::string>(config, dataTree, "type");
if (type == "partial_integration") {
return std::make_shared<PartialIntegrationSourceModel<
typename Solver::Traits::FunctionSpace::GFS, V>>(solver.functionSpace().getGFS(),
......
......@@ -41,10 +41,11 @@ namespace duneuro
}
AnalyticSolution(const Dune::ParameterTree& config,
std::vector<Dune::FieldVector<ctype, dim>> electrodePositions)
: sphereRadii_(config.get<std::vector<ctype>>("radii"))
, sphereCenter_(config.get<Dune::FieldVector<ctype, dim>>("center"))
, conductivities_(config.get<std::vector<ctype>>("conductivities"))
std::vector<Dune::FieldVector<ctype, dim>> electrodePositions,
DataTree dataTree = DataTree())
: sphereRadii_(get_and_set<std::vector<ctype>>(config, dataTree, "radii"))
, sphereCenter_(get_and_set<Dune::FieldVector<ctype, dim>>(config, dataTree, "center"))
, conductivities_(get_and_set<std::vector<ctype>>(config, dataTree, "conductivities"))
, electrodePositions_(electrodePositions)
{
if (sphereRadii_.size() != conductivities_.size()) {
......
......@@ -19,10 +19,10 @@ namespace duneuro
make_electrode_projection(const Dune::ParameterTree& config, const GV& gridView,
DataTree dataTree = DataTree())
{
auto type = config.get<std::string>("type");
auto type = get_and_set<std::string>(config, dataTree, "type");
if (type == "closest_subentity_center") {
return Dune::Std::make_unique<ClosestSubEntityCenterElectrodeProjection<GV>>(
gridView, config.get<std::vector<unsigned int>>("codims"));
gridView, get_and_set<std::vector<unsigned int>>(config, dataTree, "codims"));
} else if (type == "normal") {
return Dune::Std::make_unique<NormalElectrodeProjection<GV>>(gridView);
} else {
......
......@@ -31,13 +31,15 @@ namespace duneuro
using SearchType = typename BaseT::SearchType;
SubtractionSourceModel(std::shared_ptr<VC> volumeConductor, const FS& fs,
std::shared_ptr<SearchType> search, const Dune::ParameterTree& config)
std::shared_ptr<SearchType> search, const Dune::ParameterTree& config,
DataTree dataTree = DataTree())
: BaseT(search)
, problem_(volumeConductor->gridView(), volumeConductor)
, edgeNormProvider_()
, lop_(problem_, edgeNormProvider_, ConvectionDiffusion_DG_Scheme::SIPG,
ConvectionDiffusion_DG_Weights::weightsOn, 1.0,
config.get<unsigned int>("intorderadd"), config.get<unsigned int>("intorderadd_lb"))
get_and_set<unsigned int>(config, dataTree, "intorderadd"),
get_and_set<unsigned int>(config, dataTree, "intorderadd_lb"))
, x_(fs.getGFS(), 0.0)
, res_(fs.getGFS(), 0.0)
, interp_(fs.getGFS(), 0.0)
......
......@@ -54,7 +54,7 @@ namespace duneuro
denseSourceModel_ =
UDGSourceModelFactory::template createDense<compartments - 1,
typename Traits::RangeDOFVector>(