diff --git a/NumLib/Extrapolation/Extrapolator.h b/NumLib/Extrapolation/Extrapolator.h index da8ebe315085e29f0cc6d9c21df9284d0efcc714..0867cfa389a937efd852c24313d88d3516e5e823 100644 --- a/NumLib/Extrapolation/Extrapolator.h +++ b/NumLib/Extrapolation/Extrapolator.h @@ -12,6 +12,9 @@ #include <vector> +#include <Eigen/Eigen> +#include "NumLib/NumericsConfig.h" + namespace NumLib { diff --git a/ProcessLib/SecondaryVariable.cpp b/ProcessLib/SecondaryVariable.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3ceff2c9e083721bc4f45eb4a17585a772aa96d9 --- /dev/null +++ b/ProcessLib/SecondaryVariable.cpp @@ -0,0 +1,84 @@ +/** + * \copyright + * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include "SecondaryVariable.h" + +namespace ProcessLib +{ + +SecondaryVariableCollection::SecondaryVariableCollection( + boost::optional<BaseLib::ConfigTree> const& config, + std::initializer_list<std::string> tag_names) +{ + if (!config) return; + + // read which variables are defined in the config + for (auto const& tag_name : tag_names) { + if (!_all_secondary_variables.insert(tag_name).second) { + OGS_FATAL("Tag name <%s> has been specified twice as a secondary variable."); + } + + //! \ogs_file_special + if (auto var_name = config->getConfigParameterOptional<std::string>(tag_name)) + { + // TODO check primary vars, too + BaseLib::insertIfKeyValueUniqueElseError( + _map_tagname_to_varname, tag_name, *var_name, + "Secondary variable names must be unique."); + } + } +} + +bool SecondaryVariableCollection::variableExists(std::string const& variable_name) const +{ + auto pred = [&variable_name](std::pair<std::string, std::string> const& p) { + return p.second == variable_name; + }; + + // check if out_var is a secondary variable + auto const& var = std::find_if( + _map_tagname_to_varname.cbegin(), _map_tagname_to_varname.cend(), pred); + + return var != _map_tagname_to_varname.cend(); +} + +void SecondaryVariableCollection::addSecondaryVariable(std::string const& tag_name, + const unsigned num_components, + SecondaryVariableFunctions&& fcts) +{ + auto it = _map_tagname_to_varname.find(tag_name); + + // get user-supplied var_name for the given tag_name + if (it != _map_tagname_to_varname.end()) + { + auto const& var_name = it->first; + + if (!_configured_secondary_variables + .emplace(std::make_pair( + var_name, + SecondaryVariable{ + var_name, num_components, std::move(fcts)})) + .second) + { + OGS_FATAL("The secondary variable with name `%s' has already been " + "set up.", + var_name.c_str()); + } + } + else if (_all_secondary_variables.find(tag_name) == + _all_secondary_variables.end()) + { + OGS_FATAL("The tag <%s> has not been registered to mark a secondary " + "variable.", + tag_name.c_str()); + } +} + + +} // namespace ProcessLib diff --git a/ProcessLib/SecondaryVariable.h b/ProcessLib/SecondaryVariable.h index d6744c6ee0bb3ee5238cb47dc331e5236b908697..bf99e2e4c3fb4dfef1072c3be335b9caac102063 100644 --- a/ProcessLib/SecondaryVariable.h +++ b/ProcessLib/SecondaryVariable.h @@ -106,43 +106,13 @@ public: */ SecondaryVariableCollection( boost::optional<BaseLib::ConfigTree> const& config, - std::initializer_list<std::string> tag_names) - { - if (!config) return; - - // read which variables are defined in the config - for (auto const& tag_name : tag_names) { - if (!_all_secondary_variables.insert(tag_name).second) { - OGS_FATAL("Tag name <%s> has been specified twice as a secondary variable."); - } - - //! \ogs_file_special - if (auto var_name = config->getConfigParameterOptional<std::string>(tag_name)) - { - // TODO check primary vars, too - BaseLib::insertIfKeyValueUniqueElseError( - _map_tagname_to_varname, tag_name, *var_name, - "Secondary variable names must be unique."); - } - } - } + std::initializer_list<std::string> tag_names); /*! Tells if a secondary variable with the specified name has been set up. * * \note \c variable_name is not the tag name in the project file! */ - bool variableExists(std::string const& variable_name) const - { - auto pred = [&variable_name](std::pair<std::string, std::string> const& p) { - return p.second == variable_name; - }; - - // check if out_var is a secondary variable - auto const& var = std::find_if( - _map_tagname_to_varname.cbegin(), _map_tagname_to_varname.cend(), pred); - - return var != _map_tagname_to_varname.cend(); - } + bool variableExists(std::string const& variable_name) const; /*! Set up a secondary variable. * @@ -158,35 +128,7 @@ public: */ void addSecondaryVariable(std::string const& tag_name, const unsigned num_components, - SecondaryVariableFunctions&& fcts) - { - auto it = _map_tagname_to_varname.find(tag_name); - - // get user-supplied var_name for the given tag_name - if (it != _map_tagname_to_varname.end()) - { - auto const& var_name = it->first; - - if (!_configured_secondary_variables - .emplace(std::make_pair( - var_name, - SecondaryVariable{ - var_name, num_components, std::move(fcts)})) - .second) - { - OGS_FATAL("The secondary variable with name `%s' has already been " - "set up.", - var_name.c_str()); - } - } - else if (_all_secondary_variables.find(tag_name) == - _all_secondary_variables.end()) - { - OGS_FATAL("The tag <%s> has not been registered to mark a secondary " - "variable.", - tag_name.c_str()); - } - } + SecondaryVariableFunctions&& fcts); //! Returns an iterator to the first secondary variable. std::map<std::string, SecondaryVariable>::const_iterator