VTK-m  2.0
CellShapeAndSizeMetric.h
Go to the documentation of this file.
1 // Copyright (c) Kitware, Inc.
2 // All rights reserved.
3 // See LICENSE.txt for details.
4 // This software is distributed WITHOUT ANY WARRANTY; without even
5 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
6 // PURPOSE. See the above copyright notice for more information.
7 //
8 // Copyright 2014 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
9 // Copyright 2014 UT-Battelle, LLC.
10 // Copyright 2014 Los Alamos National Security.
11 //
12 // Under the terms of Contract DE-NA0003525 with NTESS,
13 // the U.S. Government retains certain rights in this software.
14 //
15 // Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
16 // Laboratory (LANL), the U.S. Government retains certain rights in
17 // this software.
18 //============================================================================
19 #ifndef vtk_m_worklet_cellmetrics_CellShapeAndSizeMetric_h
20 #define vtk_m_worklet_cellmetrics_CellShapeAndSizeMetric_h
21 /*
22  * Mesh quality metric functions that compute the shape and size of a cell. This
23  * takes the shape metric and multiplies it by the relative size squared metric.
24  *
25  * These metric computations are adapted from the VTK implementation of the
26  * Verdict library, which provides a set of mesh/cell metrics for evaluating the
27  * geometric qualities of regions of mesh spaces.
28  *
29  * See: The Verdict Library Reference Manual (for per-cell-type metric formulae)
30  * See: vtk/ThirdParty/verdict/vtkverdict (for VTK code implementation of this
31  * metric)
32  */
33 
35 #include "CellShapeMetric.h"
36 #include <vtkm/CellShape.h>
37 #include <vtkm/CellTraits.h>
38 #include <vtkm/ErrorCode.h>
39 #include <vtkm/VecTraits.h>
40 #include <vtkm/VectorAnalysis.h>
41 
42 #define UNUSED(expr) (void)(expr);
43 
44 namespace vtkm
45 {
46 namespace worklet
47 {
48 namespace cellmetrics
49 {
50 
52 
53 // ========================= Unsupported cells ==================================
54 
55 // By default, cells have zero shape unless the shape type template is specialized below.
56 template <typename OutType, typename PointCoordVecType, typename CellShapeType>
58  const PointCoordVecType& pts,
59  const OutType& avgArea,
60  CellShapeType shape,
62 {
63  UNUSED(numPts);
64  UNUSED(pts);
65  UNUSED(avgArea);
66  UNUSED(shape);
67  return OutType(-1.);
68 }
69 
70 // ========================= 2D cells ==================================
71 
72 template <typename OutType, typename PointCoordVecType>
74  const PointCoordVecType& pts,
75  const OutType& avgArea,
76  vtkm::CellShapeTagTriangle tag,
77  vtkm::ErrorCode& ec)
78 {
79  OutType rss = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric<OutType>(
80  numPts, pts, avgArea, tag, ec);
81  OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric<OutType>(numPts, pts, tag, ec);
82  OutType q = rss * shape;
83  return OutType(q);
84 }
85 
86 template <typename OutType, typename PointCoordVecType>
88  const PointCoordVecType& pts,
89  const OutType& avgArea,
90  vtkm::CellShapeTagQuad tag,
91  vtkm::ErrorCode& ec)
92 {
93  OutType rss = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric<OutType>(
94  numPts, pts, avgArea, tag, ec);
95  OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric<OutType>(numPts, pts, tag, ec);
96  OutType q = rss * shape;
97  return OutType(q);
98 }
99 
100 // ========================= 3D cells ==================================
101 
102 template <typename OutType, typename PointCoordVecType>
104  const PointCoordVecType& pts,
105  const OutType& avgVolume,
106  vtkm::CellShapeTagTetra tag,
107  vtkm::ErrorCode& ec)
108 {
109  OutType rss = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric<OutType>(
110  numPts, pts, avgVolume, tag, ec);
111  OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric<OutType>(numPts, pts, tag, ec);
112  OutType q = rss * shape;
113  return OutType(q);
114 }
115 
116 template <typename OutType, typename PointCoordVecType>
118  const PointCoordVecType& pts,
119  const OutType& avgVolume,
120  vtkm::CellShapeTagHexahedron tag,
121  vtkm::ErrorCode& ec)
122 {
123  OutType rss = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric<OutType>(
124  numPts, pts, avgVolume, tag, ec);
125  OutType shape = vtkm::worklet::cellmetrics::CellShapeMetric<OutType>(numPts, pts, tag, ec);
126  OutType q = rss * shape;
127  return OutType(q);
128 }
129 
130 } // namespace cellmetrics
131 } // namespace worklet
132 } // namespace vtkm
133 
134 #endif // vtk_m_worklet_cellmetrics_CellShapeAndSizeMetric_h
vtkm::ErrorCode
ErrorCode
Definition: ErrorCode.h:19
vtkm::worklet::cellmetrics::CellShapeAndSizeMetric
VTKM_EXEC OutType CellShapeAndSizeMetric(const vtkm::IdComponent &numPts, const PointCoordVecType &pts, const OutType &avgArea, CellShapeType shape, vtkm::ErrorCode &)
Definition: CellShapeAndSizeMetric.h:57
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
UNUSED
#define UNUSED(expr)
Definition: CellShapeAndSizeMetric.h:42
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
CellShapeMetric.h
CellRelativeSizeSquaredMetric.h
vtkm::worklet::cellmetrics::FloatType
vtkm::FloatDefault FloatType
Definition: CellAspectFrobeniusMetric.h:50
CellShape.h
ErrorCode.h
VectorAnalysis.h
vtkm::FloatDefault
vtkm::Float32 FloatDefault
The floating point type to use when no other precision is specified.
Definition: Types.h:198
CellTraits.h
VecTraits.h