mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Merge topic 'vtkm_vec_constructor_bug'
adcabb03 VTK-m Vec<> constructors are now more conservative. 6267deb6 CellDerivativeFor3DCell has a better version for Vec of Vec fields. Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Kenneth Moreland <kmorel@sandia.gov> Merge-request: !1170
This commit is contained in:
commit
06e15e601d
73
vtkm/Types.h
73
vtkm/Types.h
@ -388,7 +388,10 @@ namespace detail
|
||||
#if (defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8))
|
||||
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wfloat-conversion"
|
||||
#endif // gcc || clang
|
||||
#endif // use cuda < 8
|
||||
template <typename T, typename DerivedClass>
|
||||
@ -479,7 +482,10 @@ public:
|
||||
#if (!(defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8)))
|
||||
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wfloat-conversion"
|
||||
#endif // gcc || clang
|
||||
#endif // not using cuda < 8
|
||||
|
||||
@ -596,11 +602,7 @@ public:
|
||||
VTKM_EXEC_CONT
|
||||
const ComponentType* GetPointer() const { return &this->Component(0); }
|
||||
};
|
||||
#if (defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8))
|
||||
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // gcc || clang
|
||||
#endif // use cuda < 8
|
||||
|
||||
|
||||
/// Base implementation of all Vec classes.
|
||||
///
|
||||
@ -623,12 +625,28 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
#if (!(defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8)))
|
||||
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#pragma GCC diagnostic ignored "-Wfloat-conversion"
|
||||
#endif // gcc || clang
|
||||
#endif //not using cuda < 8
|
||||
#if defined(VTKM_MSVC)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4244)
|
||||
#endif
|
||||
|
||||
template <typename OtherValueType, typename OtherDerivedType>
|
||||
VTKM_EXEC_CONT VecBase(const VecBase<OtherValueType, Size, OtherDerivedType>& src)
|
||||
VTKM_EXEC_CONT explicit VecBase(const VecBase<OtherValueType, Size, OtherDerivedType>& src)
|
||||
{
|
||||
//DO NOT CHANGE THIS AND THE ABOVE PRAGMA'S UNLESS YOU FULLY UNDERSTAND THE
|
||||
//ISSUE https://gitlab.kitware.com/vtk/vtk-m/issues/221
|
||||
for (vtkm::IdComponent i = 0; i < Size; ++i)
|
||||
{
|
||||
this->Components[i] = static_cast<T>(src[i]);
|
||||
this->Components[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -649,12 +667,6 @@ public:
|
||||
return this->Components[idx];
|
||||
}
|
||||
|
||||
#if (!(defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8)))
|
||||
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif // gcc || clang
|
||||
#endif // not using cuda < 8
|
||||
|
||||
template <typename OtherComponentType, typename OtherClass>
|
||||
inline VTKM_EXEC_CONT DerivedClass
|
||||
@ -721,11 +733,20 @@ public:
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // gcc || clang
|
||||
#endif // not using cuda < 8
|
||||
#if defined(VTKM_MSVC)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
protected:
|
||||
ComponentType Components[NUM_COMPONENTS];
|
||||
};
|
||||
|
||||
#if (defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8))
|
||||
#if (defined(VTKM_GCC) || defined(VTKM_CLANG))
|
||||
#pragma GCC diagnostic pop
|
||||
#endif // gcc || clang
|
||||
#endif // use cuda < 8
|
||||
|
||||
/// Base of all VecC and VecCConst classes.
|
||||
///
|
||||
template <typename T, typename DerivedClass>
|
||||
@ -771,10 +792,9 @@ public:
|
||||
: Superclass(value)
|
||||
{
|
||||
}
|
||||
// VTKM_EXEC_CONT explicit Vec(const T* values) : Superclass(values) { }
|
||||
|
||||
template <typename OtherType>
|
||||
VTKM_EXEC_CONT Vec(const Vec<OtherType, Size>& src)
|
||||
VTKM_EXEC_CONT explicit Vec(const Vec<OtherType, Size>& src)
|
||||
: Superclass(src)
|
||||
{
|
||||
}
|
||||
@ -835,14 +855,6 @@ public:
|
||||
: Superclass(src)
|
||||
{
|
||||
}
|
||||
|
||||
// This convenience operator removed because it was causing ambiguous
|
||||
// overload errors
|
||||
// VTKM_EXEC_CONT
|
||||
// operator T() const
|
||||
// {
|
||||
// return this->Components[0];
|
||||
// }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -936,21 +948,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// Provides the appropriate type when not sure if using a Vec or a scalar in a
|
||||
/// templated class or function. The \c Type in the struct is the same as the
|
||||
/// \c ComponentType when \c NumComponents is 1 and a \c Vec otherwise.
|
||||
///
|
||||
template <typename ComponentType, vtkm::IdComponent NumComponents>
|
||||
struct VecOrScalar
|
||||
{
|
||||
using Type = vtkm::Vec<ComponentType, NumComponents>;
|
||||
};
|
||||
template <typename ComponentType>
|
||||
struct VecOrScalar<ComponentType, 1>
|
||||
{
|
||||
using Type = ComponentType;
|
||||
};
|
||||
|
||||
/// Initializes and returns a Vec of length 2.
|
||||
///
|
||||
template <typename T>
|
||||
|
@ -181,26 +181,26 @@ ParametricDerivative(const FieldVecType &field,
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename FieldVecType,
|
||||
template <typename FieldType,
|
||||
int NumPoints,
|
||||
typename WorldCoordType,
|
||||
typename ParametricCoordType,
|
||||
typename CellShapeTag>
|
||||
VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivativeFor3DCell(
|
||||
const FieldVecType& field,
|
||||
VTKM_EXEC vtkm::Vec<FieldType, 3> CellDerivativeFor3DCell(
|
||||
const vtkm::Vec<FieldType, NumPoints>& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag)
|
||||
CellShapeTag tag)
|
||||
{
|
||||
using FieldType = typename FieldVecType::ComponentType;
|
||||
using GradientType = vtkm::Vec<FieldType, 3>;
|
||||
|
||||
// For reasons that should become apparent in a moment, we actually want
|
||||
// the transpose of the Jacobian.
|
||||
vtkm::Matrix<FieldType, 3, 3> jacobianTranspose;
|
||||
vtkm::exec::JacobianFor3DCell(wCoords, pcoords, jacobianTranspose, CellShapeTag());
|
||||
vtkm::exec::JacobianFor3DCell(wCoords, pcoords, jacobianTranspose, tag);
|
||||
jacobianTranspose = vtkm::MatrixTranspose(jacobianTranspose);
|
||||
|
||||
GradientType parametricDerivative = ParametricDerivative(field, pcoords, CellShapeTag());
|
||||
GradientType parametricDerivative = ParametricDerivative(field, pcoords, tag);
|
||||
|
||||
// If we write out the matrices below, it should become clear that the
|
||||
// Jacobian transpose times the field derivative in world space equals
|
||||
@ -221,6 +221,44 @@ VTKM_EXEC vtkm::Vec<typename FieldVecType::ComponentType, 3> CellDerivativeFor3D
|
||||
return vtkm::SolveLinearSystem(jacobianTranspose, parametricDerivative, valid);
|
||||
}
|
||||
|
||||
template <typename T,
|
||||
int N,
|
||||
int NumPoints,
|
||||
typename WorldCoordType,
|
||||
typename ParametricCoordType,
|
||||
typename CellShapeTag>
|
||||
VTKM_EXEC vtkm::Vec<vtkm::Vec<T, N>, 3> CellDerivativeFor3DCell(
|
||||
const vtkm::Vec<vtkm::Vec<T, N>, NumPoints>& field,
|
||||
const WorldCoordType& wCoords,
|
||||
const vtkm::Vec<ParametricCoordType, 3>& pcoords,
|
||||
CellShapeTag tag)
|
||||
{
|
||||
//We have been given a vector field so we need to solve for each
|
||||
//component of the vector. For explanation of the logic used see the
|
||||
//scalar version of CellDerivativeFor3DCell.
|
||||
vtkm::Matrix<T, 3, 3> perComponentJacobianTranspose;
|
||||
vtkm::exec::JacobianFor3DCell(wCoords, pcoords, perComponentJacobianTranspose, tag);
|
||||
perComponentJacobianTranspose = vtkm::MatrixTranspose(perComponentJacobianTranspose);
|
||||
|
||||
bool valid; // Ignored.
|
||||
vtkm::Vec<vtkm::Vec<T, N>, 3> result(vtkm::Vec<T, N>(0.0f));
|
||||
vtkm::Vec<T, NumPoints> perPoint;
|
||||
for (vtkm::IdComponent i = 0; i < N; ++i)
|
||||
{
|
||||
for (vtkm::IdComponent c = 0; c < NumPoints; ++c)
|
||||
{
|
||||
perPoint[c] = field[c][i];
|
||||
}
|
||||
vtkm::Vec<T, 3> p = ParametricDerivative(perPoint, pcoords, tag);
|
||||
vtkm::Vec<T, 3> grad = vtkm::SolveLinearSystem(perComponentJacobianTranspose, p, valid);
|
||||
|
||||
result[0][i] += grad[0];
|
||||
result[1][i] += grad[1];
|
||||
result[2][i] += grad[2];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename FieldType, typename LUType, typename ParametricCoordType, typename CellShapeTag>
|
||||
VTKM_EXEC vtkm::Vec<FieldType, 3> CellDerivativeFor2DCellFinish(
|
||||
const vtkm::Vec<FieldType, 4>& field,
|
||||
|
Loading…
Reference in New Issue
Block a user