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.)

Commit 5acaf211 authored by Santiago Ospina De Los Ríos's avatar Santiago Ospina De Los Ríos
Browse files

[Transport] Move parameter factory to an independent file

parent ae7df29b
#ifndef DUNE_DORIE_PARAM_TRANSPORT_FACTORY_HH
#define DUNE_DORIE_PARAM_TRANSPORT_FACTORY_HH
#include <dune/dorie/common/parameterization_factory.hh>
#include <dune/dorie/model/transport/parameterization/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/power_law.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/isotropic.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/longitudinal/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/longitudinal/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/transverse/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/transverse/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_diffusion/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_diffusion/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_diffusion/millington_quirk_1.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_diffusion/millington_quirk_2.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/superposition.hh>
namespace Dune {
namespace Dorie {
namespace Parameterization {
/*-------------------------------------------------------------------------*//**
* @brief { struct_description }
*
* @tparam Traits { description }
*/
template<class Traits>
struct TransportFactory
: public ParameterizationFactory<Transport<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<Transport<Traits>>
selector(
const YAML::Node& type_node,
const std::string name) const override
{
std::shared_ptr<Transport<Traits>> hd_dips;
const auto type = type_node["type"].as<std::string>();
if (type == ConstHydrodynamicDispersion<Traits>::type) {
hd_dips = std::make_shared<ConstHydrodynamicDispersion<Traits>>(name);
} else if (type == PowerLawDispersion<Traits>::type) {
hd_dips = std::make_shared<PowerLawDispersion<Traits>>(name);
} else if (type == HydrodynamicDispersionSuperposition<Traits>::type) {
// Select type for effective diffusion
const YAML::Node& eff_diff_node = type_node["eff_diff"];
auto eff_diff_type = eff_diff_node["type"].as<std::string>();
std::shared_ptr<EffectiveDiffusion<Traits>> eff_diff;
// Build parametrization for effective diffusion
if (eff_diff_type == ConstEffectiveDiffusion<Traits>::type) {
eff_diff = std::make_shared<ConstEffectiveDiffusion<Traits>>(name);
} else if (eff_diff_type == MillingtonQuirk1<Traits>::type) {
eff_diff = std::make_shared<MillingtonQuirk1<Traits>>(name);
} else if (eff_diff_type == MillingtonQuirk2<Traits>::type) {
eff_diff = std::make_shared<MillingtonQuirk2<Traits>>(name);
} else {
DUNE_THROW(NotImplemented,"Invalid eff_diff");
}
// Select type for effective hydromechanic dispersion
const YAML::Node& eff_hm_disp_node = type_node["eff_hydromechanic_disp"];
auto eff_hm_disp_type = eff_hm_disp_node["type"].as<std::string>();
std::shared_ptr<EffectiveHydromechanicDispersion<Traits>> eff_hm_disp;
// Build parametrization for effective hydromechanic dispersion
if (eff_hm_disp_type == ConstEffectiveHydromechanicDispersion<Traits>::type) {
eff_hm_disp = std::make_shared<ConstEffectiveHydromechanicDispersion<Traits>>(name);
} else if (eff_hm_disp_type == IsotropicEffectiveHydromechanicDispersion<Traits>::type) {
// Select type for longitudinal and transverse dispersivity
const YAML::Node& long_disp_node = eff_hm_disp_node["long_disp"];
const YAML::Node& trans_disp_node = eff_hm_disp_node["trans_disp"];
auto long_disp_type = long_disp_node["type"].as<std::string>();
auto trans_disp_type = trans_disp_node["type"].as<std::string>();
std::shared_ptr<ConstLongitudinalDispersivity<Traits>> lambda_l;
std::shared_ptr<ConstTransverseDispersivity<Traits>> lambda_t;
// Build parametrization for longitudinal dispersivity
if (long_disp_type == ConstLongitudinalDispersivity<Traits>::type) {
lambda_l = std::make_shared<ConstLongitudinalDispersivity<Traits>>(name);
} else {
DUNE_THROW(NotImplemented,"Invalid long_disp");
}
// Build parametrization for transverse dispersivity
if (trans_disp_type == ConstTransverseDispersivity<Traits>::type) {
lambda_t = std::make_shared<ConstTransverseDispersivity<Traits>>(name);
} else {
DUNE_THROW(NotImplemented,"Invalid trans_disp");
}
eff_hm_disp = std::make_shared<IsotropicEffectiveHydromechanicDispersion<Traits>>(name,lambda_l,lambda_t);
} else {
DUNE_THROW(NotImplemented,"Invalid eff_hydromech_disp");
}
hd_dips = std::make_shared<HydrodynamicDispersionSuperposition<Traits>>(name,eff_diff,eff_hm_disp);
} else {
DUNE_THROW(NotImplemented,"Invalid hydrodyn_disp" );
}
return hd_dips;
}
};
} // namespace Parameterization
} // namespace Dune
} // namespace Dorie
#endif // DUNE_DORIE_PARAM_TRANSPORT_FACTORY_HH
\ No newline at end of file
......@@ -14,114 +14,11 @@
#include <dune/common/exceptions.hh>
#include <dune/grid/common/mcmgmapper.hh>
#include <dune/dorie/common/parameterization_factory.hh>
#include <dune/dorie/model/transport/parameterization/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/power_law.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/isotropic.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/longitudinal/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/longitudinal/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/transverse/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_hydromechanic_dispersion/transverse/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_diffusion/interface.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_diffusion/const.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_diffusion/millington_quirk_1.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/eff_diffusion/millington_quirk_2.hh>
#include <dune/dorie/model/transport/parameterization/hydrodynamic_dispersion/superposition.hh>
#include <dune/dorie/model/transport/parameterization/factory.hh>
namespace Dune {
namespace Dorie {
template<class Traits>
struct TransportParameterizationFactory
: public ParameterizationFactory<Dorie::Parameterization::Transport<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::Transport<Traits>>
selector(
const YAML::Node& type_node,
const std::string name) const override
{
std::shared_ptr<Parameterization::Transport<Traits>> hd_dips;
const auto type = type_node["type"].as<std::string>();
if (type == Parameterization::ConstHydrodynamicDispersion<Traits>::type) {
hd_dips = std::make_shared<Parameterization::ConstHydrodynamicDispersion<Traits>>(name);
} else if (type == Parameterization::PowerLawDispersion<Traits>::type) {
hd_dips = std::make_shared<Parameterization::PowerLawDispersion<Traits>>(name);
} else if (type == Parameterization::HydrodynamicDispersionSuperposition<Traits>::type) {
// Select type for effective diffusion
const YAML::Node& eff_diff_node = type_node["eff_diff"];
auto eff_diff_type = eff_diff_node["type"].as<std::string>();
std::shared_ptr<Parameterization::EffectiveDiffusion<Traits>> eff_diff;
// Build parametrization for effective diffusion
if (eff_diff_type == Parameterization::ConstEffectiveDiffusion<Traits>::type) {
eff_diff = std::make_shared<Parameterization::ConstEffectiveDiffusion<Traits>>(name);
} else if (eff_diff_type == Parameterization::MillingtonQuirk1<Traits>::type) {
eff_diff = std::make_shared<Parameterization::MillingtonQuirk1<Traits>>(name);
} else if (eff_diff_type == Parameterization::MillingtonQuirk2<Traits>::type) {
eff_diff = std::make_shared<Parameterization::MillingtonQuirk2<Traits>>(name);
} else {
DUNE_THROW(NotImplemented,"Invalid eff_diff");
}
// Select type for effective hydromechanic dispersion
const YAML::Node& eff_hm_disp_node = type_node["eff_hydromechanic_disp"];
auto eff_hm_disp_type = eff_hm_disp_node["type"].as<std::string>();
std::shared_ptr<Parameterization::EffectiveHydromechanicDispersion<Traits>> eff_hm_disp;
// Build parametrization for effective hydromechanic dispersion
if (eff_hm_disp_type == Parameterization::ConstEffectiveHydromechanicDispersion<Traits>::type) {
eff_hm_disp = std::make_shared<Parameterization::ConstEffectiveHydromechanicDispersion<Traits>>(name);
} else if (eff_hm_disp_type == Parameterization::IsotropicEffectiveHydromechanicDispersion<Traits>::type) {
// Select type for longitudinal and transverse dispersivity
const YAML::Node& long_disp_node = eff_hm_disp_node["long_disp"];
const YAML::Node& trans_disp_node = eff_hm_disp_node["trans_disp"];
auto long_disp_type = long_disp_node["type"].as<std::string>();
auto trans_disp_type = trans_disp_node["type"].as<std::string>();
std::shared_ptr<Parameterization::ConstLongitudinalDispersivity<Traits>> lambda_l;
std::shared_ptr<Parameterization::ConstTransverseDispersivity<Traits>> lambda_t;
// Build parametrization for longitudinal dispersivity
if (long_disp_type == Parameterization::ConstLongitudinalDispersivity<Traits>::type) {
lambda_l = std::make_shared<Parameterization::ConstLongitudinalDispersivity<Traits>>(name);
} else {
DUNE_THROW(NotImplemented,"Invalid long_disp");
}
// Build parametrization for transverse dispersivity
if (trans_disp_type == Parameterization::ConstTransverseDispersivity<Traits>::type) {
lambda_t = std::make_shared<Parameterization::ConstTransverseDispersivity<Traits>>(name);
} else {
DUNE_THROW(NotImplemented,"Invalid trans_disp");
}
eff_hm_disp = std::make_shared<Parameterization::IsotropicEffectiveHydromechanicDispersion<Traits>>(name,lambda_l,lambda_t);
} else {
DUNE_THROW(NotImplemented,"Invalid eff_hydromech_disp");
}
hd_dips = std::make_shared<Parameterization::HydrodynamicDispersionSuperposition<Traits>>(name,eff_diff,eff_hm_disp);
} else {
DUNE_THROW(NotImplemented,"Invalid hydrodyn_disp" );
}
return hd_dips;
}
};
/// 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
......@@ -161,7 +58,7 @@ private:
/// Base class of the parameterization
using ParameterizationType = typename Dorie::Parameterization::Transport<Traits>;
/// Parameterization factory
using ParameterizationFactory = Dorie::TransportParameterizationFactory<Traits>;
using ParameterizationFactory = Dorie::Parameterization::TransportFactory<Traits>;
/// Storage for parameters
using ParameterStorage = std::unordered_map<Index,std::shared_ptr<ParameterizationType>>;
......
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