The TS-GitLab will have to shut down towards the end of the year — please think about migrating your projects to GitLab.com or GitHub.
(This is still a very early message, meant to keep you informed. There will be more urgent ones in the future.)

h5.hh 1.88 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
// -*- tab-width: 4; indent-tabs-mode: nil -*-
#ifndef DUNE_DORIE_INITIAL_CONDITION_H5_HH
#define DUNE_DORIE_INITIAL_CONDITION_H5_HH


#include <string>

#include <dune/common/exceptions.hh>
#include <dune/common/parametertree.hh>

11
#include <dune/dorie/common/interpolator.hh>
12 13 14 15 16 17
#include <dune/dorie/common/initial_condition/initial_condition.hh>

namespace Dune{
namespace Dorie{

/*-------------------------------------------------------------------------*//**
18 19 20 21 22
 * @brief      Class for initial conditions from hdf5 data files.
 *
 * @ingroup    InitialConditions
 * @author     Santiago Ospina
 * @date       2019
23 24 25
 *
 * @tparam     T     BaseTraits
 */
26

27
template<class T>
28
class InitialConditionH5
29
  : public InitialCondition<T>
30
{
31
  using Base = InitialCondition<T>;
32 33 34 35 36 37 38 39 40
  using RF = typename T::RF;
  using Domain = typename T::Domain;
  using GV = typename T::GV;
  static constexpr int dim = T::dim;

public:

  using Traits = typename Base::Traits;

41 42 43
  InitialConditionH5( const GV& grid_view,
                      const Dune::ParameterTree& config, 
                      std::shared_ptr<spdlog::logger> log)
44 45 46 47 48
    : Base(grid_view),
      _interpolator(InterpolatorFactory<T>::create(config.sub("initial"),
                                                   grid_view,
                                                   log))
  { }
49

50 51 52 53 54
  /// Evaluate the initial condition at certain position
  /** \param y 
  * \param x Position in local element coordinates
  * \param e Element enitity
  */
55 56 57 58 59 60 61 62 63
  void evaluate ( const typename Traits::ElementType& e,
                  const typename Traits::DomainType& x,
                        typename Traits::RangeType& y) const override
  {
    auto x_global = e.geometry().global(x);
    y = _interpolator->evaluate(x_global);
  }

private:
64
  std::shared_ptr<Interpolator<RF, T>> _interpolator;
65 66 67 68 69
};

} // namespace Dorie
} // namespace Dune

70
#endif // DUNE_DORIE_INITIAL_CONDITION_H5_HH