swh:1:snp:f521c49ab17ef7db6ec70b2430e1ed203f50383f
Raw File
Tip revision: d1f8740e1b116bc0738b9922552bad6c092f56a3 authored by Lars Bilke on 28 June 2021, 07:20:52 UTC
drop
Tip revision: d1f8740
ElementQualityMetric.cpp
/**
 * \file
 * \author Thomas Fischer
 * \date   2010-12-08
 * \brief  Implementation of the ElementQualityMetricBase class.
 *
 * \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 "ElementQualityMetric.h"

#include <cmath>

#include "MeshLib/Node.h"

namespace MeshLib
{
ElementQualityMetric::ElementQualityMetric(Mesh const& mesh)
    : _min(std::numeric_limits<double>::max()), _max(0), _mesh(mesh)
{
    _element_quality_metric.resize(_mesh.getNumberOfElements(), -1.0);
}

BaseLib::Histogram<double> ElementQualityMetric::getHistogram(
    std::size_t n_bins) const
{
    if (n_bins == 0)
    {
        n_bins = static_cast<std::size_t>(
            1 + 3.3 * log(static_cast<float>((_mesh.getNumberOfElements()))));
    }

    return BaseLib::Histogram<double>(getElementQuality(), n_bins, true);
}

std::vector<double> const& ElementQualityMetric::getElementQuality() const
{
    return _element_quality_metric;
}
}  // namespace MeshLib
back to top