Revision 13672f6d45a9c0e149f6b5b41bfffecf007e3706 authored by Dmitry Yu. Naumov on 13 March 2021, 10:23:49 UTC, committed by Dmitry Yu. Naumov on 13 March 2021, 10:23:49 UTC
[CL] Update of solid/liquid ratio of the medium due to evolving parameters linked to reactions

See merge request ogs/ogs!3490
2 parent s 168c3e3 + 5d8f37f
Raw File
TestIntegration.cpp
/**
 * \file
 * \author Norihiro Watanabe
 * \date   2013-08-29
 *
 * \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 <gtest/gtest.h>

#include <cmath>
#include <limits>

#include "MathLib/Integration/GaussLegendre.h"

namespace
{
    double square(double const x)
    {
        return x*x;
    }
}

TEST(MathLib, IntegrationGaussLegendre)
{
    double const eps = 10 * std::numeric_limits<double>::epsilon();

    EXPECT_EQ(0.0, MathLib::WeightedSum<MathLib::GaussLegendre<1>>::add(square));
    EXPECT_NEAR(2./3, MathLib::WeightedSum<MathLib::GaussLegendre<2>>::add(square),
            eps);
    EXPECT_NEAR(2./3, MathLib::WeightedSum<MathLib::GaussLegendre<3>>::add(square),
            eps);
    EXPECT_NEAR(2./3, MathLib::WeightedSum<MathLib::GaussLegendre<4>>::add(square),
            eps);

    auto const& cube = [](double const x) { return x * x * x; };
    EXPECT_NEAR(0.0, MathLib::WeightedSum<MathLib::GaussLegendre<1>>::add(cube),
                eps);
    EXPECT_NEAR(0.0, MathLib::WeightedSum<MathLib::GaussLegendre<2>>::add(cube),
                eps);
    EXPECT_NEAR(0.0, MathLib::WeightedSum<MathLib::GaussLegendre<3>>::add(cube),
                eps);
    EXPECT_NEAR(0.0, MathLib::WeightedSum<MathLib::GaussLegendre<4>>::add(cube),
                eps);
}


back to top