2018-09-06 15:39:04 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2018-09-06 15:39:04 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
|
2019-08-21 19:00:38 +00:00
|
|
|
#ifndef vtk_m_filter_GhostCellRemove_hxx
|
|
|
|
#define vtk_m_filter_GhostCellRemove_hxx
|
|
|
|
#include <vtkm/filter/GhostCellRemove.h>
|
|
|
|
|
2018-09-06 15:39:04 +00:00
|
|
|
#include <vtkm/cont/ArrayHandleCounting.h>
|
|
|
|
#include <vtkm/cont/ArrayHandlePermutation.h>
|
|
|
|
#include <vtkm/cont/CellSetPermutation.h>
|
|
|
|
#include <vtkm/cont/DynamicCellSet.h>
|
|
|
|
|
2019-02-28 20:51:55 +00:00
|
|
|
#include <vtkm/RangeId3.h>
|
2019-02-26 21:45:01 +00:00
|
|
|
#include <vtkm/filter/ExtractStructured.h>
|
2020-02-06 21:58:59 +00:00
|
|
|
#include <vtkm/filter/MapFieldPermutation.h>
|
2018-09-06 15:39:04 +00:00
|
|
|
#include <vtkm/worklet/CellDeepCopy.h>
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
|
|
|
|
class RemoveAllGhosts
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VTKM_CONT
|
|
|
|
RemoveAllGhosts() {}
|
|
|
|
|
|
|
|
VTKM_EXEC bool operator()(const vtkm::UInt8& value) const { return (value == 0); }
|
|
|
|
};
|
|
|
|
|
|
|
|
class RemoveGhostByType
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VTKM_CONT
|
|
|
|
RemoveGhostByType()
|
|
|
|
: RemoveType(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
|
|
|
RemoveGhostByType(const vtkm::UInt8& val)
|
2018-09-06 17:07:27 +00:00
|
|
|
: RemoveType(static_cast<vtkm::UInt8>(~val))
|
2018-09-06 15:39:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_EXEC bool operator()(const vtkm::UInt8& value) const
|
|
|
|
{
|
|
|
|
return value == 0 || (value & RemoveType);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
vtkm::UInt8 RemoveType;
|
|
|
|
};
|
|
|
|
|
2019-02-26 21:45:01 +00:00
|
|
|
template <int DIMS>
|
2019-07-31 16:20:38 +00:00
|
|
|
VTKM_EXEC_CONT vtkm::Id3 getLogical(const vtkm::Id& index, const vtkm::Id3& cellDims);
|
2019-02-26 21:45:01 +00:00
|
|
|
|
|
|
|
template <>
|
2019-07-31 16:20:38 +00:00
|
|
|
VTKM_EXEC_CONT vtkm::Id3 getLogical<3>(const vtkm::Id& index, const vtkm::Id3& cellDims)
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Id3 res(0, 0, 0);
|
2019-02-26 21:45:01 +00:00
|
|
|
res[0] = index % cellDims[0];
|
|
|
|
res[1] = (index / (cellDims[0])) % (cellDims[1]);
|
|
|
|
res[2] = index / ((cellDims[0]) * (cellDims[1]));
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
2019-07-31 16:20:38 +00:00
|
|
|
VTKM_EXEC_CONT vtkm::Id3 getLogical<2>(const vtkm::Id& index, const vtkm::Id3& cellDims)
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Id3 res(0, 0, 0);
|
2019-02-26 21:45:01 +00:00
|
|
|
res[0] = index % cellDims[0];
|
|
|
|
res[1] = index / cellDims[0];
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
2019-07-31 16:20:38 +00:00
|
|
|
VTKM_EXEC_CONT vtkm::Id3 getLogical<1>(const vtkm::Id& index, const vtkm::Id3&)
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Id3 res(0, 0, 0);
|
2019-02-26 21:45:01 +00:00
|
|
|
res[0] = index;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <int DIMS>
|
|
|
|
class RealMinMax : public vtkm::worklet::WorkletMapField
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VTKM_CONT
|
2019-07-31 16:20:38 +00:00
|
|
|
RealMinMax(vtkm::Id3 cellDims, bool removeAllGhost, vtkm::UInt8 removeType)
|
2019-02-26 21:45:01 +00:00
|
|
|
: CellDims(cellDims)
|
|
|
|
, RemoveAllGhost(removeAllGhost)
|
|
|
|
, RemoveType(removeType)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef void ControlSignature(FieldIn, AtomicArrayInOut);
|
|
|
|
typedef void ExecutionSignature(_1, InputIndex, _2);
|
|
|
|
|
|
|
|
template <typename Atomic>
|
2019-02-28 20:51:55 +00:00
|
|
|
VTKM_EXEC void Max(Atomic& atom, const vtkm::Id& val, const vtkm::Id& index) const
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
|
|
|
vtkm::Id old = -1;
|
|
|
|
do
|
|
|
|
{
|
2019-02-28 20:51:55 +00:00
|
|
|
old = atom.CompareAndSwap(index, val, old);
|
2019-02-26 21:45:01 +00:00
|
|
|
} while (old < val);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename Atomic>
|
2019-02-28 20:51:55 +00:00
|
|
|
VTKM_EXEC void Min(Atomic& atom, const vtkm::Id& val, const vtkm::Id& index) const
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
2019-03-18 20:05:48 +00:00
|
|
|
vtkm::Id old = 1000000000;
|
2019-02-26 21:45:01 +00:00
|
|
|
do
|
|
|
|
{
|
2019-02-28 20:51:55 +00:00
|
|
|
old = atom.CompareAndSwap(index, val, old);
|
2019-02-26 21:45:01 +00:00
|
|
|
} while (old > val);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename AtomicType>
|
2019-02-28 20:51:55 +00:00
|
|
|
VTKM_EXEC void operator()(const T& value, const vtkm::Id& index, AtomicType& atom) const
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
2019-03-25 13:11:02 +00:00
|
|
|
// we are finding the logical min max of valid cells
|
2019-02-28 20:51:55 +00:00
|
|
|
if ((RemoveAllGhost && value != 0) || (!RemoveAllGhost && (value != 0 && value | RemoveType)))
|
2019-02-26 21:45:01 +00:00
|
|
|
return;
|
|
|
|
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Id3 logical = getLogical<DIMS>(index, CellDims);
|
2019-02-26 21:45:01 +00:00
|
|
|
|
2019-02-28 20:51:55 +00:00
|
|
|
Min(atom, logical[0], 0);
|
|
|
|
Min(atom, logical[1], 1);
|
|
|
|
Min(atom, logical[2], 2);
|
2019-02-26 21:45:01 +00:00
|
|
|
|
2019-02-28 20:51:55 +00:00
|
|
|
Max(atom, logical[0], 3);
|
|
|
|
Max(atom, logical[1], 4);
|
|
|
|
Max(atom, logical[2], 5);
|
2019-02-26 21:45:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Id3 CellDims;
|
2019-02-26 21:45:01 +00:00
|
|
|
bool RemoveAllGhost;
|
|
|
|
vtkm::UInt8 RemoveType;
|
|
|
|
};
|
|
|
|
|
2019-02-28 20:51:55 +00:00
|
|
|
template <int DIMS>
|
2019-07-31 16:20:38 +00:00
|
|
|
VTKM_EXEC_CONT bool checkRange(const vtkm::RangeId3& range, const vtkm::Id3& p);
|
2019-02-28 20:51:55 +00:00
|
|
|
|
|
|
|
template <>
|
2019-07-31 16:20:38 +00:00
|
|
|
VTKM_EXEC_CONT bool checkRange<1>(const vtkm::RangeId3& range, const vtkm::Id3& p)
|
2019-02-28 20:51:55 +00:00
|
|
|
{
|
|
|
|
return p[0] >= range.X.Min && p[0] <= range.X.Max;
|
|
|
|
}
|
|
|
|
template <>
|
2019-07-31 16:20:38 +00:00
|
|
|
VTKM_EXEC_CONT bool checkRange<2>(const vtkm::RangeId3& range, const vtkm::Id3& p)
|
2019-02-28 20:51:55 +00:00
|
|
|
{
|
|
|
|
return p[0] >= range.X.Min && p[0] <= range.X.Max && p[1] >= range.Y.Min && p[1] <= range.Y.Max;
|
|
|
|
}
|
|
|
|
template <>
|
2019-07-31 16:20:38 +00:00
|
|
|
VTKM_EXEC_CONT bool checkRange<3>(const vtkm::RangeId3& range, const vtkm::Id3& p)
|
2019-02-28 20:51:55 +00:00
|
|
|
{
|
|
|
|
return p[0] >= range.X.Min && p[0] <= range.X.Max && p[1] >= range.Y.Min && p[1] <= range.Y.Max &&
|
|
|
|
p[2] >= range.Z.Min && p[2] <= range.Z.Max;
|
|
|
|
}
|
|
|
|
|
2019-02-26 21:45:01 +00:00
|
|
|
template <int DIMS>
|
|
|
|
class Validate : public vtkm::worklet::WorkletMapField
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
VTKM_CONT
|
2019-07-31 16:20:38 +00:00
|
|
|
Validate(const vtkm::Id3& cellDims,
|
2019-02-26 21:45:01 +00:00
|
|
|
bool removeAllGhost,
|
|
|
|
vtkm::UInt8 removeType,
|
2019-02-28 20:51:55 +00:00
|
|
|
const vtkm::RangeId3& range)
|
2019-02-26 21:45:01 +00:00
|
|
|
: CellDims(cellDims)
|
|
|
|
, RemoveAll(removeAllGhost)
|
|
|
|
, RemoveVal(removeType)
|
2019-02-28 20:51:55 +00:00
|
|
|
, Range(range)
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef void ControlSignature(FieldIn, FieldOut);
|
|
|
|
typedef void ExecutionSignature(_1, InputIndex, _2);
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
VTKM_EXEC void operator()(const T& value, const vtkm::Id& index, vtkm::UInt8& valid) const
|
|
|
|
{
|
|
|
|
valid = 0;
|
|
|
|
if (RemoveAll && value == 0)
|
|
|
|
return;
|
2019-02-28 20:51:55 +00:00
|
|
|
else if (!RemoveAll && (value == 0 || (value & RemoveVal)))
|
2019-02-26 21:45:01 +00:00
|
|
|
return;
|
|
|
|
|
2019-02-28 20:51:55 +00:00
|
|
|
if (checkRange<DIMS>(Range, getLogical<DIMS>(index, CellDims)))
|
|
|
|
valid = static_cast<vtkm::UInt8>(1);
|
2019-02-26 21:45:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2019-07-31 16:20:38 +00:00
|
|
|
vtkm::Id3 CellDims;
|
2019-02-26 21:45:01 +00:00
|
|
|
bool RemoveAll;
|
|
|
|
vtkm::UInt8 RemoveVal;
|
2019-02-28 20:51:55 +00:00
|
|
|
vtkm::RangeId3 Range;
|
2019-02-26 21:45:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <int DIMS, typename T, typename StorageType>
|
|
|
|
bool CanStrip(const vtkm::cont::ArrayHandle<T, StorageType>& ghostField,
|
2019-08-07 16:54:47 +00:00
|
|
|
const vtkm::cont::Invoker& invoke,
|
2019-02-26 21:45:01 +00:00
|
|
|
bool removeAllGhost,
|
|
|
|
vtkm::UInt8 removeType,
|
2019-02-28 20:51:55 +00:00
|
|
|
vtkm::RangeId3& range,
|
2019-07-31 16:20:38 +00:00
|
|
|
const vtkm::Id3& cellDims,
|
2019-02-26 21:45:01 +00:00
|
|
|
vtkm::Id size)
|
|
|
|
{
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::Id> minmax;
|
|
|
|
minmax.Allocate(6);
|
2020-01-28 19:14:32 +00:00
|
|
|
minmax.WritePortal().Set(0, std::numeric_limits<vtkm::Id>::max());
|
|
|
|
minmax.WritePortal().Set(1, std::numeric_limits<vtkm::Id>::max());
|
|
|
|
minmax.WritePortal().Set(2, std::numeric_limits<vtkm::Id>::max());
|
|
|
|
minmax.WritePortal().Set(3, std::numeric_limits<vtkm::Id>::min());
|
|
|
|
minmax.WritePortal().Set(4, std::numeric_limits<vtkm::Id>::min());
|
|
|
|
minmax.WritePortal().Set(5, std::numeric_limits<vtkm::Id>::min());
|
2019-02-26 21:45:01 +00:00
|
|
|
|
2019-08-07 16:54:47 +00:00
|
|
|
invoke(RealMinMax<3>(cellDims, removeAllGhost, removeType), ghostField, minmax);
|
2019-02-26 21:45:01 +00:00
|
|
|
|
2020-01-28 19:14:32 +00:00
|
|
|
auto portal = minmax.ReadPortal();
|
2019-02-28 20:51:55 +00:00
|
|
|
range = vtkm::RangeId3(
|
|
|
|
portal.Get(0), portal.Get(3), portal.Get(1), portal.Get(4), portal.Get(2), portal.Get(5));
|
2019-02-26 21:45:01 +00:00
|
|
|
|
|
|
|
vtkm::cont::ArrayHandle<vtkm::UInt8> validFlags;
|
|
|
|
validFlags.Allocate(size);
|
|
|
|
|
2019-08-07 16:54:47 +00:00
|
|
|
invoke(Validate<DIMS>(cellDims, removeAllGhost, removeType, range), ghostField, validFlags);
|
2019-02-26 21:45:01 +00:00
|
|
|
|
|
|
|
vtkm::UInt8 res = vtkm::cont::Algorithm::Reduce(validFlags, vtkm::UInt8(0), vtkm::Maximum());
|
|
|
|
return res == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T, typename StorageType>
|
|
|
|
bool CanDoStructuredStrip(const vtkm::cont::DynamicCellSet& cells,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& ghostField,
|
2019-08-07 16:54:47 +00:00
|
|
|
const vtkm::cont::Invoker& invoke,
|
2019-02-26 21:45:01 +00:00
|
|
|
bool removeAllGhost,
|
|
|
|
vtkm::UInt8 removeType,
|
2019-02-28 20:51:55 +00:00
|
|
|
vtkm::RangeId3& range)
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
|
|
|
bool canDo = false;
|
|
|
|
vtkm::Id3 cellDims(1, 1, 1);
|
|
|
|
|
|
|
|
if (cells.IsSameType(vtkm::cont::CellSetStructured<1>()))
|
|
|
|
{
|
|
|
|
auto cells1D = cells.Cast<vtkm::cont::CellSetStructured<1>>();
|
|
|
|
vtkm::Id d = cells1D.GetCellDimensions();
|
|
|
|
cellDims[0] = d;
|
|
|
|
vtkm::Id sz = d;
|
|
|
|
|
2019-08-07 16:54:47 +00:00
|
|
|
canDo = CanStrip<1>(ghostField, invoke, removeAllGhost, removeType, range, cellDims, sz);
|
2019-02-26 21:45:01 +00:00
|
|
|
}
|
|
|
|
else if (cells.IsSameType(vtkm::cont::CellSetStructured<2>()))
|
|
|
|
{
|
|
|
|
auto cells2D = cells.Cast<vtkm::cont::CellSetStructured<2>>();
|
|
|
|
vtkm::Id2 d = cells2D.GetCellDimensions();
|
|
|
|
cellDims[0] = d[0];
|
|
|
|
cellDims[1] = d[1];
|
|
|
|
vtkm::Id sz = cellDims[0] * cellDims[1];
|
2019-08-07 16:54:47 +00:00
|
|
|
canDo = CanStrip<2>(ghostField, invoke, removeAllGhost, removeType, range, cellDims, sz);
|
2019-02-26 21:45:01 +00:00
|
|
|
}
|
|
|
|
else if (cells.IsSameType(vtkm::cont::CellSetStructured<3>()))
|
|
|
|
{
|
|
|
|
auto cells3D = cells.Cast<vtkm::cont::CellSetStructured<3>>();
|
|
|
|
cellDims = cells3D.GetCellDimensions();
|
|
|
|
vtkm::Id sz = cellDims[0] * cellDims[1] * cellDims[2];
|
2019-08-07 16:54:47 +00:00
|
|
|
canDo = CanStrip<3>(ghostField, invoke, removeAllGhost, removeType, range, cellDims, sz);
|
2019-02-26 21:45:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return canDo;
|
|
|
|
}
|
|
|
|
|
2018-09-06 15:39:04 +00:00
|
|
|
} // end anon namespace
|
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace filter
|
|
|
|
{
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2019-03-25 13:08:16 +00:00
|
|
|
inline VTKM_CONT GhostCellRemove::GhostCellRemove()
|
|
|
|
: vtkm::filter::FilterDataSetWithField<GhostCellRemove>()
|
2018-09-06 15:39:04 +00:00
|
|
|
, RemoveAll(false)
|
2019-02-28 20:51:55 +00:00
|
|
|
, RemoveField(false)
|
2018-09-06 15:39:04 +00:00
|
|
|
, RemoveVals(0)
|
|
|
|
{
|
|
|
|
this->SetActiveField("vtkmGhostCells");
|
2019-02-28 20:51:55 +00:00
|
|
|
this->SetFieldsToPass("vtkmGhostCells", vtkm::filter::FieldSelection::MODE_EXCLUDE);
|
2018-09-06 15:39:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2018-08-30 15:53:18 +00:00
|
|
|
template <typename T, typename StorageType, typename DerivedPolicy>
|
2019-03-25 13:08:16 +00:00
|
|
|
inline VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(
|
2018-09-06 15:39:04 +00:00
|
|
|
const vtkm::cont::DataSet& input,
|
|
|
|
const vtkm::cont::ArrayHandle<T, StorageType>& field,
|
|
|
|
const vtkm::filter::FieldMetadata& fieldMeta,
|
2018-08-30 15:53:18 +00:00
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy> policy)
|
2018-09-06 15:39:04 +00:00
|
|
|
{
|
|
|
|
//get the cells and coordinates of the dataset
|
2019-08-13 17:08:54 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& cells = input.GetCellSet();
|
2018-09-06 15:39:04 +00:00
|
|
|
vtkm::cont::DynamicCellSet cellOut;
|
|
|
|
|
2019-02-28 20:51:55 +00:00
|
|
|
//Preserve structured output where possible.
|
2019-02-26 21:45:01 +00:00
|
|
|
if (cells.IsSameType(vtkm::cont::CellSetStructured<1>()) ||
|
|
|
|
cells.IsSameType(vtkm::cont::CellSetStructured<2>()) ||
|
|
|
|
cells.IsSameType(vtkm::cont::CellSetStructured<3>()))
|
|
|
|
{
|
2019-02-28 20:51:55 +00:00
|
|
|
vtkm::RangeId3 range;
|
2019-08-07 16:54:47 +00:00
|
|
|
if (CanDoStructuredStrip(
|
|
|
|
cells, field, this->Invoke, this->GetRemoveAllGhost(), this->GetRemoveType(), range))
|
2019-02-26 21:45:01 +00:00
|
|
|
{
|
|
|
|
vtkm::filter::ExtractStructured extract;
|
2019-08-07 16:54:47 +00:00
|
|
|
extract.SetInvoker(this->Invoke);
|
2019-02-28 20:51:55 +00:00
|
|
|
vtkm::RangeId3 erange(
|
|
|
|
range.X.Min, range.X.Max + 2, range.Y.Min, range.Y.Max + 2, range.Z.Min, range.Z.Max + 2);
|
2019-02-26 21:45:01 +00:00
|
|
|
vtkm::Id3 sample(1, 1, 1);
|
2019-02-28 20:51:55 +00:00
|
|
|
extract.SetVOI(erange);
|
2019-02-26 21:45:01 +00:00
|
|
|
extract.SetSampleRate(sample);
|
2019-02-28 20:51:55 +00:00
|
|
|
if (this->GetRemoveGhostField())
|
|
|
|
extract.SetFieldsToPass(this->GetActiveFieldName(),
|
|
|
|
vtkm::filter::FieldSelection::MODE_EXCLUDE);
|
|
|
|
|
2019-09-09 13:39:23 +00:00
|
|
|
auto output = extract.Execute(input);
|
2019-02-26 21:45:01 +00:00
|
|
|
return output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-06 15:39:04 +00:00
|
|
|
if (this->GetRemoveAllGhost())
|
2019-08-21 19:00:38 +00:00
|
|
|
{
|
2020-05-15 23:47:30 +00:00
|
|
|
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
2018-09-06 15:39:04 +00:00
|
|
|
field,
|
|
|
|
fieldMeta.GetAssociation(),
|
2018-08-30 15:53:18 +00:00
|
|
|
RemoveAllGhosts());
|
2019-08-21 19:00:38 +00:00
|
|
|
}
|
2018-09-06 15:39:04 +00:00
|
|
|
else if (this->GetRemoveByType())
|
2019-08-21 19:00:38 +00:00
|
|
|
{
|
2020-05-15 23:47:30 +00:00
|
|
|
cellOut = this->Worklet.Run(vtkm::filter::ApplyPolicyCellSet(cells, policy, *this),
|
2018-09-06 15:39:04 +00:00
|
|
|
field,
|
|
|
|
fieldMeta.GetAssociation(),
|
2018-08-30 15:53:18 +00:00
|
|
|
RemoveGhostByType(this->GetRemoveType()));
|
2019-08-21 19:00:38 +00:00
|
|
|
}
|
2018-09-06 15:39:04 +00:00
|
|
|
else
|
2019-08-21 19:00:38 +00:00
|
|
|
{
|
2018-09-06 15:39:04 +00:00
|
|
|
throw vtkm::cont::ErrorFilterExecution("Unsupported ghost cell removal type");
|
2019-08-21 19:00:38 +00:00
|
|
|
}
|
2018-09-06 15:39:04 +00:00
|
|
|
|
|
|
|
vtkm::cont::DataSet output;
|
|
|
|
output.AddCoordinateSystem(input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex()));
|
2019-08-13 17:08:54 +00:00
|
|
|
output.SetCellSet(cellOut);
|
2018-09-06 15:39:04 +00:00
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2020-02-06 21:58:59 +00:00
|
|
|
template <typename DerivedPolicy>
|
|
|
|
VTKM_CONT bool GhostCellRemove::MapFieldOntoOutput(vtkm::cont::DataSet& result,
|
|
|
|
const vtkm::cont::Field& field,
|
|
|
|
vtkm::filter::PolicyBase<DerivedPolicy>)
|
2018-09-06 15:39:04 +00:00
|
|
|
{
|
2020-02-06 21:58:59 +00:00
|
|
|
if (field.IsFieldPoint())
|
2018-09-06 15:39:04 +00:00
|
|
|
{
|
|
|
|
//we copy the input handle to the result dataset, reusing the metadata
|
2020-02-06 21:58:59 +00:00
|
|
|
result.AddField(field);
|
2018-09-06 15:39:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-02-06 21:58:59 +00:00
|
|
|
else if (field.IsFieldCell())
|
2018-09-06 15:39:04 +00:00
|
|
|
{
|
2020-02-06 21:58:59 +00:00
|
|
|
return vtkm::filter::MapFieldPermutation(field, this->Worklet.GetValidCellIds(), result);
|
2018-09-06 15:39:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-21 19:00:38 +00:00
|
|
|
|
|
|
|
#endif //vtk_m_filter_GhostCellRemove_hxx
|