Revision 2a483a61e70d3b8642c66229630a9171d8816b79 authored by Thomas Fischer on 09 July 2021, 15:15:16 UTC, committed by Dmitry Yu. Naumov on 05 October 2021, 20:56:20 UTC
1 parent e8af0af
Raw File
MeshElementParameter.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 "MeshElementParameter.h"

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

namespace ParameterLib
{
std::unique_ptr<ParameterBase> createMeshElementParameter(
    std::string const& name, BaseLib::ConfigTree const& config,
    MeshLib::Mesh const& mesh)
{
    //! \ogs_file_param{prj__parameters__parameter__type}
    config.checkConfigParameter("type", "MeshElement");
    auto const field_name =
        //! \ogs_file_param{prj__parameters__parameter__MeshElement__field_name}
        config.getConfigParameter<std::string>("field_name");
    DBUG("Using field_name {:s}", field_name);

    // TODO other data types than only double
    auto const& property =
        mesh.getProperties().getPropertyVector<double>(field_name);

    if (property->getMeshItemType() != MeshLib::MeshItemType::Cell)
    {
        OGS_FATAL("The mesh property `{:s}' is not an element property.",
                  field_name);
    }

    return std::make_unique<MeshElementParameter<double>>(name, mesh,
                                                          *property);
}

}  // namespace ParameterLib
back to top