From 78b7b70e2c062a9631952714595b01a9f3e6b80c Mon Sep 17 00:00:00 2001 From: renchao_lu <renchao.lu@gmail.com> Date: Sat, 21 Sep 2019 15:40:06 +0200 Subject: [PATCH] [CL] Add Surface (definition and creation). --- .../CreateChemicalSolverInterface.cpp | 7 +++ ChemistryLib/PhreeqcIOData/CreateSurface.cpp | 52 +++++++++++++++++++ ChemistryLib/PhreeqcIOData/CreateSurface.h | 29 +++++++++++ ChemistryLib/PhreeqcIOData/Surface.cpp | 27 ++++++++++ ChemistryLib/PhreeqcIOData/Surface.h | 46 ++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 ChemistryLib/PhreeqcIOData/CreateSurface.cpp create mode 100644 ChemistryLib/PhreeqcIOData/CreateSurface.h create mode 100644 ChemistryLib/PhreeqcIOData/Surface.cpp create mode 100644 ChemistryLib/PhreeqcIOData/Surface.h diff --git a/ChemistryLib/CreateChemicalSolverInterface.cpp b/ChemistryLib/CreateChemicalSolverInterface.cpp index 3f4a3d28253..489c91e1c30 100644 --- a/ChemistryLib/CreateChemicalSolverInterface.cpp +++ b/ChemistryLib/CreateChemicalSolverInterface.cpp @@ -17,10 +17,12 @@ #include "PhreeqcIOData/CreateEquilibriumPhase.h" #include "PhreeqcIOData/CreateKineticReactant.h" #include "PhreeqcIOData/CreateOutput.h" +#include "PhreeqcIOData/CreateSurface.h" #include "PhreeqcIOData/CreateUserPunch.h" #include "PhreeqcIOData/EquilibriumPhase.h" #include "PhreeqcIOData/KineticReactant.h" #include "PhreeqcIOData/ReactionRate.h" +#include "PhreeqcIOData/Surface.h" #include "PhreeqcIOData/UserPunch.h" #include "PhreeqcKernel.h" #include "PhreeqcKernelData/AqueousSolution.h" @@ -90,6 +92,11 @@ createChemicalSolverInterface<ChemicalSolver::Phreeqc>( //! \ogs_file_param{prj__chemical_system__equilibrium_phases} config.getConfigSubtreeOptional("equilibrium_phases"), mesh); + // surface + auto surface = PhreeqcIOData::createSurface( + //! \ogs_file_param{prj__chemical_system__surface} + config.getConfigSubtreeOptional("surface")); + // output auto const& components = aqueous_solution.components; auto const project_file_name = BaseLib::joinPaths( diff --git a/ChemistryLib/PhreeqcIOData/CreateSurface.cpp b/ChemistryLib/PhreeqcIOData/CreateSurface.cpp new file mode 100644 index 00000000000..48be1050f6d --- /dev/null +++ b/ChemistryLib/PhreeqcIOData/CreateSurface.cpp @@ -0,0 +1,52 @@ +/** + * \copyright + * Copyright (c) 2012-2019, 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 <boost/optional/optional.hpp> + +#include "BaseLib/ConfigTree.h" +#include "Surface.h" + +namespace ChemistryLib +{ +namespace PhreeqcIOData +{ +std::vector<SurfaceSite> createSurface( + boost::optional<BaseLib::ConfigTree> const& config) +{ + if (!config) + return {}; + + std::vector<SurfaceSite> surface; + for (auto const& site_config : + //! \ogs_file_param{prj__chemical_system__surface__site} + config->getConfigSubtreeList("site")) + { + //! \ogs_file_param{prj__chemical_system__surface__site__mineral} + auto mineral = site_config.getConfigParameter<std::string>("mineral"); + + auto const site_density = + //! \ogs_file_param{prj__chemical_system__surface__site__site_density} + site_config.getConfigParameter<double>("site_density"); + + auto const specific_surface_area = + //! \ogs_file_param{prj__chemical_system__surface__site__specific_surface_area} + site_config.getConfigParameter<double>("specific_surface_area"); + + auto const mass = + //! \ogs_file_param{prj__chemical_system__surface__site__mass} + site_config.getConfigParameter<double>("mass"); + + surface.emplace_back( + std::move(mineral), site_density, specific_surface_area, mass); + } + + return surface; +} +} // namespace PhreeqcIOData +} // namespace ChemistryLib diff --git a/ChemistryLib/PhreeqcIOData/CreateSurface.h b/ChemistryLib/PhreeqcIOData/CreateSurface.h new file mode 100644 index 00000000000..08da56da749 --- /dev/null +++ b/ChemistryLib/PhreeqcIOData/CreateSurface.h @@ -0,0 +1,29 @@ +/** + * \copyright + * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#pragma once + +#include <boost/optional/optional_fwd.hpp> +#include <vector> + +namespace BaseLib +{ +class ConfigTree; +} + +namespace ChemistryLib +{ +namespace PhreeqcIOData +{ +struct SurfaceSite; + +std::vector<SurfaceSite> createSurface( + boost::optional<BaseLib::ConfigTree> const& config); +} // namespace PhreeqcIOData +} // namespace ChemistryLib diff --git a/ChemistryLib/PhreeqcIOData/Surface.cpp b/ChemistryLib/PhreeqcIOData/Surface.cpp new file mode 100644 index 00000000000..54d604d873c --- /dev/null +++ b/ChemistryLib/PhreeqcIOData/Surface.cpp @@ -0,0 +1,27 @@ +/** + * \copyright + * Copyright (c) 2012-2019, 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 <ostream> + +#include "Surface.h" + +namespace ChemistryLib +{ +namespace PhreeqcIOData +{ +std::ostream& operator<<(std::ostream& os, SurfaceSite const& surface_site) +{ + os << surface_site.mineral.c_str() << " " << surface_site.site_density + << " " << surface_site.specific_surface_area << " " << surface_site.mass + << "\n"; + + return os; +} +} // namespace PhreeqcIOData +} // namespace ChemistryLib diff --git a/ChemistryLib/PhreeqcIOData/Surface.h b/ChemistryLib/PhreeqcIOData/Surface.h new file mode 100644 index 00000000000..dddfac90415 --- /dev/null +++ b/ChemistryLib/PhreeqcIOData/Surface.h @@ -0,0 +1,46 @@ +/** + * \copyright + * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#pragma once + +#include <iosfwd> +#include <string> + +namespace BaseLib +{ +class ConfigTree; +} + +namespace ChemistryLib +{ +namespace PhreeqcIOData +{ +struct SurfaceSite +{ + SurfaceSite(std::string&& mineral_, + double const site_density_, + double const specific_surface_area_, + double const mass_) + : mineral(std::move(mineral_)), + site_density(site_density_), + specific_surface_area(specific_surface_area_), + mass(mass_) + { + } + + friend std::ostream& operator<<(std::ostream& os, + SurfaceSite const& surface_site); + + std::string const mineral; + double const site_density; + double const specific_surface_area; + double const mass; +}; +} // namespace PhreeqcIOData +} // namespace ChemistryLib -- GitLab