From 40fe133d88d2bd0eb14af5453974bce07d2e5a5a Mon Sep 17 00:00:00 2001 From: ayenpure Date: Wed, 2 May 2018 13:49:16 -0700 Subject: [PATCH] Fix compile warnings for Temporal Advection --- .../particleadvection/GridEvaluators.h | 39 ++++++++++------ vtkm/worklet/particleadvection/Integrators.h | 4 +- .../TemporalGridEvaluators.h | 46 +++++++++++-------- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/vtkm/worklet/particleadvection/GridEvaluators.h b/vtkm/worklet/particleadvection/GridEvaluators.h index 2441d8536..10e9bcde6 100644 --- a/vtkm/worklet/particleadvection/GridEvaluators.h +++ b/vtkm/worklet/particleadvection/GridEvaluators.h @@ -209,9 +209,12 @@ public: // output = (input - input_min) * scale + output_min // // In our case output_min is 0 - scale[0] = (dims[0] - 1) / (bounds.X.Max - bounds.X.Min); - scale[1] = (dims[1] - 1) / (bounds.Y.Max - bounds.Y.Min); - scale[2] = (dims[2] - 1) / (bounds.Z.Max - bounds.Z.Min); + scale[0] = + static_cast(dims[0] - 1) / static_cast(bounds.X.Max - bounds.X.Min); + scale[1] = + static_cast(dims[1] - 1) / static_cast(bounds.Y.Max - bounds.Y.Min); + scale[2] = + static_cast(dims[2] - 1) / static_cast(bounds.Z.Max - bounds.Z.Min); planeSize = dims[0] * dims[1]; rowSize = dims[0]; @@ -240,9 +243,12 @@ public: // output = (input - input_min) * scale + output_min // // In our case output_min is 0 - scale[0] = (dims[0] - 1) / (bounds.X.Max - bounds.X.Min); - scale[1] = (dims[1] - 1) / (bounds.Y.Max - bounds.Y.Min); - scale[2] = (dims[2] - 1) / (bounds.Z.Max - bounds.Z.Min); + scale[0] = + static_cast(dims[0] - 1) / static_cast(bounds.X.Max - bounds.X.Min); + scale[1] = + static_cast(dims[1] - 1) / static_cast(bounds.Y.Max - bounds.Y.Min); + scale[2] = + static_cast(dims[2] - 1) / static_cast(bounds.Z.Max - bounds.Z.Min); planeSize = dims[0] * dims[1]; rowSize = dims[0]; @@ -297,13 +303,13 @@ public: // to a unit spacing volume with origin as (0,0,0) // The method used is described in the constructor. vtkm::Vec normalizedPos; - normalizedPos[0] = (pos[0] - bounds.X.Min) * scale[0]; - normalizedPos[1] = (pos[1] - bounds.Y.Min) * scale[1]; - normalizedPos[2] = (pos[2] - bounds.Z.Min) * scale[2]; + normalizedPos[0] = static_cast((pos[0] - bounds.X.Min) * scale[0]); + normalizedPos[1] = static_cast((pos[1] - bounds.Y.Min) * scale[1]); + normalizedPos[2] = static_cast((pos[2] - bounds.Z.Min) * scale[2]); - idx000[0] = floor(normalizedPos[0]); - idx000[1] = floor(normalizedPos[1]); - idx000[2] = floor(normalizedPos[2]); + idx000[0] = static_cast(floor(normalizedPos[0])); + idx000[1] = static_cast(floor(normalizedPos[1])); + idx000[2] = static_cast(floor(normalizedPos[2])); idx001 = idx000; idx001[0] = (idx001[0] + 1) <= dims[0] - 1 ? idx001[0] + 1 : dims[0] - 1; @@ -334,7 +340,7 @@ public: // Interpolation in X vtkm::Vec v00, v01, v10, v11; - FieldType a = normalizedPos[0] - floor(normalizedPos[0]); + FieldType a = normalizedPos[0] - static_cast(floor(normalizedPos[0])); v00[0] = (1.0f - a) * v000[0] + a * v001[0]; v00[1] = (1.0f - a) * v000[1] + a * v001[1]; v00[2] = (1.0f - a) * v000[2] + a * v001[2]; @@ -354,7 +360,7 @@ public: // Interpolation in Y vtkm::Vec v0, v1; - a = normalizedPos[1] - floor(normalizedPos[1]); + a = normalizedPos[1] - static_cast(floor(normalizedPos[1])); v0[0] = (1.0f - a) * v00[0] + a * v01[0]; v0[1] = (1.0f - a) * v00[1] + a * v01[1]; v0[2] = (1.0f - a) * v00[2] + a * v01[2]; @@ -363,7 +369,7 @@ public: v1[1] = (1.0f - a) * v10[1] + a * v11[1]; v1[2] = (1.0f - a) * v10[2] + a * v11[2]; - a = normalizedPos[2] - floor(normalizedPos[2]); + a = normalizedPos[2] - static_cast(floor(normalizedPos[2])); out[0] = (1.0f - a) * v0[0] + a * v1[0]; out[1] = (1.0f - a) * v0[1] + a * v1[1]; out[2] = (1.0f - a) * v0[2] + a * v1[2]; @@ -385,6 +391,9 @@ class RectilinearGridEvaluate using FieldHandle = vtkm::cont::ArrayHandle>; public: + VTKM_CONT + RectilinearGridEvaluate() {} + VTKM_CONT RectilinearGridEvaluate(const vtkm::cont::CoordinateSystem& coords, const vtkm::cont::DynamicCellSet& cellSet, diff --git a/vtkm/worklet/particleadvection/Integrators.h b/vtkm/worklet/particleadvection/Integrators.h index 8c320cccf..7897781fc 100644 --- a/vtkm/worklet/particleadvection/Integrators.h +++ b/vtkm/worklet/particleadvection/Integrators.h @@ -97,10 +97,10 @@ public: if (MinimizeError) { //Take short steps and minimize error - FieldType threshold = StepLength / numSteps; + FieldType threshold = StepLength / static_cast(numSteps); do { - stepLength /= 2.0; + stepLength /= static_cast(2.0); status = CheckStep(inpos, stepLength, time, velocity); if (status == ParticleStatus::STATUS_OK) { diff --git a/vtkm/worklet/particleadvection/TemporalGridEvaluators.h b/vtkm/worklet/particleadvection/TemporalGridEvaluators.h index 1060e8d0e..797e55817 100644 --- a/vtkm/worklet/particleadvection/TemporalGridEvaluators.h +++ b/vtkm/worklet/particleadvection/TemporalGridEvaluators.h @@ -97,13 +97,19 @@ public: planeSize2 = dims2[1] * dims2[1]; rowSize2 = dims2[0]; - scale1[0] = dims1[0] / (FieldType)(bounds1.X.Max - bounds1.X.Min); - scale1[1] = dims1[1] / (FieldType)(bounds1.Y.Max - bounds1.Y.Min); - scale1[2] = dims1[2] / (FieldType)(bounds1.Z.Max - bounds1.Z.Min); + scale1[0] = + static_cast(dims1[0] - 1) / static_cast(bounds1.X.Max - bounds1.X.Min); + scale1[1] = + static_cast(dims1[1] - 1) / static_cast(bounds1.Y.Max - bounds1.Y.Min); + scale1[2] = + static_cast(dims1[2] - 1) / static_cast(bounds1.Z.Max - bounds1.Z.Min); - scale2[0] = dims2[0] / (FieldType)(bounds2.X.Max - bounds2.X.Min); - scale2[1] = dims2[1] / (FieldType)(bounds2.Y.Max - bounds2.Y.Min); - scale2[2] = dims2[2] / (FieldType)(bounds2.Z.Max - bounds2.Z.Min); + scale2[0] = + static_cast(dims2[0] - 1) / static_cast(bounds2.X.Max - bounds2.X.Min); + scale2[1] = + static_cast(dims2[1] - 1) / static_cast(bounds2.Y.Max - bounds2.Y.Min); + scale2[2] = + static_cast(dims2[2] - 1) / static_cast(bounds2.Z.Max - bounds2.Z.Min); }; @@ -175,9 +181,13 @@ public: time2 = time; planeSize2 = dims2[1] * dims2[1]; rowSize2 = dims2[0]; - scale2[0] = dims2[0] / (FieldType)(bounds2.X.Max - bounds2.X.Min); - scale2[1] = dims2[1] / (FieldType)(bounds2.Y.Max - bounds2.Y.Min); - scale2[2] = dims2[2] / (FieldType)(bounds2.Z.Max - bounds2.Z.Min); + + scale2[0] = + static_cast(dims2[0] - 1) / static_cast(bounds2.X.Max - bounds2.X.Min); + scale2[1] = + static_cast(dims2[1] - 1) / static_cast(bounds2.Y.Max - bounds2.Y.Min); + scale2[2] = + static_cast(dims2[2] - 1) / static_cast(bounds2.Z.Max - bounds2.Z.Min); }; VTKM_EXEC @@ -196,13 +206,13 @@ public: vtkm::Id3 idx000, idx001, idx010, idx011, idx100, idx101, idx110, idx111; vtkm::Vec normalized = - vtkm::Vec((position[0] - bounds.X.Min) * scale[0], - (position[1] - bounds.Y.Min) * scale[1], - (position[2] - bounds.Z.Min) * scale[2]); + vtkm::Vec((position[0] - static_cast(bounds.X.Min)) * scale[0], + (position[1] - static_cast(bounds.Y.Min)) * scale[1], + (position[2] - static_cast(bounds.Z.Min)) * scale[2]); - idx000[0] = floor(normalized[0]) <= dims[0] - 1 ? floor(normalized[0]) : dims[0] - 1; - idx000[1] = floor(normalized[1]) <= dims[1] - 1 ? floor(normalized[1]) : dims[1] - 1; - idx000[2] = floor(normalized[2]) <= dims[2] - 1 ? floor(normalized[2]) : dims[2] - 1; + idx000[0] = static_cast(floor(normalized[0])); + idx000[1] = static_cast(floor(normalized[1])); + idx000[2] = static_cast(floor(normalized[2])); idx001 = idx000; idx001[0] = (idx001[0] + 1) <= dims[0] - 1 ? idx001[0] + 1 : dims[0] - 1; @@ -232,7 +242,7 @@ public: // Interpolation in X vtkm::Vec v00, v01, v10, v11; - FieldType a = normalized[0] - floor(normalized[0]); + FieldType a = normalized[0] - static_cast(floor(normalized[0])); v00[0] = (1.0f - a) * v000[0] + a * v001[0]; v00[1] = (1.0f - a) * v000[1] + a * v001[1]; v00[2] = (1.0f - a) * v000[2] + a * v001[2]; @@ -251,7 +261,7 @@ public: // Interpolation in Y vtkm::Vec v0, v1; - a = normalized[1] - floor(normalized[1]); + a = normalized[1] - static_cast(floor(normalized[1])); v0[0] = (1.0f - a) * v00[0] + a * v01[0]; v0[1] = (1.0f - a) * v00[1] + a * v01[1]; v0[2] = (1.0f - a) * v00[2] + a * v01[2]; @@ -260,7 +270,7 @@ public: v1[1] = (1.0f - a) * v10[1] + a * v11[1]; v1[2] = (1.0f - a) * v10[2] + a * v11[2]; - a = normalized[2] - floor(normalized[2]); + a = normalized[2] - static_cast(floor(normalized[2])); velocity[0] = (1.0f - a) * v0[0] + a * v1[0]; velocity[1] = (1.0f - a) * v0[1] + a * v1[1]; velocity[2] = (1.0f - a) * v0[2] + a * v1[2];