Revision 99bcb1a63c60aff851469c7ff47d2e33c213b5c2 authored by Dmitry Yu. Naumov on 02 February 2023, 10:06:47 UTC, committed by Dmitry Yu. Naumov on 02 February 2023, 10:06:47 UTC
Small fixes

See merge request ogs/ogs!4466
2 parent s f9d846a + 26b6bb1
Raw File
IntegrationGaussLegendreTet.h
/**
 * \file
 *
 * \copyright
 * Copyright (c) 2012-2023, 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 "BaseLib/Error.h"
#include "MathLib/Integration/GaussLegendreTet.h"
#include "MathLib/WeightedPoint.h"

namespace NumLib
{
/**
 * \brief Gauss-Legendre quadrature rule for tetrahedrals
 */
class IntegrationGaussLegendreTet
{
public:
    /**
     * Construct this object with the given integration order
     *
     * @param order     integration order (default 2)
     */
    explicit IntegrationGaussLegendreTet(unsigned order = 2) : _order(order)
    {
        this->setIntegrationOrder(order);
    }

    /// Change the integration order.
    void setIntegrationOrder(unsigned order)
    {
        _order = order;
        _n_sampl_pt = getNumberOfPoints(order);
    }

    /// return current integration order.
    unsigned getIntegrationOrder() const { return _order; }

    /// return the number of sampling points
    unsigned getNumberOfPoints() const { return _n_sampl_pt; }

    /**
     * get coordinates of a integration point
     *
     * @param igp      The integration point index
     * @return a weighted point
     */
    MathLib::WeightedPoint getWeightedPoint(unsigned const igp) const
    {
        return getWeightedPoint(getIntegrationOrder(), igp);
    }

    /**
     * get coordinates of a integration point
     *
     * @param order    the number of integration points
     * @param igp      the sampling point id
     * @return weight
     */
    static MathLib::WeightedPoint getWeightedPoint(unsigned const order, unsigned const igp)
    {
        switch (order)
        {
            case 1:
                return getWeightedPoint<MathLib::GaussLegendreTet<1>>(igp);
            case 2:
                return getWeightedPoint<MathLib::GaussLegendreTet<2>>(igp);
            case 3:
                return getWeightedPoint<MathLib::GaussLegendreTet<3>>(igp);
            case 4:
                return getWeightedPoint<MathLib::GaussLegendreTet<4>>(igp);
        }
        OGS_FATAL("Integration order {:d} not implemented for tetrahedrals.",
                  order);
    }

    template <typename Method>
    static MathLib::WeightedPoint getWeightedPoint(unsigned const igp)
    {
        return MathLib::WeightedPoint(Method::X[igp], Method::W[igp]);
    }

    /**
     * get the number of integration points
     *
     * @param order    the number of integration points
     * @return the number of points
     */
    static unsigned getNumberOfPoints(unsigned order)
    {
        switch (order)
        {
            case 1:
                return MathLib::GaussLegendreTet<1>::NPoints;
            case 2:
                return MathLib::GaussLegendreTet<2>::NPoints;
            case 3:
                return MathLib::GaussLegendreTet<3>::NPoints;
            case 4:
                return MathLib::GaussLegendreTet<4>::NPoints;
        }
        OGS_FATAL("Integration order {:d} not implemented for tetrahedrals.",
                  order);
    }

private:
    unsigned _order;
    unsigned _n_sampl_pt{0};
};

}  // namespace NumLib
back to top