migrate mesh info filters

This commit is contained in:
Li-Ta Lo 2022-02-08 07:18:24 -07:00
parent 569deda9b5
commit ee0f112f0e
56 changed files with 599 additions and 593 deletions

@ -22,7 +22,8 @@
#include <vector>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderExplicit.h>
#include <vtkm/filter/MeshQuality.h>
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/filter/mesh_info/MeshQuality.h>
#include <vtkm/io/VTKDataSetReader.h>
#include <vtkm/io/VTKDataSetWriter.h>
@ -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;
}

@ -10,6 +10,8 @@
#ifndef vtk_m_CellClassification_h
#define vtk_m_CellClassification_h
#include <vtkm/Types.h>
namespace vtkm
{

@ -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)
#-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -

@ -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 <vtkm/filter/FilterField.h>
#include <vtkm/worklet/CellMeasure.h>
#include <vtkm/Deprecated.h>
#include <vtkm/filter/mesh_info/CellMeasures.h>
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 <typename IntegrationType>
class CellMeasures : public vtkm::filter::FilterField<CellMeasures<IntegrationType>>
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 <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& points,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& 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 <vtkm/filter/CellMeasures.hxx>
#endif // vtk_m_filter_CellMeasures_h
#endif //vtk_m_filter_CellMeasures_h

@ -10,46 +10,31 @@
#ifndef vtk_m_filter_GhostCellClassify_h
#define vtk_m_filter_GhostCellClassify_h
#include <vtkm/filter/FilterDataSet.h>
#include <vtkm/Deprecated.h>
#include <vtkm/filter/mesh_info/GhostCellClassify.h>
namespace vtkm
{
namespace filter
{
struct VTKM_DEPRECATED(1.6,
"GhostCellClassifyPolicy no longer has an effect.") GhostCellClassifyPolicy
: vtkm::filter::PolicyBase<GhostCellClassifyPolicy>
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<vtkm::UInt8>;
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<GhostCellClassify>
{
public:
using SupportedTypes = vtkm::List<vtkm::UInt8>;
VTKM_CONT
GhostCellClassify();
template <typename Policy>
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData,
vtkm::filter::PolicyBase<Policy> policy);
template <typename DerivedPolicy>
VTKM_CONT bool MapFieldOntoOutput(vtkm::cont::DataSet& result,
const vtkm::cont::Field& field,
const vtkm::filter::PolicyBase<DerivedPolicy>&)
{
result.AddField(field);
return true;
}
private:
};
}
} // namespace vtkm::filter
#include <vtkm/filter/GhostCellClassify.hxx>
#endif //vtk_m_filter_GhostCellClassify_h

@ -39,7 +39,7 @@
#include <vtkm/worklet/WorkletMapTopology.h>
#include <vtkm/worklet/WorkletReduceByKey.h>
#include <vtkm/filter/MeshQuality.h>
#include <vtkm/filter/mesh_info/worklet/MeshQuality.h>
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<vtkm::Float64> avgSizeTot;
vtkm::worklet::MeshQuality<vtkm::filter::CellMetric> 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(),

@ -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 <vtkm/CellShape.h>
#include <vtkm/filter/FilterField.h>
#include <vtkm/worklet/MeshQuality.h>
#include <vtkm/Deprecated.h>
#include <vtkm/filter/mesh_info/MeshQuality.h>
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<MeshQuality>
{
public:
using SupportedTypes = vtkm::TypeListFieldVec3;
using SupportedCellSets =
vtkm::List<vtkm::cont::CellSetExplicit<>, vtkm::cont::CellSetSingleType<>>;
}
} // namespace vtkm::filter
VTKM_CONT MeshQuality(CellMetric);
template <typename T, typename StorageType, typename DerivedPolicy>
VTKM_CONT vtkm::cont::DataSet DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& points,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& policy);
private:
CellMetric MyMetric;
};
} // namespace filter
} // namespace vtkm
#include <vtkm/filter/MeshQuality.hxx>
#endif // vtk_m_filter_MeshQuality_h
#endif //vtk_m_filter_MeshQuality_h

