From 6afdb2bed868f7d4e1ca0c20bc8822135d4c5443 Mon Sep 17 00:00:00 2001 From: Karsten Rink <karsten.rink@ufz.de> Date: Tue, 2 Sep 2014 15:01:56 +0200 Subject: [PATCH] initial implementation of radius-edge-metric --- MeshLib/MeshQuality/RadiusEdgeRatioMetric.cpp | 45 +++++++++++++++++++ MeshLib/MeshQuality/RadiusEdgeRatioMetric.h | 36 +++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 MeshLib/MeshQuality/RadiusEdgeRatioMetric.cpp create mode 100644 MeshLib/MeshQuality/RadiusEdgeRatioMetric.h diff --git a/MeshLib/MeshQuality/RadiusEdgeRatioMetric.cpp b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.cpp new file mode 100644 index 00000000000..c0d1d537dc7 --- /dev/null +++ b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.cpp @@ -0,0 +1,45 @@ +/** + * \file RadiusEdgeRatioMetric.cpp + * \author Thomas Fischer + * \date 2014-09-02 + * \brief Implementation of the RadiusEdgeRadioMetric class. + * + * \copyright + * Copyright (c) 2012-2014, 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 "RadiusEdgeRatioMetric.h" + +#include "Node.h" +#include "MinimalBoundingSphere.h" + +namespace MeshLib +{ + +RadiusEdgeRatioMetric::RadiusEdgeRatioMetric(Mesh const*const mesh) +: ElementQualityMetric(mesh) +{} + +void RadiusEdgeRatioMetric::calculateQuality () +{ + std::vector<MeshLib::Element*> const& elements(_mesh.getElements()); + size_t const nElements (_mesh.getNElements()); + for (size_t k(0); k < nElements; k++) + { + Element const& elem (*elements[k]); + std::size_t const n_nodes (elem.getNNodes()); + MeshLib::Node* const*const nodes = elem.getNodes(); + std::vector<GeoLib::Point*> pnts(n_nodes); + std::copy_n(elem.getNodes(), n_nodes, pnts.begin()); + GeoLib::MinimalBoundingSphere const s(pnts); + double min, max; + elem.computeSqrEdgeLengthRange(min, max); + _element_quality_metric[k] = sqrt(min)/(2*s.getRadius()); + } +} + +} // end namespace MeshLib diff --git a/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h new file mode 100644 index 00000000000..9ca6738a6a4 --- /dev/null +++ b/MeshLib/MeshQuality/RadiusEdgeRatioMetric.h @@ -0,0 +1,36 @@ +/** + * \file RadiusEdgeRatioMetric.h + * \author Karsten Rink + * \date 2014-09-02 + * \brief Definition of the RadiusEdgeRatioMetric class. + * + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef RADIUSEDGERATIOMETRIC_H_ +#define RADIUSEDGERATIOMETRIC_H_ + +#include "ElementQualityMetric.h" + +namespace MeshLib +{ + +/** + * Calculates the quality of mesh elements based on the EquiAngleSkew measure + */ +class RadiusEdgeRatioMetric : public ElementQualityMetric +{ +public: + RadiusEdgeRatioMetric(Mesh const& mesh); + virtual ~RadiusEdgeRatioMetric() {}; + + virtual void calculateQuality (); +}; +} + +#endif /* RADIUSEDGERATIOMETRIC_H_ */ -- GitLab