1 //============================================================================ 2 // Copyright (c) Kitware, Inc. 3 // All rights reserved. 4 // See LICENSE.txt for details. 5 // This software is distributed WITHOUT ANY WARRANTY; without even 6 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 7 // PURPOSE. See the above copyright notice for more information. 8 // 9 // Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS). 10 // Copyright 2014 UT-Battelle, LLC. 11 // Copyright 2014 Los Alamos National Security. 12 // 13 // Under the terms of Contract DE-NA0003525 with NTESS, 14 // the U.S. Government retains certain rights in this software. 15 // 16 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National 17 // Laboratory (LANL), the U.S. Government retains certain rights in 18 // this software. 19 //============================================================================ 20 21 #ifndef vtk_m_filter_MeshQuality_h 22 #define vtk_m_filter_MeshQuality_h 23 24 #include <vtkm/CellShape.h> 25 #include <vtkm/filter/FilterField.h> 26 #include <vtkm/worklet/MeshQuality.h> 27 28 namespace vtkm 29 { 30 namespace filter 31 { 32 33 //Names of the available cell metrics, for use in 34 //the output dataset fields 35 static const std::string MetricNames[] = { "area", 36 "aspectGamma", 37 "aspectRatio", 38 "condition", 39 "diagonalRatio", 40 "dimension", 41 "jacobian", 42 "maxAngle", 43 "maxDiagonal", 44 "minAngle", 45 "minDiagonal", 46 "oddy", 47 "relativeSizeSquared", 48 "scaledJacobian", 49 "shape", 50 "shapeAndSize", 51 "shear", 52 "skew", 53 "stretch", 54 "taper", 55 "volume", 56 "warpage" }; 57 58 //Different cell metrics available to use 59 //This must follow the same order as the MetricNames above 60 enum class CellMetric 61 { 62 AREA, 63 ASPECT_GAMMA, 64 ASPECT_RATIO, 65 CONDITION, 66 DIAGONAL_RATIO, 67 DIMENSION, 68 JACOBIAN, 69 MAX_ANGLE, 70 MAX_DIAGONAL, 71 MIN_ANGLE, 72 MIN_DIAGONAL, 73 ODDY, 74 RELATIVE_SIZE_SQUARED, 75 SCALED_JACOBIAN, 76 SHAPE, 77 SHAPE_AND_SIZE, 78 SHEAR, 79 SKEW, 80 STRETCH, 81 TAPER, 82 VOLUME, 83 WARPAGE, 84 NUMBER_OF_CELL_METRICS, 85 EMPTY 86 }; 87 88 /** \brief Computes the quality of an unstructured cell-based mesh. The quality is defined in terms of the 89 * summary statistics (frequency, mean, variance, min, max) of metrics computed over the mesh 90 * cells. One of several different metrics can be specified for a given cell type, and the mesh 91 * can consist of one or more different cell types. The resulting mesh quality is stored as one 92 * or more new fields in the output dataset of this filter, with a separate field for each cell type. 93 * Each field contains the metric summary statistics for the cell type. 94 * Summary statists with all 0 values imply that the specified metric does not support the cell type. 95 */ 96 class MeshQuality : public vtkm::filter::FilterField<MeshQuality> 97 { 98 public: 99 using SupportedTypes = vtkm::TypeListFieldVec3; 100 101 VTKM_CONT MeshQuality(CellMetric); 102 103 template <typename T, typename StorageType, typename DerivedPolicy> 104 VTKM_CONT vtkm::cont::DataSet DoExecute( 105 const vtkm::cont::DataSet& input, 106 const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& points, 107 const vtkm::filter::FieldMetadata& fieldMeta, 108 const vtkm::filter::PolicyBase<DerivedPolicy>& policy); 109 110 private: 111 CellMetric MyMetric; 112 }; 113 114 } // namespace filter 115 } // namespace vtkm 116 117 #include <vtkm/filter/MeshQuality.hxx> 118 119 #endif // vtk_m_filter_MeshQuality_h 120