mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Special implementation of parametric coordinates for rectilinear cells
This commit is contained in:
parent
429f9c0cb7
commit
493656e419
@ -22,6 +22,7 @@
|
||||
|
||||
#include <vtkm/CellShape.h>
|
||||
#include <vtkm/Math.h>
|
||||
#include <vtkm/VecRectilinearPointCoordinates.h>
|
||||
#include <vtkm/exec/Assert.h>
|
||||
#include <vtkm/exec/CellDerivative.h>
|
||||
#include <vtkm/exec/CellInterpolate.h>
|
||||
@ -732,6 +733,17 @@ WorldCoordinatesToParametricCoordinates(
|
||||
return Vector3(numerator/denominator, 0, 0);
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Vec<vtkm::FloatDefault,3>
|
||||
WorldCoordinatesToParametricCoordinates(
|
||||
const vtkm::VecRectilinearPointCoordinates<1> &pointWCoords,
|
||||
const vtkm::Vec<vtkm::FloatDefault,3> &wcoords,
|
||||
vtkm::CellShapeTagLine,
|
||||
const FunctorBase &)
|
||||
{
|
||||
return (wcoords - pointWCoords.GetOrigin())/pointWCoords.GetSpacing();
|
||||
}
|
||||
|
||||
template<typename WorldCoordVector>
|
||||
VTKM_EXEC_EXPORT
|
||||
typename WorldCoordVector::ComponentType
|
||||
@ -911,6 +923,17 @@ WorldCoordinatesToParametricCoordinates(
|
||||
return Vector3(pcoords[0], pcoords[1], 0);
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Vec<vtkm::FloatDefault,3>
|
||||
WorldCoordinatesToParametricCoordinates(
|
||||
const vtkm::VecRectilinearPointCoordinates<2> &pointWCoords,
|
||||
const vtkm::Vec<vtkm::FloatDefault,3> &wcoords,
|
||||
vtkm::CellShapeTagQuad,
|
||||
const FunctorBase &)
|
||||
{
|
||||
return (wcoords - pointWCoords.GetOrigin())/pointWCoords.GetSpacing();
|
||||
}
|
||||
|
||||
template<typename WorldCoordVector>
|
||||
VTKM_EXEC_EXPORT
|
||||
typename WorldCoordVector::ComponentType
|
||||
@ -982,6 +1005,17 @@ WorldCoordinatesToParametricCoordinates(
|
||||
pointWCoords, wcoords, vtkm::CellShapeTagHexahedron(), worklet);
|
||||
}
|
||||
|
||||
VTKM_EXEC_EXPORT
|
||||
vtkm::Vec<vtkm::FloatDefault,3>
|
||||
WorldCoordinatesToParametricCoordinates(
|
||||
const vtkm::VecRectilinearPointCoordinates<3> &pointWCoords,
|
||||
const vtkm::Vec<vtkm::FloatDefault,3> &wcoords,
|
||||
vtkm::CellShapeTagHexahedron,
|
||||
const FunctorBase &)
|
||||
{
|
||||
return (wcoords - pointWCoords.GetOrigin())/pointWCoords.GetSpacing();
|
||||
}
|
||||
|
||||
template<typename WorldCoordVector>
|
||||
VTKM_EXEC_EXPORT
|
||||
typename WorldCoordVector::ComponentType
|
||||
|
@ -295,6 +295,22 @@ void TestAllPCoords()
|
||||
vtkm::testing::Testing::TryAllCellShapes(TestPCoordsFunctor<vtkm::Float32>());
|
||||
std::cout << "======== Float64 ==========================" << std::endl;
|
||||
vtkm::testing::Testing::TryAllCellShapes(TestPCoordsFunctor<vtkm::Float64>());
|
||||
|
||||
std::cout << "======== Rectilinear Shapes ===============" << std::endl;
|
||||
boost::random::uniform_real_distribution<vtkm::FloatDefault> randomDist(0.01f,1.0f);
|
||||
vtkm::Vec<vtkm::FloatDefault,3> origin(randomDist(g_RandomGenerator),
|
||||
randomDist(g_RandomGenerator),
|
||||
randomDist(g_RandomGenerator));
|
||||
vtkm::Vec<vtkm::FloatDefault,3> spacing(randomDist(g_RandomGenerator),
|
||||
randomDist(g_RandomGenerator),
|
||||
randomDist(g_RandomGenerator));
|
||||
|
||||
TestPCoords(vtkm::VecRectilinearPointCoordinates<3>(origin, spacing),
|
||||
vtkm::CellShapeTagHexahedron());
|
||||
TestPCoords(vtkm::VecRectilinearPointCoordinates<2>(origin, spacing),
|
||||
vtkm::CellShapeTagQuad());
|
||||
TestPCoords(vtkm::VecRectilinearPointCoordinates<1>(origin, spacing),
|
||||
vtkm::CellShapeTagLine());
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
@ -116,6 +116,10 @@ void TryVecRectilinearPointCoordinates(
|
||||
vtkm::Vec<vtkm::Vec<vtkm::FloatDefault,3>,VecCoordsType::NUM_COMPONENTS> copy2;
|
||||
VTraits::CopyInto(coords, copy2);
|
||||
CheckCoordsValues(copy2);
|
||||
|
||||
std::cout << "Check origin and spacing." << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(coords.GetOrigin(), g_Origin), "Wrong origin.");
|
||||
VTKM_TEST_ASSERT(test_equal(coords.GetSpacing(), g_Spacing), "Wrong spacing");
|
||||
}
|
||||
|
||||
void TestVecRectilinearPointCoordinates()
|
||||
|
Loading…
Reference in New Issue
Block a user