@ -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 <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/cont/Field.h>
#include <vtkm/filter/CellMeasures.h>
#include <vtkm/filter/CreateResult.h>
// #define DEBUG_PRINT
namespace vtkm
{
namespace filter
{
inline VTKM_CONT MeshQuality::MeshQuality(CellMetric metric)
: vtkm::filter::FilterField<MeshQuality>()
{
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 <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet MeshQuality::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& points,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& 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<CellMetric> 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<CellMetric> subWorklet;
vtkm::cont::ArrayHandle<T> 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<vtkm::FloatDefault>(numVals);
averageVolume = totalVolume / static_cast<vtkm::FloatDefault>(numVals);
}
qualityWorklet.SetAverageArea(averageArea);
qualityWorklet.SetAverageVolume(averageVolume);
}
//Invoke the MeshQuality worklet
vtkm::cont::ArrayHandle<T> 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

@ -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 ()

@ -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 <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/filter/mesh_info/CellMeasures.h>
#include <vtkm/filter/mesh_info/worklet/CellMeasure.h>
namespace vtkm
{
namespace filter
{
namespace mesh_info
{
//-----------------------------------------------------------------------------
template <typename IntegrationType>
inline VTKM_CONT CellMeasures<IntegrationType>::CellMeasures()
: vtkm::filter::FilterField<CellMeasures<IntegrationType>>()
VTKM_CONT CellMeasures::CellMeasures(IntegrationType m)
: measure(m)
{
this->SetUseCoordinateSystemAsField(true);
this->SetCellMeasureName("measure");
}
//-----------------------------------------------------------------------------
template <typename IntegrationType>
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet CellMeasures<IntegrationType>::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<vtkm::Vec<T, 3>, StorageType>& points,
const vtkm::filter::FieldMetadata& fieldMeta,
const vtkm::filter::PolicyBase<DerivedPolicy>& 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<T> outArray;
vtkm::cont::ArrayHandle<vtkm::FloatDefault> outArray;
this->Invoke(vtkm::worklet::CellMeasure<IntegrationType>{},
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<IntegrationType>::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

@ -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 <vtkm/filter/NewFilterField.h>
#include <vtkm/filter/mesh_info/vtkm_filter_mesh_info_export.h>
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

@ -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 <vtkm/CellClassification.h>
#include <vtkm/RangeId.h>
#include <vtkm/RangeId2.h>
#include <vtkm/RangeId3.h>
#include <vtkm/Types.h>
#include <vtkm/cont/ArrayCopy.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/filter/mesh_info/GhostCellClassify.h>
#include <vtkm/worklet/WorkletPointNeighborhood.h>
namespace vtkm
@ -92,11 +86,9 @@ private:
};
} // namespace detail
inline VTKM_CONT GhostCellClassify::GhostCellClassify() {}
template <typename Policy>
inline VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<Policy>)
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<vtkm::UInt8> 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
}

@ -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 <vtkm/filter/NewFilter.h>
#include <vtkm/filter/mesh_info/vtkm_filter_mesh_info_export.h>
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

@ -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 <vtkm/cont/Algorithm.h>
#include <vtkm/cont/ErrorFilterExecution.h>
#include <vtkm/cont/Field.h>
#include <vtkm/filter/CreateResult.h>
#include <vtkm/filter/mesh_info/MeshQuality.h>
#include <vtkm/filter/mesh_info/worklet/MeshQuality.h>
namespace vtkm
{
namespace filter
{
namespace mesh_info
{
namespace
{
//Names of the available cell metrics, for use in
//the output dataset fields
const std::map<CellMetric, std::string> 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<decltype(concrete)>::ValueType::ComponentType;
vtkm::cont::ArrayHandle<T> 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<vtkm::FloatDefault>(numCells);
averageVolume = totalVolume / static_cast<vtkm::FloatDefault>(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<decltype(concrete)>::ValueType::ComponentType;
vtkm::cont::ArrayHandle<T> 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

@ -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 <vtkm/filter/NewFilterField.h>
#include <vtkm/filter/mesh_info/vtkm_filter_mesh_info_export.h>
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

@ -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
)

@ -8,12 +8,12 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/filter/CellMeasures.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <vector>
#include <vtkm/filter/mesh_info/CellMeasures.h>
//#include <vtkm/filter/mesh_info/worklet/CellMeasure.h>
namespace
{
@ -37,15 +37,14 @@ struct CheckCellMeasuresFunctor
}
};
template <typename IntegrationType>
void TestCellMeasuresFilter(vtkm::cont::DataSet& dataset,
const char* msg,
const std::vector<vtkm::Float32>& expected,
const IntegrationType&)
const vtkm::filter::mesh_info::IntegrationType& type)
{
std::cout << "Testing CellMeasures Filter on " << msg << "\n";
vtkm::filter::CellMeasures<IntegrationType> 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

@ -9,12 +9,12 @@
//============================================================================
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderExplicit.h>
#include <vtkm/cont/DataSetBuilderRectilinear.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/GhostCellClassify.h>
#include <vtkm/CellClassification.h>
#include <vtkm/filter/mesh_info/GhostCellClassify.h>
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);

@ -26,8 +26,9 @@
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/DataSetBuilderExplicit.h>
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
#include <vtkm/cont/ErrorExecution.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/MeshQuality.h>
#include <vtkm/filter/mesh_info/MeshQuality.h>
#include <vtkm/io/VTKDataSetReader.h>
namespace
@ -142,7 +143,7 @@ inline vtkm::cont::DataSet MakeSingleTypeDataSet()
bool TestMeshQualityFilter(const vtkm::cont::DataSet& input,
const std::vector<vtkm::FloatDefault>& 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<FloatVec> expectedValues;
std::vector<vtkm::filter::CellMetric> metrics;
std::vector<vtkm::filter::mesh_info::CellMetric> metrics;
std::vector<std::string> metricName;
std::vector<vtkm::cont::DataSet> 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)
{

@ -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)

@ -11,33 +11,13 @@
#ifndef vtk_m_worklet_CellMeasure_h
#define vtk_m_worklet_CellMeasure_h
#include <vtkm/worklet/WorkletMapTopology.h>
#include <vtkm/exec/CellMeasure.h>
#include <vtkm/filter/mesh_info/CellMeasures.h>
#include <vtkm/worklet/WorkletMapTopology.h>
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<IntegrateOverCurve>;
using Area = vtkm::List<IntegrateOverSurface>;
using Volume = vtkm::List<IntegrateOverSolid>;
using AllMeasures = vtkm::List<IntegrateOverSolid, IntegrateOverSurface, IntegrateOverCurve>;
namespace worklet
{
@ -51,7 +31,6 @@ namespace worklet
*
* Note that the integrals are signed; inverted cells will report negative values.
*/
template <typename IntegrationTypeList>
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 <typename CellShape, typename PointCoordVecType, typename OutType>
VTKM_EXEC void operator()(CellShape shape,
const vtkm::IdComponent& numPoints,
@ -77,7 +61,7 @@ public:
}
}
protected:
private:
template <typename OutType, typename PointCoordVecType, typename CellShapeType>
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<CellShapeType>::TOPOLOGICAL_DIMENSIONS)
@ -99,19 +84,19 @@ protected:
// Fall through to return 0 measure.
break;
case 1:
if (vtkm::ListHas<IntegrationTypeList, IntegrateOverCurve>::value)
if (this->measure & IntegrationType::ArcLength)
{
return vtkm::exec::CellMeasure<OutType>(numPts, pts, CellShapeType(), ec);
}
break;
case 2:
if (vtkm::ListHas<IntegrationTypeList, IntegrateOverSurface>::value)
if (this->measure & IntegrationType::Area)
{
return vtkm::exec::CellMeasure<OutType>(numPts, pts, CellShapeType(), ec);
}
break;
case 3:
if (vtkm::ListHas<IntegrationTypeList, IntegrateOverSolid>::value)
if (this->measure & IntegrationType::Volume)
{
return vtkm::exec::CellMeasure<OutType>(numPts, pts, CellShapeType(), ec);
}
@ -128,6 +113,8 @@ protected:
#pragma warning(pop)
#endif
}
vtkm::filter::mesh_info::IntegrationType measure;
};
}
} // namespace vtkm::worklet

