Revision 71de76f6c662926f5da5408853e22786055a6194 authored by Thomas Fischer on 09 July 2021, 06:29:00 UTC, committed by Thomas Fischer on 30 August 2021, 05:26:04 UTC
The getContent() method is used only on very few
places. Especially, it isn't used in the computation
of any THMC processes. So the content doesn't need
to be stored which saves memory. Furthermore, the time
time for reading / initializing a mesh is reduced.

In a hex mesh with 100x100x100 elements this saves
2.6% of storage and circa 25% time.
1 parent deb816d
Raw File
SelectSolidConstitutiveRelation.h
/**
 * \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
 */

#pragma once

#include <map>

#include "MeshLib/PropertyVector.h"

#include "MechanicsBase.h"

namespace MaterialLib
{
namespace Solids
{
/// Choose solid material model for given element id out of a set of models,
/// possibly using the material ids.
///
/// Only two possibilities yield a valid result and result in OGS_FATAL call
/// otherwise.
/// 1. There is only one constitutive relation in the set of
/// constitutive_relations, then the material and element ids are ignored and
/// the only constitutive relation (under id 0) is returned.
/// 2. For each material id chosen for the given element id there exists a
/// constitutive relation in the set.
template <int DisplacementDim>
MechanicsBase<DisplacementDim>& selectSolidConstitutiveRelation(
    std::map<int, std::unique_ptr<MechanicsBase<DisplacementDim>>> const&
        constitutive_relations,
    MeshLib::PropertyVector<int> const* const material_ids,
    std::size_t const element_id)
{
    int material_id;
    if (constitutive_relations.size() == 1 || material_ids == nullptr)
    {
        material_id = 0;
    }
    else
    {
        material_id = (*material_ids)[element_id];
    }

    auto const constitutive_relation = constitutive_relations.find(material_id);
    if (constitutive_relation == end(constitutive_relations))
    {
        OGS_FATAL(
            "No constitutive relation found for material id {:d} and element "
            "{:d}. There are {:d} constitutive relations available.",
            material_id, element_id, constitutive_relations.size());
    }

    if (constitutive_relation->second == nullptr)
    {
        OGS_FATAL(
            "The constitutive relation found for material id {:d} and element "
            "{:d} is a nullptr, which is impossible.",
            material_id, element_id);
    }

    return *constitutive_relation->second;
}
}  // namespace Solids
}  // namespace MaterialLib
back to top