From ee0f112f0e4dbe2afe97ba7052583fd0f98fa02b Mon Sep 17 00:00:00 2001 From: Li-Ta Lo Date: Tue, 8 Feb 2022 07:18:24 -0700 Subject: [PATCH] migrate mesh info filters --- examples/mesh_quality/MeshQuality.cxx | 9 +- vtkm/CellClassification.h | 2 + vtkm/filter/CMakeLists.txt | 10 +- vtkm/filter/CellMeasures.h | 45 ++---- vtkm/filter/GhostCellClassify.h | 45 ++---- vtkm/filter/MIRFilter.hxx | 7 +- vtkm/filter/MeshQuality.h | 116 +++------------ vtkm/filter/MeshQuality.hxx | 116 --------------- vtkm/filter/mesh_info/CMakeLists.txt | 37 +++++ .../CellMeasures.cxx} | 44 +++--- vtkm/filter/mesh_info/CellMeasures.h | 57 ++++++++ .../GhostCellClassify.cxx} | 24 ++-- vtkm/filter/mesh_info/GhostCellClassify.h | 30 ++++ vtkm/filter/mesh_info/MeshQuality.cxx | 132 ++++++++++++++++++ vtkm/filter/mesh_info/MeshQuality.h | 85 +++++++++++ vtkm/filter/mesh_info/testing/CMakeLists.txt | 25 ++++ .../testing/UnitTestCellMeasuresFilter.cxx | 28 ++-- .../testing/UnitTestGhostCellClassify.cxx | 6 +- .../testing/UnitTestMeshQualityFilter.cxx | 71 +++++----- vtkm/filter/mesh_info/worklet/CMakeLists.txt | 18 +++ .../mesh_info}/worklet/CellMeasure.h | 41 ++---- .../mesh_info}/worklet/MeshQuality.h | 101 +++++++------- .../worklet/cellmetrics/CMakeLists.txt | 0 .../cellmetrics/CellAspectFrobeniusMetric.h | 0 .../cellmetrics/CellAspectGammaMetric.h | 0 .../cellmetrics/CellAspectRatioMetric.h | 0 .../worklet/cellmetrics/CellConditionMetric.h | 0 .../cellmetrics/CellDiagonalRatioMetric.h | 0 .../worklet/cellmetrics/CellDimensionMetric.h | 0 .../worklet/cellmetrics/CellEdgeRatioMetric.h | 0 .../worklet/cellmetrics/CellJacobianMetric.h | 0 .../worklet/cellmetrics/CellMaxAngleMetric.h | 0 .../CellMaxAspectFrobeniusMetric.h | 2 +- .../cellmetrics/CellMaxDiagonalMetric.h | 0 .../worklet/cellmetrics/CellMinAngleMetric.h | 0 .../cellmetrics/CellMinDiagonalMetric.h | 0 .../worklet/cellmetrics/CellOddyMetric.h | 0 .../CellRelativeSizeSquaredMetric.h | 0 .../cellmetrics/CellScaledJacobianMetric.h | 0 .../cellmetrics/CellShapeAndSizeMetric.h | 2 +- .../worklet/cellmetrics/CellShapeMetric.h | 4 +- .../worklet/cellmetrics/CellShearMetric.h | 0 .../worklet/cellmetrics/CellSkewMetric.h | 2 +- .../worklet/cellmetrics/CellStretchMetric.h | 0 .../worklet/cellmetrics/CellTaperMetric.h | 0 .../worklet/cellmetrics/CellWarpageMetric.h | 0 .../cellmetrics/TypeOfCellHexahedral.h | 0 .../cellmetrics/TypeOfCellQuadrilateral.h | 0 .../cellmetrics/TypeOfCellTetrahedral.h | 0 .../worklet/cellmetrics/TypeOfCellTriangle.h | 0 vtkm/filter/testing/CMakeLists.txt | 3 - vtkm/worklet/CMakeLists.txt | 3 - vtkm/worklet/testing/CMakeLists.txt | 1 - vtkm/worklet/testing/GenerateTestDataSets.h | 6 +- vtkm/worklet/testing/UnitTestCellMeasure.cxx | 118 ---------------- .../testing/UnitTestParticleAdvection.cxx | 2 +- 56 files changed, 599 insertions(+), 593 deletions(-) delete mode 100644 vtkm/filter/MeshQuality.hxx create mode 100644 vtkm/filter/mesh_info/CMakeLists.txt rename vtkm/filter/{CellMeasures.hxx => mesh_info/CellMeasures.cxx} (52%) create mode 100644 vtkm/filter/mesh_info/CellMeasures.h rename vtkm/filter/{GhostCellClassify.hxx => mesh_info/GhostCellClassify.cxx} (89%) create mode 100644 vtkm/filter/mesh_info/GhostCellClassify.h create mode 100644 vtkm/filter/mesh_info/MeshQuality.cxx create mode 100644 vtkm/filter/mesh_info/MeshQuality.h create mode 100644 vtkm/filter/mesh_info/testing/CMakeLists.txt rename vtkm/filter/{ => mesh_info}/testing/UnitTestCellMeasuresFilter.cxx (81%) rename vtkm/filter/{ => mesh_info}/testing/UnitTestGhostCellClassify.cxx (96%) rename vtkm/filter/{ => mesh_info}/testing/UnitTestMeshQualityFilter.cxx (82%) create mode 100644 vtkm/filter/mesh_info/worklet/CMakeLists.txt rename vtkm/{ => filter/mesh_info}/worklet/CellMeasure.h (81%) rename vtkm/{ => filter/mesh_info}/worklet/MeshQuality.h (68%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CMakeLists.txt (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellAspectFrobeniusMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellAspectGammaMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellAspectRatioMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellConditionMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellDiagonalRatioMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellDimensionMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellEdgeRatioMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellJacobianMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellMaxAngleMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h (99%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellMaxDiagonalMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellMinAngleMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellMinDiagonalMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellOddyMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellScaledJacobianMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellShapeAndSizeMetric.h (99%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellShapeMetric.h (98%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellShearMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellSkewMetric.h (98%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellStretchMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellTaperMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/CellWarpageMetric.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/TypeOfCellHexahedral.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/TypeOfCellQuadrilateral.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/TypeOfCellTetrahedral.h (100%) rename vtkm/{ => filter/mesh_info}/worklet/cellmetrics/TypeOfCellTriangle.h (100%) delete mode 100644 vtkm/worklet/testing/UnitTestCellMeasure.cxx diff --git a/examples/mesh_quality/MeshQuality.cxx b/examples/mesh_quality/MeshQuality.cxx index b60f99e68..2ee3d578a 100644 --- a/examples/mesh_quality/MeshQuality.cxx +++ b/examples/mesh_quality/MeshQuality.cxx @@ -22,7 +22,8 @@ #include #include #include -#include +#include +#include #include #include @@ -200,7 +201,7 @@ inline vtkm::cont::DataSet Make3DExplicitDataSet() int TestMetrics(const char* outFileName, vtkm::cont::DataSet data, - vtkm::filter::MeshQuality& filter) + vtkm::filter::mesh_info::MeshQuality& filter) { vtkm::cont::DataSet outputData; try @@ -257,7 +258,7 @@ int main(int argc, char* argv[]) // A cell metric is now computed for every shape type that exists in the // input dataset. - vtkm::filter::CellMetric shapeMetric = vtkm::filter::CellMetric::VOLUME; + vtkm::filter::mesh_info::CellMetric shapeMetric = vtkm::filter::mesh_info::CellMetric::VOLUME; try { @@ -270,7 +271,7 @@ int main(int argc, char* argv[]) return 1; } - vtkm::filter::MeshQuality filter(shapeMetric); + vtkm::filter::mesh_info::MeshQuality filter(shapeMetric); TestMetrics(outFileName, input, filter); return 0; } diff --git a/vtkm/CellClassification.h b/vtkm/CellClassification.h index 6ab306c6e..2aa68ee86 100644 --- a/vtkm/CellClassification.h +++ b/vtkm/CellClassification.h @@ -10,6 +10,8 @@ #ifndef vtk_m_CellClassification_h #define vtk_m_CellClassification_h +#include + namespace vtkm { diff --git a/vtkm/filter/CMakeLists.txt b/vtkm/filter/CMakeLists.txt index 390910347..81f3b8276 100644 --- a/vtkm/filter/CMakeLists.txt +++ b/vtkm/filter/CMakeLists.txt @@ -10,6 +10,7 @@ set(deprecated_headers CellAverage.h + CellMeasures.h CellSetConnectivity.h CleanGrid.h ClipWithField.h @@ -25,12 +26,14 @@ set(deprecated_headers ExtractStructured.h FieldToColors.h GenerateIds.h + GhostCellClassify.h GhostCellRemove.h Gradient.h Histogram.h ImageConnectivity.h Mask.h MaskPoints.h + MeshQuality.h NDEntropy.h NDHistogram.h ParticleDensityCloudInCell.h @@ -50,7 +53,6 @@ set(deprecated_headers vtkm_declare_headers(${deprecated_headers}) set(common_headers - CellMeasures.h FieldMetadata.h FilterCell.h FilterDataSet.h @@ -69,7 +71,6 @@ set(common_headers vtkm_declare_headers(${common_headers}) set(common_header_template_sources - CellMeasures.hxx FilterDataSet.hxx FilterDataSetWithField.hxx FilterField.hxx @@ -88,12 +89,10 @@ set(extra_headers ContourTreeUniform.h CreateResult.h FieldSelection.h - GhostCellClassify.h ImageDifference.h ImageMedian.h Lagrangian.h LagrangianStructures.h - MeshQuality.h MIRFilter.h ParticleAdvection.h Pathline.h @@ -120,12 +119,10 @@ set(extra_header_template_sources ContourTreeUniformAugmented.hxx ContourTreeUniformDistributed.hxx ContourTreeUniform.hxx - GhostCellClassify.hxx ImageDifference.hxx ImageMedian.hxx Lagrangian.hxx LagrangianStructures.hxx - MeshQuality.hxx MIRFilter.hxx ParticleAdvection.hxx Pathline.hxx @@ -214,6 +211,7 @@ add_subdirectory(internal) add_subdirectory(particleadvection) add_subdirectory(field_conversion) add_subdirectory(field_transform) +add_subdirectory(mesh_info) add_subdirectory(vector_analysis) #-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - diff --git a/vtkm/filter/CellMeasures.h b/vtkm/filter/CellMeasures.h index b6487fc3e..97e80b40f 100644 --- a/vtkm/filter/CellMeasures.h +++ b/vtkm/filter/CellMeasures.h @@ -7,48 +7,33 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ - #ifndef vtk_m_filter_CellMeasures_h #define vtk_m_filter_CellMeasures_h -#include -#include +#include +#include namespace vtkm { namespace filter { -/// \brief Compute the measure of each (3D) cell in a dataset. -/// -/// CellMeasures is a filter that generates a new cell data array (i.e., one value -/// specified per cell) holding the signed measure of the cell -/// or 0 (if measure is not well defined or the cell type is unsupported). -/// -/// By default, the new cell-data array is named "measure". -template -class CellMeasures : public vtkm::filter::FilterField> +VTKM_DEPRECATED(1.8, + "Use vtkm/filter/mesh_info/CellMeasures.h instead of vtkm/filter/CellMeasures.h.") +inline void CellMeasures_deprecated() {} + +inline void CellMeasures_deprecated_warning() { -public: - using SupportedTypes = vtkm::TypeListFieldVec3; + CellMeasures_deprecated(); +} - VTKM_CONT - CellMeasures(); - - /// Set/Get the name of the cell measure field. If not set, "measure" is used. - void SetCellMeasureName(const std::string& name) { this->SetOutputFieldName(name); } - const std::string& GetCellMeasureName() const { return this->GetOutputFieldName(); } - - template - VTKM_CONT vtkm::cont::DataSet DoExecute( - const vtkm::cont::DataSet& input, - const vtkm::cont::ArrayHandle, StorageType>& points, - const vtkm::filter::FieldMetadata& fieldMeta, - const vtkm::filter::PolicyBase& policy); +class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::CellMeasures.") CellMeasures + : public vtkm::filter::mesh_info::CellMeasures +{ + using mesh_info::CellMeasures::CellMeasures; }; + } } // namespace vtkm::filter -#include - -#endif // vtk_m_filter_CellMeasures_h +#endif //vtk_m_filter_CellMeasures_h diff --git a/vtkm/filter/GhostCellClassify.h b/vtkm/filter/GhostCellClassify.h index 875d79405..4dcd5ea48 100644 --- a/vtkm/filter/GhostCellClassify.h +++ b/vtkm/filter/GhostCellClassify.h @@ -10,46 +10,31 @@ #ifndef vtk_m_filter_GhostCellClassify_h #define vtk_m_filter_GhostCellClassify_h -#include +#include +#include namespace vtkm { namespace filter { -struct VTKM_DEPRECATED(1.6, - "GhostCellClassifyPolicy no longer has an effect.") GhostCellClassifyPolicy - : vtkm::filter::PolicyBase +VTKM_DEPRECATED( + 1.8, + "Use vtkm/filter/mesh_info/GhostCellClassify.h instead of vtkm/filter/GhostCellClassify.h.") +inline void GhostCellClassify_deprecated() {} + +inline void GhostCellClassify_deprecated_warning() { - using FieldTypeList = vtkm::List; + GhostCellClassify_deprecated(); +} + +class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::GhostCellClassify.") GhostCellClassify + : public vtkm::filter::mesh_info::GhostCellClassify +{ + using mesh_info::GhostCellClassify::GhostCellClassify; }; -class GhostCellClassify : public vtkm::filter::FilterDataSet -{ -public: - using SupportedTypes = vtkm::List; - - VTKM_CONT - GhostCellClassify(); - - template - VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData, - vtkm::filter::PolicyBase policy); - - template - VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result, - const vtkm::cont::Field& field, - const vtkm::filter::PolicyBase&) - { - result.AddField(field); - return true; - } - -private: -}; } } // namespace vtkm::filter -#include - #endif //vtk_m_filter_GhostCellClassify_h diff --git a/vtkm/filter/MIRFilter.hxx b/vtkm/filter/MIRFilter.hxx index 2f9531a36..0e2040540 100644 --- a/vtkm/filter/MIRFilter.hxx +++ b/vtkm/filter/MIRFilter.hxx @@ -39,7 +39,7 @@ #include #include -#include +#include namespace vtkm { @@ -99,8 +99,9 @@ inline VTKM_CONT vtkm::cont::DataSet MIRFilter::DoExecute( const vtkm::cont::CoordinateSystem inputCoords = input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()); vtkm::cont::ArrayHandle avgSizeTot; - vtkm::worklet::MeshQuality getVol; - getVol.SetMetric(c3 > 0 ? vtkm::filter::CellMetric::VOLUME : vtkm::filter::CellMetric::AREA); + vtkm::worklet::MeshQuality getVol; + getVol.SetMetric(c3 > 0 ? vtkm::filter::mesh_info::CellMetric::VOLUME + : vtkm::filter::mesh_info::CellMetric::AREA); this->Invoke(getVol, vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this), inputCoords.GetData(), diff --git a/vtkm/filter/MeshQuality.h b/vtkm/filter/MeshQuality.h index 16548cad3..9dd9f236f 100644 --- a/vtkm/filter/MeshQuality.h +++ b/vtkm/filter/MeshQuality.h @@ -2,120 +2,38 @@ // Copyright (c) Kitware, Inc. // All rights reserved. // See LICENSE.txt for details. +// // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. -// -// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS). -// Copyright 2014 UT-Battelle, LLC. -// Copyright 2014 Los Alamos National Security. -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National -// Laboratory (LANL), the U.S. Government retains certain rights in -// this software. //============================================================================ - #ifndef vtk_m_filter_MeshQuality_h #define vtk_m_filter_MeshQuality_h -#include -#include -#include +#include +#include namespace vtkm { namespace filter { -//Names of the available cell metrics, for use in -//the output dataset fields -static const std::string MetricNames[] = { "area", - "aspectGamma", - "aspectRatio", - "condition", - "diagonalRatio", - "dimension", - "jacobian", - "maxAngle", - "maxDiagonal", - "minAngle", - "minDiagonal", - "oddy", - "relativeSizeSquared", - "scaledJacobian", - "shape", - "shapeAndSize", - "shear", - "skew", - "stretch", - "taper", - "volume", - "warpage" }; +VTKM_DEPRECATED(1.8, + "Use vtkm/filter/mesh_info/MeshQuality.h instead of vtkm/filter/MeshQuality.h.") +inline void MeshQuality_deprecated() {} -//Different cell metrics available to use -//This must follow the same order as the MetricNames above -enum class CellMetric +inline void MeshQuality_deprecated_warning() { - AREA, - ASPECT_GAMMA, - ASPECT_RATIO, - CONDITION, - DIAGONAL_RATIO, - DIMENSION, - JACOBIAN, - MAX_ANGLE, - MAX_DIAGONAL, - MIN_ANGLE, - MIN_DIAGONAL, - ODDY, - RELATIVE_SIZE_SQUARED, - SCALED_JACOBIAN, - SHAPE, - SHAPE_AND_SIZE, - SHEAR, - SKEW, - STRETCH, - TAPER, - VOLUME, - WARPAGE, - NUMBER_OF_CELL_METRICS, - EMPTY + MeshQuality_deprecated(); +} + +class VTKM_DEPRECATED(1.8, "Use vtkm::filter::mesh_info::MeshQuality.") MeshQuality + : public vtkm::filter::mesh_info::MeshQuality +{ + using mesh_info::MeshQuality::MeshQuality; }; -/** \brief Computes the quality of an unstructured cell-based mesh. The quality is defined in terms of the - * summary statistics (frequency, mean, variance, min, max) of metrics computed over the mesh - * cells. One of several different metrics can be specified for a given cell type, and the mesh - * can consist of one or more different cell types. The resulting mesh quality is stored as one - * or more new fields in the output dataset of this filter, with a separate field for each cell type. - * Each field contains the metric summary statistics for the cell type. - * Summary statists with all 0 values imply that the specified metric does not support the cell type. - */ -class MeshQuality : public vtkm::filter::FilterField -{ -public: - using SupportedTypes = vtkm::TypeListFieldVec3; - using SupportedCellSets = - vtkm::List, vtkm::cont::CellSetSingleType<>>; +} +} // namespace vtkm::filter - VTKM_CONT MeshQuality(CellMetric); - - template - VTKM_CONT vtkm::cont::DataSet DoExecute( - const vtkm::cont::DataSet& input, - const vtkm::cont::ArrayHandle, StorageType>& points, - const vtkm::filter::FieldMetadata& fieldMeta, - const vtkm::filter::PolicyBase& policy); - -private: - CellMetric MyMetric; -}; - -} // namespace filter -} // namespace vtkm - -#include - -#endif // vtk_m_filter_MeshQuality_h +#endif //vtk_m_filter_MeshQuality_h diff --git a/vtkm/filter/MeshQuality.hxx b/vtkm/filter/MeshQuality.hxx deleted file mode 100644 index f1b3b27ac..000000000 --- a/vtkm/filter/MeshQuality.hxx +++ /dev/null @@ -1,116 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -// -// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS). -// Copyright 2014 UT-Battelle, LLC. -// Copyright 2014 Los Alamos National Security. -// -// Under the terms of Contract DE-NA0003525 with NTESS, -// the U.S. Government retains certain rights in this software. -// -// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National -// Laboratory (LANL), the U.S. Government retains certain rights in -// this software. -//========================================================================= -#ifndef vtk_m_filter_MeshQuality_hxx -#define vtk_m_filter_MeshQuality_hxx - -#include -#include -#include -#include -#include - -// #define DEBUG_PRINT - -namespace vtkm -{ -namespace filter -{ - - -inline VTKM_CONT MeshQuality::MeshQuality(CellMetric metric) - : vtkm::filter::FilterField() -{ - this->SetUseCoordinateSystemAsField(true); - this->MyMetric = metric; - if (this->MyMetric < CellMetric::AREA || this->MyMetric >= CellMetric::NUMBER_OF_CELL_METRICS) - { - VTKM_ASSERT(true); - } - this->SetOutputFieldName(MetricNames[(int)this->MyMetric]); -} - -template -inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute( - const vtkm::cont::DataSet& input, - const vtkm::cont::ArrayHandle, StorageType>& points, - const vtkm::filter::FieldMetadata& fieldMeta, - const vtkm::filter::PolicyBase& policy) -{ - if (!fieldMeta.IsPointField()) - { - throw vtkm::cont::ErrorBadValue("Active field for MeshQuality must be point coordinates. " - "But the active field is not a point field."); - } - - vtkm::worklet::MeshQuality qualityWorklet; - - if (this->MyMetric == vtkm::filter::CellMetric::RELATIVE_SIZE_SQUARED || - this->MyMetric == vtkm::filter::CellMetric::SHAPE_AND_SIZE) - { - vtkm::FloatDefault averageArea = 1.; - vtkm::worklet::MeshQuality subWorklet; - vtkm::cont::ArrayHandle array; - subWorklet.SetMetric(vtkm::filter::CellMetric::AREA); - this->Invoke(subWorklet, - vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this), - points, - array); - T zero = 0.0; - vtkm::FloatDefault totalArea = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, zero); - - vtkm::FloatDefault averageVolume = 1.; - subWorklet.SetMetric(vtkm::filter::CellMetric::VOLUME); - this->Invoke(subWorklet, - vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this), - points, - array); - vtkm::FloatDefault totalVolume = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, zero); - - vtkm::Id numVals = array.GetNumberOfValues(); - if (numVals > 0) - { - averageArea = totalArea / static_cast(numVals); - averageVolume = totalVolume / static_cast(numVals); - } - qualityWorklet.SetAverageArea(averageArea); - qualityWorklet.SetAverageVolume(averageVolume); - } - - //Invoke the MeshQuality worklet - vtkm::cont::ArrayHandle outArray; - qualityWorklet.SetMetric(this->MyMetric); - this->Invoke(qualityWorklet, - vtkm::filter::ApplyPolicyCellSet(input.GetCellSet(), policy, *this), - points, - outArray); - - vtkm::cont::DataSet result; - result.CopyStructure(input); //clone of the input dataset - - //Append the metric values of all cells into the output - //dataset as a new field - result.AddField(vtkm::cont::make_FieldCell(this->GetOutputFieldName(), outArray)); - - return result; -} - -} // namespace filter -} // namespace vtkm -#endif diff --git a/vtkm/filter/mesh_info/CMakeLists.txt b/vtkm/filter/mesh_info/CMakeLists.txt new file mode 100644 index 000000000..c17d06294 --- /dev/null +++ b/vtkm/filter/mesh_info/CMakeLists.txt @@ -0,0 +1,37 @@ +##============================================================================ +## Copyright (c) Kitware, Inc. +## All rights reserved. +## See LICENSE.txt for details. +## +## This software is distributed WITHOUT ANY WARRANTY; without even +## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +## PURPOSE. See the above copyright notice for more information. +##============================================================================ +set(mesh_info_headers + CellMeasures.h + GhostCellClassify.h + MeshQuality.h + ) + +set(mesh_info_sources + CellMeasures.cxx + GhostCellClassify.cxx + MeshQuality.cxx + ) + +vtkm_library( + NAME vtkm_filter_mesh_info + HEADERS ${mesh_info_headers} + DEVICE_SOURCES ${mesh_info_sources} + USE_VTKM_JOB_POOL +) + +target_link_libraries(vtkm_filter_mesh_info PUBLIC vtkm_worklet vtkm_filter_core) +target_link_libraries(vtkm_filter PUBLIC INTERFACE vtkm_filter_mesh_info) + +add_subdirectory(worklet) + +#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - +if (VTKm_ENABLE_TESTING) + add_subdirectory(testing) +endif () diff --git a/vtkm/filter/CellMeasures.hxx b/vtkm/filter/mesh_info/CellMeasures.cxx similarity index 52% rename from vtkm/filter/CellMeasures.hxx rename to vtkm/filter/mesh_info/CellMeasures.cxx index bb75daf35..f29fd498c 100644 --- a/vtkm/filter/CellMeasures.hxx +++ b/vtkm/filter/mesh_info/CellMeasures.cxx @@ -8,46 +8,41 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#ifndef vtk_m_filter_CellMeasures_hxx -#define vtk_m_filter_CellMeasures_hxx - #include +#include +#include namespace vtkm { namespace filter { - +namespace mesh_info +{ //----------------------------------------------------------------------------- -template -inline VTKM_CONT CellMeasures::CellMeasures() - : vtkm::filter::FilterField>() +VTKM_CONT CellMeasures::CellMeasures(IntegrationType m) + : measure(m) { this->SetUseCoordinateSystemAsField(true); this->SetCellMeasureName("measure"); } //----------------------------------------------------------------------------- -template -template -inline VTKM_CONT vtkm::cont::DataSet CellMeasures::DoExecute( - const vtkm::cont::DataSet& input, - const vtkm::cont::ArrayHandle, StorageType>& points, - const vtkm::filter::FieldMetadata& fieldMeta, - const vtkm::filter::PolicyBase& policy) + +VTKM_CONT vtkm::cont::DataSet CellMeasures::DoExecute(const vtkm::cont::DataSet& input) { - if (fieldMeta.IsPointField() == false) + const auto& field = this->GetFieldFromDataSet(input); + if (!field.IsFieldPoint()) { throw vtkm::cont::ErrorFilterExecution("CellMeasures expects point field input."); } const auto& cellset = input.GetCellSet(); - vtkm::cont::ArrayHandle outArray; + vtkm::cont::ArrayHandle outArray; - this->Invoke(vtkm::worklet::CellMeasure{}, - vtkm::filter::ApplyPolicyCellSet(cellset, policy, *this), - points, - outArray); + auto resolveType = [&](const auto& concrete) { + this->Invoke(vtkm::worklet::CellMeasure{ this->measure }, cellset, concrete, outArray); + }; + this->CastAndCallVecField<3>(field, resolveType); std::string outputName = this->GetCellMeasureName(); if (outputName.empty()) @@ -55,9 +50,8 @@ inline VTKM_CONT vtkm::cont::DataSet CellMeasures::DoExecute( // Default name is name of input. outputName = "measure"; } - return CreateResultFieldCell(input, outArray, outputName); + return this->CreateResultFieldCell(input, outputName, outArray); } -} -} // namespace vtkm::filter - -#endif +} // namespace mesh_info +} // namespace filter +} // namespace vtkm diff --git a/vtkm/filter/mesh_info/CellMeasures.h b/vtkm/filter/mesh_info/CellMeasures.h new file mode 100644 index 000000000..ac0bf6e50 --- /dev/null +++ b/vtkm/filter/mesh_info/CellMeasures.h @@ -0,0 +1,57 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//============================================================================ + +#ifndef vtk_m_filter_mesh_info_CellMeasure_h +#define vtk_m_filter_mesh_info_CellMeasure_h + +#include +#include + +namespace vtkm +{ +namespace filter +{ +namespace mesh_info +{ +enum IntegrationType +{ + ArcLength = 0x01, + Area = 0x02, + Volume = 0x04, + AllMeasures = ArcLength | Area | Volume +}; + +/// \brief Compute the measure of each (3D) cell in a dataset. +/// +/// CellMeasures is a filter that generates a new cell data array (i.e., one value +/// specified per cell) holding the signed measure of the cell +/// or 0 (if measure is not well defined or the cell type is unsupported). +/// +/// By default, the new cell-data array is named "measure". +class VTKM_FILTER_MESH_INFO_EXPORT CellMeasures : public vtkm::filter::NewFilterField +{ +public: + VTKM_CONT + CellMeasures(IntegrationType); + + /// Set/Get the name of the cell measure field. If not set, "measure" is used. + void SetCellMeasureName(const std::string& name) { this->SetOutputFieldName(name); } + const std::string& GetCellMeasureName() const { return this->GetOutputFieldName(); } + +private: + VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; + + IntegrationType measure; +}; +} // namespace mesh_info +} // namespace filter +} // namespace vtkm + +#endif // vtk_m_filter_mesh_info_CellMeasure_h diff --git a/vtkm/filter/GhostCellClassify.hxx b/vtkm/filter/mesh_info/GhostCellClassify.cxx similarity index 89% rename from vtkm/filter/GhostCellClassify.hxx rename to vtkm/filter/mesh_info/GhostCellClassify.cxx index 6e56370bf..38072d803 100644 --- a/vtkm/filter/GhostCellClassify.hxx +++ b/vtkm/filter/mesh_info/GhostCellClassify.cxx @@ -7,17 +7,11 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ -#ifndef vtk_m_filter_GhostCellClassify_hxx -#define vtk_m_filter_GhostCellClassify_hxx #include -#include -#include -#include -#include -#include #include - +#include +#include #include namespace vtkm @@ -92,11 +86,9 @@ private: }; } // namespace detail -inline VTKM_CONT GhostCellClassify::GhostCellClassify() {} - -template -inline VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::cont::DataSet& input, - vtkm::filter::PolicyBase) +namespace mesh_info +{ +VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::cont::DataSet& input) { const vtkm::cont::UnknownCellSet& cellset = input.GetCellSet(); vtkm::cont::ArrayHandle ghosts; @@ -149,8 +141,10 @@ inline VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::co throw vtkm::cont::ErrorFilterExecution("Unsupported cellset type for GhostCellClassify."); } - return CreateResultFieldCell(input, ghosts, "vtkmGhostCells"); + auto output = this->CreateResult(input); + output.AddCellField("vtkmGhostCells", ghosts); + return output; } } } -#endif +} \ No newline at end of file diff --git a/vtkm/filter/mesh_info/GhostCellClassify.h b/vtkm/filter/mesh_info/GhostCellClassify.h new file mode 100644 index 000000000..cbba99230 --- /dev/null +++ b/vtkm/filter/mesh_info/GhostCellClassify.h @@ -0,0 +1,30 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +//============================================================================ +#ifndef vtk_m_filter_mesh_info_GhostCellClassify_h +#define vtk_m_filter_mesh_info_GhostCellClassify_h + +#include +#include + +namespace vtkm +{ +namespace filter +{ +namespace mesh_info +{ +class VTKM_FILTER_MESH_INFO_EXPORT GhostCellClassify : public vtkm::filter::NewFilter +{ + VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) override; +}; +} // namespace mesh_info +} // namespace filter +} // namespace vtkm + +#endif //vtk_m_filter_mesh_info_GhostCellClassify_h diff --git a/vtkm/filter/mesh_info/MeshQuality.cxx b/vtkm/filter/mesh_info/MeshQuality.cxx new file mode 100644 index 000000000..7d16db738 --- /dev/null +++ b/vtkm/filter/mesh_info/MeshQuality.cxx @@ -0,0 +1,132 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +// +// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS). +// Copyright 2014 UT-Battelle, LLC. +// Copyright 2014 Los Alamos National Security. +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//========================================================================= +#include +#include +#include +#include +#include +#include + +namespace vtkm +{ +namespace filter +{ +namespace mesh_info +{ +namespace +{ +//Names of the available cell metrics, for use in +//the output dataset fields +const std::map MetricNames = { + { CellMetric::AREA, "area" }, + { CellMetric::ASPECT_GAMMA, "aspectGamma" }, + { CellMetric::ASPECT_RATIO, "aspectRatio" }, + { CellMetric::CONDITION, "condition" }, + { CellMetric::DIAGONAL_RATIO, "diagonalRatio" }, + { CellMetric::DIMENSION, "dimension" }, + { CellMetric::JACOBIAN, "jacobian" }, + { CellMetric::MAX_ANGLE, "maxAngle" }, + { CellMetric::MAX_DIAGONAL, "maxDiagonal" }, + { CellMetric::MIN_ANGLE, "minAngle" }, + { CellMetric::MIN_DIAGONAL, "minDiagonal" }, + { CellMetric::ODDY, "oddy" }, + { CellMetric::RELATIVE_SIZE_SQUARED, "relativeSizeSquared" }, + { CellMetric::SCALED_JACOBIAN, "scaledJacobian" }, + { CellMetric::SHAPE, "shape" }, + { CellMetric::SHAPE_AND_SIZE, "shapeAndSize" }, + { CellMetric::SHEAR, "shear" }, + { CellMetric::SKEW, "skew" }, + { CellMetric::STRETCH, "stretch" }, + { CellMetric::TAPER, "taper" }, + { CellMetric::VOLUME, "volume" }, + { CellMetric::WARPAGE, "warpage" } +}; +} // anonymous namespace + +VTKM_CONT MeshQuality::MeshQuality(CellMetric metric) + : MyMetric(metric) +{ + this->SetUseCoordinateSystemAsField(true); + this->SetOutputFieldName(MetricNames.at(this->MyMetric)); +} + +VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(const vtkm::cont::DataSet& input) +{ + const auto& field = this->GetFieldFromDataSet(input); + if (!field.IsFieldPoint()) + { + throw vtkm::cont::ErrorBadValue("Active field for MeshQuality must be point coordinates. " + "But the active field is not a point field."); + } + + vtkm::cont::UnknownCellSet inputCellSet = input.GetCellSet(); + vtkm::worklet::MeshQuality qualityWorklet; + + if (this->MyMetric == CellMetric::RELATIVE_SIZE_SQUARED || + this->MyMetric == CellMetric::SHAPE_AND_SIZE) + { + vtkm::worklet::MeshQuality subWorklet; + vtkm::FloatDefault totalArea; + vtkm::FloatDefault totalVolume; + + auto resolveType = [&](const auto& concrete) { + // use std::decay to remove const ref from the decltype of concrete. + using T = typename std::decay_t::ValueType::ComponentType; + vtkm::cont::ArrayHandle array; + + subWorklet.SetMetric(CellMetric::AREA); + this->Invoke(subWorklet, inputCellSet, concrete, array); + totalArea = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, T{}); + + subWorklet.SetMetric(CellMetric::VOLUME); + this->Invoke(subWorklet, inputCellSet, concrete, array); + totalVolume = (vtkm::FloatDefault)vtkm::cont::Algorithm::Reduce(array, T{}); + }; + this->CastAndCallVecField<3>(field, resolveType); + + vtkm::FloatDefault averageArea = 1.; + vtkm::FloatDefault averageVolume = 1.; + vtkm::Id numCells = inputCellSet.GetNumberOfCells(); + if (numCells > 0) + { + averageArea = totalArea / static_cast(numCells); + averageVolume = totalVolume / static_cast(numCells); + } + qualityWorklet.SetAverageArea(averageArea); + qualityWorklet.SetAverageVolume(averageVolume); + } + + vtkm::cont::UnknownArrayHandle outArray; + + //Invoke the MeshQuality worklet + auto resolveType = [&](const auto& concrete) { + using T = typename std::decay_t::ValueType::ComponentType; + vtkm::cont::ArrayHandle result; + qualityWorklet.SetMetric(this->MyMetric); + this->Invoke(qualityWorklet, inputCellSet, concrete, result); + outArray = result; + }; + this->CastAndCallVecField<3>(field, resolveType); + + return this->CreateResultFieldCell(input, this->GetOutputFieldName(), outArray); +} +} // namespace mesh_info +} // namespace filter +} // namespace vtkm diff --git a/vtkm/filter/mesh_info/MeshQuality.h b/vtkm/filter/mesh_info/MeshQuality.h new file mode 100644 index 000000000..57abb5fb3 --- /dev/null +++ b/vtkm/filter/mesh_info/MeshQuality.h @@ -0,0 +1,85 @@ +//============================================================================ +// Copyright (c) Kitware, Inc. +// All rights reserved. +// See LICENSE.txt for details. +// This software is distributed WITHOUT ANY WARRANTY; without even +// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +// PURPOSE. See the above copyright notice for more information. +// +// Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS). +// Copyright 2014 UT-Battelle, LLC. +// Copyright 2014 Los Alamos National Security. +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. +// +// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National +// Laboratory (LANL), the U.S. Government retains certain rights in +// this software. +//============================================================================ + +#ifndef vtk_m_filter_mesh_info_MeshQuality_h +#define vtk_m_filter_mesh_info_MeshQuality_h + +#include +#include + +namespace vtkm +{ +namespace filter +{ +namespace mesh_info +{ +//Different cell metrics available to use +//This must follow the same order as the MetricNames above +enum class CellMetric +{ + AREA, + ASPECT_GAMMA, + ASPECT_RATIO, + CONDITION, + DIAGONAL_RATIO, + DIMENSION, + JACOBIAN, + MAX_ANGLE, + MAX_DIAGONAL, + MIN_ANGLE, + MIN_DIAGONAL, + ODDY, + RELATIVE_SIZE_SQUARED, + SCALED_JACOBIAN, + SHAPE, + SHAPE_AND_SIZE, + SHEAR, + SKEW, + STRETCH, + TAPER, + VOLUME, + WARPAGE, + NUMBER_OF_CELL_METRICS, + EMPTY +}; + +/** \brief Computes the quality of an unstructured cell-based mesh. The quality is defined in terms of the + * summary statistics (frequency, mean, variance, min, max) of metrics computed over the mesh + * cells. One of several different metrics can be specified for a given cell type, and the mesh + * can consist of one or more different cell types. The resulting mesh quality is stored as one + * or more new fields in the output dataset of this filter, with a separate field for each cell type. + * Each field contains the metric summary statistics for the cell type. + * Summary statists with all 0 values imply that the specified metric does not support the cell type. + */ +class VTKM_FILTER_MESH_INFO_EXPORT MeshQuality : public vtkm::filter::NewFilterField +{ +public: + VTKM_CONT MeshQuality(CellMetric); + +private: + VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; + + CellMetric MyMetric; +}; +} // namespace mesh_info +} // namespace filter +} // namespace vtkm + +#endif // vtk_m_filter_mesh_info_MeshQuality_h diff --git a/vtkm/filter/mesh_info/testing/CMakeLists.txt b/vtkm/filter/mesh_info/testing/CMakeLists.txt new file mode 100644 index 000000000..8c6e7e6db --- /dev/null +++ b/vtkm/filter/mesh_info/testing/CMakeLists.txt @@ -0,0 +1,25 @@ +##============================================================================ +## Copyright (c) Kitware, Inc. +## All rights reserved. +## See LICENSE.txt for details. +## +## This software is distributed WITHOUT ANY WARRANTY; without even +## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +## PURPOSE. See the above copyright notice for more information. +##============================================================================ + +set(unit_tests + UnitTestCellMeasuresFilter.cxx + UnitTestGhostCellClassify.cxx + UnitTestMeshQualityFilter.cxx + ) + +set(libraries + vtkm_filter_mesh_info + ) + +vtkm_unit_tests( + SOURCES ${unit_tests} + LIBRARIES ${libraries} + USE_VTKM_JOB_POOL +) diff --git a/vtkm/filter/testing/UnitTestCellMeasuresFilter.cxx b/vtkm/filter/mesh_info/testing/UnitTestCellMeasuresFilter.cxx similarity index 81% rename from vtkm/filter/testing/UnitTestCellMeasuresFilter.cxx rename to vtkm/filter/mesh_info/testing/UnitTestCellMeasuresFilter.cxx index 7cbc90de6..24af1b40c 100644 --- a/vtkm/filter/testing/UnitTestCellMeasuresFilter.cxx +++ b/vtkm/filter/mesh_info/testing/UnitTestCellMeasuresFilter.cxx @@ -8,12 +8,12 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include - #include #include #include +#include +//#include namespace { @@ -37,15 +37,14 @@ struct CheckCellMeasuresFunctor } }; -template void TestCellMeasuresFilter(vtkm::cont::DataSet& dataset, const char* msg, const std::vector& expected, - const IntegrationType&) + const vtkm::filter::mesh_info::IntegrationType& type) { std::cout << "Testing CellMeasures Filter on " << msg << "\n"; - vtkm::filter::CellMeasures vols; + vtkm::filter::mesh_info::CellMeasures vols{ type }; vtkm::cont::DataSet outputData = vols.Execute(dataset); VTKM_TEST_ASSERT(vols.GetCellMeasureName() == "measure"); @@ -67,35 +66,36 @@ void TestCellMeasuresFilter(vtkm::cont::DataSet& dataset, void TestCellMeasures() { - using vtkm::AllMeasures; - using vtkm::Volume; + using vtkm::filter::mesh_info::IntegrationType; vtkm::cont::testing::MakeTestDataSet factory; vtkm::cont::DataSet data; data = factory.Make3DExplicitDataSet2(); - TestCellMeasuresFilter(data, "explicit dataset 2", { -1.f }, AllMeasures()); + TestCellMeasuresFilter(data, "explicit dataset 2", { -1.f }, IntegrationType::AllMeasures); data = factory.Make3DExplicitDataSet3(); - TestCellMeasuresFilter(data, "explicit dataset 3", { -1.f / 6.f }, AllMeasures()); + TestCellMeasuresFilter(data, "explicit dataset 3", { -1.f / 6.f }, IntegrationType::AllMeasures); data = factory.Make3DExplicitDataSet4(); - TestCellMeasuresFilter(data, "explicit dataset 4", { -1.f, -1.f }, AllMeasures()); + TestCellMeasuresFilter(data, "explicit dataset 4", { -1.f, -1.f }, IntegrationType::AllMeasures); data = factory.Make3DExplicitDataSet5(); - TestCellMeasuresFilter( - data, "explicit dataset 5", { 1.f, 1.f / 3.f, 1.f / 6.f, -1.f / 2.f }, AllMeasures()); + TestCellMeasuresFilter(data, + "explicit dataset 5", + { 1.f, 1.f / 3.f, 1.f / 6.f, -1.f / 2.f }, + IntegrationType::AllMeasures); data = factory.Make3DExplicitDataSet6(); TestCellMeasuresFilter(data, "explicit dataset 6 (only volume)", { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.083426f, 0.25028f }, - Volume()); + IntegrationType::Volume); TestCellMeasuresFilter( data, "explicit dataset 6 (all)", { 0.999924f, 0.999924f, 0.f, 0.f, 3.85516f, 1.00119f, 0.083426f, 0.25028f }, - AllMeasures()); + IntegrationType::AllMeasures); } } // anonymous namespace diff --git a/vtkm/filter/testing/UnitTestGhostCellClassify.cxx b/vtkm/filter/mesh_info/testing/UnitTestGhostCellClassify.cxx similarity index 96% rename from vtkm/filter/testing/UnitTestGhostCellClassify.cxx rename to vtkm/filter/mesh_info/testing/UnitTestGhostCellClassify.cxx index 491574591..c6b2f16d8 100644 --- a/vtkm/filter/testing/UnitTestGhostCellClassify.cxx +++ b/vtkm/filter/mesh_info/testing/UnitTestGhostCellClassify.cxx @@ -9,12 +9,12 @@ //============================================================================ #include -#include #include #include #include -#include +#include +#include namespace { @@ -100,7 +100,7 @@ void TestStructured() else if (dsType == "rectilinear") ds = MakeRectilinear(nx, ny, nz); - vtkm::filter::GhostCellClassify addGhost; + vtkm::filter::mesh_info::GhostCellClassify addGhost; auto output = addGhost.Execute(ds); diff --git a/vtkm/filter/testing/UnitTestMeshQualityFilter.cxx b/vtkm/filter/mesh_info/testing/UnitTestMeshQualityFilter.cxx similarity index 82% rename from vtkm/filter/testing/UnitTestMeshQualityFilter.cxx rename to vtkm/filter/mesh_info/testing/UnitTestMeshQualityFilter.cxx index 638ebe2a0..c8a0d985d 100644 --- a/vtkm/filter/testing/UnitTestMeshQualityFilter.cxx +++ b/vtkm/filter/mesh_info/testing/UnitTestMeshQualityFilter.cxx @@ -26,8 +26,9 @@ #include #include #include +#include #include -#include +#include #include namespace @@ -142,7 +143,7 @@ inline vtkm::cont::DataSet MakeSingleTypeDataSet() bool TestMeshQualityFilter(const vtkm::cont::DataSet& input, const std::vector& expectedVals, const std::string& outputname, - vtkm::filter::MeshQuality& filter) + vtkm::filter::mesh_info::MeshQuality& filter) { vtkm::cont::DataSet output; try @@ -193,162 +194,162 @@ int TestMeshQuality() bool testFailed = false; std::vector expectedValues; - std::vector metrics; + std::vector metrics; std::vector metricName; std::vector inputs; expectedValues.push_back(FloatVec{ 0, 0, 1, 1.333333333f, 4, 4 }); - metrics.push_back(vtkm::filter::CellMetric::VOLUME); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::VOLUME); metricName.push_back("volume"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 3, 4, 0, 0, 0, 0 }); - metrics.push_back(vtkm::filter::CellMetric::AREA); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::AREA); metricName.push_back("area"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 3, 1 }); - metrics.push_back(vtkm::filter::CellMetric::AREA); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::AREA); metricName.push_back("area"); inputs.push_back(singleTypeInput); expectedValues.push_back(FloatVec{ 1.164010f, 1.118034f, 1.648938f, 0, 0, 1.1547f }); - metrics.push_back(vtkm::filter::CellMetric::ASPECT_RATIO); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::ASPECT_RATIO); metricName.push_back("aspectRatio"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 1.164010f, 2.47582f }); - metrics.push_back(vtkm::filter::CellMetric::ASPECT_RATIO); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::ASPECT_RATIO); metricName.push_back("aspectRatio"); inputs.push_back(singleTypeInput); expectedValues.push_back(FloatVec{ 0, 0, 1.52012f, 0, 0, 0 }); - metrics.push_back(vtkm::filter::CellMetric::ASPECT_GAMMA); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::ASPECT_GAMMA); metricName.push_back("aspectGamma"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 1.058475f, 2.25f, 1.354007f, 0, 0, 1.563472f }); - metrics.push_back(vtkm::filter::CellMetric::CONDITION); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::CONDITION); metricName.push_back("condition"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 1.058475f, 2.02073f }); - metrics.push_back(vtkm::filter::CellMetric::CONDITION); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::CONDITION); metricName.push_back("condition"); inputs.push_back(singleTypeInput); expectedValues.push_back(FloatVec{ 45, 45, -1, -1, -1, -1 }); - metrics.push_back(vtkm::filter::CellMetric::MIN_ANGLE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::MIN_ANGLE); metricName.push_back("minAngle"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 45, 18.4348f }); - metrics.push_back(vtkm::filter::CellMetric::MIN_ANGLE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::MIN_ANGLE); metricName.push_back("minAngle"); inputs.push_back(singleTypeInput); expectedValues.push_back(FloatVec{ 71.56505f, 135, -1, -1, -1, -1 }); - metrics.push_back(vtkm::filter::CellMetric::MAX_ANGLE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::MAX_ANGLE); metricName.push_back("maxAngle"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 71.56505f, 116.565f }); - metrics.push_back(vtkm::filter::CellMetric::MAX_ANGLE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::MAX_ANGLE); metricName.push_back("maxAngle"); inputs.push_back(singleTypeInput); expectedValues.push_back(FloatVec{ -1, -1, -1, -1, -1, 1.73205f }); - metrics.push_back(vtkm::filter::CellMetric::MIN_DIAGONAL); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::MIN_DIAGONAL); metricName.push_back("minDiagonal"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ -1, -1, -1, -1, -1, 4.3589f }); - metrics.push_back(vtkm::filter::CellMetric::MAX_DIAGONAL); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::MAX_DIAGONAL); metricName.push_back("maxDiagonal"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 0, 2, 6, 0, 0, 4 }); - metrics.push_back(vtkm::filter::CellMetric::JACOBIAN); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::JACOBIAN); metricName.push_back("jacobian"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 0.816497f, 0.707107f, 0.408248f, -2, -2, 0.57735f }); - metrics.push_back(vtkm::filter::CellMetric::SCALED_JACOBIAN); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::SCALED_JACOBIAN); metricName.push_back("scaledJacobian"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 0.816497f, 0.365148f }); - metrics.push_back(vtkm::filter::CellMetric::SCALED_JACOBIAN); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::SCALED_JACOBIAN); metricName.push_back("scaledJacobian"); inputs.push_back(singleTypeInput); expectedValues.push_back(FloatVec{ -1, 8.125f, -1, -1, -1, 2.62484f }); - metrics.push_back(vtkm::filter::CellMetric::ODDY); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::ODDY); metricName.push_back("oddy"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ -1, 0.620174f, -1, -1, -1, 0.397360f }); - metrics.push_back(vtkm::filter::CellMetric::DIAGONAL_RATIO); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::DIAGONAL_RATIO); metricName.push_back("diagonalRatio"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 0.944755f, 0.444444f, 0.756394f, -1, -1, 0.68723f }); - metrics.push_back(vtkm::filter::CellMetric::SHAPE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::SHAPE); metricName.push_back("shape"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 0.944755f, 0.494872f }); - metrics.push_back(vtkm::filter::CellMetric::SHAPE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::SHAPE); metricName.push_back("shape"); inputs.push_back(singleTypeInput); expectedValues.push_back(FloatVec{ -1, 0.707107f, -1, -1, -1, 0.57735f }); - metrics.push_back(vtkm::filter::CellMetric::SHEAR); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::SHEAR); metricName.push_back("shear"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ -1, 0.447214f, -1, -1, -1, 0.57735f }); - metrics.push_back(vtkm::filter::CellMetric::SKEW); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::SKEW); metricName.push_back("skew"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ -1, (float)0.392232, -1, -1, -1, (float)0.688247 }); - metrics.push_back(vtkm::filter::CellMetric::STRETCH); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::STRETCH); metricName.push_back("stretch"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ -1, 0.5, -1, -1, -1, 0 }); - metrics.push_back(vtkm::filter::CellMetric::TAPER); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::TAPER); metricName.push_back("taper"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ -1, 1, -1, -1, -1, -1 }); - metrics.push_back(vtkm::filter::CellMetric::WARPAGE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::WARPAGE); metricName.push_back("warpage"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ -1, -1, -1, -1, -1, 0.707107f }); - metrics.push_back(vtkm::filter::CellMetric::DIMENSION); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::DIMENSION); metricName.push_back("dimension"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 0.151235f, 0.085069f, 0.337149f, -1, -1, 0.185378f }); - metrics.push_back(vtkm::filter::CellMetric::RELATIVE_SIZE_SQUARED); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::RELATIVE_SIZE_SQUARED); metricName.push_back("relativeSizeSquared"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 0.444444f, 0.25f }); - metrics.push_back(vtkm::filter::CellMetric::RELATIVE_SIZE_SQUARED); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::RELATIVE_SIZE_SQUARED); metricName.push_back("relativeSizeSquared"); inputs.push_back(singleTypeInput); expectedValues.push_back(FloatVec{ 0.142880f, 0.037809f, 0.255017f, -1, -1, 0.127397f }); - metrics.push_back(vtkm::filter::CellMetric::SHAPE_AND_SIZE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::SHAPE_AND_SIZE); metricName.push_back("shapeAndSize"); inputs.push_back(explicitInput); expectedValues.push_back(FloatVec{ 0.419891f, 0.123718f }); - metrics.push_back(vtkm::filter::CellMetric::SHAPE_AND_SIZE); + metrics.push_back(vtkm::filter::mesh_info::CellMetric::SHAPE_AND_SIZE); metricName.push_back("shapeAndSize"); inputs.push_back(singleTypeInput); @@ -356,7 +357,7 @@ int TestMeshQuality() for (unsigned long i = 0; i < numTests; i++) { printf("Testing metric %s\n", metricName[i].c_str()); - vtkm::filter::MeshQuality filter(metrics[i]); + vtkm::filter::mesh_info::MeshQuality filter(metrics[i]); testFailed = TestMeshQualityFilter(inputs[i], expectedValues[i], metricName[i], filter); if (testFailed) { diff --git a/vtkm/filter/mesh_info/worklet/CMakeLists.txt b/vtkm/filter/mesh_info/worklet/CMakeLists.txt new file mode 100644 index 000000000..8178fefe5 --- /dev/null +++ b/vtkm/filter/mesh_info/worklet/CMakeLists.txt @@ -0,0 +1,18 @@ +##============================================================================ +## Copyright (c) Kitware, Inc. +## All rights reserved. +## See LICENSE.txt for details. +## +## This software is distributed WITHOUT ANY WARRANTY; without even +## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +## PURPOSE. See the above copyright notice for more information. +##============================================================================ + +set(headers + CellMeasure.h + MeshQuality.h + ) + +vtkm_declare_headers(${headers}) + +add_subdirectory(cellmetrics) \ No newline at end of file diff --git a/vtkm/worklet/CellMeasure.h b/vtkm/filter/mesh_info/worklet/CellMeasure.h similarity index 81% rename from vtkm/worklet/CellMeasure.h rename to vtkm/filter/mesh_info/worklet/CellMeasure.h index 9018484d5..852adcc59 100644 --- a/vtkm/worklet/CellMeasure.h +++ b/vtkm/filter/mesh_info/worklet/CellMeasure.h @@ -11,33 +11,13 @@ #ifndef vtk_m_worklet_CellMeasure_h #define vtk_m_worklet_CellMeasure_h -#include - #include +#include +#include namespace vtkm { -// Tags used to choose which types of integration are performed on cells: -struct IntegrateOver -{ -}; -struct IntegrateOverCurve : IntegrateOver -{ -}; -struct IntegrateOverSurface : IntegrateOver -{ -}; -struct IntegrateOverSolid : IntegrateOver -{ -}; - -// Lists of acceptable types of integration -using ArcLength = vtkm::List; -using Area = vtkm::List; -using Volume = vtkm::List; -using AllMeasures = vtkm::List; - namespace worklet { @@ -51,7 +31,6 @@ namespace worklet * * Note that the integrals are signed; inverted cells will report negative values. */ -template class CellMeasure : public vtkm::worklet::WorkletVisitCellsWithPoints { public: @@ -61,6 +40,11 @@ public: using ExecutionSignature = void(CellShape, PointCount, _2, _3); using InputDomain = _1; + explicit CellMeasure(vtkm::filter::mesh_info::IntegrationType m) + : measure(m) + { + } + template VTKM_EXEC void operator()(CellShape shape, const vtkm::IdComponent& numPoints, @@ -77,7 +61,7 @@ public: } } -protected: +private: template VTKM_EXEC OutType ComputeMeasure(const vtkm::IdComponent& numPts, const PointCoordVecType& pts, @@ -91,6 +75,7 @@ protected: #pragma push #pragma diag_suppress = code_is_unreachable #endif + using vtkm::filter::mesh_info::IntegrationType; vtkm::ErrorCode ec; switch (vtkm::CellTraits::TOPOLOGICAL_DIMENSIONS) @@ -99,19 +84,19 @@ protected: // Fall through to return 0 measure. break; case 1: - if (vtkm::ListHas::value) + if (this->measure & IntegrationType::ArcLength) { return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), ec); } break; case 2: - if (vtkm::ListHas::value) + if (this->measure & IntegrationType::Area) { return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), ec); } break; case 3: - if (vtkm::ListHas::value) + if (this->measure & IntegrationType::Volume) { return vtkm::exec::CellMeasure(numPts, pts, CellShapeType(), ec); } @@ -128,6 +113,8 @@ protected: #pragma warning(pop) #endif } + + vtkm::filter::mesh_info::IntegrationType measure; }; } } // namespace vtkm::worklet diff --git a/vtkm/worklet/MeshQuality.h b/vtkm/filter/mesh_info/worklet/MeshQuality.h similarity index 68% rename from vtkm/worklet/MeshQuality.h rename to vtkm/filter/mesh_info/worklet/MeshQuality.h index 0affa645d..9a50633e0 100644 --- a/vtkm/worklet/MeshQuality.h +++ b/vtkm/filter/mesh_info/worklet/MeshQuality.h @@ -21,29 +21,30 @@ #ifndef vtk_m_worklet_MeshQuality_h #define vtk_m_worklet_MeshQuality_h -#include "vtkm/ErrorCode.h" -#include "vtkm/worklet/CellMeasure.h" -#include "vtkm/worklet/WorkletMapTopology.h" -#include "vtkm/worklet/cellmetrics/CellAspectGammaMetric.h" -#include "vtkm/worklet/cellmetrics/CellAspectRatioMetric.h" -#include "vtkm/worklet/cellmetrics/CellConditionMetric.h" -#include "vtkm/worklet/cellmetrics/CellDiagonalRatioMetric.h" -#include "vtkm/worklet/cellmetrics/CellDimensionMetric.h" -#include "vtkm/worklet/cellmetrics/CellJacobianMetric.h" -#include "vtkm/worklet/cellmetrics/CellMaxAngleMetric.h" -#include "vtkm/worklet/cellmetrics/CellMaxDiagonalMetric.h" -#include "vtkm/worklet/cellmetrics/CellMinAngleMetric.h" -#include "vtkm/worklet/cellmetrics/CellMinDiagonalMetric.h" -#include "vtkm/worklet/cellmetrics/CellOddyMetric.h" -#include "vtkm/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h" -#include "vtkm/worklet/cellmetrics/CellScaledJacobianMetric.h" -#include "vtkm/worklet/cellmetrics/CellShapeAndSizeMetric.h" -#include "vtkm/worklet/cellmetrics/CellShapeMetric.h" -#include "vtkm/worklet/cellmetrics/CellShearMetric.h" -#include "vtkm/worklet/cellmetrics/CellSkewMetric.h" -#include "vtkm/worklet/cellmetrics/CellStretchMetric.h" -#include "vtkm/worklet/cellmetrics/CellTaperMetric.h" -#include "vtkm/worklet/cellmetrics/CellWarpageMetric.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace vtkm { @@ -56,7 +57,6 @@ namespace worklet * and this metric is invoked over all cells of that cell type. An array of * the computed metric values (one per cell) is returned as output. */ -template class MeshQuality : public vtkm::worklet::WorkletVisitCellsWithPoints { public: @@ -66,16 +66,13 @@ public: using ExecutionSignature = void(CellShape, PointCount, _2, _3); using InputDomain = _1; - void SetMetric(MetricTagType m) { this->Metric = m; } + void SetMetric(vtkm::filter::mesh_info::CellMetric m) { this->Metric = m; } void SetAverageArea(vtkm::FloatDefault a) { this->AverageArea = a; }; void SetAverageVolume(vtkm::FloatDefault v) { this->AverageVolume = v; }; template VTKM_EXEC void operator()(CellShapeType shape, const vtkm::IdComponent& numPoints, - //const CountsArrayType& counts, - //const MetricsArrayType& metrics, - //MetricTagType metric, const PointCoordVecType& pts, OutType& metricValue) const { @@ -99,7 +96,7 @@ public: protected: // data member - MetricTagType Metric; + vtkm::filter::mesh_info::CellMetric Metric; vtkm::FloatDefault AverageArea; vtkm::FloatDefault AverageVolume; @@ -119,92 +116,92 @@ protected: vtkm::ErrorCode ec{ vtkm::ErrorCode::Success }; switch (this->Metric) { - case MetricTagType::AREA: + case vtkm::filter::mesh_info::CellMetric::AREA: metricValue = vtkm::exec::CellMeasure(numPts, pts, tag, ec); if (dims != 2) metricValue = 0.; break; - case MetricTagType::ASPECT_GAMMA: + case vtkm::filter::mesh_info::CellMetric::ASPECT_GAMMA: metricValue = vtkm::worklet::cellmetrics::CellAspectGammaMetric(numPts, pts, tag, ec); break; - case MetricTagType::ASPECT_RATIO: + case vtkm::filter::mesh_info::CellMetric::ASPECT_RATIO: metricValue = vtkm::worklet::cellmetrics::CellAspectRatioMetric(numPts, pts, tag, ec); break; - case MetricTagType::CONDITION: + case vtkm::filter::mesh_info::CellMetric::CONDITION: metricValue = vtkm::worklet::cellmetrics::CellConditionMetric(numPts, pts, tag, ec); break; - case MetricTagType::DIAGONAL_RATIO: + case vtkm::filter::mesh_info::CellMetric::DIAGONAL_RATIO: metricValue = vtkm::worklet::cellmetrics::CellDiagonalRatioMetric(numPts, pts, tag, ec); break; - case MetricTagType::DIMENSION: + case vtkm::filter::mesh_info::CellMetric::DIMENSION: metricValue = vtkm::worklet::cellmetrics::CellDimensionMetric(numPts, pts, tag, ec); break; - case MetricTagType::JACOBIAN: + case vtkm::filter::mesh_info::CellMetric::JACOBIAN: metricValue = vtkm::worklet::cellmetrics::CellJacobianMetric(numPts, pts, tag, ec); break; - case MetricTagType::MAX_ANGLE: + case vtkm::filter::mesh_info::CellMetric::MAX_ANGLE: metricValue = vtkm::worklet::cellmetrics::CellMaxAngleMetric(numPts, pts, tag, ec); break; - case MetricTagType::MAX_DIAGONAL: + case vtkm::filter::mesh_info::CellMetric::MAX_DIAGONAL: metricValue = vtkm::worklet::cellmetrics::CellMaxDiagonalMetric(numPts, pts, tag, ec); break; - case MetricTagType::MIN_ANGLE: + case vtkm::filter::mesh_info::CellMetric::MIN_ANGLE: metricValue = vtkm::worklet::cellmetrics::CellMinAngleMetric(numPts, pts, tag, ec); break; - case MetricTagType::MIN_DIAGONAL: + case vtkm::filter::mesh_info::CellMetric::MIN_DIAGONAL: metricValue = vtkm::worklet::cellmetrics::CellMinDiagonalMetric(numPts, pts, tag, ec); break; - case MetricTagType::ODDY: + case vtkm::filter::mesh_info::CellMetric::ODDY: metricValue = vtkm::worklet::cellmetrics::CellOddyMetric(numPts, pts, tag, ec); break; - case MetricTagType::RELATIVE_SIZE_SQUARED: + case vtkm::filter::mesh_info::CellMetric::RELATIVE_SIZE_SQUARED: metricValue = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric( numPts, pts, static_cast(average), tag, ec); break; - case MetricTagType::SHAPE_AND_SIZE: + case vtkm::filter::mesh_info::CellMetric::SHAPE_AND_SIZE: metricValue = vtkm::worklet::cellmetrics::CellShapeAndSizeMetric( numPts, pts, static_cast(average), tag, ec); break; - case MetricTagType::SCALED_JACOBIAN: + case vtkm::filter::mesh_info::CellMetric::SCALED_JACOBIAN: metricValue = vtkm::worklet::cellmetrics::CellScaledJacobianMetric(numPts, pts, tag, ec); break; - case MetricTagType::SHAPE: + case vtkm::filter::mesh_info::CellMetric::SHAPE: metricValue = vtkm::worklet::cellmetrics::CellShapeMetric(numPts, pts, tag, ec); break; - case MetricTagType::SHEAR: + case vtkm::filter::mesh_info::CellMetric::SHEAR: metricValue = vtkm::worklet::cellmetrics::CellShearMetric(numPts, pts, tag, ec); break; - case MetricTagType::SKEW: + case vtkm::filter::mesh_info::CellMetric::SKEW: metricValue = vtkm::worklet::cellmetrics::CellSkewMetric(numPts, pts, tag, ec); break; - case MetricTagType::STRETCH: + case vtkm::filter::mesh_info::CellMetric::STRETCH: metricValue = vtkm::worklet::cellmetrics::CellStretchMetric(numPts, pts, tag, ec); break; - case MetricTagType::TAPER: + case vtkm::filter::mesh_info::CellMetric::TAPER: metricValue = vtkm::worklet::cellmetrics::CellTaperMetric(numPts, pts, tag, ec); break; - case MetricTagType::VOLUME: + case vtkm::filter::mesh_info::CellMetric::VOLUME: metricValue = vtkm::exec::CellMeasure(numPts, pts, tag, ec); if (dims != 3) metricValue = 0.; break; - case MetricTagType::WARPAGE: + case vtkm::filter::mesh_info::CellMetric::WARPAGE: metricValue = vtkm::worklet::cellmetrics::CellWarpageMetric(numPts, pts, tag, ec); break; - case MetricTagType::EMPTY: + case vtkm::filter::mesh_info::CellMetric::EMPTY: break; default: //Only call metric function if a metric is specified for this shape type diff --git a/vtkm/worklet/cellmetrics/CMakeLists.txt b/vtkm/filter/mesh_info/worklet/cellmetrics/CMakeLists.txt similarity index 100% rename from vtkm/worklet/cellmetrics/CMakeLists.txt rename to vtkm/filter/mesh_info/worklet/cellmetrics/CMakeLists.txt diff --git a/vtkm/worklet/cellmetrics/CellAspectFrobeniusMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellAspectFrobeniusMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellAspectFrobeniusMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellAspectFrobeniusMetric.h diff --git a/vtkm/worklet/cellmetrics/CellAspectGammaMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellAspectGammaMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellAspectGammaMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellAspectGammaMetric.h diff --git a/vtkm/worklet/cellmetrics/CellAspectRatioMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellAspectRatioMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellAspectRatioMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellAspectRatioMetric.h diff --git a/vtkm/worklet/cellmetrics/CellConditionMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellConditionMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellConditionMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellConditionMetric.h diff --git a/vtkm/worklet/cellmetrics/CellDiagonalRatioMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellDiagonalRatioMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellDiagonalRatioMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellDiagonalRatioMetric.h diff --git a/vtkm/worklet/cellmetrics/CellDimensionMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellDimensionMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellDimensionMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellDimensionMetric.h diff --git a/vtkm/worklet/cellmetrics/CellEdgeRatioMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellEdgeRatioMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellEdgeRatioMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellEdgeRatioMetric.h diff --git a/vtkm/worklet/cellmetrics/CellJacobianMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellJacobianMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellJacobianMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellJacobianMetric.h diff --git a/vtkm/worklet/cellmetrics/CellMaxAngleMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxAngleMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellMaxAngleMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxAngleMetric.h diff --git a/vtkm/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h similarity index 99% rename from vtkm/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h index 5f315c124..71b81b61a 100644 --- a/vtkm/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h +++ b/vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxAspectFrobeniusMetric.h @@ -35,12 +35,12 @@ * See: vtk/ThirdParty/verdict/vtkverdict (for VTK code implementation of this metric) */ +#include "CellAspectFrobeniusMetric.h" #include "vtkm/CellShape.h" #include "vtkm/CellTraits.h" #include "vtkm/VecTraits.h" #include "vtkm/VectorAnalysis.h" #include "vtkm/exec/FunctorBase.h" -#include "vtkm/worklet/cellmetrics/CellAspectFrobeniusMetric.h" #define UNUSED(expr) (void)(expr); diff --git a/vtkm/worklet/cellmetrics/CellMaxDiagonalMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxDiagonalMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellMaxDiagonalMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxDiagonalMetric.h diff --git a/vtkm/worklet/cellmetrics/CellMinAngleMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellMinAngleMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellMinAngleMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellMinAngleMetric.h diff --git a/vtkm/worklet/cellmetrics/CellMinDiagonalMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellMinDiagonalMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellMinDiagonalMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellMinDiagonalMetric.h diff --git a/vtkm/worklet/cellmetrics/CellOddyMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellOddyMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellOddyMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellOddyMetric.h diff --git a/vtkm/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h diff --git a/vtkm/worklet/cellmetrics/CellScaledJacobianMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellScaledJacobianMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellScaledJacobianMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellScaledJacobianMetric.h diff --git a/vtkm/worklet/cellmetrics/CellShapeAndSizeMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellShapeAndSizeMetric.h similarity index 99% rename from vtkm/worklet/cellmetrics/CellShapeAndSizeMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellShapeAndSizeMetric.h index 0ae2677b3..0c39d150b 100644 --- a/vtkm/worklet/cellmetrics/CellShapeAndSizeMetric.h +++ b/vtkm/filter/mesh_info/worklet/cellmetrics/CellShapeAndSizeMetric.h @@ -31,12 +31,12 @@ * metric) */ +#include "CellShapeMetric.h" #include "vtkm/CellShape.h" #include "vtkm/CellTraits.h" #include "vtkm/VecTraits.h" #include "vtkm/VectorAnalysis.h" #include "vtkm/exec/FunctorBase.h" -#include "vtkm/worklet/cellmetrics/CellShapeMetric.h" #define UNUSED(expr) (void)(expr); diff --git a/vtkm/worklet/cellmetrics/CellShapeMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellShapeMetric.h similarity index 98% rename from vtkm/worklet/cellmetrics/CellShapeMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellShapeMetric.h index 13952464a..b449f8ebf 100644 --- a/vtkm/worklet/cellmetrics/CellShapeMetric.h +++ b/vtkm/filter/mesh_info/worklet/cellmetrics/CellShapeMetric.h @@ -28,6 +28,8 @@ * See: vtk/ThirdParty/verdict/vtkverdict (for VTK code implementation of this metric) */ +#include "CellConditionMetric.h" +#include "CellJacobianMetric.h" #include "TypeOfCellHexahedral.h" #include "TypeOfCellQuadrilateral.h" #include "TypeOfCellTetrahedral.h" @@ -37,8 +39,6 @@ #include "vtkm/VecTraits.h" #include "vtkm/VectorAnalysis.h" #include "vtkm/exec/FunctorBase.h" -#include "vtkm/worklet/cellmetrics/CellConditionMetric.h" -#include "vtkm/worklet/cellmetrics/CellJacobianMetric.h" namespace vtkm { diff --git a/vtkm/worklet/cellmetrics/CellShearMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellShearMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellShearMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellShearMetric.h diff --git a/vtkm/worklet/cellmetrics/CellSkewMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellSkewMetric.h similarity index 98% rename from vtkm/worklet/cellmetrics/CellSkewMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellSkewMetric.h index d3128db41..e1bfd356a 100644 --- a/vtkm/worklet/cellmetrics/CellSkewMetric.h +++ b/vtkm/filter/mesh_info/worklet/cellmetrics/CellSkewMetric.h @@ -22,6 +22,7 @@ /* */ +#include "CellConditionMetric.h" #include "TypeOfCellHexahedral.h" #include "TypeOfCellQuadrilateral.h" #include "TypeOfCellTetrahedral.h" @@ -31,7 +32,6 @@ #include "vtkm/VecTraits.h" #include "vtkm/VectorAnalysis.h" #include "vtkm/exec/FunctorBase.h" -#include "vtkm/worklet/cellmetrics/CellConditionMetric.h" namespace vtkm { diff --git a/vtkm/worklet/cellmetrics/CellStretchMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellStretchMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellStretchMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellStretchMetric.h diff --git a/vtkm/worklet/cellmetrics/CellTaperMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellTaperMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellTaperMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellTaperMetric.h diff --git a/vtkm/worklet/cellmetrics/CellWarpageMetric.h b/vtkm/filter/mesh_info/worklet/cellmetrics/CellWarpageMetric.h similarity index 100% rename from vtkm/worklet/cellmetrics/CellWarpageMetric.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/CellWarpageMetric.h diff --git a/vtkm/worklet/cellmetrics/TypeOfCellHexahedral.h b/vtkm/filter/mesh_info/worklet/cellmetrics/TypeOfCellHexahedral.h similarity index 100% rename from vtkm/worklet/cellmetrics/TypeOfCellHexahedral.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/TypeOfCellHexahedral.h diff --git a/vtkm/worklet/cellmetrics/TypeOfCellQuadrilateral.h b/vtkm/filter/mesh_info/worklet/cellmetrics/TypeOfCellQuadrilateral.h similarity index 100% rename from vtkm/worklet/cellmetrics/TypeOfCellQuadrilateral.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/TypeOfCellQuadrilateral.h diff --git a/vtkm/worklet/cellmetrics/TypeOfCellTetrahedral.h b/vtkm/filter/mesh_info/worklet/cellmetrics/TypeOfCellTetrahedral.h similarity index 100% rename from vtkm/worklet/cellmetrics/TypeOfCellTetrahedral.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/TypeOfCellTetrahedral.h diff --git a/vtkm/worklet/cellmetrics/TypeOfCellTriangle.h b/vtkm/filter/mesh_info/worklet/cellmetrics/TypeOfCellTriangle.h similarity index 100% rename from vtkm/worklet/cellmetrics/TypeOfCellTriangle.h rename to vtkm/filter/mesh_info/worklet/cellmetrics/TypeOfCellTriangle.h diff --git a/vtkm/filter/testing/CMakeLists.txt b/vtkm/filter/testing/CMakeLists.txt index 27b4407ae..a9e318501 100644 --- a/vtkm/filter/testing/CMakeLists.txt +++ b/vtkm/filter/testing/CMakeLists.txt @@ -13,20 +13,17 @@ set(headers ) set(unit_tests - UnitTestCellMeasuresFilter.cxx UnitTestContourTreeUniformFilter.cxx UnitTestContourTreeUniformAugmentedFilter.cxx UnitTestContourTreeUniformDistributedFilter.cxx UnitTestFieldMetadata.cxx UnitTestFieldSelection.cxx - UnitTestGhostCellClassify.cxx UnitTestImageDifferenceFilter.cxx UnitTestImageMedianFilter.cxx UnitTestLagrangianFilter.cxx UnitTestLagrangianStructuresFilter.cxx UnitTestMapFieldMergeAverage.cxx UnitTestMapFieldPermutation.cxx - UnitTestMeshQualityFilter.cxx UnitTestMIRFilter.cxx UnitTestMultiBlockFilter.cxx UnitTestPartitionedDataSetFilters.cxx diff --git a/vtkm/worklet/CMakeLists.txt b/vtkm/worklet/CMakeLists.txt index 18e5c6acb..72afd4052 100644 --- a/vtkm/worklet/CMakeLists.txt +++ b/vtkm/worklet/CMakeLists.txt @@ -13,7 +13,6 @@ set(headers BoundaryTypes.h AveragePointNeighborhood.h CellDeepCopy.h - CellMeasure.h ContourTreeUniform.h ContourTreeUniformAugmented.h CosmoTools.h @@ -31,7 +30,6 @@ set(headers MaskIndices.h MaskNone.h MaskSelect.h - MeshQuality.h MIR.h NDimsHistMarginalization.h Normalize.h @@ -91,7 +89,6 @@ set(sources_device #----------------------------------------------------------------------------- add_subdirectory(internal) -add_subdirectory(cellmetrics) add_subdirectory(colorconversion) add_subdirectory(contourtree) add_subdirectory(contourtree_augmented) diff --git a/vtkm/worklet/testing/CMakeLists.txt b/vtkm/worklet/testing/CMakeLists.txt index d6b91eb3d..f6bd66341 100644 --- a/vtkm/worklet/testing/CMakeLists.txt +++ b/vtkm/worklet/testing/CMakeLists.txt @@ -17,7 +17,6 @@ set(unit_tests UnitTestAverageByKey.cxx UnitTestBoundingIntervalHierarchy.cxx UnitTestCellDeepCopy.cxx - UnitTestCellMeasure.cxx UnitTestContourTreeUniform.cxx UnitTestContourTreeUniformAugmented.cxx UnitTestContourTreeUniformDistributed.cxx diff --git a/vtkm/worklet/testing/GenerateTestDataSets.h b/vtkm/worklet/testing/GenerateTestDataSets.h index ffe760ef6..2abddcdfa 100644 --- a/vtkm/worklet/testing/GenerateTestDataSets.h +++ b/vtkm/worklet/testing/GenerateTestDataSets.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include namespace vtkm { @@ -46,7 +46,7 @@ inline vtkm::cont::DataSet CreateUniformDataSet(const vtkm::Bounds& bounds, if (addGhost) { - vtkm::filter::GhostCellClassify addGhostFilter; + vtkm::filter::mesh_info::GhostCellClassify addGhostFilter; return addGhostFilter.Execute(ds); } return ds; @@ -84,7 +84,7 @@ inline vtkm::cont::DataSet CreateRectilinearDataSet(const vtkm::Bounds& bounds, if (addGhost) { - vtkm::filter::GhostCellClassify addGhostFilter; + vtkm::filter::mesh_info::GhostCellClassify addGhostFilter; return addGhostFilter.Execute(ds); } return ds; diff --git a/vtkm/worklet/testing/UnitTestCellMeasure.cxx b/vtkm/worklet/testing/UnitTestCellMeasure.cxx deleted file mode 100644 index e1f95c7af..000000000 --- a/vtkm/worklet/testing/UnitTestCellMeasure.cxx +++ /dev/null @@ -1,118 +0,0 @@ -//============================================================================ -// Copyright (c) Kitware, Inc. -// All rights reserved. -// See LICENSE.txt for details. -// -// This software is distributed WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -// PURPOSE. See the above copyright notice for more information. -//============================================================================ - -#include -#include - -#include -#include - -namespace -{ - -void TestCellMeasureUniform3D() -{ - std::cout << "Testing CellMeasure Worklet on 3D structured data" << std::endl; - - vtkm::cont::testing::MakeTestDataSet testDataSet; - vtkm::cont::DataSet dataSet = testDataSet.Make3DUniformDataSet0(); - - vtkm::cont::ArrayHandle result; - - vtkm::worklet::DispatcherMapTopology> dispatcher; - dispatcher.Invoke( - dataSet.GetCellSet(), dataSet.GetCoordinateSystem().GetDataAsMultiplexer(), result); - - vtkm::Float32 expected[4] = { 1.f, 1.f, 1.f, 1.f }; - for (int i = 0; i < 4; ++i) - { - VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(vtkm::Id(i)), expected[i]), - "Wrong result for CellMeasure worklet on 3D uniform data"); - } -} - -template -void TestCellMeasureWorklet(vtkm::cont::DataSet& dataset, - const char* msg, - const std::vector& expected, - const IntegrationType&) -{ - std::cout << "Testing CellMeasures Filter on " << msg << "\n"; - - vtkm::cont::ArrayHandle result; - - vtkm::worklet::DispatcherMapTopology> dispatcher; - dispatcher.Invoke( - dataset.GetCellSet(), dataset.GetCoordinateSystem().GetDataAsMultiplexer(), result); - - VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast(expected.size()), - "Wrong number of values in the output array"); - - for (unsigned int i = 0; i < static_cast(expected.size()); ++i) - { - VTKM_TEST_ASSERT(test_equal(result.ReadPortal().Get(vtkm::Id(i)), expected[i]), - "Wrong result for CellMeasure filter"); - } -} - -void TestCellMeasure() -{ - using vtkm::AllMeasures; - using vtkm::ArcLength; - using vtkm::Area; - using vtkm::Volume; - - TestCellMeasureUniform3D(); - - vtkm::cont::testing::MakeTestDataSet factory; - vtkm::cont::DataSet data; - - data = factory.Make3DExplicitDataSet2(); - TestCellMeasureWorklet(data, "explicit dataset 2", { -1.f }, Volume()); - - data = factory.Make3DExplicitDataSet3(); - TestCellMeasureWorklet(data, "explicit dataset 3", { -1.f / 6.f }, Volume()); - - data = factory.Make3DExplicitDataSet4(); - TestCellMeasureWorklet(data, "explicit dataset 4", { -1.f, -1.f }, Volume()); - - data = factory.Make3DExplicitDataSet5(); - TestCellMeasureWorklet( - data, "explicit dataset 5", { 1.f, 1.f / 3.f, 1.f / 6.f, -1.f / 2.f }, Volume()); - - data = factory.Make3DExplicitDataSet6(); - TestCellMeasureWorklet( - data, - "explicit dataset 6 (all)", - { 0.999924f, 0.999924f, 0.f, 0.f, 3.85516f, 1.00119f, 0.083426f, 0.25028f }, - AllMeasures()); - TestCellMeasureWorklet(data, - "explicit dataset 6 (arc length)", - { 0.999924f, 0.999924f, 0.f, 0.f, 0.0f, 0.0f, 0.0f, 0.0f }, - ArcLength()); - TestCellMeasureWorklet(data, - "explicit dataset 6 (area)", - { 0.0f, 0.0f, 0.f, 0.f, 3.85516f, 1.00119f, 0.0f, 0.0f }, - Area()); - TestCellMeasureWorklet(data, - "explicit dataset 6 (volume)", - { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.083426f, 0.25028f }, - Volume()); - TestCellMeasureWorklet(data, - "explicit dataset 6 (empty)", - { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.0f, 0.0f }, - vtkm::List<>()); -} -} - -int UnitTestCellMeasure(int argc, char* argv[]) -{ - return vtkm::cont::testing::Testing::Run(TestCellMeasure, argc, argv); -} diff --git a/vtkm/worklet/testing/UnitTestParticleAdvection.cxx b/vtkm/worklet/testing/UnitTestParticleAdvection.cxx index fb9417f46..82cdea921 100644 --- a/vtkm/worklet/testing/UnitTestParticleAdvection.cxx +++ b/vtkm/worklet/testing/UnitTestParticleAdvection.cxx @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include