OGS
CreateSurface.cpp
Go to the documentation of this file.
1
11#include "CreateSurface.h"
12
13#include "BaseLib/ConfigTree.h"
14#include "MeshLib/Mesh.h"
16#include "Surface.h"
17
18namespace ChemistryLib
19{
20namespace PhreeqcIOData
21{
22std::vector<std::variant<DensityBasedSurfaceSite, MoleBasedSurfaceSite>>
23createSurface(std::optional<BaseLib::ConfigTree> const& config,
24 MeshLib::Mesh& mesh)
25{
26 if (!config)
27 {
28 return {};
29 }
30
31 std::vector<std::variant<DensityBasedSurfaceSite, MoleBasedSurfaceSite>>
32 surface;
33
34 auto const surface_site_unit =
36 config->getConfigAttribute<std::string>("site_unit", "mole");
37
38 if (surface_site_unit == "density")
39 {
40 for (auto const& site_config :
42 config->getConfigSubtreeList("site"))
43 {
45 auto name = site_config.getConfigParameter<std::string>("name");
46
47 auto const site_density =
49 site_config.getConfigParameter<double>("site_density");
50
51 auto const specific_surface_area =
53 site_config.getConfigParameter<double>("specific_surface_area");
54
55 auto const mass =
57 site_config.getConfigParameter<double>("mass");
58
59 surface.push_back(DensityBasedSurfaceSite(
60 std::move(name), site_density, specific_surface_area, mass));
61 }
62
63 return surface;
64 }
65
66 if (surface_site_unit == "mole")
67 {
68 for (auto const& site_config :
70 config->getConfigSubtreeList("site"))
71 {
73 auto name = site_config.getConfigParameter<std::string>("name");
74
75 auto const molality = MeshLib::getOrCreateMeshProperty<double>(
77
78 surface.push_back(MoleBasedSurfaceSite(std::move(name), molality));
79 }
80
81 return surface;
82 }
83
84 OGS_FATAL("Surface site unit should be either of 'density' or 'mole'.");
85}
86} // namespace PhreeqcIOData
87} // namespace ChemistryLib
#define OGS_FATAL(...)
Definition Error.h:26
Definition of the Mesh class.
std::vector< std::variant< DensityBasedSurfaceSite, MoleBasedSurfaceSite > > createSurface(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh &mesh)
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)