[Richards] Move parameter factory to an independent file

parent a2851797
......@@ -14,45 +14,12 @@
#include <dune/grid/common/mcmgmapper.hh>
#include <dune/dorie/common/logging.hh>
#include <dune/dorie/common/parameterization_factory.hh>
#include <dune/dorie/model/richards/parameterization/interface.hh>
#include <dune/dorie/model/richards/parameterization/mualem_van_genuchten.hh>
#include <dune/dorie/model/richards/parameterization/factory.hh>
#include <dune/dorie/model/richards/parameterization/scaling.hh>
namespace Dune {
namespace Dorie {
/**
* @brief Factory of richards parameters
*
* @tparam Traits The base traits
*/
template<class Traits>
struct RichardsParameterizationFactory
: public ParameterizationFactory<Dorie::Parameterization::Richards<Traits>>
{
/// Return a default-initialized parameterization object
/** \param type The type indicating the parameterization implementation
* \param name The name of the parameterization object (layer type)
*/
std::shared_ptr<Dorie::Parameterization::Richards<Traits>>
selector(
const YAML::Node& type_node,
const std::string name) const override
{
auto log = Dorie::get_logger(log_richards);
const auto type = type_node["type"].as<std::string>();
if (type == Parameterization::MualemVanGenuchten<Traits>::type) {
return std::make_shared<Parameterization::MualemVanGenuchten<Traits>>(name);
}
else {
log->error("Parameterization '{}' has unknown type '{}'",
name, type);
DUNE_THROW(IOError, "Unknown parameterization type");
}
}
};
/// Top-level parameterization interface for the local operator.
/** This class loads and stores the parameters, maps them to grid entities,
* and provides functions to access the parameterization. For doing so, the
......@@ -98,7 +65,7 @@ private:
/// Base class of the parameterization
using ParameterizationType = Dorie::Parameterization::Richards<Traits>;
/// Parameterization factory
using ParameterizationFactory = Dorie::RichardsParameterizationFactory<Traits>;
using ParameterizationFactory = Dorie::Parameterization::RichardsFactory<Traits>;
/// Struct for storing scaling factors
using Scaling = Dorie::Parameterization::ScalingFactors<RF>;
/// Base class for scaling adapters
......
#ifndef DUNE_DORIE_PARAM_RICHARDS_FACTORY_HH
#define DUNE_DORIE_PARAM_RICHARDS_FACTORY_HH
#include <dune/common/exceptions.hh>
#include <dune/dorie/common/parameterization_factory.hh>
#include <dune/dorie/model/richards/parameterization/interface.hh>
#include <dune/dorie/model/richards/parameterization/mualem_van_genuchten.hh>
namespace Dune {
namespace Dorie {
namespace Parameterization {
/**
* @brief Factory of richards parameters
*
* @tparam Traits The base traits
*/
template<class Traits>
struct RichardsFactory
: public ParameterizationFactory<Richards<Traits>>
{
/// Return a default-initialized parameterization object
/** \param type The type indicating the parameterization implementation
* \param name The name of the parameterization object (layer type)
*/
std::shared_ptr<Richards<Traits>>
selector(
const YAML::Node& type_node,
const std::string name) const override
{
auto log = Dorie::get_logger(log_richards);
const auto type = type_node["type"].as<std::string>();
if (type == Parameterization::MualemVanGenuchten<Traits>::type) {
return std::make_shared<Parameterization::MualemVanGenuchten<Traits>>(name);
}
else {
log->error("Parameterization '{}' has unknown type '{}'",
name, type);
DUNE_THROW(IOError, "Unknown parameterization type");
}
}
};
} // namespace Parameterization
} // namespace Dorie
} // namespace Dune
#endif // DUNE_DORIE_PARAM_RICHARDS_FACTORY_HH
\ No newline at end of file
Markdown is supported
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