Rename ghost cell filters.

This commit is contained in:
Dave Pugmire 2019-03-25 09:08:16 -04:00
parent 256e0c3c11
commit 83e81c5e0b
8 changed files with 79 additions and 77 deletions

@ -19,7 +19,6 @@
##============================================================================
set(headers
AddGhostZone.h
CellAverage.h
CellMeasures.h
CleanGrid.h
@ -44,7 +43,8 @@ set(headers
FilterDataSetWithField.h
FilterField.h
FilterTraits.h
GhostZone.h
GhostCellClassify.h
GhostCellRemove.h
Gradient.h
Histogram.h
Lagrangian.h
@ -80,7 +80,6 @@ set(headers
)
set(header_template_sources
AddGhostZone.hxx
CellAverage.hxx
CellMeasures.hxx
CleanGrid.hxx
@ -102,7 +101,8 @@ set(header_template_sources
FilterDataSet.hxx
FilterDataSetWithField.hxx
FilterField.hxx
GhostZone.hxx
GhostCellClassify.hxx
GhostCellRemove.hxx
Gradient.hxx
Histogram.hxx
Lagrangian.hxx

@ -17,8 +17,8 @@
// Laboratory (LANL), the U.S. Government retains certain rights in
// this software.
//============================================================================
#ifndef vtk_m_filter_AddGhostZone_h
#define vtk_m_filter_AddGhostZone_h
#ifndef vtk_m_filter_GhostCellClassify_h
#define vtk_m_filter_GhostCellClassify_h
#include <vtkm/filter/FilterDataSet.h>
@ -27,16 +27,16 @@ namespace vtkm
namespace filter
{
struct AddGhostZonePolicy : vtkm::filter::PolicyBase<AddGhostZonePolicy>
struct GhostCellClassifyPolicy : vtkm::filter::PolicyBase<GhostCellClassifyPolicy>
{
using FieldTypeList = vtkm::ListTagBase<vtkm::UInt8>;
};
class AddGhostZone : public vtkm::filter::FilterDataSet<AddGhostZone>
class GhostCellClassify : public vtkm::filter::FilterDataSet<GhostCellClassify>
{
public:
VTKM_CONT
AddGhostZone();
GhostCellClassify();
template <typename Policy>
VTKM_CONT vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData,
@ -53,6 +53,6 @@ private:
}
} // namespace vtkm::filter
#include <vtkm/filter/AddGhostZone.hxx>
#include <vtkm/filter/GhostCellClassify.hxx>
#endif //vtk_m_filter_AddGhostZone_h
#endif //vtk_m_filter_GhostCellClassify_h

@ -36,10 +36,10 @@ struct TypeUInt8 : vtkm::ListTagBase<vtkm::UInt8>
{
};
class SetStructuredGhostZones1D : public vtkm::worklet::WorkletMapField
class SetStructuredGhostCells1D : public vtkm::worklet::WorkletMapField
{
public:
SetStructuredGhostZones1D(const vtkm::Id& dim, const vtkm::Id& numLayers = 1)
SetStructuredGhostCells1D(const vtkm::Id& dim, const vtkm::Id& numLayers = 1)
: Dim(dim)
, NumLayers(numLayers)
, Range(NumLayers, Dim - NumLayers)
@ -65,10 +65,10 @@ private:
static_cast<vtkm::UInt8>(vtkm::CellClassification::GHOST);
};
class SetStructuredGhostZones2D : public vtkm::worklet::WorkletMapField
class SetStructuredGhostCells2D : public vtkm::worklet::WorkletMapField
{
public:
SetStructuredGhostZones2D(const vtkm::Id2& dims, const vtkm::Id& numLayers = 1)
SetStructuredGhostCells2D(const vtkm::Id2& dims, const vtkm::Id& numLayers = 1)
: Dims(dims)
, NumLayers(numLayers)
, Range(NumLayers, Dims[0] - NumLayers, NumLayers, Dims[1] - NumLayers)
@ -96,10 +96,10 @@ private:
static_cast<vtkm::UInt8>(vtkm::CellClassification::GHOST);
};
class SetStructuredGhostZones3D : public vtkm::worklet::WorkletMapField
class SetStructuredGhostCells3D : public vtkm::worklet::WorkletMapField
{
public:
SetStructuredGhostZones3D(const vtkm::Id3& dims, const vtkm::Id& numLayers = 1)
SetStructuredGhostCells3D(const vtkm::Id3& dims, const vtkm::Id& numLayers = 1)
: Dims(dims)
, NumLayers(numLayers)
, Range(NumLayers,
@ -139,13 +139,13 @@ namespace vtkm
namespace filter
{
inline VTKM_CONT AddGhostZone::AddGhostZone()
inline VTKM_CONT GhostCellClassify::GhostCellClassify()
{
}
template <typename Policy>
inline VTKM_CONT vtkm::cont::DataSet AddGhostZone::DoExecute(const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<Policy>)
inline VTKM_CONT vtkm::cont::DataSet GhostCellClassify::DoExecute(const vtkm::cont::DataSet& input,
vtkm::filter::PolicyBase<Policy>)
{
const vtkm::cont::DynamicCellSet& cellset = input.GetCellSet(this->GetActiveCellSetIndex());
vtkm::Id numCells = cellset.GetNumberOfCells();
@ -158,35 +158,35 @@ inline VTKM_CONT vtkm::cont::DataSet AddGhostZone::DoExecute(const vtkm::cont::D
if (cellset.template IsType<vtkm::cont::CellSetStructured<1>>())
{
if (numCells <= 2)
throw vtkm::cont::ErrorFilterExecution("insufficient number of cells for AddGhostZone.");
throw vtkm::cont::ErrorFilterExecution("insufficient number of cells for GhostCellClassify.");
vtkm::cont::CellSetStructured<1> cellset1d = cellset.Cast<vtkm::cont::CellSetStructured<1>>();
SetStructuredGhostZones1D structuredGhosts1D(cellset1d.GetCellDimensions());
vtkm::worklet::DispatcherMapField<SetStructuredGhostZones1D> dispatcher(structuredGhosts1D);
SetStructuredGhostCells1D structuredGhosts1D(cellset1d.GetCellDimensions());
vtkm::worklet::DispatcherMapField<SetStructuredGhostCells1D> dispatcher(structuredGhosts1D);
dispatcher.Invoke(indexArray, ghosts);
}
else if (cellset.template IsType<vtkm::cont::CellSetStructured<2>>())
{
if (numCells <= 4)
throw vtkm::cont::ErrorFilterExecution("insufficient number of cells for AddGhostZone.");
throw vtkm::cont::ErrorFilterExecution("insufficient number of cells for GhostCellClassify.");
vtkm::cont::CellSetStructured<2> cellset2d = cellset.Cast<vtkm::cont::CellSetStructured<2>>();
SetStructuredGhostZones2D structuredGhosts2D(cellset2d.GetCellDimensions());
vtkm::worklet::DispatcherMapField<SetStructuredGhostZones2D> dispatcher(structuredGhosts2D);
SetStructuredGhostCells2D structuredGhosts2D(cellset2d.GetCellDimensions());
vtkm::worklet::DispatcherMapField<SetStructuredGhostCells2D> dispatcher(structuredGhosts2D);
dispatcher.Invoke(indexArray, ghosts);
}
else if (cellset.template IsType<vtkm::cont::CellSetStructured<3>>())
{
if (numCells <= 8)
throw vtkm::cont::ErrorFilterExecution("insufficient number of cells for AddGhostZone.");
throw vtkm::cont::ErrorFilterExecution("insufficient number of cells for GhostCellClassify.");
vtkm::cont::CellSetStructured<3> cellset3d = cellset.Cast<vtkm::cont::CellSetStructured<3>>();
SetStructuredGhostZones3D structuredGhosts3D(cellset3d.GetCellDimensions());
vtkm::worklet::DispatcherMapField<SetStructuredGhostZones3D> dispatcher(structuredGhosts3D);
SetStructuredGhostCells3D structuredGhosts3D(cellset3d.GetCellDimensions());
vtkm::worklet::DispatcherMapField<SetStructuredGhostCells3D> dispatcher(structuredGhosts3D);
dispatcher.Invoke(indexArray, ghosts);
}
else
throw vtkm::cont::ErrorFilterExecution("Unsupported cellset type for AddGhostZone.");
throw vtkm::cont::ErrorFilterExecution("Unsupported cellset type for GhostCellClassify.");
vtkm::cont::DataSet output = internal::CreateResult(
input, ghosts, "vtkmGhostCells", vtkm::cont::Field::Association::CELL_SET, cellset.GetName());
@ -194,10 +194,11 @@ inline VTKM_CONT vtkm::cont::DataSet AddGhostZone::DoExecute(const vtkm::cont::D
}
template <typename ValueType, typename Storage, typename Policy>
inline VTKM_CONT bool AddGhostZone::DoMapField(vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<ValueType, Storage>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<Policy>)
inline VTKM_CONT bool GhostCellClassify::DoMapField(
vtkm::cont::DataSet&,
const vtkm::cont::ArrayHandle<ValueType, Storage>&,
const vtkm::filter::FieldMetadata&,
vtkm::filter::PolicyBase<Policy>)
{
return true;
}

@ -18,8 +18,8 @@
// this software.
//============================================================================
#ifndef vtk_m_filter_GhostZone_h
#define vtk_m_filter_GhostZone_h
#ifndef vtk_m_filter_GhostCellRemove_h
#define vtk_m_filter_GhostCellRemove_h
#include <vtkm/CellClassification.h>
#include <vtkm/filter/FilterDataSetWithField.h>
@ -30,18 +30,18 @@ namespace vtkm
namespace filter
{
struct GhostZonePolicy : vtkm::filter::PolicyBase<GhostZonePolicy>
struct GhostCellRemovePolicy : vtkm::filter::PolicyBase<GhostCellRemovePolicy>
{
using FieldTypeList = vtkm::ListTagBase<vtkm::UInt8>;
};
/// \brief Removes ghost zones
///
class GhostZone : public vtkm::filter::FilterDataSetWithField<GhostZone>
class GhostCellRemove : public vtkm::filter::FilterDataSetWithField<GhostCellRemove>
{
public:
VTKM_CONT
GhostZone();
GhostCellRemove();
VTKM_CONT
void RemoveGhostField() { this->RemoveField = true; }
@ -94,7 +94,7 @@ private:
};
template <>
class FilterTraits<GhostZone>
class FilterTraits<GhostCellRemove>
{ //currently the ghostzone filter only works on uint8 data.
public:
using InputFieldTypeList = vtkm::ListTagBase<vtkm::UInt8>;
@ -102,6 +102,6 @@ public:
}
} // namespace vtkm::filter
#include <vtkm/filter/GhostZone.hxx>
#include <vtkm/filter/GhostCellRemove.hxx>
#endif // vtk_m_filter_GhostZone_h
#endif // vtk_m_filter_GhostCellRemove_h

@ -302,8 +302,8 @@ namespace filter
{
//-----------------------------------------------------------------------------
inline VTKM_CONT GhostZone::GhostZone()
: vtkm::filter::FilterDataSetWithField<GhostZone>()
inline VTKM_CONT GhostCellRemove::GhostCellRemove()
: vtkm::filter::FilterDataSetWithField<GhostCellRemove>()
, RemoveAll(false)
, RemoveField(false)
, ConvertToUnstructured(false)
@ -315,7 +315,7 @@ inline VTKM_CONT GhostZone::GhostZone()
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT vtkm::cont::DataSet GhostZone::DoExecute(
inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
const vtkm::cont::DataSet& input,
const vtkm::cont::ArrayHandle<T, StorageType>& field,
const vtkm::filter::FieldMetadata& fieldMeta,
@ -344,7 +344,7 @@ inline VTKM_CONT vtkm::cont::DataSet GhostZone::DoExecute(
extract.SetFieldsToPass(this->GetActiveFieldName(),
vtkm::filter::FieldSelection::MODE_EXCLUDE);
auto output = extract.Execute(input, vtkm::filter::GhostZonePolicy());
auto output = extract.Execute(input, vtkm::filter::GhostCellRemovePolicy());
return output;
}
}
@ -379,10 +379,11 @@ inline VTKM_CONT vtkm::cont::DataSet GhostZone::DoExecute(
//-----------------------------------------------------------------------------
template <typename T, typename StorageType, typename DerivedPolicy>
inline VTKM_CONT bool GhostZone::DoMapField(vtkm::cont::DataSet& result,
const vtkm::cont::ArrayHandle<T, StorageType>& input,
const vtkm::filter::FieldMetadata& fieldMeta,
vtkm::filter::PolicyBase<DerivedPolicy>)
inline VTKM_CONT bool GhostCellRemove::DoMapField(
vtkm::cont::DataSet& result,
const vtkm::cont::ArrayHandle<T, StorageType>& input,
const vtkm::filter::FieldMetadata& fieldMeta,
vtkm::filter::PolicyBase<DerivedPolicy>)
{
if (fieldMeta.IsPointField())
{
@ -402,7 +403,7 @@ inline VTKM_CONT bool GhostZone::DoMapField(vtkm::cont::DataSet& result,
}
}
inline VTKM_CONT vtkm::cont::CellSetExplicit<> GhostZone::ConvertOutputToUnstructured(
inline VTKM_CONT vtkm::cont::CellSetExplicit<> GhostCellRemove::ConvertOutputToUnstructured(
vtkm::cont::DynamicCellSet& inCells)
{
using PermStructured2d = vtkm::cont::CellSetPermutation<vtkm::cont::CellSetStructured<2>>;

@ -19,7 +19,6 @@
##============================================================================
set(unit_tests
UnitTestAddGhostZone.cxx
UnitTestCellAverageFilter.cxx
UnitTestCellMeasuresFilter.cxx
UnitTestCleanGrid.cxx
@ -39,7 +38,8 @@ set(unit_tests
UnitTestFieldSelection.cxx
UnitTestFieldToColors.cxx
UnitTestGradient.cxx
UnitTestGhostZone.cxx
UnitTestGhostCellClassify.cxx
UnitTestGhostCellRemove.cxx
UnitTestHistogramFilter.cxx
UnitTestLagrangianFilter.cxx
UnitTestMarchingCubesFilter.cxx

@ -25,7 +25,7 @@
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/AddGhostZone.h>
#include <vtkm/filter/GhostCellClassify.h>
namespace
{
@ -111,9 +111,9 @@ void TestStructured()
else if (dsType == "rectilinear")
ds = MakeRectilinear(nx, ny, nz);
vtkm::filter::AddGhostZone addGhost;
vtkm::filter::GhostCellClassify addGhost;
auto output = addGhost.Execute(ds, vtkm::filter::AddGhostZonePolicy());
auto output = addGhost.Execute(ds, vtkm::filter::GhostCellClassifyPolicy());
//Validate the output.
VTKM_TEST_ASSERT(output.GetNumberOfCellSets() == 1, "Wrong number of cell sets in output");
@ -148,13 +148,13 @@ void TestStructured()
}
}
void TestAddGhostZone()
void TestGhostCellClassify()
{
TestStructured();
}
}
int UnitTestAddGhostZone(int argc, char* argv[])
int UnitTestGhostCellClassify(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(TestAddGhostZone, argc, argv);
return vtkm::cont::testing::Testing::Run(TestGhostCellClassify, argc, argv);
}

@ -25,7 +25,7 @@
#include <vtkm/cont/DataSetFieldAdd.h>
#include <vtkm/cont/testing/Testing.h>
#include <vtkm/filter/GhostZone.h>
#include <vtkm/filter/GhostCellRemove.h>
#include <vtkm/io/writer/VTKDataSetWriter.h>
@ -33,7 +33,7 @@
namespace
{
static vtkm::cont::ArrayHandle<vtkm::UInt8> StructuredGhostZoneArray(vtkm::Id nx,
static vtkm::cont::ArrayHandle<vtkm::UInt8> StructuredGhostCellArray(vtkm::Id nx,
vtkm::Id ny,
vtkm::Id nz,
int numLayers,
@ -107,7 +107,7 @@ static vtkm::cont::DataSet MakeUniform(vtkm::Id numI,
ds = dsb.Create(vtkm::Id2(numI + 1, numJ + 1));
else
ds = dsb.Create(vtkm::Id3(numI + 1, numJ + 1, numK + 1));
auto ghosts = StructuredGhostZoneArray(numI, numJ, numK, numLayers, addMidGhost);
auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers, addMidGhost);
vtkm::cont::DataSetFieldAdd dsf;
dsf.AddCellField(ds, "vtkmGhostCells", ghosts);
@ -143,7 +143,7 @@ static vtkm::cont::DataSet MakeRectilinear(vtkm::Id numI,
ds = dsb.Create(x, y, z);
}
auto ghosts = StructuredGhostZoneArray(numI, numJ, numK, numLayers, addMidGhost);
auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers, addMidGhost);
vtkm::cont::DataSetFieldAdd dsf;
dsf.AddCellField(ds, "vtkmGhostCells", ghosts);
@ -221,7 +221,7 @@ static vtkm::cont::DataSet MakeExplicit(vtkm::Id numI, vtkm::Id numJ, vtkm::Id n
ds = dsb.Create(explCoords, vtkm::CellShapeTagHexahedron(), 8, conn, "coordinates", "cells");
}
auto ghosts = StructuredGhostZoneArray(numI, numJ, numK, numLayers);
auto ghosts = StructuredGhostCellArray(numI, numJ, numK, numLayers);
vtkm::cont::DataSetFieldAdd dsf;
dsf.AddCellField(ds, "vtkmGhostCells", ghosts);
@ -229,7 +229,7 @@ static vtkm::cont::DataSet MakeExplicit(vtkm::Id numI, vtkm::Id numJ, vtkm::Id n
return ds;
}
void TestGhostZone()
void TestGhostCellRemove()
{
// specify some 2d tests: {numI, numJ, numK, numGhostLayers}.
std::vector<std::vector<vtkm::Id>> tests2D = { { 4, 4, 0, 2 }, { 5, 5, 0, 2 }, { 10, 10, 0, 3 },
@ -265,22 +265,22 @@ void TestGhostZone()
std::vector<std::string> removeType = { "all", "byType" };
for (auto& rt : removeType)
{
vtkm::filter::GhostZone ghostZoneRemoval;
ghostZoneRemoval.RemoveGhostField();
vtkm::filter::GhostCellRemove ghostCellRemoval;
ghostCellRemoval.RemoveGhostField();
if (rt == "all")
ghostZoneRemoval.RemoveAllGhost();
ghostCellRemoval.RemoveAllGhost();
else if (rt == "byType")
ghostZoneRemoval.RemoveByType(
ghostCellRemoval.RemoveByType(
static_cast<vtkm::UInt8>(vtkm::CellClassification::GHOST));
std::vector<std::string> outputType = { "permutation", "explicit" };
for (auto& ot : outputType)
{
if (ot == "explicit")
ghostZoneRemoval.ConvertOutputToUnstructured();
ghostCellRemoval.ConvertOutputToUnstructured();
auto output = ghostZoneRemoval.Execute(ds, vtkm::filter::GhostZonePolicy());
auto output = ghostCellRemoval.Execute(ds, vtkm::filter::GhostCellRemovePolicy());
vtkm::Id numCells = output.GetCellSet(0).GetNumberOfCells();
//Validate the output.
@ -317,10 +317,10 @@ void TestGhostZone()
else if (dsType == "rectilinear")
ds = MakeRectilinear(nx, ny, nz, layer, true);
vtkm::filter::GhostZone ghostZoneRemoval;
ghostZoneRemoval.RemoveGhostField();
ghostZoneRemoval.ConvertOutputToUnstructured();
auto output = ghostZoneRemoval.Execute(ds, vtkm::filter::GhostZonePolicy());
vtkm::filter::GhostCellRemove ghostCellRemoval;
ghostCellRemoval.RemoveGhostField();
ghostCellRemoval.ConvertOutputToUnstructured();
auto output = ghostCellRemoval.Execute(ds, vtkm::filter::GhostCellRemovePolicy());
VTKM_TEST_ASSERT(output.GetCellSet(0).IsType<vtkm::cont::CellSetExplicit<>>(),
"Wrong cell type for explicit conversion");
}
@ -330,7 +330,7 @@ void TestGhostZone()
}
}
int UnitTestGhostZone(int argc, char* argv[])
int UnitTestGhostCellRemove(int argc, char* argv[])
{
return vtkm::cont::testing::Testing::Run(TestGhostZone, argc, argv);
return vtkm::cont::testing::Testing::Run(TestGhostCellRemove, argc, argv);
}