From cb119cf23119d15f1f22f2c9de9e5a9e5d345948 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Wed, 22 Jun 2022 09:01:05 -0600 Subject: [PATCH] Move MeshQualityJacobian to its own filter --- vtkm/filter/mesh_info/CMakeLists.txt | 2 + vtkm/filter/mesh_info/MeshQuality.cxx | 4 ++ vtkm/filter/mesh_info/MeshQualityJacobian.cxx | 66 +++++++++++++++++++ vtkm/filter/mesh_info/MeshQualityJacobian.h | 46 +++++++++++++ vtkm/filter/mesh_info/worklet/MeshQuality.h | 5 -- 5 files changed, 118 insertions(+), 5 deletions(-) create mode 100644 vtkm/filter/mesh_info/MeshQualityJacobian.cxx create mode 100644 vtkm/filter/mesh_info/MeshQualityJacobian.h diff --git a/vtkm/filter/mesh_info/CMakeLists.txt b/vtkm/filter/mesh_info/CMakeLists.txt index ed9fa664f..113504a88 100644 --- a/vtkm/filter/mesh_info/CMakeLists.txt +++ b/vtkm/filter/mesh_info/CMakeLists.txt @@ -12,6 +12,7 @@ set(mesh_info_headers GhostCellClassify.h MeshQuality.h MeshQualityArea.h + MeshQualityJacobian.h MeshQualityMaxAngle.h MeshQualityMaxDiagonal.h MeshQualityMinAngle.h @@ -34,6 +35,7 @@ set(mesh_info_sources GhostCellClassify.cxx MeshQuality.cxx MeshQualityArea.cxx + MeshQualityJacobian.cxx MeshQualityMaxAngle.cxx MeshQualityMaxDiagonal.cxx MeshQualityMinAngle.cxx diff --git a/vtkm/filter/mesh_info/MeshQuality.cxx b/vtkm/filter/mesh_info/MeshQuality.cxx index 79d0c939b..2413028ee 100644 --- a/vtkm/filter/mesh_info/MeshQuality.cxx +++ b/vtkm/filter/mesh_info/MeshQuality.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,9 @@ VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(const vtkm::cont::DataSet& case vtkm::filter::mesh_info::CellMetric::Area: implementation.reset(new vtkm::filter::mesh_info::MeshQualityArea); break; + case vtkm::filter::mesh_info::CellMetric::Jacobian: + implementation.reset(new vtkm::filter::mesh_info::MeshQualityJacobian); + break; case vtkm::filter::mesh_info::CellMetric::MaxAngle: implementation.reset(new vtkm::filter::mesh_info::MeshQualityMaxAngle); break; diff --git a/vtkm/filter/mesh_info/MeshQualityJacobian.cxx b/vtkm/filter/mesh_info/MeshQualityJacobian.cxx new file mode 100644 index 000000000..5c7304972 --- /dev/null +++ b/vtkm/filter/mesh_info/MeshQualityJacobian.cxx @@ -0,0 +1,66 @@ +//============================================================================ +// 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 + +namespace +{ + +struct JacobianWorklet : MeshQualityWorklet +{ + template + VTKM_EXEC OutType ComputeMetric(const vtkm::IdComponent& numPts, + const PointCoordVecType& pts, + CellShapeType shape, + vtkm::ErrorCode& ec) const + { + return vtkm::worklet::cellmetrics::CellJacobianMetric(numPts, pts, shape, ec); + } +}; + +} // anonymous namespace + +namespace vtkm +{ +namespace filter +{ +namespace mesh_info +{ + +MeshQualityJacobian::MeshQualityJacobian() +{ + this->SetUseCoordinateSystemAsField(true); + this->SetOutputFieldName("jacobian"); +} + +vtkm::cont::DataSet MeshQualityJacobian::DoExecute(const vtkm::cont::DataSet& input) +{ + vtkm::cont::UnknownArrayHandle outArray = + JacobianWorklet{}.Run(input, this->GetFieldFromDataSet(input)); + + return this->CreateResultFieldCell(input, this->GetOutputFieldName(), outArray); +} + +} // namespace mesh_info +} // namespace filter +} // namespace vtkm diff --git a/vtkm/filter/mesh_info/MeshQualityJacobian.h b/vtkm/filter/mesh_info/MeshQualityJacobian.h new file mode 100644 index 000000000..3045443bd --- /dev/null +++ b/vtkm/filter/mesh_info/MeshQualityJacobian.h @@ -0,0 +1,46 @@ +//============================================================================ +// 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_MeshQualityJacobian_h +#define vtk_m_filter_mesh_info_MeshQualityJacobian_h + +#include +#include + +namespace vtkm +{ +namespace filter +{ +namespace mesh_info +{ + +class VTKM_FILTER_MESH_INFO_EXPORT MeshQualityJacobian : public vtkm::filter::NewFilterField +{ +public: + MeshQualityJacobian(); + +private: + vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& input) override; +}; + +} // namespace mesh_info +} // namespace filter +} // namespace vtkm + +#endif //vtk_m_filter_mesh_info_MeshQualityJacobian_h diff --git a/vtkm/filter/mesh_info/worklet/MeshQuality.h b/vtkm/filter/mesh_info/worklet/MeshQuality.h index b16349275..8a026372e 100644 --- a/vtkm/filter/mesh_info/worklet/MeshQuality.h +++ b/vtkm/filter/mesh_info/worklet/MeshQuality.h @@ -29,7 +29,6 @@ #include #include #include -#include #include namespace vtkm @@ -121,10 +120,6 @@ private: metricValue = vtkm::worklet::cellmetrics::CellDimensionMetric(numPts, pts, tag, ec); break; - case vtkm::filter::mesh_info::CellMetric::Jacobian: - metricValue = - vtkm::worklet::cellmetrics::CellJacobianMetric(numPts, pts, tag, ec); - break; case vtkm::filter::mesh_info::CellMetric::None: break; default: