VTK-m  2.0
CellStretchMetric.h
Go to the documentation of this file.
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 #ifndef vtk_m_worklet_cellmetrics_CellStretchMetric_h
21 #define vtk_m_worklet_cellmetrics_CellStretchMetric_h
22 
23 /*
24 * Mesh quality metric functions that compute the aspect frobenius of certain mesh cells.
25 * The aspect frobenius metric generally measures the degree of regularity of a cell, with
26 * a value of 1 representing a regular cell..
27 ** These metric computations are adapted from the VTK implementation of the Verdict library,
28 * which provides a set of mesh/cell metrics for evaluating the geometric qualities of regions
29 * of mesh spaces.
30 ** See: The Verdict Library Reference Manual (for per-cell-type metric formulae)
31 * See: vtk/ThirdParty/verdict/vtkverdict (for VTK code implementation of this metric)
32 */
33 
34 #include "TypeOfCellHexahedral.h"
36 #include "TypeOfCellTetrahedral.h"
37 #include "TypeOfCellTriangle.h"
38 #include <vtkm/CellShape.h>
39 #include <vtkm/CellTraits.h>
40 #include <vtkm/ErrorCode.h>
41 #include <vtkm/VecTraits.h>
42 #include <vtkm/VectorAnalysis.h>
43 
44 #define UNUSED(expr) (void)(expr);
45 
46 namespace vtkm
47 {
48 namespace worklet
49 {
50 namespace cellmetrics
51 {
52 
53 template <typename OutType, typename PointCoordVecType, typename CellShapeType>
55  const PointCoordVecType& pts,
56  CellShapeType shape,
57  vtkm::ErrorCode& ec)
58 {
59  UNUSED(numPts);
60  UNUSED(pts);
61  UNUSED(shape);
62  UNUSED(ec);
63  return OutType(-1.0);
64 }
65 
66 template <typename OutType, typename PointCoordVecType>
68  const PointCoordVecType& pts,
69  vtkm::CellShapeTagQuad,
70  vtkm::ErrorCode& ec)
71 {
72  UNUSED(numPts);
73  UNUSED(ec);
74  using Scalar = OutType;
75  using CollectionOfPoints = PointCoordVecType;
76  using Vector = typename PointCoordVecType::ComponentType;
77 
78  const Scalar root2 = vtkm::Sqrt(Scalar(2.0));
79  const Scalar LMin = GetQuadLMin<Scalar, Vector, CollectionOfPoints>(pts);
80  const Scalar DMax = GetQuadDMax<Scalar, Vector, CollectionOfPoints>(pts);
81 
82  if (DMax <= Scalar(0.0))
83  {
84  return vtkm::Infinity<Scalar>();
85  }
86 
87  const Scalar q = root2 * (LMin / DMax);
88 
89  return q;
90 }
91 
92 template <typename OutType, typename PointCoordVecType>
94  const PointCoordVecType& pts,
95  vtkm::CellShapeTagHexahedron,
96  vtkm::ErrorCode& ec)
97 {
98  UNUSED(numPts);
99  UNUSED(ec);
100  using Scalar = OutType;
101  using CollectionOfPoints = PointCoordVecType;
102  using Vector = typename PointCoordVecType::ComponentType;
103 
104  const Scalar root3 = vtkm::Sqrt(Scalar(3.0));
105  const Scalar LMin = GetHexLMin<Scalar, Vector, CollectionOfPoints>(pts);
106  const Scalar DMax = GetHexDMax<Scalar, Vector, CollectionOfPoints>(pts);
107 
108  if (DMax <= Scalar(0.0))
109  {
110  return vtkm::Infinity<Scalar>();
111  }
112 
113  const Scalar q = root3 * (LMin / DMax);
114 
115  return q;
116 }
117 }
118 }
119 }
120 #endif // vtk_m_worklet_cellmetrics_CellStretchMetric_h
vtkm::Sqrt
VTKM_EXEC_CONT vtkm::Float32 Sqrt(vtkm::Float32 x)
Compute the square root of x.
Definition: Math.h:958
vtkm::ErrorCode
ErrorCode
Definition: ErrorCode.h:19
VTKM_EXEC
#define VTKM_EXEC
Definition: ExportMacros.h:51
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
vtkm::worklet::cellmetrics::CellStretchMetric
VTKM_EXEC OutType CellStretchMetric(const vtkm::IdComponent &numPts, const PointCoordVecType &pts, CellShapeType shape, vtkm::ErrorCode &ec)
Definition: CellStretchMetric.h:54
vtkm::IdComponent
vtkm::Int32 IdComponent
Represents a component ID (index of component in a vector).
Definition: Types.h:168
CellShape.h
ErrorCode.h
VectorAnalysis.h
UNUSED
#define UNUSED(expr)
Definition: CellStretchMetric.h:44
TypeOfCellTetrahedral.h
TypeOfCellTriangle.h
TypeOfCellHexahedral.h
TypeOfCellQuadrilateral.h
CellTraits.h
VecTraits.h