OGS
CreateUserPunch.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include <optional>
5
7#include "MeshLib/Mesh.h"
9#include "UserPunch.h"
10
11namespace ChemistryLib
12{
13namespace PhreeqcIOData
14{
15std::unique_ptr<UserPunch> createUserPunch(
16 std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh const& mesh)
17{
18 if (!config)
19 {
20 return nullptr;
21 }
22
23 std::vector<SecondaryVariable> secondary_variables;
24 for (auto const& variable_name :
26 config->getConfigParameter<std::vector<std::string>>("headline"))
27 {
29 const_cast<MeshLib::Mesh&>(mesh),
30 variable_name,
32 1);
33 std::fill(std::begin(*value),
34 std::end(*value),
35 std::numeric_limits<double>::quiet_NaN());
36
37 secondary_variables.emplace_back(variable_name, value);
38 }
39
40 std::vector<std::string> statements;
41 for (auto const& statement :
43 config->getConfigParameterList<std::string>("statement"))
44 {
45 statements.emplace_back(statement);
46 }
47
48 return std::make_unique<UserPunch>(std::move(secondary_variables),
49 std::move(statements));
50}
51} // namespace PhreeqcIOData
52} // namespace ChemistryLib
std::unique_ptr< UserPunch > createUserPunch(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)