1#ifndef DUNE_COPASI_MODEL_LOCAL_VALUES_PARSED_FUNCTOR_FACTORY_IMPL_HH
2#define DUNE_COPASI_MODEL_LOCAL_VALUES_PARSED_FUNCTOR_FACTORY_IMPL_HH
9#ifdef DUNE_COPASI_PRECOMPILED_MODE
10#warning "Including this file in pre-compiled mode may defeat the purpose of pre-compilation"
16static inline const std::regex scientific_notation_regex(
"/[+\\-]?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+\\-]?\\d+)?/");
17static inline const std::regex float_regex(
"-?([0-9]+)?([\\.]?)([0-9]+)?");
18static inline const std::regex zero_regex(
"-?([0]+)?([\\.]?)([0]+)?");
21template<std::
size_t dim>
24template<std::
size_t dim>
34template<std::
size_t dim>
56 for (std::size_t
i = 0;
i != dim; ++
i) {
63template<std::
size_t dim>
72 std::string
type =
config.get(
"type",
"scalar");
73 if (
type ==
"scalar") {
79 }
else if (
type ==
"tensor") {
81 std::array<std::array<ScalarFunctor, dim>, dim>
tensor_parser;
100 for (std::size_t
i = 0;
i != dim; ++
i) {
102 for (std::size_t
j = 0;
j != dim; ++
j) {
109 spdlog::error(
"not known type 'scalar_value.{}.type = {}'",
prefix,
type);
114template<std::
size_t dim>
121 auto expression =
config.get(
"expression", std::string{});
122 if (expression.empty()
or std::regex_match(expression, Impl::zero_regex)) {
125 if (std::regex_match(expression, Impl::float_regex)
126 or std::regex_match(expression, Impl::scientific_notation_regex)) {
127 double value = std::stod(expression);
128 return [_value = value]()
noexcept {
return Scalar{ _value }; };
131 string2parser.at(
config.get(
"parser_type", std::string{ parser2string.at(_parser_type) }));
139 parser_ptr->define_constant(
"no_value", std::numeric_limits<double>::max());
160 parser_ptr->define_variable(std::string{name}, &(value[0]));
Definition functor_factory_parser.hh:13
ScalarFunctor make_scalar(std::string_view, const ParameterTree &, const LocalDomain< dim > &, int=0) const override
Definition functor_factory_parser.impl.hh:26
FieldVector< double, dim > Vector
Definition functor_factory_parser.hh:16
typename FunctorFactory< dim >::ScalarFunctor ScalarFunctor
Definition functor_factory_parser.hh:19
VectorFunctor make_vector(std::string_view, const ParameterTree &, const LocalDomain< dim > &, int=0) const override
Definition functor_factory_parser.impl.hh:36
TensorApplyFunctor make_tensor_apply(std::string_view, const ParameterTree &, const LocalDomain< dim > &, int=0) const override
Definition functor_factory_parser.impl.hh:65
typename FunctorFactory< dim >::VectorFunctor VectorFunctor
Definition functor_factory_parser.hh:20
typename FunctorFactory< dim >::TensorApplyFunctor TensorApplyFunctor
Definition functor_factory_parser.hh:21
Definition functor_factory_parser.impl.hh:22
Definition axis_names.hh:7
std::unique_ptr< Parser > make_parser(ParserType parser_type=default_parser)
constexpr bool is_bitflags_v
Alias for Bitflag indicator.
Definition bit_flags.hh:24
std::vector< std::string > axis_names
Definition local_domain.hh:15