diff --git a/dune/dorie/common/initial_condition/h5.hh b/dune/dorie/common/initial_condition/h5.hh index bcb2d7446e223e1d35b91007af426741771f1d42..cbf811352cb6784762d33068b61c620d5fc1a18c 100644 --- a/dune/dorie/common/initial_condition/h5.hh +++ b/dune/dorie/common/initial_condition/h5.hh @@ -41,60 +41,11 @@ public: InitialConditionH5( const GV& grid_view, const Dune::ParameterTree& config, std::shared_ptr log) - : Base(grid_view) - { - // open the H5 file - const auto datafile = config.template get("initial.datafile"); - const auto dataset = config.template get("initial.dataset"); - - H5File h5file(datafile, log); - - // read the dataset - std::vector data; - std::vector shape; - h5file.read_dataset(dataset, H5T_NATIVE_DOUBLE, data, shape); - std::reverse(std::begin(shape), std::end(shape)); - - /// retrieve extensions and offset from grid extensions - const auto level_gv = grid_view.grid().levelGridView(0); - const auto [off, upper_right] = get_grid_extensions(level_gv); - const auto ext = upper_right - off; - - if (shape.size() != dim) { - log->error("Expected {}-dimensional dataset. File: {}, " - "Dataset: {}, Dimensions: {}", - dim, datafile, dataset, shape.size()); - DUNE_THROW(Dune::IOError, "Invalid dataset for interpolator"); - } - if (ext.size() != dim) { - log->error("Expected {}-dimensional sequence as 'extensions'", - dim); - DUNE_THROW(Dune::IOError, "Invalid interpolator input"); - } - if (off.size() != dim) { - log->error("Expected {}-dimensional sequence as 'offset'", - dim); - DUNE_THROW(Dune::IOError, "Invalid interpolator input"); - } - - // copy into correct data structure - Domain extensions; - std::copy(std::begin(ext), std::end(ext), std::begin(extensions)); - Domain offset; - std::copy(std::begin(off), std::end(off), std::begin(offset)); - - // build interpolator - _interpolator = InterpolatorFactory::create( - config.template get("initial.interpolation"), - data, - shape, - extensions, - offset, - log - ); - - } - + : Base(grid_view), + _interpolator(InterpolatorFactory::create(config.sub("initial"), + grid_view, + log)) + { } /// Evaluate the initial condition at certain position /** \param y @@ -110,10 +61,10 @@ public: } private: - std::shared_ptr> _interpolator; + std::shared_ptr> _interpolator; }; } // namespace Dorie } // namespace Dune -#endif // DUNE_DORIE_INITIAL_CONDITION_H5_HH \ No newline at end of file +#endif // DUNE_DORIE_INITIAL_CONDITION_H5_HH