21 std::vector<PairTimeParameterName>
22 time_parameter_name_mapping)
23 :
Parameter<double>(std::move(name), nullptr),
24 _time_parameter_name_mapping(std::move(time_parameter_name_mapping))
44 "Coordinate system not expected to be set for curve scaled "
66 "Could not find parameter for time {}. There are {:d} "
67 "time-parameter pairs.",
72 auto const alpha = (t - t0) / (t1 - t0);
75 std::transform(r0.begin(), r0.end(), r0.begin(),
76 [alpha](
auto const& v) { return (1 - alpha) * v; });
78 std::transform(r1.begin(), r1.end(), r1.begin(),
79 [alpha](
auto const& v) { return alpha * v; });
80 std::transform(r0.begin(), r0.end(), r1.begin(), r0.begin(),
81 [](
auto const& v0,
auto const& v1) { return v0 + v1; });
86 std::vector<std::unique_ptr<ParameterBase>>
const& parameters)
88 DBUG(
"TimeDependentHeterogeneousParameter init {:d} time series entries.",
104 { return n == p.second->getNumberOfGlobalComponents(); }))
107 "All referenced parameters in time dependent heterogeneous "
108 "parameter '{:s}' have to have the same number of components.",
118 auto const time_series_config =
122 std::vector<TimeDependentHeterogeneousParameter::PairTimeParameterName>
125 for (
auto const p : time_series_config.getConfigSubtreeList(
"pair"))
128 auto time = p.getConfigParameter<
double>(
"time");
129 auto parameter_name =
131 p.getConfigParameter<std::string>(
"parameter_name");
132 time_series.emplace_back(time, parameter_name);
135 if (time_series.empty())
138 "Time dependent heterogeneous parameter '{:s}' doesn't contain "
139 "necessary time series data.",
144 time_series.begin(), time_series.end(),
148 p1) { return p0.first < p1.first; }))
151 "The points in time in the time series '{:s}' aren't in ascending "
156 return std::make_unique<TimeDependentHeterogeneousParameter>(
157 name, std::move(time_series));
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
ConfigTree getConfigSubtree(std::string const &root) const
void checkConfigParameter(std::string const ¶m, std::string_view const value) const
std::vector< double > operator()(double const t, SpatialPosition const &pos) const override
Returns the parameter value at the given time and position.
TimeDependentHeterogeneousParameter(std::string name, std::vector< PairTimeParameterName > time_parameter_name_mapping)
std::vector< PairTimeParameter > _time_parameter_mapping
bool isTimeDependent() const override
std::pair< double, std::string > PairTimeParameterName
int getNumberOfGlobalComponents() const override
void initialize(std::vector< std::unique_ptr< ParameterBase > > const ¶meters) override
std::vector< PairTimeParameterName > _time_parameter_name_mapping
std::unique_ptr< ParameterBase > createTimeDependentHeterogeneousParameter(std::string const &name, BaseLib::ConfigTree const &config)
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const ¶meter_name, std::vector< std::unique_ptr< ParameterBase > > const ¶meters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
std::optional< CoordinateSystem > _coordinate_system
virtual int getNumberOfGlobalComponents() const =0