OGS
CreateUserPunch.cpp
Go to the documentation of this file.
1
11#include <optional>
12
13#include "BaseLib/ConfigTree.h"
14#include "MeshLib/Mesh.h"
16#include "UserPunch.h"
17
18namespace ChemistryLib
19{
20namespace PhreeqcIOData
21{
22std::unique_ptr<UserPunch> createUserPunch(
23 std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh const& mesh)
24{
25 if (!config)
26 {
27 return nullptr;
28 }
29
30 std::vector<SecondaryVariable> secondary_variables;
31 for (auto const& variable_name :
33 config->getConfigParameter<std::vector<std::string>>("headline"))
34 {
35 auto value = MeshLib::getOrCreateMeshProperty<double>(
36 const_cast<MeshLib::Mesh&>(mesh),
37 variable_name,
39 1);
40 std::fill(std::begin(*value),
41 std::end(*value),
42 std::numeric_limits<double>::quiet_NaN());
43
44 secondary_variables.emplace_back(variable_name, value);
45 }
46
47 std::vector<std::string> statements;
48 for (auto const& statement :
50 config->getConfigParameterList<std::string>("statement"))
51 {
52 statements.emplace_back(statement);
53 }
54
55 return std::make_unique<UserPunch>(std::move(secondary_variables),
56 std::move(statements));
57}
58} // namespace PhreeqcIOData
59} // namespace ChemistryLib
Definition of the Mesh class.
std::unique_ptr< UserPunch > createUserPunch(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)