swh:1:snp:f521c49ab17ef7db6ec70b2430e1ed203f50383f
Raw File
Tip revision: 63005e54d906a953d24af54c168ff8af1e732124 authored by Dmitri Naumov on 04 March 2021, 08:52:46 UTC
[T/App/U] Add GMSH2OGS snakemake ctest.
Tip revision: 63005e5
CreateMaterialSpatialDistributionMap.cpp
/**
 * \file
 * \date   Nov 28, 2017
 *
 * \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 "CreateMaterialSpatialDistributionMap.h"
#include "MaterialSpatialDistributionMap.h"
#include "MeshLib/Mesh.h"

namespace MaterialPropertyLib
{
std::unique_ptr<MaterialSpatialDistributionMap>
createMaterialSpatialDistributionMap(
    std::map<int, std::shared_ptr<Medium>> const& media,
    MeshLib::Mesh const& mesh)
{
    auto const material_ids = materialIDs(mesh);

    int const max_material_id =
        !material_ids
            ? 0
            : *std::max_element(begin(*material_ids), end(*material_ids));

    if (max_material_id > static_cast<int>(media.size() - 1))
    {
        WARN(
            "The maximum value of MaterialIDs in mesh is {:d}. As the given "
            "number of porous media definitions in the project file is {:d}, "
            "the "
            "maximum value of MaterialIDs in mesh must be {:d} (index starts "
            "with zero).",
            max_material_id, media.size(), max_material_id - 1);
    }

    if (max_material_id < static_cast<int>(media.size() - 1))
    {
        WARN(
            "There are {:d} porous medium definitions in the project file but "
            "only {:d} different values in the MaterialIDs vector/data_array "
            "in "
            "the mesh.",
            media.size(), max_material_id - 1);
    }
    return std::make_unique<MaterialSpatialDistributionMap>(media,
                                                            material_ids);
}
}  // namespace MaterialPropertyLib
back to top