mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-08 03:18:58 +00:00
Introduce vtkm::ErrorCode
This is a flag that functions in the execution environment can return to report on the status of the operation. This way they can report an error without forcing the entire invocation to shut down.
This commit is contained in:
parent
04edc3d202
commit
51e817adc1
@ -27,6 +27,7 @@ set(headers
|
||||
CellShape.h
|
||||
CellTraits.h
|
||||
Deprecated.h
|
||||
ErrorCode.h
|
||||
Flags.h
|
||||
Geometry.h
|
||||
Hash.h
|
||||
|
118
vtkm/ErrorCode.h
Normal file
118
vtkm/ErrorCode.h
Normal file
@ -0,0 +1,118 @@
|
||||
//============================================================================
|
||||
// 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_exec_ErrorCode_h
|
||||
#define vtk_m_exec_ErrorCode_h
|
||||
|
||||
#include <lcl/ErrorCode.h>
|
||||
|
||||
#include <vtkm/internal/ExportMacros.h>
|
||||
namespace vtkm
|
||||
{
|
||||
|
||||
enum class ErrorCode
|
||||
{
|
||||
Success,
|
||||
InvalidShapeId,
|
||||
InvalidNumberOfPoints,
|
||||
WrongShapeIdForTagType,
|
||||
InvalidPointId,
|
||||
InvalidEdgeId,
|
||||
InvalidFaceId,
|
||||
SolutionDidNotConverge,
|
||||
MatrixFactorizationFailed,
|
||||
DegenerateCellDetected,
|
||||
MalformedCellDetected,
|
||||
OperationOnEmptyCell,
|
||||
CellNotFound,
|
||||
|
||||
UnknownError
|
||||
};
|
||||
|
||||
VTKM_EXEC_CONT
|
||||
inline const char* ErrorString(vtkm::ErrorCode code) noexcept
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case vtkm::ErrorCode::Success:
|
||||
return "Success";
|
||||
case vtkm::ErrorCode::InvalidShapeId:
|
||||
return "Invalid shape id";
|
||||
case vtkm::ErrorCode::InvalidNumberOfPoints:
|
||||
return "Invalid number of points";
|
||||
case vtkm::ErrorCode::WrongShapeIdForTagType:
|
||||
return "Wrong shape id for tag type";
|
||||
case vtkm::ErrorCode::InvalidPointId:
|
||||
return "Invalid point id";
|
||||
case vtkm::ErrorCode::InvalidEdgeId:
|
||||
return "Invalid edge id";
|
||||
case vtkm::ErrorCode::InvalidFaceId:
|
||||
return "Invalid face id";
|
||||
case vtkm::ErrorCode::SolutionDidNotConverge:
|
||||
return "Solution did not converge";
|
||||
case vtkm::ErrorCode::MatrixFactorizationFailed:
|
||||
return "Matrix factorization failed";
|
||||
case vtkm::ErrorCode::DegenerateCellDetected:
|
||||
return "Degenerate cell detected";
|
||||
case vtkm::ErrorCode::MalformedCellDetected:
|
||||
return "Malformed cell detected";
|
||||
case vtkm::ErrorCode::OperationOnEmptyCell:
|
||||
return "Operation on empty cell";
|
||||
case vtkm::ErrorCode::CellNotFound:
|
||||
return "Cell not found";
|
||||
case vtkm::ErrorCode::UnknownError:
|
||||
return "Unknown error";
|
||||
}
|
||||
|
||||
return "Invalid error";
|
||||
}
|
||||
|
||||
namespace internal
|
||||
{
|
||||
|
||||
VTKM_EXEC_CONT inline vtkm::ErrorCode LclErrorToVtkmError(lcl::ErrorCode code) noexcept
|
||||
{
|
||||
switch (code)
|
||||
{
|
||||
case lcl::ErrorCode::SUCCESS:
|
||||
return vtkm::ErrorCode::Success;
|
||||
case lcl::ErrorCode::INVALID_SHAPE_ID:
|
||||
return vtkm::ErrorCode::InvalidShapeId;
|
||||
case lcl::ErrorCode::INVALID_NUMBER_OF_POINTS:
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
case lcl::ErrorCode::WRONG_SHAPE_ID_FOR_TAG_TYPE:
|
||||
return vtkm::ErrorCode::WrongShapeIdForTagType;
|
||||
case lcl::ErrorCode::INVALID_POINT_ID:
|
||||
return vtkm::ErrorCode::InvalidPointId;
|
||||
case lcl::ErrorCode::SOLUTION_DID_NOT_CONVERGE:
|
||||
return vtkm::ErrorCode::SolutionDidNotConverge;
|
||||
case lcl::ErrorCode::MATRIX_LUP_FACTORIZATION_FAILED:
|
||||
return vtkm::ErrorCode::MatrixFactorizationFailed;
|
||||
case lcl::ErrorCode::DEGENERATE_CELL_DETECTED:
|
||||
return vtkm::ErrorCode::DegenerateCellDetected;
|
||||
}
|
||||
|
||||
return vtkm::ErrorCode::UnknownError;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace vtkm
|
||||
|
||||
#define VTKM_RETURN_ON_ERROR(call) \
|
||||
do \
|
||||
{ \
|
||||
auto status = (call); \
|
||||
if (status != ::vtkm::ErrorCode::Success) \
|
||||
{ \
|
||||
return status; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#endif //vtk_m_exec_ErrorCode_h
|
@ -108,22 +108,26 @@ private:
|
||||
// tests are done on the projection of the point on the cell. Extra checks
|
||||
// should be added to test if the point actually falls on the cell.
|
||||
template <typename CellShapeTag, typename CoordsType>
|
||||
VTKM_EXEC static bool PointInsideCell(FloatVec3 point,
|
||||
CellShapeTag cellShape,
|
||||
CoordsType cellPoints,
|
||||
const vtkm::exec::FunctorBase* worklet,
|
||||
FloatVec3& parametricCoordinates)
|
||||
VTKM_EXEC static vtkm::ErrorCode PointInsideCell(FloatVec3 point,
|
||||
CellShapeTag cellShape,
|
||||
CoordsType cellPoints,
|
||||
FloatVec3& parametricCoordinates,
|
||||
bool& inside)
|
||||
{
|
||||
auto bounds = vtkm::internal::cl_uniform_bins::ComputeCellBounds(cellPoints);
|
||||
if (point[0] >= bounds.Min[0] && point[0] <= bounds.Max[0] && point[1] >= bounds.Min[1] &&
|
||||
point[1] <= bounds.Max[1] && point[2] >= bounds.Min[2] && point[2] <= bounds.Max[2])
|
||||
{
|
||||
bool success = false;
|
||||
parametricCoordinates = vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
cellPoints, point, cellShape, success, worklet);
|
||||
return success && vtkm::exec::CellInside(parametricCoordinates, cellShape);
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
cellPoints, point, cellShape, parametricCoordinates));
|
||||
inside = vtkm::exec::CellInside(parametricCoordinates, cellShape);
|
||||
}
|
||||
return false;
|
||||
else
|
||||
{
|
||||
inside = false;
|
||||
}
|
||||
// Return success error code even point is not inside this cell
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
public:
|
||||
@ -157,10 +161,9 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
void FindCell(const FloatVec3& point,
|
||||
vtkm::Id& cellId,
|
||||
FloatVec3& parametric,
|
||||
const vtkm::exec::FunctorBase* worklet) const override
|
||||
vtkm::ErrorCode FindCell(const FloatVec3& point,
|
||||
vtkm::Id& cellId,
|
||||
FloatVec3& parametric) const override
|
||||
{
|
||||
using namespace vtkm::internal::cl_uniform_bins;
|
||||
|
||||
@ -176,7 +179,7 @@ public:
|
||||
auto ldim = this->LeafDimensions.Get(binId);
|
||||
if (!ldim[0] || !ldim[1] || !ldim[2])
|
||||
{
|
||||
return;
|
||||
return vtkm::ErrorCode::CellNotFound;
|
||||
}
|
||||
|
||||
auto leafGrid = ComputeLeafGrid(binId3, ldim, this->TopLevel);
|
||||
@ -196,14 +199,19 @@ public:
|
||||
auto indices = this->CellSet.GetIndices(cid);
|
||||
auto pts = vtkm::make_VecFromPortalPermute(&indices, this->Coords);
|
||||
FloatVec3 pc;
|
||||
if (PointInsideCell(point, this->CellSet.GetCellShape(cid), pts, worklet, pc))
|
||||
bool inside;
|
||||
VTKM_RETURN_ON_ERROR(
|
||||
PointInsideCell(point, this->CellSet.GetCellShape(cid), pts, pc, inside));
|
||||
if (inside)
|
||||
{
|
||||
cellId = cid;
|
||||
parametric = pc;
|
||||
break;
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vtkm::ErrorCode::CellNotFound;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -104,7 +104,13 @@ public:
|
||||
bool& match) const
|
||||
{
|
||||
vtkm::Id calculated = CalculateCellId(pointIn);
|
||||
locator->FindCell(pointIn, cellId, parametric, (*this));
|
||||
vtkm::ErrorCode status = locator->FindCell(pointIn, cellId, parametric);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
this->RaiseError(vtkm::ErrorString(status));
|
||||
match = false;
|
||||
return;
|
||||
}
|
||||
match = (calculated == cellId);
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,11 @@ public:
|
||||
const PointType& pc,
|
||||
PointType& wc) const
|
||||
{
|
||||
wc = vtkm::exec::ParametricCoordinatesToWorldCoordinates(points, pc, cellShape, *this);
|
||||
auto status = vtkm::exec::ParametricCoordinatesToWorldCoordinates(points, pc, cellShape, wc);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
this->RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -166,7 +170,11 @@ public:
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& pcoords) const
|
||||
{
|
||||
locator->FindCell(point, cellId, pcoords, *this);
|
||||
vtkm::ErrorCode status = locator->FindCell(point, cellId, pcoords);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
this->RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,13 @@ public:
|
||||
bool& match) const
|
||||
{
|
||||
vtkm::Id calculated = CalculateCellId(pointIn);
|
||||
locator->FindCell(pointIn, cellId, parametric, (*this));
|
||||
vtkm::ErrorCode status = locator->FindCell(pointIn, cellId, parametric);
|
||||
if ((status != vtkm::ErrorCode::Success) && (status != vtkm::ErrorCode::CellNotFound))
|
||||
{
|
||||
this->RaiseError(vtkm::ErrorString(status));
|
||||
match = false;
|
||||
return;
|
||||
}
|
||||
match = (calculated == cellId);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,11 @@ public:
|
||||
const PointType& pc,
|
||||
PointType& wc) const
|
||||
{
|
||||
wc = vtkm::exec::CellInterpolate(points, pc, cellShape, *this);
|
||||
auto status = vtkm::exec::CellInterpolate(points, pc, cellShape, wc);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
this->RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -155,7 +159,11 @@ public:
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& pcoords) const
|
||||
{
|
||||
locator->FindCell(point, cellId, pcoords, *this);
|
||||
vtkm::ErrorCode status = locator->FindCell(point, cellId, pcoords);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
this->RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include <vtkm/Assert.h>
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/ErrorCode.h>
|
||||
#include <vtkm/VecAxisAlignedPointCoordinates.h>
|
||||
#include <vtkm/VecTraits.h>
|
||||
|
||||
@ -25,77 +27,38 @@ namespace vtkm
|
||||
namespace exec
|
||||
{
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \brief Take the derivative (get the gradient) of a point field in a cell.
|
||||
///
|
||||
/// Given the point field values for each node and the parametric coordinates
|
||||
/// of a point within the cell, finds the derivative with respect to each
|
||||
/// coordinate (i.e. the gradient) at that point. The derivative is not always
|
||||
/// constant in some "linear" cells.
|
||||
///
|
||||
template <typename FieldVecType, typename WorldCoordType, typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
const FieldVecType& pointFieldValues,
|
||||
const WorldCoordType& worldCoordinateValues,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& parametricCoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
{
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3> result;
|
||||
switch (shape.Id)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(
|
||||
result = CellDerivative(
|
||||
pointFieldValues, worldCoordinateValues, parametricCoords, CellShapeTag(), worklet));
|
||||
default:
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Unknown cell shape sent to derivative.");
|
||||
}
|
||||
return vtkm::Vec<typename FieldVecType::ComponentType, 3>();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename VtkcCellShapeTag,
|
||||
template <typename LclCellShapeTag,
|
||||
typename FieldVecType,
|
||||
typename WorldCoordType,
|
||||
typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivativeImpl(
|
||||
VtkcCellShapeTag tag,
|
||||
VTKM_EXEC vtkm::ErrorCode CellDerivativeImpl(
|
||||
LclCellShapeTag tag,
|
||||
const FieldVecType& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const ParametricCoordType& pcoords,
|
||||
const vtkm::exec::FunctorBase* worklet)
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3>& result)
|
||||
{
|
||||
VTKM_ASSERT(field.GetNumberOfComponents() == tag.numberOfPoints());
|
||||
VTKM_ASSERT(wCoords.GetNumberOfComponents() == tag.numberOfPoints());
|
||||
if ((field.GetNumberOfComponents() != tag.numberOfPoints()) ||
|
||||
(wCoords.GetNumberOfComponents() != tag.numberOfPoints()))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
|
||||
using FieldType = typename FieldVecType::ComponentType;
|
||||
|
||||
auto fieldNumComponents = vtkm::VecTraits<FieldType>::GetNumberOfComponents(field[0]);
|
||||
vtkm::Vec<FieldType, 3> derivs;
|
||||
auto status = lcl::derivative(tag,
|
||||
lcl::makeFieldAccessorNestedSOA(wCoords, 3),
|
||||
lcl::makeFieldAccessorNestedSOA(field, fieldNumComponents),
|
||||
pcoords,
|
||||
derivs[0],
|
||||
derivs[1],
|
||||
derivs[2]);
|
||||
if (status != lcl::ErrorCode::SUCCESS)
|
||||
{
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError(lcl::errorString(status));
|
||||
}
|
||||
derivs = vtkm::TypeTraits<vtkm::Vec<FieldType, 3>>::ZeroInitialization();
|
||||
}
|
||||
|
||||
return derivs;
|
||||
result[0],
|
||||
result[1],
|
||||
result[2]);
|
||||
return vtkm::internal::LclErrorToVtkmError(status);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
@ -104,50 +67,45 @@ template <typename FieldVecType,
|
||||
typename WorldCoordType,
|
||||
typename ParametricCoordType,
|
||||
typename CellShapeTag>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
const FieldVecType& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellDerivative(const FieldVecType& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3>& result)
|
||||
{
|
||||
return internal::CellDerivativeImpl(
|
||||
vtkm::internal::make_LclCellShapeTag(shape), field, wCoords, pcoords, worklet);
|
||||
vtkm::internal::make_LclCellShapeTag(shape), field, wCoords, pcoords, result);
|
||||
}
|
||||
|
||||
template <typename FieldVecType, typename WorldCoordType, typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
const FieldVecType&,
|
||||
const WorldCoordType&,
|
||||
const vtkm::Vec<ParametricCoordType, 3>&,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellDerivative(const FieldVecType&,
|
||||
const WorldCoordType&,
|
||||
const vtkm::Vec<ParametricCoordType, 3>&,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3>)
|
||||
{
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Attempted to take derivative in empty cell.");
|
||||
}
|
||||
return vtkm::Vec<typename FieldVecType::ComponentType, 3>();
|
||||
return vtkm::ErrorCode::OperationOnEmptyCell;
|
||||
}
|
||||
|
||||
template <typename FieldVecType, typename WorldCoordType, typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
const FieldVecType& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellDerivative(const FieldVecType& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3>& result)
|
||||
{
|
||||
vtkm::IdComponent numPoints = field.GetNumberOfComponents();
|
||||
VTKM_ASSERT(numPoints >= 1);
|
||||
VTKM_ASSERT(numPoints == wCoords.GetNumberOfComponents());
|
||||
if (numPoints != wCoords.GetNumberOfComponents())
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
|
||||
switch (numPoints)
|
||||
{
|
||||
case 1:
|
||||
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagVertex(), worklet);
|
||||
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagVertex(), result);
|
||||
case 2:
|
||||
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagLine(), worklet);
|
||||
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagLine(), result);
|
||||
}
|
||||
|
||||
auto dt = static_cast<ParametricCoordType>(1) / static_cast<ParametricCoordType>(numPoints - 1);
|
||||
@ -164,62 +122,87 @@ VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
auto lineField = vtkm::make_Vec(field[idx - 1], field[idx]);
|
||||
auto lineWCoords = vtkm::make_Vec(wCoords[idx - 1], wCoords[idx]);
|
||||
auto pc = (pcoords[0] - static_cast<ParametricCoordType>(idx) * dt) / dt;
|
||||
return internal::CellDerivativeImpl(lcl::Line{}, lineField, lineWCoords, &pc, worklet);
|
||||
return internal::CellDerivativeImpl(lcl::Line{}, lineField, lineWCoords, &pc, result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename FieldVecType, typename WorldCoordType, typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
const FieldVecType& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellDerivative(const FieldVecType& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3>& result)
|
||||
{
|
||||
VTKM_ASSERT(field.GetNumberOfComponents() == wCoords.GetNumberOfComponents());
|
||||
|
||||
const vtkm::IdComponent numPoints = field.GetNumberOfComponents();
|
||||
VTKM_ASSERT(numPoints > 0);
|
||||
if ((numPoints <= 0) || (numPoints != wCoords.GetNumberOfComponents()))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
|
||||
switch (field.GetNumberOfComponents())
|
||||
{
|
||||
case 1:
|
||||
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagVertex(), worklet);
|
||||
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagVertex(), result);
|
||||
case 2:
|
||||
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagLine(), worklet);
|
||||
return CellDerivative(field, wCoords, pcoords, vtkm::CellShapeTagLine(), result);
|
||||
default:
|
||||
return internal::CellDerivativeImpl(
|
||||
lcl::Polygon(numPoints), field, wCoords, pcoords, worklet);
|
||||
return internal::CellDerivativeImpl(lcl::Polygon(numPoints), field, wCoords, pcoords, result);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename FieldVecType, typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
const FieldVecType& field,
|
||||
const vtkm::VecAxisAlignedPointCoordinates<2>& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagQuad,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellDerivative(const FieldVecType& field,
|
||||
const vtkm::VecAxisAlignedPointCoordinates<2>& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagQuad,
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3>& result)
|
||||
{
|
||||
return internal::CellDerivativeImpl(lcl::Pixel{}, field, wCoords, pcoords, worklet);
|
||||
return internal::CellDerivativeImpl(lcl::Pixel{}, field, wCoords, pcoords, result);
|
||||
}
|
||||
|
||||
template <typename FieldVecType, typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
const FieldVecType& field,
|
||||
const vtkm::VecAxisAlignedPointCoordinates<3>& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagHexahedron,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellDerivative(const FieldVecType& field,
|
||||
const vtkm::VecAxisAlignedPointCoordinates<3>& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagHexahedron,
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3>& result)
|
||||
{
|
||||
return internal::CellDerivativeImpl(lcl::Voxel{}, field, wCoords, pcoords, worklet);
|
||||
return internal::CellDerivativeImpl(lcl::Voxel{}, field, wCoords, pcoords, result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \brief Take the derivative (get the gradient) of a point field in a cell.
|
||||
///
|
||||
/// Given the point field values for each node and the parametric coordinates
|
||||
/// of a point within the cell, finds the derivative with respect to each
|
||||
/// coordinate (i.e. the gradient) at that point. The derivative is not always
|
||||
/// constant in some "linear" cells.
|
||||
///
|
||||
template <typename FieldVecType, typename WorldCoordType, typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::ErrorCode CellDerivative(const FieldVecType& pointFieldValues,
|
||||
const WorldCoordType& worldCoordinateValues,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& parametricCoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3>& result)
|
||||
{
|
||||
switch (shape.Id)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(return CellDerivative(
|
||||
pointFieldValues, worldCoordinateValues, parametricCoords, CellShapeTag(), result));
|
||||
default:
|
||||
return vtkm::ErrorCode::InvalidShapeId;
|
||||
}
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename FieldVecType,
|
||||
typename WorldCoordType,
|
||||
typename ParametricCoordType,
|
||||
typename CellShapeTag>
|
||||
VTKM_DEPRECATED(
|
||||
1.6,
|
||||
"Call signature has changed to CellDerivative(field, wCoords, pcoords, shape, result).")
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
const FieldVecType& field,
|
||||
const WorldCoordType& wCoords,
|
||||
@ -227,7 +210,13 @@ VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivative(
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellDerivative(field, wCoords, pcoords, shape, &worklet);
|
||||
vtkm::Vec<typename FieldVecType::ComponentType, 3> result;
|
||||
vtkm::ErrorCode status = CellDerivative(field, wCoords, pcoords, shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <vtkm/Assert.h>
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/CellTraits.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/ErrorCode.h>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/exec/FunctorBase.h>
|
||||
#include <vtkm/internal/Assume.h>
|
||||
@ -116,152 +118,185 @@ public:
|
||||
} // namespace detail
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(
|
||||
vtkm::IdComponent numPoints,
|
||||
CellShapeTag,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellEdgeNumberOfEdges(vtkm::IdComponent numPoints,
|
||||
CellShapeTag,
|
||||
vtkm::IdComponent& numEdges)
|
||||
{
|
||||
(void)numPoints; // Silence compiler warnings.
|
||||
VTKM_ASSERT(numPoints == vtkm::CellTraits<CellShapeTag>::NUM_POINTS);
|
||||
return detail::CellEdgeTables{}.NumEdges(CellShapeTag::Id);
|
||||
if (numPoints != vtkm::CellTraits<CellShapeTag>::NUM_POINTS)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
numEdges = detail::CellEdgeTables{}.NumEdges(CellShapeTag::Id);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellEdgeNumberOfEdges(vtkm::IdComponent numPoints,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
vtkm::IdComponent& numEdges)
|
||||
{
|
||||
VTKM_ASSUME(numPoints > 0);
|
||||
return numPoints;
|
||||
if (numPoints <= 0)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
numEdges = numPoints;
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellEdgeNumberOfEdges(vtkm::IdComponent numPoints,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
vtkm::IdComponent& numEdges)
|
||||
{
|
||||
(void)numPoints; // Silence compiler warnings.
|
||||
VTKM_ASSUME(numPoints > 0);
|
||||
return detail::CellEdgeTables{}.NumEdges(vtkm::CELL_SHAPE_POLY_LINE);
|
||||
if (numPoints <= 0)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
numEdges = detail::CellEdgeTables{}.NumEdges(vtkm::CELL_SHAPE_POLY_LINE);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellEdgeNumberOfEdges(vtkm::IdComponent numPoints,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
vtkm::IdComponent& numEdges)
|
||||
{
|
||||
if (shape.Id == vtkm::CELL_SHAPE_POLYGON)
|
||||
{
|
||||
return CellEdgeNumberOfEdges(numPoints, vtkm::CellShapeTagPolygon(), worklet);
|
||||
return CellEdgeNumberOfEdges(numPoints, vtkm::CellShapeTagPolygon(), numEdges);
|
||||
}
|
||||
else if (shape.Id == vtkm::CELL_SHAPE_POLY_LINE)
|
||||
{
|
||||
return CellEdgeNumberOfEdges(numPoints, vtkm::CellShapeTagPolyLine(), worklet);
|
||||
return CellEdgeNumberOfEdges(numPoints, vtkm::CellShapeTagPolyLine(), numEdges);
|
||||
}
|
||||
else
|
||||
{
|
||||
return detail::CellEdgeTables{}.NumEdges(shape.Id);
|
||||
numEdges = detail::CellEdgeTables{}.NumEdges(shape.Id);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeNumberOfEdges(
|
||||
vtkm::IdComponent numPoints,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
VTKM_DEPRECATED(1.6, "Signature changed to CellEdgeNumberOfEdges(numPoints, shape, result).")
|
||||
static inline VTKM_EXEC vtkm::IdComponent
|
||||
CellEdgeNumberOfEdges(vtkm::IdComponent numPoints,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellEdgeNumberOfEdges(numPoints, shape, &worklet);
|
||||
vtkm::IdComponent numEdges;
|
||||
vtkm::ErrorCode status = CellEdgeNumberOfEdges(numPoints, shape, numEdges);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return numEdges;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeLocalIndex(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellEdgeLocalIndex(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
CellShapeTag shape,
|
||||
vtkm::IdComponent& result)
|
||||
{
|
||||
VTKM_ASSUME(pointIndex >= 0);
|
||||
VTKM_ASSUME(pointIndex < 2);
|
||||
VTKM_ASSUME(edgeIndex >= 0);
|
||||
VTKM_ASSUME(edgeIndex < detail::CellEdgeTables::MAX_NUM_EDGES);
|
||||
if (edgeIndex >= vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, worklet))
|
||||
if ((pointIndex < 0) || (pointIndex > 1))
|
||||
{
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Invalid edge number.");
|
||||
}
|
||||
return 0;
|
||||
return vtkm::ErrorCode::InvalidPointId;
|
||||
}
|
||||
if ((edgeIndex < 0) || (edgeIndex >= detail::CellEdgeTables::MAX_NUM_EDGES))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidEdgeId;
|
||||
}
|
||||
|
||||
vtkm::IdComponent numEdges;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, numEdges));
|
||||
if (edgeIndex >= numEdges)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidEdgeId;
|
||||
}
|
||||
|
||||
detail::CellEdgeTables table;
|
||||
return table.PointsInEdge(CellShapeTag::Id, edgeIndex, pointIndex);
|
||||
result = table.PointsInEdge(CellShapeTag::Id, edgeIndex, pointIndex);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeLocalIndex(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellEdgeLocalIndex(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
vtkm::IdComponent& result)
|
||||
{
|
||||
VTKM_ASSUME(numPoints >= 3);
|
||||
VTKM_ASSUME(pointIndex >= 0);
|
||||
VTKM_ASSUME(pointIndex < 2);
|
||||
VTKM_ASSUME(edgeIndex >= 0);
|
||||
VTKM_ASSUME(edgeIndex < numPoints);
|
||||
if (numPoints < 3)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
if ((pointIndex < 0) || (pointIndex > 1))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidPointId;
|
||||
}
|
||||
if ((edgeIndex < 0) || (edgeIndex >= numPoints))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidEdgeId;
|
||||
}
|
||||
|
||||
if (edgeIndex + pointIndex < numPoints)
|
||||
{
|
||||
return edgeIndex + pointIndex;
|
||||
result = edgeIndex + pointIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
result = 0;
|
||||
}
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeLocalIndex(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellEdgeLocalIndex(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
vtkm::IdComponent& result)
|
||||
{
|
||||
VTKM_ASSUME(pointIndex >= 0);
|
||||
VTKM_ASSUME(pointIndex < 2);
|
||||
VTKM_ASSUME(edgeIndex >= 0);
|
||||
VTKM_ASSUME(edgeIndex < detail::CellEdgeTables::MAX_NUM_EDGES);
|
||||
if ((pointIndex < 0) || (pointIndex > 1))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidPointId;
|
||||
}
|
||||
if ((edgeIndex < 0) || (edgeIndex >= detail::CellEdgeTables::MAX_NUM_EDGES))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidEdgeId;
|
||||
}
|
||||
|
||||
if (shape.Id == vtkm::CELL_SHAPE_POLYGON)
|
||||
{
|
||||
return CellEdgeLocalIndex(
|
||||
numPoints, pointIndex, edgeIndex, vtkm::CellShapeTagPolygon(), worklet);
|
||||
numPoints, pointIndex, edgeIndex, vtkm::CellShapeTagPolygon(), result);
|
||||
}
|
||||
else
|
||||
{
|
||||
detail::CellEdgeTables table;
|
||||
if (edgeIndex >= table.NumEdges(shape.Id))
|
||||
{
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Invalid edge number.");
|
||||
}
|
||||
return 0;
|
||||
return vtkm::ErrorCode::InvalidEdgeId;
|
||||
}
|
||||
|
||||
return table.PointsInEdge(shape.Id, edgeIndex, pointIndex);
|
||||
result = table.PointsInEdge(shape.Id, edgeIndex, pointIndex);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
VTKM_DEPRECATED(
|
||||
1.6,
|
||||
"Signature changed to CellEdgeLocalIndex(numPoints, pointIndex, edgeIndex, shape, result).")
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellEdgeLocalIndex(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellEdgeLocalIndex(numPoints, pointIndex, edgeIndex, shape, &worklet);
|
||||
vtkm::IdComponent result;
|
||||
vtkm::ErrorCode status = CellEdgeLocalIndex(numPoints, pointIndex, edgeIndex, shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// \brief Returns a canonical identifier for a cell edge
|
||||
@ -271,36 +306,52 @@ static inline VTKM_EXEC vtkm::IdComponent CellEdgeLocalIndex(vtkm::IdComponent n
|
||||
/// the same if and only if the edges contain the same points.
|
||||
///
|
||||
template <typename CellShapeTag, typename GlobalPointIndicesVecType>
|
||||
static inline VTKM_EXEC vtkm::Id2 CellEdgeCanonicalId(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellEdgeCanonicalId(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
CellShapeTag shape,
|
||||
const GlobalPointIndicesVecType& globalPointIndicesVec,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Id2& result)
|
||||
{
|
||||
vtkm::Id pointIndex0 =
|
||||
globalPointIndicesVec[vtkm::exec::CellEdgeLocalIndex(numPoints, 0, edgeIndex, shape, worklet)];
|
||||
vtkm::Id pointIndex1 =
|
||||
globalPointIndicesVec[vtkm::exec::CellEdgeLocalIndex(numPoints, 1, edgeIndex, shape, worklet)];
|
||||
vtkm::IdComponent localIndex0;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellEdgeLocalIndex(numPoints, 0, edgeIndex, shape, localIndex0));
|
||||
vtkm::Id pointIndex0 = globalPointIndicesVec[localIndex0];
|
||||
|
||||
vtkm::IdComponent localIndex1;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellEdgeLocalIndex(numPoints, 1, edgeIndex, shape, localIndex1));
|
||||
vtkm::Id pointIndex1 = globalPointIndicesVec[localIndex1];
|
||||
|
||||
if (pointIndex0 < pointIndex1)
|
||||
{
|
||||
return vtkm::Id2(pointIndex0, pointIndex1);
|
||||
result = vtkm::Id2(pointIndex0, pointIndex1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return vtkm::Id2(pointIndex1, pointIndex0);
|
||||
result = vtkm::Id2(pointIndex1, pointIndex0);
|
||||
}
|
||||
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag, typename GlobalPointIndicesVecType>
|
||||
static inline VTKM_EXEC vtkm::Id2 CellEdgeCanonicalId(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
CellShapeTag shape,
|
||||
const GlobalPointIndicesVecType& globalPointIndicesVec,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
VTKM_DEPRECATED(
|
||||
1.6,
|
||||
"Signature changed to CellEdgeCononicalId(numPoints, edgeIndex, shape, globalIds, result).")
|
||||
static inline VTKM_EXEC vtkm::Id2
|
||||
CellEdgeCanonicalId(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent edgeIndex,
|
||||
CellShapeTag shape,
|
||||
const GlobalPointIndicesVecType& globalPointIndicesVec,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellEdgeCanonicalId(numPoints, edgeIndex, shape, globalPointIndicesVec, &worklet);
|
||||
vtkm::Id2 result;
|
||||
vtkm::ErrorCode status =
|
||||
CellEdgeCanonicalId(numPoints, edgeIndex, shape, globalPointIndicesVec, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include <vtkm/Assert.h>
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/ErrorCode.h>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/exec/FunctorBase.h>
|
||||
#include <vtkm/internal/Assume.h>
|
||||
@ -140,104 +142,144 @@ public:
|
||||
} // namespace detail
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellFaceNumberOfFaces(
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellFaceNumberOfFaces(CellShapeTag shape,
|
||||
vtkm::IdComponent& result)
|
||||
{
|
||||
(void)shape; //C4100 false positive workaround
|
||||
detail::CellFaceTables table;
|
||||
return table.NumFaces(shape.Id);
|
||||
result = table.NumFaces(shape.Id);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellFaceNumberOfFaces(
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
VTKM_DEPRECATED(1.6, "Signature changed to CellFaceNumberOfFaces(shape, result).")
|
||||
static inline VTKM_EXEC vtkm::IdComponent
|
||||
CellFaceNumberOfFaces(CellShapeTag shape, const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellFaceNumberOfFaces(shape, &worklet);
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellFaceNumberOfPoints(
|
||||
vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
{
|
||||
VTKM_ASSUME(faceIndex >= 0);
|
||||
VTKM_ASSUME(faceIndex < detail::CellFaceTables::MAX_NUM_FACES);
|
||||
if (faceIndex >= vtkm::exec::CellFaceNumberOfFaces(shape, worklet))
|
||||
vtkm::IdComponent result;
|
||||
vtkm::ErrorCode status = CellFaceNumberOfFaces(shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Invalid face number.");
|
||||
}
|
||||
return 0;
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellFaceNumberOfPoints(vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
vtkm::IdComponent& result)
|
||||
{
|
||||
if ((faceIndex < 0) || (faceIndex >= detail::CellFaceTables::MAX_NUM_FACES))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidFaceId;
|
||||
}
|
||||
|
||||
vtkm::IdComponent numFaces;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellFaceNumberOfFaces(shape, numFaces));
|
||||
if (faceIndex >= numFaces)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidFaceId;
|
||||
}
|
||||
detail::CellFaceTables table;
|
||||
return table.NumPointsInFace(shape.Id, faceIndex);
|
||||
result = table.NumPointsInFace(shape.Id, faceIndex);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellFaceNumberOfPoints(
|
||||
vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
VTKM_DEPRECATED(1.6, "Signature changed to CellFaceNumberOfPoints(faceIndex, shape, result).")
|
||||
static inline VTKM_EXEC vtkm::IdComponent
|
||||
CellFaceNumberOfPoints(vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellFaceNumberOfPoints(faceIndex, shape, &worklet);
|
||||
vtkm::IdComponent result;
|
||||
vtkm::ErrorCode status = CellFaceNumberOfPoints(faceIndex, shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::UInt8 CellFaceShape(vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellFaceShape(vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
vtkm::UInt8& result)
|
||||
{
|
||||
VTKM_ASSUME(faceIndex >= 0);
|
||||
VTKM_ASSUME(faceIndex < detail::CellFaceTables::MAX_NUM_FACES);
|
||||
switch (CellFaceNumberOfPoints(faceIndex, shape, worklet))
|
||||
|
||||
if ((faceIndex < 0) || (faceIndex >= detail::CellFaceTables::MAX_NUM_FACES))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidFaceId;
|
||||
}
|
||||
|
||||
vtkm::IdComponent numFacePoints;
|
||||
VTKM_RETURN_ON_ERROR(CellFaceNumberOfPoints(faceIndex, shape, numFacePoints));
|
||||
switch (numFacePoints)
|
||||
{
|
||||
case 3:
|
||||
return vtkm::CELL_SHAPE_TRIANGLE;
|
||||
result = vtkm::CELL_SHAPE_TRIANGLE;
|
||||
break;
|
||||
case 4:
|
||||
return vtkm::CELL_SHAPE_QUAD;
|
||||
result = vtkm::CELL_SHAPE_QUAD;
|
||||
break;
|
||||
default:
|
||||
return vtkm::CELL_SHAPE_POLYGON;
|
||||
result = vtkm::CELL_SHAPE_POLYGON;
|
||||
break;
|
||||
}
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
VTKM_DEPRECATED(1.6, "Signature changed to CellFaceShape(faceIndex, shape, result).")
|
||||
static inline VTKM_EXEC vtkm::UInt8 CellFaceShape(vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellFaceShape(faceIndex, shape, &worklet);
|
||||
vtkm::UInt8 result;
|
||||
vtkm::ErrorCode status = CellFaceShape(faceIndex, shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellFaceLocalIndex(
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellFaceLocalIndex(vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
vtkm::IdComponent& result)
|
||||
{
|
||||
vtkm::IdComponent numPointsInFace = vtkm::exec::CellFaceNumberOfPoints(faceIndex, shape, worklet);
|
||||
vtkm::IdComponent numPointsInFace;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellFaceNumberOfPoints(faceIndex, shape, numPointsInFace));
|
||||
if (numPointsInFace < 1)
|
||||
{
|
||||
// An invalid face. We should already have gotten an error from
|
||||
// CellFaceNumberOfPoints.
|
||||
return -1;
|
||||
return vtkm::ErrorCode::InvalidFaceId;
|
||||
}
|
||||
|
||||
detail::CellFaceTables table;
|
||||
return table.PointsInFace(shape.Id, faceIndex, pointIndex);
|
||||
result = table.PointsInFace(shape.Id, faceIndex, pointIndex);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
VTKM_DEPRECATED(1.6,
|
||||
"Signature changed to CellFaceLocalIndex(pointIndex, faceIndex, shape, result).")
|
||||
static inline VTKM_EXEC vtkm::IdComponent CellFaceLocalIndex(vtkm::IdComponent pointIndex,
|
||||
vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellFaceLocalIndex(pointIndex, faceIndex, shape, &worklet);
|
||||
vtkm::IdComponent result;
|
||||
vtkm::ErrorCode status = CellFaceLocalIndex(pointIndex, faceIndex, shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// \brief Returns a canonical identifier for a cell face
|
||||
@ -251,68 +293,68 @@ static inline VTKM_EXEC vtkm::IdComponent CellFaceLocalIndex(vtkm::IdComponent p
|
||||
/// than a single point or single edge.
|
||||
///
|
||||
template <typename CellShapeTag, typename GlobalPointIndicesVecType>
|
||||
static inline VTKM_EXEC vtkm::Id3 CellFaceCanonicalId(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode CellFaceCanonicalId(
|
||||
vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const GlobalPointIndicesVecType& globalPointIndicesVec,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Id3& result)
|
||||
{
|
||||
const vtkm::IdComponent numPointsInFace =
|
||||
vtkm::exec::CellFaceNumberOfPoints(faceIndex, shape, worklet);
|
||||
vtkm::IdComponent numPointsInFace;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellFaceNumberOfPoints(faceIndex, shape, numPointsInFace));
|
||||
if (numPointsInFace == 0)
|
||||
{
|
||||
// An invalid face. We should already have gotten an error from
|
||||
// CellFaceNumberOfPoints.
|
||||
return vtkm::Id3(0);
|
||||
return vtkm::ErrorCode::InvalidFaceId;
|
||||
}
|
||||
|
||||
detail::CellFaceTables table;
|
||||
//Sort the first 3 face points/nodes in ascending order
|
||||
vtkm::Id3 sorted(globalPointIndicesVec[table.PointsInFace(shape.Id, faceIndex, 0)],
|
||||
globalPointIndicesVec[table.PointsInFace(shape.Id, faceIndex, 1)],
|
||||
globalPointIndicesVec[table.PointsInFace(shape.Id, faceIndex, 2)]);
|
||||
result = vtkm::Id3(globalPointIndicesVec[table.PointsInFace(shape.Id, faceIndex, 0)],
|
||||
globalPointIndicesVec[table.PointsInFace(shape.Id, faceIndex, 1)],
|
||||
globalPointIndicesVec[table.PointsInFace(shape.Id, faceIndex, 2)]);
|
||||
vtkm::Id temp;
|
||||
if (sorted[0] > sorted[2])
|
||||
if (result[0] > result[2])
|
||||
{
|
||||
temp = sorted[0];
|
||||
sorted[0] = sorted[2];
|
||||
sorted[2] = temp;
|
||||
temp = result[0];
|
||||
result[0] = result[2];
|
||||
result[2] = temp;
|
||||
}
|
||||
if (sorted[0] > sorted[1])
|
||||
if (result[0] > result[1])
|
||||
{
|
||||
temp = sorted[0];
|
||||
sorted[0] = sorted[1];
|
||||
sorted[1] = temp;
|
||||
temp = result[0];
|
||||
result[0] = result[1];
|
||||
result[1] = temp;
|
||||
}
|
||||
if (sorted[1] > sorted[2])
|
||||
if (result[1] > result[2])
|
||||
{
|
||||
temp = sorted[1];
|
||||
sorted[1] = sorted[2];
|
||||
sorted[2] = temp;
|
||||
temp = result[1];
|
||||
result[1] = result[2];
|
||||
result[2] = temp;
|
||||
}
|
||||
|
||||
// Check the rest of the points to see if they are in the lowest 3
|
||||
for (vtkm::IdComponent pointIndex = 3; pointIndex < numPointsInFace; pointIndex++)
|
||||
{
|
||||
vtkm::Id nextPoint = globalPointIndicesVec[table.PointsInFace(shape.Id, faceIndex, pointIndex)];
|
||||
if (nextPoint < sorted[2])
|
||||
if (nextPoint < result[2])
|
||||
{
|
||||
if (nextPoint < sorted[1])
|
||||
if (nextPoint < result[1])
|
||||
{
|
||||
sorted[2] = sorted[1];
|
||||
if (nextPoint < sorted[0])
|
||||
result[2] = result[1];
|
||||
if (nextPoint < result[0])
|
||||
{
|
||||
sorted[1] = sorted[0];
|
||||
sorted[0] = nextPoint;
|
||||
result[1] = result[0];
|
||||
result[0] = nextPoint;
|
||||
}
|
||||
else // nextPoint > P0, nextPoint < P1
|
||||
{
|
||||
sorted[1] = nextPoint;
|
||||
result[1] = nextPoint;
|
||||
}
|
||||
}
|
||||
else // nextPoint > P1, nextPoint < P2
|
||||
{
|
||||
sorted[2] = nextPoint;
|
||||
result[2] = nextPoint;
|
||||
}
|
||||
}
|
||||
else // nextPoint > P2
|
||||
@ -321,17 +363,25 @@ static inline VTKM_EXEC vtkm::Id3 CellFaceCanonicalId(
|
||||
}
|
||||
}
|
||||
|
||||
return sorted;
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag, typename GlobalPointIndicesVecType>
|
||||
static inline VTKM_EXEC vtkm::Id3 CellFaceCanonicalId(
|
||||
vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const GlobalPointIndicesVecType& globalPointIndicesVec,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
VTKM_DEPRECATED(1.6,
|
||||
"Signature changed to CellFaceCononicalId(faceIndex, shape, globalIds, result).")
|
||||
static inline VTKM_EXEC vtkm::Id3
|
||||
CellFaceCanonicalId(vtkm::IdComponent faceIndex,
|
||||
CellShapeTag shape,
|
||||
const GlobalPointIndicesVecType& globalPointIndicesVec,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellFaceCanonicalId(faceIndex, shape, globalPointIndicesVec, &worklet);
|
||||
vtkm::Id3 result;
|
||||
vtkm::ErrorCode status = CellFaceCanonicalId(faceIndex, shape, globalPointIndicesVec, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include <vtkm/Assert.h>
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/ErrorCode.h>
|
||||
#include <vtkm/VecAxisAlignedPointCoordinates.h>
|
||||
#include <vtkm/exec/FunctorBase.h>
|
||||
|
||||
@ -31,97 +33,62 @@ namespace internal
|
||||
{
|
||||
|
||||
template <typename VtkcCellShapeTag, typename FieldVecType, typename ParametricCoordType>
|
||||
VTKM_EXEC typename FieldVecType::ComponentType CellInterpolateImpl(
|
||||
VtkcCellShapeTag tag,
|
||||
const FieldVecType& field,
|
||||
const ParametricCoordType& pcoords,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellInterpolateImpl(VtkcCellShapeTag tag,
|
||||
const FieldVecType& field,
|
||||
const ParametricCoordType& pcoords,
|
||||
typename FieldVecType::ComponentType& result)
|
||||
{
|
||||
VTKM_ASSERT(tag.numberOfPoints() == field.GetNumberOfComponents());
|
||||
if (tag.numberOfPoints() != field.GetNumberOfComponents())
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
|
||||
using FieldValueType = typename FieldVecType::ComponentType;
|
||||
IdComponent numComponents = vtkm::VecTraits<FieldValueType>::GetNumberOfComponents(field[0]);
|
||||
FieldValueType result(0);
|
||||
auto status =
|
||||
lcl::interpolate(tag, lcl::makeFieldAccessorNestedSOA(field, numComponents), pcoords, result);
|
||||
if ((status != lcl::ErrorCode::SUCCESS) && (worklet != nullptr))
|
||||
{
|
||||
worklet->RaiseError(lcl::errorString(status));
|
||||
}
|
||||
return result;
|
||||
return vtkm::internal::LclErrorToVtkmError(status);
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \brief Interpolate a point field in a cell.
|
||||
///
|
||||
/// Given the point field values for each node and the parametric coordinates
|
||||
/// of a point within the cell, interpolates the field to that point.
|
||||
///
|
||||
template <typename FieldVecType, typename ParametricCoordType>
|
||||
VTKM_EXEC typename FieldVecType::ComponentType CellInterpolate(
|
||||
const FieldVecType& pointFieldValues,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& parametricCoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
{
|
||||
typename FieldVecType::ComponentType result;
|
||||
switch (shape.Id)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(
|
||||
result = CellInterpolate(pointFieldValues, parametricCoords, CellShapeTag(), worklet));
|
||||
default:
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Unknown cell shape sent to interpolate.");
|
||||
}
|
||||
return typename FieldVecType::ComponentType();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename FieldVecType, typename ParametricCoordType, typename CellShapeTag>
|
||||
VTKM_EXEC typename FieldVecType::ComponentType CellInterpolate(
|
||||
const FieldVecType& pointFieldValues,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag tag,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellInterpolate(const FieldVecType& pointFieldValues,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag tag,
|
||||
typename FieldVecType::ComponentType& result)
|
||||
{
|
||||
auto lclTag = vtkm::internal::make_LclCellShapeTag(tag, pointFieldValues.GetNumberOfComponents());
|
||||
return internal::CellInterpolateImpl(lclTag, pointFieldValues, pcoords, worklet);
|
||||
return internal::CellInterpolateImpl(lclTag, pointFieldValues, pcoords, result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename FieldVecType, typename ParametricCoordType>
|
||||
VTKM_EXEC typename FieldVecType::ComponentType CellInterpolate(
|
||||
const FieldVecType&,
|
||||
const vtkm::Vec<ParametricCoordType, 3>&,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellInterpolate(const FieldVecType&,
|
||||
const vtkm::Vec<ParametricCoordType, 3>&,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
typename FieldVecType::ComponentType&)
|
||||
{
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Attempted to interpolate an empty cell.");
|
||||
}
|
||||
return typename FieldVecType::ComponentType();
|
||||
return vtkm::ErrorCode::OperationOnEmptyCell;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename FieldVecType, typename ParametricCoordType>
|
||||
VTKM_EXEC typename FieldVecType::ComponentType CellInterpolate(
|
||||
const FieldVecType& field,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellInterpolate(const FieldVecType& field,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
typename FieldVecType::ComponentType& result)
|
||||
{
|
||||
const vtkm::IdComponent numPoints = field.GetNumberOfComponents();
|
||||
VTKM_ASSERT(numPoints >= 1);
|
||||
if (numPoints < 1)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
|
||||
if (numPoints == 1)
|
||||
{
|
||||
return CellInterpolate(field, pcoords, vtkm::CellShapeTagVertex(), worklet);
|
||||
return CellInterpolate(field, pcoords, vtkm::CellShapeTagVertex(), result);
|
||||
}
|
||||
|
||||
using T = ParametricCoordType;
|
||||
@ -130,64 +97,97 @@ VTKM_EXEC typename FieldVecType::ComponentType CellInterpolate(
|
||||
vtkm::IdComponent idx = static_cast<vtkm::IdComponent>(pcoords[0] / dt);
|
||||
if (idx == numPoints - 1)
|
||||
{
|
||||
return field[numPoints - 1];
|
||||
result = field[numPoints - 1];
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
T pc = (pcoords[0] - static_cast<T>(idx) * dt) / dt;
|
||||
return internal::CellInterpolateImpl(
|
||||
lcl::Line{}, vtkm::make_Vec(field[idx], field[idx + 1]), &pc, worklet);
|
||||
lcl::Line{}, vtkm::make_Vec(field[idx], field[idx + 1]), &pc, result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename FieldVecType, typename ParametricCoordType>
|
||||
VTKM_EXEC typename FieldVecType::ComponentType CellInterpolate(
|
||||
const FieldVecType& field,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellInterpolate(const FieldVecType& field,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
typename FieldVecType::ComponentType& result)
|
||||
{
|
||||
const vtkm::IdComponent numPoints = field.GetNumberOfComponents();
|
||||
VTKM_ASSERT(numPoints > 0);
|
||||
if (numPoints < 1)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
|
||||
switch (numPoints)
|
||||
{
|
||||
case 1:
|
||||
return CellInterpolate(field, pcoords, vtkm::CellShapeTagVertex(), worklet);
|
||||
return CellInterpolate(field, pcoords, vtkm::CellShapeTagVertex(), result);
|
||||
case 2:
|
||||
return CellInterpolate(field, pcoords, vtkm::CellShapeTagLine(), worklet);
|
||||
return CellInterpolate(field, pcoords, vtkm::CellShapeTagLine(), result);
|
||||
default:
|
||||
return internal::CellInterpolateImpl(lcl::Polygon(numPoints), field, pcoords, worklet);
|
||||
return internal::CellInterpolateImpl(lcl::Polygon(numPoints), field, pcoords, result);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec3f CellInterpolate(const vtkm::VecAxisAlignedPointCoordinates<2>& field,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagQuad,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellInterpolate(const vtkm::VecAxisAlignedPointCoordinates<2>& field,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagQuad,
|
||||
vtkm::Vec3f& result)
|
||||
{
|
||||
return internal::CellInterpolateImpl(lcl::Pixel{}, field, pcoords, worklet);
|
||||
return internal::CellInterpolateImpl(lcl::Pixel{}, field, pcoords, result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::Vec3f CellInterpolate(const vtkm::VecAxisAlignedPointCoordinates<3>& field,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagHexahedron,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_EXEC vtkm::ErrorCode CellInterpolate(const vtkm::VecAxisAlignedPointCoordinates<3>& field,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagHexahedron,
|
||||
vtkm::Vec3f& result)
|
||||
{
|
||||
return internal::CellInterpolateImpl(lcl::Voxel{}, field, pcoords, worklet);
|
||||
return internal::CellInterpolateImpl(lcl::Voxel{}, field, pcoords, result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \brief Interpolate a point field in a cell.
|
||||
///
|
||||
/// Given the point field values for each node and the parametric coordinates
|
||||
/// of a point within the cell, interpolates the field to that point.
|
||||
///
|
||||
template <typename FieldVecType, typename ParametricCoordType>
|
||||
VTKM_EXEC vtkm::ErrorCode CellInterpolate(const FieldVecType& pointFieldValues,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& parametricCoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
typename FieldVecType::ComponentType& result)
|
||||
{
|
||||
switch (shape.Id)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(
|
||||
return CellInterpolate(pointFieldValues, parametricCoords, CellShapeTag(), result));
|
||||
default:
|
||||
return vtkm::ErrorCode::InvalidShapeId;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename FieldVecType, typename ParametricCoordType, typename CellShapeTag>
|
||||
VTKM_EXEC typename FieldVecType::ComponentType CellInterpolate(
|
||||
const FieldVecType& pointFieldValues,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
VTKM_DEPRECATED(1.6,
|
||||
"Signature changed to CellInterpolate(pointFieldValues, pcoords, shape, result).")
|
||||
VTKM_EXEC typename FieldVecType::ComponentType
|
||||
CellInterpolate(const FieldVecType& pointFieldValues,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return CellInterpolate(pointFieldValues, pcoords, shape, &worklet);
|
||||
typename FieldVecType::ComponentType result;
|
||||
vtkm::ErrorCode status = CellInterpolate(pointFieldValues, pcoords, shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec
|
||||
|
@ -10,6 +10,8 @@
|
||||
#ifndef vtk_m_exec_CellLocator_h
|
||||
#define vtk_m_exec_CellLocator_h
|
||||
|
||||
#include <vtkm/Deprecated.h>
|
||||
#include <vtkm/ErrorCode.h>
|
||||
#include <vtkm/Types.h>
|
||||
#include <vtkm/VirtualObjectBase.h>
|
||||
#include <vtkm/exec/FunctorBase.h>
|
||||
@ -29,24 +31,22 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
virtual void FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric,
|
||||
const vtkm::exec::FunctorBase* worklet) const = 0;
|
||||
virtual vtkm::ErrorCode FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric) const = 0;
|
||||
|
||||
VTKM_EXEC
|
||||
VTKM_DEPRECATED(1.6, "FindCell no longer takes worklet argument.")
|
||||
void FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric,
|
||||
const vtkm::exec::FunctorBase& worklet) const
|
||||
{
|
||||
this->FindCell(point, cellId, parametric, &worklet);
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
void FindCell(const vtkm::Vec3f& point, vtkm::Id& cellId, vtkm::Vec3f& parametric) const
|
||||
{
|
||||
this->FindCell(point, cellId, parametric, nullptr);
|
||||
vtkm::ErrorCode status = this->FindCell(point, cellId, parametric);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -95,10 +95,9 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
void FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric,
|
||||
const vtkm::exec::FunctorBase* worklet) const override
|
||||
vtkm::ErrorCode FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric) const override
|
||||
{
|
||||
cellId = -1;
|
||||
vtkm::Id nodeIndex = 0;
|
||||
@ -109,7 +108,7 @@ public:
|
||||
switch (state)
|
||||
{
|
||||
case FindCellState::EnterNode:
|
||||
this->EnterNode(state, point, cellId, nodeIndex, parametric, worklet);
|
||||
VTKM_RETURN_ON_ERROR(this->EnterNode(state, point, cellId, nodeIndex, parametric));
|
||||
break;
|
||||
case FindCellState::AscendFromNode:
|
||||
this->AscendFromNode(state, nodeIndex);
|
||||
@ -122,6 +121,15 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cellId >= 0)
|
||||
{
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
return vtkm::ErrorCode::CellNotFound;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
@ -134,12 +142,11 @@ private:
|
||||
};
|
||||
|
||||
VTKM_EXEC
|
||||
void EnterNode(FindCellState& state,
|
||||
const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Id nodeIndex,
|
||||
vtkm::Vec3f& parametric,
|
||||
const vtkm::exec::FunctorBase* worklet) const
|
||||
vtkm::ErrorCode EnterNode(FindCellState& state,
|
||||
const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Id nodeIndex,
|
||||
vtkm::Vec3f& parametric) const
|
||||
{
|
||||
VTKM_ASSERT(state == FindCellState::EnterNode);
|
||||
|
||||
@ -148,13 +155,14 @@ private:
|
||||
if (node.ChildIndex < 0)
|
||||
{
|
||||
// In a leaf node. Look for a containing cell.
|
||||
cellId = this->FindInLeaf(point, parametric, node, worklet);
|
||||
VTKM_RETURN_ON_ERROR(this->FindInLeaf(point, parametric, node, cellId));
|
||||
state = FindCellState::AscendFromNode;
|
||||
}
|
||||
else
|
||||
{
|
||||
state = FindCellState::DescendLeftChild;
|
||||
}
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
@ -221,10 +229,11 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_EXEC vtkm::Id FindInLeaf(const vtkm::Vec3f& point,
|
||||
vtkm::Vec3f& parametric,
|
||||
const vtkm::exec::CellLocatorBoundingIntervalHierarchyNode& node,
|
||||
const vtkm::exec::FunctorBase* worklet) const
|
||||
VTKM_EXEC vtkm::ErrorCode FindInLeaf(
|
||||
const vtkm::Vec3f& point,
|
||||
vtkm::Vec3f& parametric,
|
||||
const vtkm::exec::CellLocatorBoundingIntervalHierarchyNode& node,
|
||||
vtkm::Id& containingCellId) const
|
||||
{
|
||||
using IndicesType = typename CellSetPortal::IndicesType;
|
||||
for (vtkm::Id i = node.Leaf.Start; i < node.Leaf.Start + node.Leaf.Size; ++i)
|
||||
@ -233,25 +242,31 @@ private:
|
||||
IndicesType cellPointIndices = this->CellSet.GetIndices(cellId);
|
||||
vtkm::VecFromPortalPermute<IndicesType, CoordsPortal> cellPoints(&cellPointIndices,
|
||||
this->Coords);
|
||||
if (IsPointInCell(point, parametric, this->CellSet.GetCellShape(cellId), cellPoints, worklet))
|
||||
bool found;
|
||||
VTKM_RETURN_ON_ERROR(this->IsPointInCell(
|
||||
point, parametric, this->CellSet.GetCellShape(cellId), cellPoints, found));
|
||||
if (found)
|
||||
{
|
||||
return cellId;
|
||||
containingCellId = cellId;
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
containingCellId = -1;
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename CoordsType, typename CellShapeTag>
|
||||
VTKM_EXEC static bool IsPointInCell(const vtkm::Vec3f& point,
|
||||
vtkm::Vec3f& parametric,
|
||||
CellShapeTag cellShape,
|
||||
const CoordsType& cellPoints,
|
||||
const vtkm::exec::FunctorBase* worklet)
|
||||
VTKM_EXEC static vtkm::ErrorCode IsPointInCell(const vtkm::Vec3f& point,
|
||||
vtkm::Vec3f& parametric,
|
||||
CellShapeTag cellShape,
|
||||
const CoordsType& cellPoints,
|
||||
bool& isInside)
|
||||
{
|
||||
bool success = false;
|
||||
parametric = vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
cellPoints, point, cellShape, success, worklet);
|
||||
return success && vtkm::exec::CellInside(parametric, cellShape);
|
||||
isInside = false;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
cellPoints, point, cellShape, parametric));
|
||||
isInside = vtkm::exec::CellInside(parametric, cellShape);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
using VisitType = vtkm::TopologyElementTagCell;
|
||||
|
@ -95,15 +95,14 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
void FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric,
|
||||
const vtkm::exec::FunctorBase* vtkmNotUsed(worklet)) const override
|
||||
vtkm::ErrorCode FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric) const override
|
||||
{
|
||||
if (!this->IsInside(point))
|
||||
{
|
||||
cellId = -1;
|
||||
return;
|
||||
return vtkm::ErrorCode::CellNotFound;
|
||||
}
|
||||
|
||||
// Get the Cell Id from the point.
|
||||
@ -147,6 +146,8 @@ public:
|
||||
}
|
||||
// Get the actual cellId, from the logical cell index of the cell
|
||||
cellId = logicalCell[2] * this->PlaneSize + logicalCell[1] * this->RowSize + logicalCell[0];
|
||||
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -75,15 +75,14 @@ public:
|
||||
}
|
||||
|
||||
VTKM_EXEC
|
||||
void FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric,
|
||||
const vtkm::exec::FunctorBase* vtkmNotUsed(worklet)) const override
|
||||
vtkm::ErrorCode FindCell(const vtkm::Vec3f& point,
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& parametric) const override
|
||||
{
|
||||
if (!this->IsInside(point))
|
||||
{
|
||||
cellId = -1;
|
||||
return;
|
||||
return vtkm::ErrorCode::CellNotFound;
|
||||
}
|
||||
// Get the Cell Id from the point.
|
||||
vtkm::Id3 logicalCell(0, 0, 0);
|
||||
@ -111,6 +110,8 @@ public:
|
||||
cellId =
|
||||
(logicalCell[2] * this->CellDims[1] + logicalCell[1]) * this->CellDims[0] + logicalCell[0];
|
||||
parametric = temp - logicalCell;
|
||||
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -27,83 +27,89 @@ namespace exec
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename ParametricCoordType, typename CellShapeTag>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesCenter(vtkm::IdComponent numPoints,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesCenter(
|
||||
vtkm::IdComponent numPoints,
|
||||
CellShapeTag,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
auto lclTag = typename vtkm::internal::CellShapeTagVtkmToVtkc<CellShapeTag>::Type{};
|
||||
|
||||
(void)numPoints; // Silence compiler warnings.
|
||||
VTKM_ASSERT(numPoints == lclTag.numberOfPoints());
|
||||
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
lcl::parametricCenter(lclTag, pcoords);
|
||||
if (numPoints != lclTag.numberOfPoints())
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
|
||||
return vtkm::internal::LclErrorToVtkmError(lcl::parametricCenter(lclTag, pcoords));
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesCenter(vtkm::IdComponent numPoints,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
{
|
||||
(void)numPoints; // Silence compiler warnings.
|
||||
VTKM_ASSERT(numPoints == 0);
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesCenter(vtkm::IdComponent numPoints,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagVertex,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
{
|
||||
(void)numPoints; // Silence compiler warnings.
|
||||
VTKM_ASSERT(numPoints == 1);
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesCenter(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesCenter(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
if (numPoints != 0)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesCenter(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::CellShapeTagVertex,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
if (numPoints != 1)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesCenter(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
switch (numPoints)
|
||||
{
|
||||
case 1:
|
||||
ParametricCoordinatesCenter(numPoints, pcoords, vtkm::CellShapeTagVertex(), worklet);
|
||||
return;
|
||||
return ParametricCoordinatesCenter(numPoints, vtkm::CellShapeTagVertex(), pcoords);
|
||||
case 2:
|
||||
ParametricCoordinatesCenter(numPoints, pcoords, vtkm::CellShapeTagLine(), worklet);
|
||||
return;
|
||||
return ParametricCoordinatesCenter(numPoints, vtkm::CellShapeTagLine(), pcoords);
|
||||
}
|
||||
pcoords[0] = 0.5;
|
||||
pcoords[1] = 0;
|
||||
pcoords[2] = 0;
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesCenter(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesCenter(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
VTKM_ASSERT(numPoints > 0);
|
||||
if (numPoints < 1)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
switch (numPoints)
|
||||
{
|
||||
case 1:
|
||||
ParametricCoordinatesCenter(numPoints, pcoords, vtkm::CellShapeTagVertex(), worklet);
|
||||
break;
|
||||
return ParametricCoordinatesCenter(numPoints, vtkm::CellShapeTagVertex(), pcoords);
|
||||
case 2:
|
||||
ParametricCoordinatesCenter(numPoints, pcoords, vtkm::CellShapeTagLine(), worklet);
|
||||
break;
|
||||
return ParametricCoordinatesCenter(numPoints, vtkm::CellShapeTagLine(), pcoords);
|
||||
default:
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
lcl::parametricCenter(lcl::Polygon(numPoints), pcoords);
|
||||
break;
|
||||
return vtkm::internal::LclErrorToVtkmError(
|
||||
lcl::parametricCenter(lcl::Polygon(numPoints), pcoords));
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,153 +118,148 @@ static inline VTKM_EXEC void ParametricCoordinatesCenter(
|
||||
/// of points.
|
||||
///
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesCenter(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesCenter(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
switch (shape.Id)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(
|
||||
ParametricCoordinatesCenter(numPoints, pcoords, CellShapeTag(), worklet));
|
||||
return ParametricCoordinatesCenter(numPoints, CellShapeTag(), pcoords));
|
||||
default:
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Bad shape given to ParametricCoordinatesCenter.");
|
||||
}
|
||||
pcoords[0] = pcoords[1] = pcoords[2] = 0;
|
||||
break;
|
||||
return vtkm::ErrorCode::InvalidShapeId;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType, typename CellShapeTag>
|
||||
VTKM_DEPRECATED(1.6, "Signature changed to ParametricCoordinatesCenter(numPoints, shape, result).")
|
||||
static inline VTKM_EXEC void ParametricCoordinatesCenter(vtkm::IdComponent numPoints,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
ParametricCoordinatesCenter(numPoints, pcoords, shape, &worklet);
|
||||
vtkm::ErrorCode status = ParametricCoordinatesCenter(numPoints, shape, pcoords);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the parametric center of the given cell shape with the given number
|
||||
/// of points.
|
||||
///
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::Vec3f ParametricCoordinatesCenter(
|
||||
vtkm::IdComponent numPoints,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_DEPRECATED(1.6, "Signature changed to ParametricCoordinatesCenter(numPoints, shape, result).")
|
||||
static inline VTKM_EXEC vtkm::Vec3f
|
||||
ParametricCoordinatesCenter(vtkm::IdComponent numPoints,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
vtkm::Vec3f pcoords(0.0f);
|
||||
ParametricCoordinatesCenter(numPoints, pcoords, shape, worklet);
|
||||
vtkm::ErrorCode status = ParametricCoordinatesCenter(numPoints, shape, pcoords);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return pcoords;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::Vec3f ParametricCoordinatesCenter(
|
||||
vtkm::IdComponent numPoints,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return ParametricCoordinatesCenter(numPoints, shape, &worklet);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
template <typename ParametricCoordType, typename CellShapeTag>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesPoint(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
CellShapeTag,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
auto lclTag = typename vtkm::internal::CellShapeTagVtkmToVtkc<CellShapeTag>::Type{};
|
||||
|
||||
(void)numPoints; // Silence compiler warnings.
|
||||
VTKM_ASSUME(numPoints == lclTag.numberOfPoints());
|
||||
VTKM_ASSUME((pointIndex >= 0) && (pointIndex < numPoints));
|
||||
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
lcl::parametricPoint(lclTag, pointIndex, pcoords);
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent,
|
||||
vtkm::IdComponent,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
{
|
||||
if (worklet)
|
||||
if (numPoints != lclTag.numberOfPoints())
|
||||
{
|
||||
worklet->RaiseError("Empty cell has no points.");
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
if ((pointIndex < 0) || (pointIndex >= numPoints))
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidPointId;
|
||||
}
|
||||
pcoords[0] = pcoords[1] = pcoords[2] = 0;
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesPoint(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagVertex,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
{
|
||||
(void)numPoints; // Silence compiler warnings.
|
||||
(void)pointIndex; // Silence compiler warnings.
|
||||
VTKM_ASSUME(numPoints == 1);
|
||||
VTKM_ASSUME(pointIndex == 0);
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
return vtkm::internal::LclErrorToVtkmError(lcl::parametricPoint(lclTag, pointIndex, pcoords));
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesPoint(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent,
|
||||
vtkm::IdComponent,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
pcoords[0] = pcoords[1] = pcoords[2] = 0;
|
||||
return vtkm::ErrorCode::OperationOnEmptyCell;
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
const vtkm::exec::FunctorBase* functor = nullptr)
|
||||
vtkm::CellShapeTagVertex,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
if (numPoints != 1)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
if (pointIndex != 0)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidPointId;
|
||||
}
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
if (numPoints < 1)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
switch (numPoints)
|
||||
{
|
||||
case 1:
|
||||
ParametricCoordinatesPoint(
|
||||
numPoints, pointIndex, pcoords, vtkm::CellShapeTagVertex(), functor);
|
||||
return;
|
||||
return ParametricCoordinatesPoint(numPoints, pointIndex, vtkm::CellShapeTagVertex(), pcoords);
|
||||
case 2:
|
||||
ParametricCoordinatesPoint(numPoints, pointIndex, pcoords, vtkm::CellShapeTagLine(), functor);
|
||||
return;
|
||||
return ParametricCoordinatesPoint(numPoints, pointIndex, vtkm::CellShapeTagLine(), pcoords);
|
||||
}
|
||||
pcoords[0] =
|
||||
static_cast<ParametricCoordType>(pointIndex) / static_cast<ParametricCoordType>(numPoints - 1);
|
||||
pcoords[1] = 0;
|
||||
pcoords[2] = 0;
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesPoint(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
VTKM_ASSUME((numPoints > 0));
|
||||
VTKM_ASSUME((pointIndex >= 0) && (pointIndex < numPoints));
|
||||
|
||||
switch (numPoints)
|
||||
{
|
||||
case 1:
|
||||
ParametricCoordinatesPoint(
|
||||
numPoints, pointIndex, pcoords, vtkm::CellShapeTagVertex(), worklet);
|
||||
return;
|
||||
return ParametricCoordinatesPoint(numPoints, pointIndex, vtkm::CellShapeTagVertex(), pcoords);
|
||||
case 2:
|
||||
ParametricCoordinatesPoint(numPoints, pointIndex, pcoords, vtkm::CellShapeTagLine(), worklet);
|
||||
return;
|
||||
return ParametricCoordinatesPoint(numPoints, pointIndex, vtkm::CellShapeTagLine(), pcoords);
|
||||
default:
|
||||
pcoords = vtkm::TypeTraits<vtkm::Vec<ParametricCoordType, 3>>::ZeroInitialization();
|
||||
lcl::parametricPoint(lcl::Polygon(numPoints), pointIndex, pcoords);
|
||||
return;
|
||||
return vtkm::internal::LclErrorToVtkmError(
|
||||
lcl::parametricPoint(lcl::Polygon(numPoints), pointIndex, pcoords));
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,287 +268,270 @@ static inline VTKM_EXEC void ParametricCoordinatesPoint(
|
||||
/// the given number of points.
|
||||
///
|
||||
template <typename ParametricCoordType>
|
||||
static inline VTKM_EXEC void ParametricCoordinatesPoint(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords)
|
||||
{
|
||||
switch (shape.Id)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(
|
||||
ParametricCoordinatesPoint(numPoints, pointIndex, pcoords, CellShapeTag(), worklet));
|
||||
return ParametricCoordinatesPoint(numPoints, pointIndex, CellShapeTag(), pcoords));
|
||||
default:
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Bad shape given to ParametricCoordinatesPoint.");
|
||||
}
|
||||
pcoords[0] = pcoords[1] = pcoords[2] = 0;
|
||||
break;
|
||||
return vtkm::ErrorCode::InvalidShapeId;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ParametricCoordType, typename CellShapeTag>
|
||||
VTKM_DEPRECATED(
|
||||
1.6,
|
||||
"Signature changed to ParametricCoordinatesPoint(numPoints, pointIndex, shape, result).")
|
||||
static inline VTKM_EXEC void ParametricCoordinatesPoint(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
ParametricCoordinatesPoint(numPoints, pointIndex, pcoords, shape, &worklet);
|
||||
vtkm::ErrorCode status = ParametricCoordinatesPoint(numPoints, pointIndex, shape, pcoords);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the parametric coordinate of a cell point of the given shape with
|
||||
/// the given number of points.
|
||||
///
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::Vec3f ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
VTKM_DEPRECATED(
|
||||
1.6,
|
||||
"Signature changed to ParametricCoordinatesPoint(numPoints, pointIndex, shape, result).")
|
||||
static inline VTKM_EXEC vtkm::Vec3f
|
||||
ParametricCoordinatesPoint(vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
vtkm::Vec3f pcoords(0.0f);
|
||||
ParametricCoordinatesPoint(numPoints, pointIndex, pcoords, shape, worklet);
|
||||
vtkm::Vec3f pcoords;
|
||||
vtkm::ErrorCode status = ParametricCoordinatesPoint(numPoints, pointIndex, shape, pcoords);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return pcoords;
|
||||
}
|
||||
|
||||
template <typename CellShapeTag>
|
||||
static inline VTKM_EXEC vtkm::Vec3f ParametricCoordinatesPoint(
|
||||
vtkm::IdComponent numPoints,
|
||||
vtkm::IdComponent pointIndex,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return ParametricCoordinatesPoint(numPoints, pointIndex, shape, &worklet);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename LclCellShapeTag, typename WorldCoordVector, typename PCoordType>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinatesImpl(LclCellShapeTag tag,
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const PCoordType& pcoords,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinatesImpl(
|
||||
LclCellShapeTag tag,
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const PCoordType& pcoords,
|
||||
typename WorldCoordVector::ComponentType& wcoords)
|
||||
{
|
||||
typename WorldCoordVector::ComponentType wcoords(0);
|
||||
auto status =
|
||||
lcl::parametricToWorld(tag, lcl::makeFieldAccessorNestedSOA(pointWCoords, 3), pcoords, wcoords);
|
||||
if ((status != lcl::ErrorCode::SUCCESS) && (worklet != nullptr))
|
||||
{
|
||||
worklet->RaiseError(lcl::errorString(status));
|
||||
}
|
||||
return wcoords;
|
||||
return vtkm::internal::LclErrorToVtkmError(lcl::parametricToWorld(
|
||||
tag, lcl::makeFieldAccessorNestedSOA(pointWCoords, 3), pcoords, wcoords));
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <typename WorldCoordVector, typename PCoordType, typename CellShapeTag>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
auto numPoints = pointWCoords.GetNumberOfComponents();
|
||||
return internal::ParametricCoordinatesToWorldCoordinatesImpl(
|
||||
vtkm::internal::make_LclCellShapeTag(shape, numPoints), pointWCoords, pcoords, worklet);
|
||||
vtkm::internal::make_LclCellShapeTag(shape, numPoints), pointWCoords, pcoords, result);
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector, typename PCoordType>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagEmpty empty,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagEmpty empty,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
return vtkm::exec::CellInterpolate(pointWCoords, pcoords, empty, worklet);
|
||||
return vtkm::exec::CellInterpolate(pointWCoords, pcoords, empty, result);
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector, typename PCoordType>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolyLine polyLine,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolyLine polyLine,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
return vtkm::exec::CellInterpolate(pointWCoords, pcoords, polyLine, worklet);
|
||||
return vtkm::exec::CellInterpolate(pointWCoords, pcoords, polyLine, result);
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector, typename PCoordType>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
auto numPoints = pointWCoords.GetNumberOfComponents();
|
||||
switch (numPoints)
|
||||
{
|
||||
case 1:
|
||||
return ParametricCoordinatesToWorldCoordinates(
|
||||
pointWCoords, pcoords, vtkm::CellShapeTagVertex{}, worklet);
|
||||
pointWCoords, pcoords, vtkm::CellShapeTagVertex{}, result);
|
||||
case 2:
|
||||
return ParametricCoordinatesToWorldCoordinates(
|
||||
pointWCoords, pcoords, vtkm::CellShapeTagLine{}, worklet);
|
||||
pointWCoords, pcoords, vtkm::CellShapeTagLine{}, result);
|
||||
default:
|
||||
return internal::ParametricCoordinatesToWorldCoordinatesImpl(
|
||||
lcl::Polygon(numPoints), pointWCoords, pcoords, worklet);
|
||||
lcl::Polygon(numPoints), pointWCoords, pcoords, result);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector, typename PCoordType>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinates(const vtkm::VecAxisAlignedPointCoordinates<2>& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagQuad,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinates(
|
||||
const vtkm::VecAxisAlignedPointCoordinates<2>& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagQuad,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
return internal::ParametricCoordinatesToWorldCoordinatesImpl(
|
||||
lcl::Pixel{}, pointWCoords, pcoords, worklet);
|
||||
lcl::Pixel{}, pointWCoords, pcoords, result);
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector, typename PCoordType>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinates(const vtkm::VecAxisAlignedPointCoordinates<3>& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagHexahedron,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinates(
|
||||
const vtkm::VecAxisAlignedPointCoordinates<3>& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagHexahedron,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
return internal::ParametricCoordinatesToWorldCoordinatesImpl(
|
||||
lcl::Voxel{}, pointWCoords, pcoords, worklet);
|
||||
lcl::Voxel{}, pointWCoords, pcoords, result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// Returns the world coordinate corresponding to the given parametric coordinate of a cell.
|
||||
///
|
||||
template <typename WorldCoordVector, typename PCoordType>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode ParametricCoordinatesToWorldCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
typename WorldCoordVector::ComponentType wcoords(0);
|
||||
switch (shape.Id)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(wcoords = ParametricCoordinatesToWorldCoordinates(
|
||||
pointWCoords, pcoords, CellShapeTag(), worklet));
|
||||
vtkmGenericCellShapeMacro(return ParametricCoordinatesToWorldCoordinates(
|
||||
pointWCoords, pcoords, CellShapeTag(), result));
|
||||
default:
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Bad shape given to ParametricCoordinatesPoint.");
|
||||
}
|
||||
break;
|
||||
return vtkm::ErrorCode::InvalidShapeId;
|
||||
}
|
||||
return wcoords;
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector, typename PCoordType, typename CellShapeTag>
|
||||
VTKM_DEPRECATED(1.6,
|
||||
"Signature changed to "
|
||||
"ParametricCoordinatesToWorldCoordinates(pointWCoords, pcoords, shape, result).")
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
ParametricCoordinatesToWorldCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
ParametricCoordinatesToWorldCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const vtkm::Vec<PCoordType, 3>& pcoords,
|
||||
CellShapeTag shape,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return ParametricCoordinatesToWorldCoordinates(pointWCoords, pcoords, shape, &worklet);
|
||||
typename WorldCoordVector::ComponentType result;
|
||||
vtkm::ErrorCode status =
|
||||
ParametricCoordinatesToWorldCoordinates(pointWCoords, pcoords, shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <typename VtkcCellShapeTag, typename WorldCoordVector>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
WorldCoordinatesToParametricCoordinatesImpl(VtkcCellShapeTag tag,
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* worklet)
|
||||
template <typename LclCellShapeTag, typename WorldCoordVector>
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinatesImpl(
|
||||
LclCellShapeTag tag,
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
VTKM_ASSERT(pointWCoords.GetNumberOfComponents() == tag.numberOfPoints());
|
||||
|
||||
auto pcoords = vtkm::TypeTraits<typename WorldCoordVector::ComponentType>::ZeroInitialization();
|
||||
auto status =
|
||||
lcl::worldToParametric(tag, lcl::makeFieldAccessorNestedSOA(pointWCoords, 3), wcoords, pcoords);
|
||||
|
||||
success = true;
|
||||
if ((status != lcl::ErrorCode::SUCCESS) && (worklet != nullptr))
|
||||
if (pointWCoords.GetNumberOfComponents() != tag.numberOfPoints())
|
||||
{
|
||||
worklet->RaiseError(lcl::errorString(status));
|
||||
success = false;
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
return pcoords;
|
||||
|
||||
result = vtkm::TypeTraits<typename WorldCoordVector::ComponentType>::ZeroInitialization();
|
||||
return vtkm::internal::LclErrorToVtkmError(
|
||||
lcl::worldToParametric(tag, lcl::makeFieldAccessorNestedSOA(pointWCoords, 3), wcoords, result));
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template <typename WorldCoordVector, typename CellShapeTag>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
CellShapeTag shape,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
CellShapeTag shape,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
auto numPoints = pointWCoords.GetNumberOfComponents();
|
||||
return internal::WorldCoordinatesToParametricCoordinatesImpl(
|
||||
vtkm::internal::make_LclCellShapeTag(shape, numPoints),
|
||||
pointWCoords,
|
||||
wcoords,
|
||||
success,
|
||||
worklet);
|
||||
vtkm::internal::make_LclCellShapeTag(shape, numPoints), pointWCoords, wcoords, result);
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
WorldCoordinatesToParametricCoordinates(const WorldCoordVector&,
|
||||
const typename WorldCoordVector::ComponentType&,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates(
|
||||
const WorldCoordVector&,
|
||||
const typename WorldCoordVector::ComponentType&,
|
||||
vtkm::CellShapeTagEmpty,
|
||||
typename WorldCoordVector::ComponentType&)
|
||||
{
|
||||
if (worklet)
|
||||
return vtkm::ErrorCode::OperationOnEmptyCell;
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector>
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType&,
|
||||
vtkm::CellShapeTagVertex,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
if (pointWCoords.GetNumberOfComponents() != 1)
|
||||
{
|
||||
worklet->RaiseError("Attempted to find point coordinates in empty cell.");
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
success = false;
|
||||
return typename WorldCoordVector::ComponentType();
|
||||
result = typename WorldCoordVector::ComponentType(0, 0, 0);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType&,
|
||||
vtkm::CellShapeTagVertex,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* = nullptr)
|
||||
{
|
||||
(void)pointWCoords; // Silence compiler warnings.
|
||||
VTKM_ASSERT(pointWCoords.GetNumberOfComponents() == 1);
|
||||
success = true;
|
||||
return typename WorldCoordVector::ComponentType(0, 0, 0);
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
vtkm::CellShapeTagPolyLine,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
vtkm::IdComponent numPoints = pointWCoords.GetNumberOfComponents();
|
||||
VTKM_ASSERT(pointWCoords.GetNumberOfComponents() >= 1);
|
||||
if (numPoints < 1)
|
||||
{
|
||||
return vtkm::ErrorCode::InvalidNumberOfPoints;
|
||||
}
|
||||
|
||||
if (numPoints == 1)
|
||||
{
|
||||
return WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, wcoords, vtkm::CellShapeTagVertex(), success, worklet);
|
||||
pointWCoords, wcoords, vtkm::CellShapeTagVertex(), result);
|
||||
}
|
||||
|
||||
using Vector3 = typename WorldCoordVector::ComponentType;
|
||||
@ -577,99 +561,104 @@ WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords,
|
||||
}
|
||||
|
||||
vtkm::Vec<Vector3, 2> line(pointWCoords[idx - 1], pointWCoords[idx]);
|
||||
auto lpc = WorldCoordinatesToParametricCoordinates(
|
||||
line, wcoords, vtkm::CellShapeTagLine{}, success, worklet);
|
||||
Vector3 lpc;
|
||||
VTKM_RETURN_ON_ERROR(
|
||||
WorldCoordinatesToParametricCoordinates(line, wcoords, vtkm::CellShapeTagLine{}, lpc));
|
||||
|
||||
//Segment param is [0,1] on that segment.
|
||||
//Map that onto the param for the entire segment.
|
||||
T dParam = static_cast<T>(1) / static_cast<T>(numPoints - 1);
|
||||
T polyLineParam = static_cast<T>(idx - 1) * dParam + lpc[0] * dParam;
|
||||
|
||||
return Vector3(polyLineParam, 0, 0);
|
||||
result = Vector3(polyLineParam, 0, 0);
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
vtkm::CellShapeTagPolygon,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
auto numPoints = pointWCoords.GetNumberOfComponents();
|
||||
switch (numPoints)
|
||||
{
|
||||
case 1:
|
||||
return WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, wcoords, vtkm::CellShapeTagVertex{}, success, worklet);
|
||||
pointWCoords, wcoords, vtkm::CellShapeTagVertex{}, result);
|
||||
case 2:
|
||||
return WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, wcoords, vtkm::CellShapeTagLine{}, success, worklet);
|
||||
pointWCoords, wcoords, vtkm::CellShapeTagLine{}, result);
|
||||
default:
|
||||
return internal::WorldCoordinatesToParametricCoordinatesImpl(
|
||||
lcl::Polygon(numPoints), pointWCoords, wcoords, success, worklet);
|
||||
lcl::Polygon(numPoints), pointWCoords, wcoords, result);
|
||||
}
|
||||
}
|
||||
|
||||
static inline VTKM_EXEC vtkm::Vec3f WorldCoordinatesToParametricCoordinates(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates(
|
||||
const vtkm::VecAxisAlignedPointCoordinates<2>& pointWCoords,
|
||||
const vtkm::Vec3f& wcoords,
|
||||
vtkm::CellShapeTagQuad,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Vec3f& result)
|
||||
{
|
||||
return internal::WorldCoordinatesToParametricCoordinatesImpl(
|
||||
lcl::Pixel{}, pointWCoords, wcoords, success, worklet);
|
||||
lcl::Pixel{}, pointWCoords, wcoords, result);
|
||||
}
|
||||
|
||||
static inline VTKM_EXEC vtkm::Vec3f WorldCoordinatesToParametricCoordinates(
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates(
|
||||
const vtkm::VecAxisAlignedPointCoordinates<3>& pointWCoords,
|
||||
const vtkm::Vec3f& wcoords,
|
||||
vtkm::CellShapeTagHexahedron,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
vtkm::Vec3f& result)
|
||||
{
|
||||
return internal::WorldCoordinatesToParametricCoordinatesImpl(
|
||||
lcl::Voxel{}, pointWCoords, wcoords, success, worklet);
|
||||
lcl::Voxel{}, pointWCoords, wcoords, result);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// Returns the world paramteric corresponding to the given world coordinate for a cell.
|
||||
///
|
||||
template <typename WorldCoordVector>
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase* worklet = nullptr)
|
||||
static inline VTKM_EXEC vtkm::ErrorCode WorldCoordinatesToParametricCoordinates(
|
||||
const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
vtkm::CellShapeTagGeneric shape,
|
||||
typename WorldCoordVector::ComponentType& result)
|
||||
{
|
||||
typename WorldCoordVector::ComponentType result;
|
||||
switch (shape.Id)
|
||||
{
|
||||
vtkmGenericCellShapeMacro(result = WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, wcoords, CellShapeTag(), success, worklet));
|
||||
vtkmGenericCellShapeMacro(return WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, wcoords, CellShapeTag(), result));
|
||||
default:
|
||||
success = false;
|
||||
if (worklet)
|
||||
{
|
||||
worklet->RaiseError("Unknown cell shape sent to world 2 parametric.");
|
||||
}
|
||||
return typename WorldCoordVector::ComponentType();
|
||||
return vtkm::ErrorCode::InvalidShapeId;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename WorldCoordVector, typename CellShapeTag>
|
||||
VTKM_DEPRECATED(1.6,
|
||||
"Signature changed to "
|
||||
"WorldCoordinatesToParametricCoordinates(pointWCoords, wcoords, shape, result).")
|
||||
static inline VTKM_EXEC typename WorldCoordVector::ComponentType
|
||||
WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
CellShapeTag shape,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
WorldCoordinatesToParametricCoordinates(const WorldCoordVector& pointWCoords,
|
||||
const typename WorldCoordVector::ComponentType& wcoords,
|
||||
CellShapeTag shape,
|
||||
bool& success,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
{
|
||||
return WorldCoordinatesToParametricCoordinates(pointWCoords, wcoords, shape, success, &worklet);
|
||||
typename WorldCoordVector::ComponentType result;
|
||||
vtkm::ErrorCode status =
|
||||
WorldCoordinatesToParametricCoordinates(pointWCoords, wcoords, shape, result);
|
||||
if (status != vtkm::ErrorCode::Success)
|
||||
{
|
||||
success = false;
|
||||
worklet.RaiseError(vtkm::ErrorString(status));
|
||||
}
|
||||
else
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace vtkm::exec
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
|
||||
#define CHECK_CALL(call) \
|
||||
VTKM_TEST_ASSERT((call) == vtkm::ErrorCode::Success, "Call resulted in error.")
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -91,13 +94,6 @@ struct TestDerivativeFunctor
|
||||
LinearField<FieldType> field,
|
||||
vtkm::Vec<FieldType, 3> expectedGradient) const
|
||||
{
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
vtkm::IdComponent numPoints = worldCoordinates.GetNumberOfComponents();
|
||||
|
||||
vtkm::VecVariable<FieldType, MAX_POINTS> fieldValues;
|
||||
@ -119,9 +115,9 @@ struct TestDerivativeFunctor
|
||||
vtkm::FloatDefault totalWeight = 0;
|
||||
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
||||
{
|
||||
vtkm::Vec3f pointPcoords =
|
||||
vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
vtkm::Vec3f pointPcoords;
|
||||
CHECK_CALL(
|
||||
vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, pointPcoords));
|
||||
vtkm::FloatDefault weight = randomDist(g_RandomGenerator);
|
||||
pcoords = pcoords + weight * pointPcoords;
|
||||
totalWeight += weight;
|
||||
@ -130,9 +126,9 @@ struct TestDerivativeFunctor
|
||||
|
||||
std::cout << " Test derivative at " << pcoords << std::endl;
|
||||
|
||||
vtkm::Vec<FieldType, 3> computedGradient =
|
||||
vtkm::exec::CellDerivative(fieldValues, worldCoordinates, pcoords, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
vtkm::Vec<FieldType, 3> computedGradient;
|
||||
CHECK_CALL(vtkm::exec::CellDerivative(
|
||||
fieldValues, worldCoordinates, pcoords, shape, computedGradient));
|
||||
|
||||
std::cout << " Computed: " << computedGradient << std::endl;
|
||||
// Note that some gradients (particularly those near the center of
|
||||
@ -149,19 +145,11 @@ struct TestDerivativeFunctor
|
||||
LinearField<FieldType> field,
|
||||
vtkm::Vec<FieldType, 3> expectedGradient) const
|
||||
{
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
vtkm::VecVariable<vtkm::Vec3f, MAX_POINTS> worldCoordinates;
|
||||
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
||||
{
|
||||
vtkm::Vec3f pcoords =
|
||||
vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
vtkm::Vec3f pcoords;
|
||||
CHECK_CALL(vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, pcoords));
|
||||
vtkm::Vec3f wcoords = ParametricToWorld(pcoords);
|
||||
VTKM_TEST_ASSERT(test_equal(pcoords, WorldToParametric(wcoords)),
|
||||
"Test world/parametric conversion broken.");
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#define CHECK_CALL(call) \
|
||||
VTKM_TEST_ASSERT((call) == vtkm::ErrorCode::Success, "Call resulted in error.")
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -41,13 +44,6 @@ struct TestCellFacesFunctor
|
||||
CellShapeTag shape,
|
||||
vtkm::CellTopologicalDimensionsTag<3>) const
|
||||
{
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
std::vector<vtkm::Id> pointIndexProxyBuffer(static_cast<std::size_t>(numPoints));
|
||||
for (std::size_t index = 0; index < pointIndexProxyBuffer.size(); ++index)
|
||||
{
|
||||
@ -55,14 +51,16 @@ struct TestCellFacesFunctor
|
||||
}
|
||||
vtkm::VecCConst<vtkm::Id> pointIndexProxy(&pointIndexProxyBuffer.at(0), numPoints);
|
||||
|
||||
vtkm::IdComponent numEdges = vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, workletProxy);
|
||||
vtkm::IdComponent numEdges;
|
||||
CHECK_CALL(vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, numEdges));
|
||||
VTKM_TEST_ASSERT(numEdges > 0, "No edges?");
|
||||
|
||||
std::set<EdgeType> edgeSet;
|
||||
for (vtkm::IdComponent edgeIndex = 0; edgeIndex < numEdges; edgeIndex++)
|
||||
{
|
||||
EdgeType edge(vtkm::exec::CellEdgeLocalIndex(numPoints, 0, edgeIndex, shape, workletProxy),
|
||||
vtkm::exec::CellEdgeLocalIndex(numPoints, 1, edgeIndex, shape, workletProxy));
|
||||
EdgeType edge;
|
||||
CHECK_CALL(vtkm::exec::CellEdgeLocalIndex(numPoints, 0, edgeIndex, shape, edge[0]));
|
||||
CHECK_CALL(vtkm::exec::CellEdgeLocalIndex(numPoints, 1, edgeIndex, shape, edge[1]));
|
||||
VTKM_TEST_ASSERT(edge[0] >= 0, "Bad index in edge.");
|
||||
VTKM_TEST_ASSERT(edge[0] < numPoints, "Bad index in edge.");
|
||||
VTKM_TEST_ASSERT(edge[1] >= 0, "Bad index in edge.");
|
||||
@ -73,49 +71,50 @@ struct TestCellFacesFunctor
|
||||
VTKM_TEST_ASSERT(edgeSet.find(edge) == edgeSet.end(), "Found duplicate edge");
|
||||
edgeSet.insert(edge);
|
||||
|
||||
vtkm::Id2 canonicalEdgeId =
|
||||
vtkm::exec::CellEdgeCanonicalId(numPoints, edgeIndex, shape, pointIndexProxy, workletProxy);
|
||||
vtkm::Id2 canonicalEdgeId;
|
||||
CHECK_CALL(vtkm::exec::CellEdgeCanonicalId(
|
||||
numPoints, edgeIndex, shape, pointIndexProxy, canonicalEdgeId));
|
||||
VTKM_TEST_ASSERT(canonicalEdgeId[0] > 0, "Not using global ids?");
|
||||
VTKM_TEST_ASSERT(canonicalEdgeId[0] < canonicalEdgeId[1], "Bad order.");
|
||||
}
|
||||
|
||||
vtkm::IdComponent numFaces = vtkm::exec::CellFaceNumberOfFaces(shape, workletProxy);
|
||||
vtkm::IdComponent numFaces;
|
||||
CHECK_CALL(vtkm::exec::CellFaceNumberOfFaces(shape, numFaces));
|
||||
VTKM_TEST_ASSERT(numFaces > 0, "No faces?");
|
||||
|
||||
std::set<EdgeType> edgesFoundInFaces;
|
||||
for (vtkm::IdComponent faceIndex = 0; faceIndex < numFaces; faceIndex++)
|
||||
{
|
||||
const vtkm::IdComponent numPointsInFace =
|
||||
vtkm::exec::CellFaceNumberOfPoints(faceIndex, shape, workletProxy);
|
||||
vtkm::IdComponent numPointsInFace;
|
||||
CHECK_CALL(vtkm::exec::CellFaceNumberOfPoints(faceIndex, shape, numPointsInFace));
|
||||
|
||||
VTKM_TEST_ASSERT(numPointsInFace >= 3, "Face has fewer points than a triangle.");
|
||||
|
||||
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPointsInFace; pointIndex++)
|
||||
{
|
||||
vtkm::IdComponent localFaceIndex =
|
||||
vtkm::exec::CellFaceLocalIndex(pointIndex, faceIndex, shape, workletProxy);
|
||||
vtkm::IdComponent localFaceIndex;
|
||||
CHECK_CALL(vtkm::exec::CellFaceLocalIndex(pointIndex, faceIndex, shape, localFaceIndex));
|
||||
VTKM_TEST_ASSERT(localFaceIndex >= 0, "Invalid point index for face.");
|
||||
VTKM_TEST_ASSERT(localFaceIndex < numPoints, "Invalid point index for face.");
|
||||
EdgeType edge;
|
||||
if (pointIndex < numPointsInFace - 1)
|
||||
{
|
||||
edge = EdgeType(
|
||||
vtkm::exec::CellFaceLocalIndex(pointIndex, faceIndex, shape, workletProxy),
|
||||
vtkm::exec::CellFaceLocalIndex(pointIndex + 1, faceIndex, shape, workletProxy));
|
||||
CHECK_CALL(vtkm::exec::CellFaceLocalIndex(pointIndex, faceIndex, shape, edge[0]));
|
||||
CHECK_CALL(vtkm::exec::CellFaceLocalIndex(pointIndex + 1, faceIndex, shape, edge[1]));
|
||||
}
|
||||
else
|
||||
{
|
||||
edge =
|
||||
EdgeType(vtkm::exec::CellFaceLocalIndex(0, faceIndex, shape, workletProxy),
|
||||
vtkm::exec::CellFaceLocalIndex(pointIndex, faceIndex, shape, workletProxy));
|
||||
CHECK_CALL(vtkm::exec::CellFaceLocalIndex(0, faceIndex, shape, edge[0]));
|
||||
CHECK_CALL(vtkm::exec::CellFaceLocalIndex(pointIndex, faceIndex, shape, edge[1]));
|
||||
}
|
||||
MakeEdgeCanonical(edge);
|
||||
VTKM_TEST_ASSERT(edgeSet.find(edge) != edgeSet.end(), "Edge in face not in cell's edges");
|
||||
edgesFoundInFaces.insert(edge);
|
||||
}
|
||||
|
||||
vtkm::Id3 canonicalFaceId =
|
||||
vtkm::exec::CellFaceCanonicalId(faceIndex, shape, pointIndexProxy, workletProxy);
|
||||
vtkm::Id3 canonicalFaceId;
|
||||
CHECK_CALL(
|
||||
vtkm::exec::CellFaceCanonicalId(faceIndex, shape, pointIndexProxy, canonicalFaceId));
|
||||
VTKM_TEST_ASSERT(canonicalFaceId[0] > 0, "Not using global ids?");
|
||||
VTKM_TEST_ASSERT(canonicalFaceId[0] < canonicalFaceId[1], "Bad order.");
|
||||
VTKM_TEST_ASSERT(canonicalFaceId[1] < canonicalFaceId[2], "Bad order.");
|
||||
@ -130,13 +129,6 @@ struct TestCellFacesFunctor
|
||||
CellShapeTag shape,
|
||||
vtkm::CellTopologicalDimensionsTag<2>) const
|
||||
{
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
std::vector<vtkm::Id> pointIndexProxyBuffer(static_cast<std::size_t>(numPoints));
|
||||
for (std::size_t index = 0; index < pointIndexProxyBuffer.size(); ++index)
|
||||
{
|
||||
@ -144,14 +136,16 @@ struct TestCellFacesFunctor
|
||||
}
|
||||
vtkm::VecCConst<vtkm::Id> pointIndexProxy(&pointIndexProxyBuffer.at(0), numPoints);
|
||||
|
||||
vtkm::IdComponent numEdges = vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, workletProxy);
|
||||
vtkm::IdComponent numEdges;
|
||||
CHECK_CALL(vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, numEdges));
|
||||
VTKM_TEST_ASSERT(numEdges == numPoints, "Polygons should have same number of points and edges");
|
||||
|
||||
std::set<EdgeType> edgeSet;
|
||||
for (vtkm::IdComponent edgeIndex = 0; edgeIndex < numEdges; edgeIndex++)
|
||||
{
|
||||
EdgeType edge(vtkm::exec::CellEdgeLocalIndex(numPoints, 0, edgeIndex, shape, workletProxy),
|
||||
vtkm::exec::CellEdgeLocalIndex(numPoints, 1, edgeIndex, shape, workletProxy));
|
||||
EdgeType edge;
|
||||
CHECK_CALL(vtkm::exec::CellEdgeLocalIndex(numPoints, 0, edgeIndex, shape, edge[0]));
|
||||
CHECK_CALL(vtkm::exec::CellEdgeLocalIndex(numPoints, 1, edgeIndex, shape, edge[1]));
|
||||
VTKM_TEST_ASSERT(edge[0] >= 0, "Bad index in edge.");
|
||||
VTKM_TEST_ASSERT(edge[0] < numPoints, "Bad index in edge.");
|
||||
VTKM_TEST_ASSERT(edge[1] >= 0, "Bad index in edge.");
|
||||
@ -162,13 +156,15 @@ struct TestCellFacesFunctor
|
||||
VTKM_TEST_ASSERT(edgeSet.find(edge) == edgeSet.end(), "Found duplicate edge");
|
||||
edgeSet.insert(edge);
|
||||
|
||||
vtkm::Id2 canonicalEdgeId =
|
||||
vtkm::exec::CellEdgeCanonicalId(numPoints, edgeIndex, shape, pointIndexProxy, workletProxy);
|
||||
vtkm::Id2 canonicalEdgeId;
|
||||
CHECK_CALL(vtkm::exec::CellEdgeCanonicalId(
|
||||
numPoints, edgeIndex, shape, pointIndexProxy, canonicalEdgeId));
|
||||
VTKM_TEST_ASSERT(canonicalEdgeId[0] > 0, "Not using global ids?");
|
||||
VTKM_TEST_ASSERT(canonicalEdgeId[0] < canonicalEdgeId[1], "Bad order.");
|
||||
}
|
||||
|
||||
vtkm::IdComponent numFaces = vtkm::exec::CellFaceNumberOfFaces(shape, workletProxy);
|
||||
vtkm::IdComponent numFaces;
|
||||
CHECK_CALL(vtkm::exec::CellFaceNumberOfFaces(shape, numFaces));
|
||||
VTKM_TEST_ASSERT(numFaces == 0, "Non 3D shape should have no faces");
|
||||
}
|
||||
|
||||
@ -179,17 +175,12 @@ struct TestCellFacesFunctor
|
||||
CellShapeTag shape,
|
||||
vtkm::CellTopologicalDimensionsTag<NumDimensions>) const
|
||||
{
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
vtkm::IdComponent numEdges = vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, workletProxy);
|
||||
vtkm::IdComponent numEdges;
|
||||
CHECK_CALL(vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, numEdges));
|
||||
VTKM_TEST_ASSERT(numEdges == 0, "0D or 1D shape should have no edges");
|
||||
|
||||
vtkm::IdComponent numFaces = vtkm::exec::CellFaceNumberOfFaces(shape, workletProxy);
|
||||
vtkm::IdComponent numFaces;
|
||||
CHECK_CALL(vtkm::exec::CellFaceNumberOfFaces(shape, numFaces));
|
||||
VTKM_TEST_ASSERT(numFaces == 0, "Non 3D shape should have no faces");
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,9 @@
|
||||
|
||||
#include <vtkm/testing/Testing.h>
|
||||
|
||||
#define CHECK_CALL(call) \
|
||||
VTKM_TEST_ASSERT((call) == vtkm::ErrorCode::Success, "Call resulted in error.")
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -63,22 +66,13 @@ struct TestInterpolateFunctor
|
||||
}
|
||||
averageValue = static_cast<ComponentType>(1.0 / numPoints) * averageValue;
|
||||
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
std::cout << " Test interpolated value at each cell node." << std::endl;
|
||||
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
||||
{
|
||||
vtkm::Vec3f pcoord =
|
||||
vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
FieldType interpolatedValue =
|
||||
vtkm::exec::CellInterpolate(fieldValues, pcoord, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
vtkm::Vec3f pcoord;
|
||||
CHECK_CALL(vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, pcoord));
|
||||
FieldType interpolatedValue;
|
||||
CHECK_CALL(vtkm::exec::CellInterpolate(fieldValues, pcoord, shape, interpolatedValue));
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(fieldValues[pointIndex], interpolatedValue),
|
||||
"Interpolation at point not point value.");
|
||||
@ -87,11 +81,10 @@ struct TestInterpolateFunctor
|
||||
if (numPoints > 0)
|
||||
{
|
||||
std::cout << " Test interpolated value at cell center." << std::endl;
|
||||
vtkm::Vec3f pcoord = vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
FieldType interpolatedValue =
|
||||
vtkm::exec::CellInterpolate(fieldValues, pcoord, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
vtkm::Vec3f pcoord;
|
||||
CHECK_CALL(vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, pcoord));
|
||||
FieldType interpolatedValue;
|
||||
CHECK_CALL(vtkm::exec::CellInterpolate(fieldValues, pcoord, shape, interpolatedValue));
|
||||
|
||||
std::cout << "AVG= " << averageValue << " interp= " << interpolatedValue << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(averageValue, interpolatedValue),
|
||||
|
@ -20,6 +20,9 @@
|
||||
#include <ctime>
|
||||
#include <random>
|
||||
|
||||
#define CHECK_CALL(call) \
|
||||
VTKM_TEST_ASSERT((call) == vtkm::ErrorCode::Success, "Call resulted in error.")
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -57,23 +60,15 @@ static void CompareCoordinates(const PointWCoordsType& pointWCoords,
|
||||
{
|
||||
using Vector3 = vtkm::Vec<T, 3>;
|
||||
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
Vector3 computedWCoords = vtkm::exec::ParametricCoordinatesToWorldCoordinates(
|
||||
pointWCoords, truePCoords, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
Vector3 computedWCoords;
|
||||
CHECK_CALL(vtkm::exec::ParametricCoordinatesToWorldCoordinates(
|
||||
pointWCoords, truePCoords, shape, computedWCoords));
|
||||
VTKM_TEST_ASSERT(test_equal(computedWCoords, trueWCoords, 0.01),
|
||||
"Computed wrong world coords from parametric coords.");
|
||||
|
||||
bool success = false;
|
||||
Vector3 computedPCoords = vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, trueWCoords, shape, success, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
Vector3 computedPCoords;
|
||||
CHECK_CALL(vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, trueWCoords, shape, computedPCoords));
|
||||
VTKM_TEST_ASSERT(test_equal(computedPCoords, truePCoords, 0.01),
|
||||
"Computed wrong parametric coords from world coords.");
|
||||
}
|
||||
@ -84,21 +79,13 @@ void TestPCoordsSpecial(const PointWCoordsType& pointWCoords, CellShapeTag shape
|
||||
using Vector3 = typename PointWCoordsType::ComponentType;
|
||||
using T = typename Vector3::ComponentType;
|
||||
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
const vtkm::IdComponent numPoints = pointWCoords.GetNumberOfComponents();
|
||||
|
||||
std::cout << " Test parametric coordinates at cell nodes." << std::endl;
|
||||
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
||||
{
|
||||
Vector3 pcoords;
|
||||
vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, pcoords, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
CHECK_CALL(vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, pcoords));
|
||||
Vector3 wcoords = pointWCoords[pointIndex];
|
||||
CompareCoordinates(pointWCoords, pcoords, wcoords, shape);
|
||||
}
|
||||
@ -113,7 +100,7 @@ void TestPCoordsSpecial(const PointWCoordsType& pointWCoords, CellShapeTag shape
|
||||
wcoords = wcoords / Vector3(T(numPoints));
|
||||
|
||||
Vector3 pcoords;
|
||||
vtkm::exec::ParametricCoordinatesCenter(numPoints, pcoords, shape, workletProxy);
|
||||
CHECK_CALL(vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, pcoords));
|
||||
CompareCoordinates(pointWCoords, pcoords, wcoords, shape);
|
||||
}
|
||||
}
|
||||
@ -123,13 +110,6 @@ void TestPCoordsSample(const PointWCoordsType& pointWCoords, CellShapeTag shape)
|
||||
{
|
||||
using Vector3 = typename PointWCoordsType::ComponentType;
|
||||
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
const vtkm::IdComponent numPoints = pointWCoords.GetNumberOfComponents();
|
||||
|
||||
std::uniform_real_distribution<vtkm::FloatDefault> randomDist;
|
||||
@ -141,9 +121,9 @@ void TestPCoordsSample(const PointWCoordsType& pointWCoords, CellShapeTag shape)
|
||||
vtkm::FloatDefault totalWeight = 0;
|
||||
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
||||
{
|
||||
vtkm::Vec3f pointPcoords =
|
||||
vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
vtkm::Vec3f pointPcoords;
|
||||
CHECK_CALL(
|
||||
vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, shape, pointPcoords));
|
||||
vtkm::FloatDefault weight = randomDist(g_RandomGenerator);
|
||||
pcoords = pcoords + weight * pointPcoords;
|
||||
totalWeight += weight;
|
||||
@ -154,13 +134,12 @@ void TestPCoordsSample(const PointWCoordsType& pointWCoords, CellShapeTag shape)
|
||||
|
||||
// If you convert to world coordinates and back, you should get the
|
||||
// same value.
|
||||
Vector3 wcoords = vtkm::exec::ParametricCoordinatesToWorldCoordinates(
|
||||
pointWCoords, pcoords, shape, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
bool success = false;
|
||||
Vector3 computedPCoords = vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, wcoords, shape, success, workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
Vector3 wcoords;
|
||||
CHECK_CALL(
|
||||
vtkm::exec::ParametricCoordinatesToWorldCoordinates(pointWCoords, pcoords, shape, wcoords));
|
||||
Vector3 computedPCoords;
|
||||
CHECK_CALL(vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, wcoords, shape, computedPCoords));
|
||||
|
||||
VTKM_TEST_ASSERT(test_equal(pcoords, computedPCoords, 0.05),
|
||||
"pcoord/wcoord transform not symmetrical");
|
||||
@ -183,13 +162,6 @@ struct TestPCoordsFunctor
|
||||
template <typename CellShapeTag>
|
||||
PointWCoordType MakePointWCoords(CellShapeTag, vtkm::IdComponent numPoints) const
|
||||
{
|
||||
// Stuff to fake running in the execution environment.
|
||||
char messageBuffer[256];
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer errorMessage(messageBuffer, 256);
|
||||
vtkm::exec::FunctorBase workletProxy;
|
||||
workletProxy.SetErrorMessageBuffer(errorMessage);
|
||||
|
||||
std::uniform_real_distribution<T> randomDist(-1, 1);
|
||||
|
||||
Vector3 sheerVec(randomDist(g_RandomGenerator), randomDist(g_RandomGenerator), 0);
|
||||
@ -198,9 +170,8 @@ struct TestPCoordsFunctor
|
||||
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
|
||||
{
|
||||
Vector3 pcoords;
|
||||
vtkm::exec::ParametricCoordinatesPoint(
|
||||
numPoints, pointIndex, pcoords, CellShapeTag(), workletProxy);
|
||||
VTKM_TEST_ASSERT(!errorMessage.IsErrorRaised(), messageBuffer);
|
||||
CHECK_CALL(
|
||||
vtkm::exec::ParametricCoordinatesPoint(numPoints, pointIndex, CellShapeTag(), pcoords));
|
||||
|
||||
Vector3 wCoords = Vector3(pcoords[0], pcoords[1], pcoords[2] + vtkm::Dot(pcoords, sheerVec));
|
||||
pointWCoords.Append(wCoords);
|
||||
|
@ -115,7 +115,9 @@ struct EdgesCounter : public vtkm::worklet::WorkletVisitCellsWithPoints
|
||||
}
|
||||
else
|
||||
{
|
||||
return vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, *this);
|
||||
vtkm::IdComponent numEdges;
|
||||
vtkm::exec::CellEdgeNumberOfEdges(numPoints, shape, numEdges);
|
||||
return numEdges;
|
||||
}
|
||||
}
|
||||
}; // struct EdgesCounter
|
||||
@ -149,10 +151,13 @@ struct EdgesExtracter : public vtkm::worklet::WorkletVisitCellsWithPoints
|
||||
}
|
||||
else
|
||||
{
|
||||
p1 = pointIndices[vtkm::exec::CellEdgeLocalIndex(
|
||||
pointIndices.GetNumberOfComponents(), 0, visitIndex, shape, *this)];
|
||||
p2 = pointIndices[vtkm::exec::CellEdgeLocalIndex(
|
||||
pointIndices.GetNumberOfComponents(), 1, visitIndex, shape, *this)];
|
||||
vtkm::IdComponent localEdgeIndex;
|
||||
vtkm::exec::CellEdgeLocalIndex(
|
||||
pointIndices.GetNumberOfComponents(), 0, visitIndex, shape, localEdgeIndex);
|
||||
p1 = pointIndices[localEdgeIndex];
|
||||
vtkm::exec::CellEdgeLocalIndex(
|
||||
pointIndices.GetNumberOfComponents(), 1, visitIndex, shape, localEdgeIndex);
|
||||
p2 = pointIndices[localEdgeIndex];
|
||||
}
|
||||
// These indices need to be arranged in a definite order, as they will later be sorted to
|
||||
// detect duplicates
|
||||
|
@ -78,9 +78,8 @@ VTKM_EXEC_CONT inline bool Sample(const vtkm::Vec<vtkm::Vec<P, 3>, 8>& points,
|
||||
pointsVec.Append(points[i]);
|
||||
scalarVec.Append(scalars[i]);
|
||||
}
|
||||
bool success = false; // ignored
|
||||
vtkm::Vec<P, 3> pcoords = vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
pointsVec, sampleLocation, shapeTag, success);
|
||||
vtkm::Vec<P, 3> pcoords;
|
||||
vtkm::exec::WorldCoordinatesToParametricCoordinates(pointsVec, sampleLocation, shapeTag, pcoords);
|
||||
P pmin, pmax;
|
||||
pmin = vtkm::Min(vtkm::Min(pcoords[0], pcoords[1]), pcoords[2]);
|
||||
pmax = vtkm::Max(vtkm::Max(pcoords[0], pcoords[1]), pcoords[2]);
|
||||
@ -88,7 +87,7 @@ VTKM_EXEC_CONT inline bool Sample(const vtkm::Vec<vtkm::Vec<P, 3>, 8>& points,
|
||||
{
|
||||
validSample = false;
|
||||
}
|
||||
lerpedScalar = vtkm::exec::CellInterpolate(scalarVec, pcoords, shapeTag);
|
||||
vtkm::exec::CellInterpolate(scalarVec, pcoords, shapeTag, lerpedScalar);
|
||||
return validSample;
|
||||
}
|
||||
|
||||
@ -101,9 +100,9 @@ VTKM_EXEC_CONT inline bool Sample(const vtkm::VecAxisAlignedPointCoordinates<3>&
|
||||
{
|
||||
|
||||
bool validSample = true;
|
||||
bool success;
|
||||
vtkm::Vec<P, 3> pcoords = vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
points, sampleLocation, vtkm::CellShapeTagHexahedron(), success);
|
||||
vtkm::Vec<P, 3> pcoords;
|
||||
vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
points, sampleLocation, vtkm::CellShapeTagHexahedron(), pcoords);
|
||||
P pmin, pmax;
|
||||
pmin = vtkm::Min(vtkm::Min(pcoords[0], pcoords[1]), pcoords[2]);
|
||||
pmax = vtkm::Max(vtkm::Max(pcoords[0], pcoords[1]), pcoords[2]);
|
||||
@ -111,7 +110,7 @@ VTKM_EXEC_CONT inline bool Sample(const vtkm::VecAxisAlignedPointCoordinates<3>&
|
||||
{
|
||||
validSample = false;
|
||||
}
|
||||
lerpedScalar = vtkm::exec::CellInterpolate(scalars, pcoords, vtkm::CellShapeTagHexahedron());
|
||||
vtkm::exec::CellInterpolate(scalars, pcoords, vtkm::CellShapeTagHexahedron(), lerpedScalar);
|
||||
return validSample;
|
||||
}
|
||||
} // namespace detail
|
||||
|
@ -288,8 +288,8 @@ struct ExternalFaces
|
||||
|
||||
vtkm::IdComponent faceIndex = FindFaceIndexForVisit(visitIndex, pointCoordinates);
|
||||
|
||||
const vtkm::IdComponent numFacePoints =
|
||||
vtkm::exec::CellFaceNumberOfPoints(faceIndex, shape, *this);
|
||||
vtkm::IdComponent numFacePoints;
|
||||
vtkm::exec::CellFaceNumberOfPoints(faceIndex, shape, numFacePoints);
|
||||
VTKM_ASSERT(numFacePoints == faceConnectivity.GetNumberOfComponents());
|
||||
|
||||
typename CellSetType::IndicesType inCellIndices = cellSet.GetIndices(inputIndex);
|
||||
@ -299,8 +299,9 @@ struct ExternalFaces
|
||||
|
||||
for (vtkm::IdComponent facePointIndex = 0; facePointIndex < numFacePoints; facePointIndex++)
|
||||
{
|
||||
faceConnectivity[facePointIndex] =
|
||||
inCellIndices[vtkm::exec::CellFaceLocalIndex(facePointIndex, faceIndex, shape, *this)];
|
||||
vtkm::IdComponent localFaceIndex;
|
||||
vtkm::exec::CellFaceLocalIndex(facePointIndex, faceIndex, shape, localFaceIndex);
|
||||
faceConnectivity[facePointIndex] = inCellIndices[localFaceIndex];
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,13 +315,13 @@ struct ExternalFaces
|
||||
{
|
||||
public:
|
||||
using ControlSignature = void(CellSetIn inCellSet, FieldOut numFacesInCell);
|
||||
using ExecutionSignature = _2(CellShape);
|
||||
using ExecutionSignature = void(CellShape, _2);
|
||||
using InputDomain = _1;
|
||||
|
||||
template <typename CellShapeTag>
|
||||
VTKM_EXEC vtkm::IdComponent operator()(CellShapeTag shape) const
|
||||
VTKM_EXEC void operator()(CellShapeTag shape, vtkm::IdComponent& numFaces) const
|
||||
{
|
||||
return vtkm::exec::CellFaceNumberOfFaces(shape, *this);
|
||||
vtkm::exec::CellFaceNumberOfFaces(shape, numFaces);
|
||||
}
|
||||
};
|
||||
|
||||
@ -346,7 +347,9 @@ struct ExternalFaces
|
||||
vtkm::Id inputIndex,
|
||||
vtkm::IdComponent visitIndex) const
|
||||
{
|
||||
faceHash = vtkm::Hash(vtkm::exec::CellFaceCanonicalId(visitIndex, shape, cellNodeIds, *this));
|
||||
vtkm::Id3 faceId;
|
||||
vtkm::exec::CellFaceCanonicalId(visitIndex, shape, cellNodeIds, faceId);
|
||||
faceHash = vtkm::Hash(faceId);
|
||||
|
||||
cellIndex = inputIndex;
|
||||
faceIndex = visitIndex;
|
||||
@ -384,18 +387,18 @@ struct ExternalFaces
|
||||
myIndex < numCellsOnHash - 1; // Don't need to check last face
|
||||
myIndex++)
|
||||
{
|
||||
vtkm::Id3 myFace =
|
||||
vtkm::exec::CellFaceCanonicalId(originFaces[myIndex],
|
||||
cellSet.GetCellShape(originCells[myIndex]),
|
||||
cellSet.GetIndices(originCells[myIndex]),
|
||||
*this);
|
||||
vtkm::Id3 myFace;
|
||||
vtkm::exec::CellFaceCanonicalId(originFaces[myIndex],
|
||||
cellSet.GetCellShape(originCells[myIndex]),
|
||||
cellSet.GetIndices(originCells[myIndex]),
|
||||
myFace);
|
||||
for (vtkm::IdComponent otherIndex = myIndex + 1; otherIndex < numCellsOnHash; otherIndex++)
|
||||
{
|
||||
vtkm::Id3 otherFace =
|
||||
vtkm::exec::CellFaceCanonicalId(originFaces[otherIndex],
|
||||
cellSet.GetCellShape(originCells[otherIndex]),
|
||||
cellSet.GetIndices(originCells[otherIndex]),
|
||||
*this);
|
||||
vtkm::Id3 otherFace;
|
||||
vtkm::exec::CellFaceCanonicalId(originFaces[otherIndex],
|
||||
cellSet.GetCellShape(originCells[otherIndex]),
|
||||
cellSet.GetIndices(originCells[otherIndex]),
|
||||
otherFace);
|
||||
if (myFace == otherFace)
|
||||
{
|
||||
// Faces are the same. Must be internal. Remove 2, one for each face. We don't have to
|
||||
@ -421,8 +424,7 @@ private:
|
||||
VTKM_EXEC static vtkm::IdComponent FindUniqueFace(const CellSetType& cellSet,
|
||||
const OriginCellsType& originCells,
|
||||
const OriginFacesType& originFaces,
|
||||
vtkm::IdComponent visitIndex,
|
||||
const vtkm::exec::FunctorBase* self)
|
||||
vtkm::IdComponent visitIndex)
|
||||
{
|
||||
vtkm::IdComponent numCellsOnHash = originCells.GetNumberOfComponents();
|
||||
VTKM_ASSERT(originFaces.GetNumberOfComponents() == numCellsOnHash);
|
||||
@ -433,18 +435,19 @@ private:
|
||||
while (true)
|
||||
{
|
||||
VTKM_ASSERT(myIndex < numCellsOnHash);
|
||||
vtkm::Id3 myFace = vtkm::exec::CellFaceCanonicalId(originFaces[myIndex],
|
||||
cellSet.GetCellShape(originCells[myIndex]),
|
||||
cellSet.GetIndices(originCells[myIndex]),
|
||||
*self);
|
||||
vtkm::Id3 myFace;
|
||||
vtkm::exec::CellFaceCanonicalId(originFaces[myIndex],
|
||||
cellSet.GetCellShape(originCells[myIndex]),
|
||||
cellSet.GetIndices(originCells[myIndex]),
|
||||
myFace);
|
||||
bool foundPair = false;
|
||||
for (vtkm::IdComponent otherIndex = myIndex + 1; otherIndex < numCellsOnHash; otherIndex++)
|
||||
{
|
||||
vtkm::Id3 otherFace =
|
||||
vtkm::exec::CellFaceCanonicalId(originFaces[otherIndex],
|
||||
cellSet.GetCellShape(originCells[otherIndex]),
|
||||
cellSet.GetIndices(originCells[otherIndex]),
|
||||
*self);
|
||||
vtkm::Id3 otherFace;
|
||||
vtkm::exec::CellFaceCanonicalId(originFaces[otherIndex],
|
||||
cellSet.GetCellShape(originCells[otherIndex]),
|
||||
cellSet.GetIndices(originCells[otherIndex]),
|
||||
otherFace);
|
||||
if (myFace == otherFace)
|
||||
{
|
||||
// Faces are the same. Must be internal.
|
||||
@ -482,7 +485,7 @@ public:
|
||||
ValuesIn originCells,
|
||||
ValuesIn originFaces,
|
||||
ReducedValuesOut numPointsInFace);
|
||||
using ExecutionSignature = _5(_2, _3, _4, VisitIndex);
|
||||
using ExecutionSignature = void(_2, _3, _4, VisitIndex, _5);
|
||||
using InputDomain = _1;
|
||||
|
||||
using ScatterType = vtkm::worklet::ScatterCounting;
|
||||
@ -495,16 +498,17 @@ public:
|
||||
}
|
||||
|
||||
template <typename CellSetType, typename OriginCellsType, typename OriginFacesType>
|
||||
VTKM_EXEC vtkm::IdComponent operator()(const CellSetType& cellSet,
|
||||
const OriginCellsType& originCells,
|
||||
const OriginFacesType& originFaces,
|
||||
vtkm::IdComponent visitIndex) const
|
||||
VTKM_EXEC void operator()(const CellSetType& cellSet,
|
||||
const OriginCellsType& originCells,
|
||||
const OriginFacesType& originFaces,
|
||||
vtkm::IdComponent visitIndex,
|
||||
vtkm::IdComponent& numFacePoints) const
|
||||
{
|
||||
vtkm::IdComponent myIndex =
|
||||
ExternalFaces::FindUniqueFace(cellSet, originCells, originFaces, visitIndex, this);
|
||||
ExternalFaces::FindUniqueFace(cellSet, originCells, originFaces, visitIndex);
|
||||
|
||||
return vtkm::exec::CellFaceNumberOfPoints(
|
||||
originFaces[myIndex], cellSet.GetCellShape(originCells[myIndex]), *this);
|
||||
vtkm::exec::CellFaceNumberOfPoints(
|
||||
originFaces[myIndex], cellSet.GetCellShape(originCells[myIndex]), numFacePoints);
|
||||
}
|
||||
};
|
||||
|
||||
@ -537,16 +541,16 @@ public:
|
||||
vtkm::Id& cellIdMapOut) const
|
||||
{
|
||||
const vtkm::IdComponent myIndex =
|
||||
ExternalFaces::FindUniqueFace(cellSet, originCells, originFaces, visitIndex, this);
|
||||
ExternalFaces::FindUniqueFace(cellSet, originCells, originFaces, visitIndex);
|
||||
const vtkm::IdComponent myFace = originFaces[myIndex];
|
||||
|
||||
|
||||
typename CellSetType::CellShapeTag shapeIn = cellSet.GetCellShape(originCells[myIndex]);
|
||||
shapeOut = vtkm::exec::CellFaceShape(myFace, shapeIn, *this);
|
||||
vtkm::exec::CellFaceShape(myFace, shapeIn, shapeOut);
|
||||
cellIdMapOut = originCells[myIndex];
|
||||
|
||||
const vtkm::IdComponent numFacePoints =
|
||||
vtkm::exec::CellFaceNumberOfPoints(myFace, shapeIn, *this);
|
||||
vtkm::IdComponent numFacePoints;
|
||||
vtkm::exec::CellFaceNumberOfPoints(myFace, shapeIn, numFacePoints);
|
||||
|
||||
VTKM_ASSERT(numFacePoints == connectivityOut.GetNumberOfComponents());
|
||||
|
||||
@ -554,8 +558,9 @@ public:
|
||||
|
||||
for (vtkm::IdComponent facePointIndex = 0; facePointIndex < numFacePoints; facePointIndex++)
|
||||
{
|
||||
connectivityOut[facePointIndex] =
|
||||
inCellIndices[vtkm::exec::CellFaceLocalIndex(facePointIndex, myFace, shapeIn, *this)];
|
||||
vtkm::IdComponent localFaceIndex;
|
||||
vtkm::exec::CellFaceLocalIndex(facePointIndex, myFace, shapeIn, localFaceIndex);
|
||||
connectivityOut[facePointIndex] = inCellIndices[localFaceIndex];
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -570,7 +575,9 @@ public:
|
||||
template <typename CellShapeTag>
|
||||
VTKM_EXEC vtkm::IdComponent operator()(CellShapeTag shape) const
|
||||
{
|
||||
return !vtkm::exec::CellFaceNumberOfFaces(shape, *this);
|
||||
vtkm::IdComponent numFaces;
|
||||
vtkm::exec::CellFaceNumberOfFaces(shape, numFaces);
|
||||
return !numFaces;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
vtkm::Id& cellId,
|
||||
vtkm::Vec3f& pcoords) const
|
||||
{
|
||||
locator->FindCell(point, cellId, pcoords, *this);
|
||||
locator->FindCell(point, cellId, pcoords);
|
||||
}
|
||||
};
|
||||
|
||||
@ -124,10 +124,10 @@ public:
|
||||
for (vtkm::Id i = minp[0]; i <= maxp[0]; ++i)
|
||||
{
|
||||
auto pt = portal.Get(vtkm::Id3(i, j, k));
|
||||
bool success = false;
|
||||
auto pc = vtkm::exec::WorldCoordinatesToParametricCoordinates(
|
||||
cellPoints, pt, cellShape, success, *this);
|
||||
if (success && vtkm::exec::CellInside(pc, cellShape))
|
||||
CoordsType pc;
|
||||
vtkm::ErrorCode status =
|
||||
vtkm::exec::WorldCoordinatesToParametricCoordinates(cellPoints, pt, cellShape, pc);
|
||||
if ((status == vtkm::ErrorCode::Success) && vtkm::exec::CellInside(pc, cellShape))
|
||||
{
|
||||
auto pointId = i + portal.GetDimensions()[0] * (j + portal.GetDimensions()[1] * k);
|
||||
cellIds.Set(pointId, cellId);
|
||||
@ -199,7 +199,7 @@ public:
|
||||
{
|
||||
auto indices = cells.GetIndices(cellId);
|
||||
auto pointVals = vtkm::make_VecFromPortalPermute(&indices, in);
|
||||
out = vtkm::exec::CellInterpolate(pointVals, pc, cells.GetCellShape(cellId), *this);
|
||||
vtkm::exec::CellInterpolate(pointVals, pc, cells.GetCellShape(cellId), out);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -34,18 +34,17 @@ namespace internal
|
||||
// Given a cell and a point on the cell, find the two edges that are
|
||||
// associated with this point in canonical index
|
||||
template <typename PointFromCellSetType>
|
||||
VTKM_EXEC void FindRelatedEdges(const vtkm::Id& pointIndex,
|
||||
const vtkm::Id& cellIndexG,
|
||||
const PointFromCellSetType& pFromCellSet,
|
||||
vtkm::Id2& edge0G,
|
||||
vtkm::Id2& edge1G,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
VTKM_EXEC vtkm::ErrorCode FindRelatedEdges(const vtkm::Id& pointIndex,
|
||||
const vtkm::Id& cellIndexG,
|
||||
const PointFromCellSetType& pFromCellSet,
|
||||
vtkm::Id2& edge0G,
|
||||
vtkm::Id2& edge1G)
|
||||
{
|
||||
typename PointFromCellSetType::CellShapeTag cellShape = pFromCellSet.GetCellShape(cellIndexG);
|
||||
typename PointFromCellSetType::IndicesType cellConnections = pFromCellSet.GetIndices(cellIndexG);
|
||||
vtkm::IdComponent numPointsInCell = pFromCellSet.GetNumberOfIndices(cellIndexG);
|
||||
vtkm::IdComponent numEdges =
|
||||
vtkm::exec::CellEdgeNumberOfEdges(numPointsInCell, cellShape, worklet);
|
||||
vtkm::IdComponent numEdges;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellEdgeNumberOfEdges(numPointsInCell, cellShape, numEdges));
|
||||
vtkm::IdComponent edgeIndex = -1;
|
||||
// Find the two edges with the pointIndex
|
||||
while (true)
|
||||
@ -53,13 +52,16 @@ VTKM_EXEC void FindRelatedEdges(const vtkm::Id& pointIndex,
|
||||
++edgeIndex;
|
||||
if (edgeIndex >= numEdges)
|
||||
{
|
||||
worklet.RaiseError("Bad cell. Could not find two incident edges.");
|
||||
return;
|
||||
// Bad cell. Could not find two incident edges.
|
||||
return vtkm::ErrorCode::MalformedCellDetected;
|
||||
}
|
||||
vtkm::Id2 canonicalEdgeId(cellConnections[vtkm::exec::CellEdgeLocalIndex(
|
||||
numPointsInCell, 0, edgeIndex, cellShape, worklet)],
|
||||
cellConnections[vtkm::exec::CellEdgeLocalIndex(
|
||||
numPointsInCell, 1, edgeIndex, cellShape, worklet)]);
|
||||
vtkm::IdComponent2 localEdgeIndices;
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellEdgeLocalIndex(
|
||||
numPointsInCell, 0, edgeIndex, cellShape, localEdgeIndices[0]));
|
||||
VTKM_RETURN_ON_ERROR(vtkm::exec::CellEdgeLocalIndex(
|
||||
numPointsInCell, 1, edgeIndex, cellShape, localEdgeIndices[1]));
|
||||
vtkm::Id2 canonicalEdgeId(cellConnections[localEdgeIndices[0]],
|
||||
cellConnections[localEdgeIndices[1]]);
|
||||
if (canonicalEdgeId[0] == pointIndex || canonicalEdgeId[1] == pointIndex)
|
||||
{ // Assign value to edge0 first
|
||||
if ((edge0G[0] == -1) && (edge0G[1] == -1))
|
||||
@ -73,6 +75,7 @@ VTKM_EXEC void FindRelatedEdges(const vtkm::Id& pointIndex,
|
||||
}
|
||||
}
|
||||
}
|
||||
return vtkm::ErrorCode::Success;
|
||||
}
|
||||
|
||||
// TODO: We should replace this expensive lookup with a WholeCellSetIn<Edge, Cell> map.
|
||||
@ -82,8 +85,7 @@ template <typename PointFromCellSetType, typename IncidentCellVecType>
|
||||
VTKM_EXEC int FindNeighborCellInLocalIndex(const vtkm::Id2& eOI,
|
||||
const PointFromCellSetType& pFromCellSet,
|
||||
const IncidentCellVecType& incidentCells,
|
||||
const vtkm::Id currentCellLocalIndex,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
const vtkm::Id currentCellLocalIndex)
|
||||
{
|
||||
int neighboringCellIndex = -1;
|
||||
vtkm::IdComponent numberOfIncidentCells = incidentCells.GetNumberOfComponents();
|
||||
@ -100,8 +102,8 @@ VTKM_EXEC int FindNeighborCellInLocalIndex(const vtkm::Id2& eOI,
|
||||
typename PointFromCellSetType::IndicesType cellConnections =
|
||||
pFromCellSet.GetIndices(cellIndexG);
|
||||
vtkm::IdComponent numPointsInCell = pFromCellSet.GetNumberOfIndices(cellIndexG);
|
||||
vtkm::IdComponent numEdges =
|
||||
vtkm::exec::CellEdgeNumberOfEdges(numPointsInCell, cellShape, worklet);
|
||||
vtkm::IdComponent numEdges;
|
||||
vtkm::exec::CellEdgeNumberOfEdges(numPointsInCell, cellShape, numEdges);
|
||||
vtkm::IdComponent edgeIndex = -1;
|
||||
// Check if this cell has edge of interest
|
||||
while (true)
|
||||
@ -111,10 +113,11 @@ VTKM_EXEC int FindNeighborCellInLocalIndex(const vtkm::Id2& eOI,
|
||||
{
|
||||
break;
|
||||
}
|
||||
vtkm::Id2 canonicalEdgeId(cellConnections[vtkm::exec::CellEdgeLocalIndex(
|
||||
numPointsInCell, 0, edgeIndex, cellShape, worklet)],
|
||||
cellConnections[vtkm::exec::CellEdgeLocalIndex(
|
||||
numPointsInCell, 1, edgeIndex, cellShape, worklet)]);
|
||||
vtkm::IdComponent2 localEdgeIndices;
|
||||
vtkm::exec::CellEdgeLocalIndex(numPointsInCell, 0, edgeIndex, cellShape, localEdgeIndices[0]);
|
||||
vtkm::exec::CellEdgeLocalIndex(numPointsInCell, 1, edgeIndex, cellShape, localEdgeIndices[1]);
|
||||
vtkm::Id2 canonicalEdgeId(cellConnections[localEdgeIndices[0]],
|
||||
cellConnections[localEdgeIndices[1]]);
|
||||
if ((canonicalEdgeId[0] == eOI[0] && canonicalEdgeId[1] == eOI[1]) ||
|
||||
(canonicalEdgeId[0] == eOI[1] && canonicalEdgeId[1] == eOI[0]))
|
||||
{
|
||||
@ -135,8 +138,7 @@ VTKM_EXEC bool FindConnectedCellOwnerships(vtkm::FloatDefault cosFeatureAngle,
|
||||
const PointFromCellSetType& pFromCellSet,
|
||||
const FaceNormalVecType& faceNormals,
|
||||
vtkm::Id visitedCellsRegionIndex[64],
|
||||
vtkm::Id& regionIndex,
|
||||
const vtkm::exec::FunctorBase& worklet)
|
||||
vtkm::Id& regionIndex)
|
||||
{
|
||||
const vtkm::IdComponent numberOfIncidentCells = incidentCells.GetNumberOfComponents();
|
||||
VTKM_ASSERT(numberOfIncidentCells < 64);
|
||||
@ -163,7 +165,7 @@ VTKM_EXEC bool FindConnectedCellOwnerships(vtkm::FloatDefault cosFeatureAngle,
|
||||
|
||||
// Find two edges containing the current point in canonial index
|
||||
vtkm::Id2 edge0G(-1, -1), edge1G(-1, -1);
|
||||
internal::FindRelatedEdges(pointIndex, cellIndexG, pFromCellSet, edge0G, edge1G, worklet);
|
||||
internal::FindRelatedEdges(pointIndex, cellIndexG, pFromCellSet, edge0G, edge1G);
|
||||
// Grow the area along each edge
|
||||
for (size_t i = 0; i < 2; i++)
|
||||
{ // Reset these two values for each grow operation
|
||||
@ -173,7 +175,7 @@ VTKM_EXEC bool FindConnectedCellOwnerships(vtkm::FloatDefault cosFeatureAngle,
|
||||
{
|
||||
// Find the neighbor cell of the current cell edge in local index
|
||||
int neighboringCellIndexQuery = internal::FindNeighborCellInLocalIndex(
|
||||
currentEdgeG, pFromCellSet, incidentCells, currentTestingCellIndex, worklet);
|
||||
currentEdgeG, pFromCellSet, incidentCells, currentTestingCellIndex);
|
||||
// The edge should be manifold and the neighboring cell should
|
||||
// have not been visited
|
||||
if (neighboringCellIndexQuery != -1 && !visitedCells.test(neighboringCellIndexQuery))
|
||||
@ -199,8 +201,7 @@ VTKM_EXEC bool FindConnectedCellOwnerships(vtkm::FloatDefault cosFeatureAngle,
|
||||
incidentCells[currentTestingCellIndex],
|
||||
pFromCellSet,
|
||||
neighborCellEdge0G,
|
||||
neighborCellEdge1G,
|
||||
worklet);
|
||||
neighborCellEdge1G);
|
||||
// Update currentEdgeG
|
||||
if ((currentEdgeG == neighborCellEdge0G) ||
|
||||
currentEdgeG == vtkm::Id2(neighborCellEdge0G[1], neighborCellEdge0G[0]))
|
||||
@ -284,8 +285,7 @@ public:
|
||||
pFromCellSet,
|
||||
faceNormals,
|
||||
visitedCellsRegionIndex,
|
||||
regionIndex,
|
||||
*this);
|
||||
regionIndex);
|
||||
if (!foundConnections)
|
||||
{
|
||||
newPointNum = 0;
|
||||
@ -357,8 +357,7 @@ public:
|
||||
pFromCellSet,
|
||||
faceNormals,
|
||||
visitedCellsRegionIndex,
|
||||
regionIndex,
|
||||
*this);
|
||||
regionIndex);
|
||||
if (foundConnections)
|
||||
{
|
||||
// For each new region you need a new point
|
||||
|
@ -30,14 +30,16 @@ struct EdgeCount : public vtkm::worklet::WorkletVisitCellsWithPoints
|
||||
{
|
||||
using ControlSignature = void(CellSetIn, FieldOutCell numEdgesInCell);
|
||||
|
||||
using ExecutionSignature = _2(CellShape, PointCount);
|
||||
using ExecutionSignature = void(CellShape, PointCount, _2);
|
||||
|
||||
using InputDomain = _1;
|
||||
|
||||
template <typename CellShapeTag>
|
||||
VTKM_EXEC vtkm::IdComponent operator()(CellShapeTag cellShape, vtkm::IdComponent pointCount) const
|
||||
VTKM_EXEC void operator()(CellShapeTag cellShape,
|
||||
vtkm::IdComponent pointCount,
|
||||
vtkm::IdComponent& numEdges) const
|
||||
{
|
||||
return vtkm::exec::CellEdgeNumberOfEdges(pointCount, cellShape, *this);
|
||||
vtkm::exec::CellEdgeNumberOfEdges(pointCount, cellShape, numEdges);
|
||||
}
|
||||
};
|
||||
|
||||
@ -63,8 +65,8 @@ struct EdgeExtract : public vtkm::worklet::WorkletVisitCellsWithPoints
|
||||
EdgeIndexVecType& edgeIndices) const
|
||||
{
|
||||
cellIndexOut = cellIndex;
|
||||
edgeIndices = vtkm::exec::CellEdgeCanonicalId(
|
||||
pointIndices.GetNumberOfComponents(), visitIndex, cellShape, pointIndices, *this);
|
||||
vtkm::exec::CellEdgeCanonicalId(
|
||||
pointIndices.GetNumberOfComponents(), visitIndex, cellShape, pointIndices, edgeIndices);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -48,9 +48,10 @@ struct CellGradient : vtkm::worklet::WorkletVisitCellsWithPoints
|
||||
const FieldInVecType& field,
|
||||
GradientOutType& outputGradient) const
|
||||
{
|
||||
vtkm::Vec3f center = vtkm::exec::ParametricCoordinatesCenter(pointCount, shape, *this);
|
||||
vtkm::Vec3f center;
|
||||
vtkm::exec::ParametricCoordinatesCenter(pointCount, shape, center);
|
||||
|
||||
outputGradient = vtkm::exec::CellDerivative(field, wCoords, center, shape, *this);
|
||||
vtkm::exec::CellDerivative(field, wCoords, center, shape, outputGradient);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -100,10 +100,15 @@ private:
|
||||
{
|
||||
vtkm::Vec3f pCoords;
|
||||
vtkm::exec::ParametricCoordinatesPoint(
|
||||
wCoords.GetNumberOfComponents(), pointIndexForCell, pCoords, cellShape, *this);
|
||||
wCoords.GetNumberOfComponents(), pointIndexForCell, cellShape, pCoords);
|
||||
|
||||
//we need to add this to a return value
|
||||
gradient += vtkm::exec::CellDerivative(field, wCoords, pCoords, cellShape, *this);
|
||||
vtkm::Vec<OutValueType, 3> pointGradient;
|
||||
auto status = vtkm::exec::CellDerivative(field, wCoords, pCoords, cellShape, pointGradient);
|
||||
if (status == vtkm::ErrorCode::Success)
|
||||
{
|
||||
gradient += pointGradient;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename CellSetInType>
|
||||
|
@ -62,9 +62,8 @@ public:
|
||||
{
|
||||
vtkm::Id cellId;
|
||||
Point parametric;
|
||||
vtkm::exec::FunctorBase tmp;
|
||||
|
||||
Locator->FindCell(point, cellId, parametric, tmp);
|
||||
Locator->FindCell(point, cellId, parametric);
|
||||
return cellId != -1;
|
||||
}
|
||||
|
||||
@ -95,10 +94,9 @@ public:
|
||||
{
|
||||
vtkm::Id cellId;
|
||||
Point parametric;
|
||||
vtkm::exec::FunctorBase tmp;
|
||||
GridEvaluatorStatus status;
|
||||
|
||||
Locator->FindCell(point, cellId, parametric, tmp);
|
||||
Locator->FindCell(point, cellId, parametric);
|
||||
if (cellId == -1)
|
||||
{
|
||||
status.SetFail();
|
||||
@ -114,7 +112,7 @@ public:
|
||||
|
||||
for (vtkm::IdComponent i = 0; i < nVerts; i++)
|
||||
fieldValues.Append(Field.Get(ptIndices[i]));
|
||||
out = vtkm::exec::CellInterpolate(fieldValues, parametric, cellShape, tmp);
|
||||
vtkm::exec::CellInterpolate(fieldValues, parametric, cellShape, out);
|
||||
|
||||
status.SetOk();
|
||||
return status;
|
||||
|
@ -23,17 +23,18 @@ namespace
|
||||
{
|
||||
struct CellCentroidCalculator : public vtkm::worklet::WorkletVisitCellsWithPoints
|
||||
{
|
||||
typedef void ControlSignature(CellSetIn, FieldInPoint, FieldOut);
|
||||
typedef _3 ExecutionSignature(_1, PointCount, _2);
|
||||
using ControlSignature = void(CellSetIn, FieldInPoint, FieldOut);
|
||||
using ExecutionSignature = void(_1, PointCount, _2, _3);
|
||||
|
||||
template <typename CellShape, typename InputPointField>
|
||||
VTKM_EXEC typename InputPointField::ComponentType operator()(
|
||||
CellShape shape,
|
||||
vtkm::IdComponent numPoints,
|
||||
const InputPointField& inputPointField) const
|
||||
VTKM_EXEC void operator()(CellShape shape,
|
||||
vtkm::IdComponent numPoints,
|
||||
const InputPointField& inputPointField,
|
||||
typename InputPointField::ComponentType& outputField) const
|
||||
{
|
||||
vtkm::Vec3f parametricCenter = vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, *this);
|
||||
return vtkm::exec::CellInterpolate(inputPointField, parametricCenter, shape, *this);
|
||||
vtkm::Vec3f parametricCenter;
|
||||
vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, parametricCenter);
|
||||
vtkm::exec::CellInterpolate(inputPointField, parametricCenter, shape, outputField);
|
||||
}
|
||||
}; // struct CellCentroidCalculator
|
||||
|
||||
@ -49,7 +50,7 @@ struct BoundingIntervalHierarchyTester : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
vtkm::Vec3f parametric;
|
||||
vtkm::Id cellId;
|
||||
bih->FindCell(point, cellId, parametric, *this);
|
||||
bih->FindCell(point, cellId, parametric);
|
||||
return (1 - static_cast<vtkm::IdComponent>(expectedId == cellId));
|
||||
}
|
||||
}; // struct BoundingIntervalHierarchyTester
|
||||
|
@ -108,6 +108,7 @@ const std::vector<vtkm::UInt8>& GetExpectedHiddenCells()
|
||||
template <typename T>
|
||||
void TestResultArray(const vtkm::cont::ArrayHandle<T>& result, const std::vector<T>& expected)
|
||||
{
|
||||
vtkm::cont::printSummary_ArrayHandle(result, std::cout);
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfValues() == static_cast<vtkm::Id>(expected.size()),
|
||||
"Incorrect field size");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user