@ -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 <vtkm/ErrorCode.h>
#include <vtkm/exec/CellMeasure.h>
#include <vtkm/filter/mesh_info/MeshQuality.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellAspectGammaMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellAspectRatioMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellConditionMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellDiagonalRatioMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellDimensionMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellJacobianMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxAngleMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellMaxDiagonalMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellMinAngleMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellMinDiagonalMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellOddyMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellRelativeSizeSquaredMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellScaledJacobianMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellShapeAndSizeMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellShapeMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellShearMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellSkewMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellStretchMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellTaperMetric.h>
#include <vtkm/filter/mesh_info/worklet/cellmetrics/CellWarpageMetric.h>
#include <vtkm/worklet/WorkletMapTopology.h>
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 <typename MetricTagType>
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 <typename CellShapeType, typename PointCoordVecType, typename OutType>
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<OutType>(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<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::ASPECT_RATIO:
case vtkm::filter::mesh_info::CellMetric::ASPECT_RATIO:
metricValue =
vtkm::worklet::cellmetrics::CellAspectRatioMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::CONDITION:
case vtkm::filter::mesh_info::CellMetric::CONDITION:
metricValue =
vtkm::worklet::cellmetrics::CellConditionMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::DIAGONAL_RATIO:
case vtkm::filter::mesh_info::CellMetric::DIAGONAL_RATIO:
metricValue =
vtkm::worklet::cellmetrics::CellDiagonalRatioMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::DIMENSION:
case vtkm::filter::mesh_info::CellMetric::DIMENSION:
metricValue =
vtkm::worklet::cellmetrics::CellDimensionMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::JACOBIAN:
case vtkm::filter::mesh_info::CellMetric::JACOBIAN:
metricValue =
vtkm::worklet::cellmetrics::CellJacobianMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::MAX_ANGLE:
case vtkm::filter::mesh_info::CellMetric::MAX_ANGLE:
metricValue =
vtkm::worklet::cellmetrics::CellMaxAngleMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::MAX_DIAGONAL:
case vtkm::filter::mesh_info::CellMetric::MAX_DIAGONAL:
metricValue =
vtkm::worklet::cellmetrics::CellMaxDiagonalMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::MIN_ANGLE:
case vtkm::filter::mesh_info::CellMetric::MIN_ANGLE:
metricValue =
vtkm::worklet::cellmetrics::CellMinAngleMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::MIN_DIAGONAL:
case vtkm::filter::mesh_info::CellMetric::MIN_DIAGONAL:
metricValue =
vtkm::worklet::cellmetrics::CellMinDiagonalMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::ODDY:
case vtkm::filter::mesh_info::CellMetric::ODDY:
metricValue = vtkm::worklet::cellmetrics::CellOddyMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::RELATIVE_SIZE_SQUARED:
case vtkm::filter::mesh_info::CellMetric::RELATIVE_SIZE_SQUARED:
metricValue = vtkm::worklet::cellmetrics::CellRelativeSizeSquaredMetric<OutType>(
numPts, pts, static_cast<OutType>(average), tag, ec);
break;
case MetricTagType::SHAPE_AND_SIZE:
case vtkm::filter::mesh_info::CellMetric::SHAPE_AND_SIZE:
metricValue = vtkm::worklet::cellmetrics::CellShapeAndSizeMetric<OutType>(
numPts, pts, static_cast<OutType>(average), tag, ec);
break;
case MetricTagType::SCALED_JACOBIAN:
case vtkm::filter::mesh_info::CellMetric::SCALED_JACOBIAN:
metricValue =
vtkm::worklet::cellmetrics::CellScaledJacobianMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::SHAPE:
case vtkm::filter::mesh_info::CellMetric::SHAPE:
metricValue = vtkm::worklet::cellmetrics::CellShapeMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::SHEAR:
case vtkm::filter::mesh_info::CellMetric::SHEAR:
metricValue = vtkm::worklet::cellmetrics::CellShearMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::SKEW:
case vtkm::filter::mesh_info::CellMetric::SKEW:
metricValue = vtkm::worklet::cellmetrics::CellSkewMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::STRETCH:
case vtkm::filter::mesh_info::CellMetric::STRETCH:
metricValue =
vtkm::worklet::cellmetrics::CellStretchMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::TAPER:
case vtkm::filter::mesh_info::CellMetric::TAPER:
metricValue = vtkm::worklet::cellmetrics::CellTaperMetric<OutType>(numPts, pts, tag, ec);
break;
case MetricTagType::VOLUME:
case vtkm::filter::mesh_info::CellMetric::VOLUME:
metricValue = vtkm::exec::CellMeasure<OutType>(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<OutType>(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

@ -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);

@ -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);

@ -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
{

@ -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
{

@ -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

@ -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)

@ -17,7 +17,6 @@ set(unit_tests
UnitTestAverageByKey.cxx
UnitTestBoundingIntervalHierarchy.cxx
UnitTestCellDeepCopy.cxx
UnitTestCellMeasure.cxx
UnitTestContourTreeUniform.cxx
UnitTestContourTreeUniformAugmented.cxx
UnitTestContourTreeUniformDistributed.cxx

@ -11,7 +11,7 @@
#include <vtkm/cont/DataSetBuilderExplicit.h>
#include <vtkm/cont/DataSetBuilderRectilinear.h>
#include <vtkm/cont/DataSetBuilderUniform.h>
#include <vtkm/filter/GhostCellClassify.h>
#include <vtkm/filter/mesh_info/GhostCellClassify.h>
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;

@ -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 <vtkm/worklet/CellMeasure.h>
#include <vtkm/worklet/DispatcherMapTopology.h>
#include <vtkm/cont/testing/MakeTestDataSet.h>
#include <vtkm/cont/testing/Testing.h>
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<vtkm::FloatDefault> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellMeasure<vtkm::Volume>> 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 <typename IntegrationType>
void TestCellMeasureWorklet(vtkm::cont::DataSet& dataset,
const char* msg,
const std::vector<vtkm::Float32>& expected,
const IntegrationType&)
{
std::cout << "Testing CellMeasures Filter on " << msg << "\n";
vtkm::cont::ArrayHandle<vtkm::FloatDefault> result;
vtkm::worklet::DispatcherMapTopology<vtkm::worklet::CellMeasure<IntegrationType>> dispatcher;
dispatcher.Invoke(
dataset.GetCellSet(), dataset.GetCoordinateSystem().GetDataAsMultiplexer(), result);
VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
"Wrong number of values in the output array");
for (unsigned int i = 0; i < static_cast<unsigned int>(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);
}

@ -13,7 +13,7 @@
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/GhostCellClassify.h>
#include <vtkm/filter/mesh_info/GhostCellClassify.h>
#include <vtkm/io/VTKDataSetReader.h>
#include <vtkm/worklet/ParticleAdvection.h>
#include <vtkm/worklet/particleadvection/EulerIntegrator.h>