Revision a3a662c8add3b3aae93ec20a04be560cecf94785 authored by Dmitry Yu. Naumov on 22 November 2021, 20:04:44 UTC, committed by Dmitry Yu. Naumov on 22 November 2021, 20:04:44 UTC
Slightly relax ctests' tolerances.

See merge request ogs/ogs!3890
2 parent s bb0cb88 + 2e7e19c
Raw File
TestMPL.cpp
/**
 * \file
 * \author Norbert Grunwald
 * \date   Oct 22, 2018
 * \brief
 *
 * \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 "TestMPL.h"

#include <sstream>

#include "BaseLib/ConfigTree.h"
#include "MaterialLib/MPL/CreateMedium.h"
#include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"
#include "ParameterLib/CoordinateSystem.h"
#include "ParameterLib/Parameter.h"
#include "Tests/TestTools.h"

namespace Tests
{
std::unique_ptr<MPL::Medium> createTestMaterial(
    std::string const& xml, int const geometry_dimension,
    ParameterLib::CoordinateSystem const* const local_coordinate_system)
{
    auto const ptree = Tests::readXml(xml.c_str());
    BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                             BaseLib::ConfigTree::onwarning);
    auto const& config = conf.getConfigSubtree("medium");
    std::vector<std::unique_ptr<ParameterLib::ParameterBase>> parameters;
    std::map<std::string,
             std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
        curves;

    return MPL::createMedium(geometry_dimension, config, parameters,
                             local_coordinate_system, curves);
}

std::unique_ptr<MaterialPropertyLib::Property> createTestProperty(
    const char xml[],
    std::function<std::unique_ptr<MaterialPropertyLib::Property>(
        BaseLib::ConfigTree const& config)>
        createProperty)
{
    auto const ptree = Tests::readXml(xml);
    BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                             BaseLib::ConfigTree::onwarning);
    auto const& sub_config = conf.getConfigSubtree("property");
    // Parsing the property name:
    auto const property_name =
        sub_config.getConfigParameter<std::string>("name");

    return createProperty(sub_config);
}

std::string makeConstantPropertyElement(std::string const name,
                                        double const value)
{
    std::stringstream ss;

    ss << "<property>\n";
    ss << "    <name>" << name << "</name>\n";
    ss << "    <type>Constant</type>\n";
    ss << "    <value> " << value << " </value>\n";
    ss << "</property>\n";

    return ss.str();
}
}  // namespace Tests
back to top