Revision 1a8392de8a8fa45dbdb1e2da1f525b9e9338d991 authored by wenqing on 12 July 2021, 08:14:46 UTC, committed by wenqing on 12 July 2021, 08:14:46 UTC
Changed the type of temperature reference to Parameter in the SmallDefomation project files

Closes #3168

See merge request ogs/ogs!3702
2 parent s f4a331e + 0ebe8aa
Raw File
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