swh:1:snp:f521c49ab17ef7db6ec70b2430e1ed203f50383f
Raw File
Tip revision: dffc636b9639c04d1bd25eec9ed32645a1f583be authored by Wenqing Wang on 14 May 2021, 14:50:46 UTC
[LiquidFlow] Removed the old gravity parameters
Tip revision: dffc636
CreateEquilibriumReactants.cpp
/**
 * \file
 * \copyright
 * Copyright (c) 2012-2021, 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 "CreateEquilibriumReactants.h"

#include <optional>
#include <vector>

#include "BaseLib/ConfigTree.h"
#include "EquilibriumReactants.h"
#include "MeshLib/Mesh.h"

namespace ChemistryLib
{
namespace PhreeqcKernelData
{
std::unique_ptr<EquilibriumReactants> createEquilibriumReactants(
    std::optional<BaseLib::ConfigTree> const& config, MeshLib::Mesh const& mesh)
{
    if (!config)
    {
        return nullptr;
    }

    std::vector<PhaseComponent> phase_components;
    for (
        auto const& phase_component_config :
        //! \ogs_file_param{prj__chemical_system__equilibrium_reactants__phase_component}
        config->getConfigSubtreeList("phase_component"))
    {
        auto name =
            //! \ogs_file_param{prj__chemical_system__equilibrium_reactants__phase_component__name}
            phase_component_config.getConfigParameter<std::string>("name");

        double const initial_amount =
            //! \ogs_file_param{prj__chemical_system__equilibrium_reactants__phase_component__initial_amount}
            phase_component_config.getConfigParameter<double>("initial_amount");

        double const saturation_index =
            //! \ogs_file_param{prj__chemical_system__equilibrium_reactants__phase_component__saturation_index}
            phase_component_config.getConfigParameter<double>(
                "saturation_index");

        auto amount = MeshLib::getOrCreateMeshProperty<double>(
            const_cast<MeshLib::Mesh&>(mesh),
            name,
            MeshLib::MeshItemType::Node,
            1);
        std::fill(amount->begin(), amount->end(), initial_amount);

        phase_components.emplace_back(
            std::move(name), initial_amount, saturation_index);
    }

    return std::make_unique<EquilibriumReactants>(phase_components);
}
}  // namespace PhreeqcKernelData
}  // namespace ChemistryLib
back to top