mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Move virtual methods of other CellLocators to vtkm_cont
These changes caused some warnings in clang to show up based on virtual methods in other cell locators. Hence, the rest of the cell locators have also had some of their code moved to vtkm_cont.
This commit is contained in:
parent
e87864b0e3
commit
0af017b038
@ -5,3 +5,6 @@ header files. This is sometimes problematic with virtual methods. Since
|
||||
everything implemented in it can just be embedded in a library, move the
|
||||
code into the vtkm_cont library.
|
||||
|
||||
These changes caused some warnings in clang to show up based on virtual
|
||||
methods in other cell locators. Hence, the rest of the cell locators
|
||||
have also had some of their code moved to vtkm_cont.
|
||||
|
@ -131,6 +131,7 @@ set(sources
|
||||
AssignerMultiBlock.cxx
|
||||
BoundsCompute.cxx
|
||||
BoundsGlobalCompute.cxx
|
||||
CellLocator.cxx
|
||||
CellSet.cxx
|
||||
CellSetStructured.cxx
|
||||
ColorTable.cxx
|
||||
@ -166,6 +167,8 @@ set(sources
|
||||
set(device_sources
|
||||
ArrayRangeCompute.cxx
|
||||
CellLocatorBoundingIntervalHierarchy.cxx
|
||||
CellLocatorRectilinearGrid.cxx
|
||||
CellLocatorUniformGrid.cxx
|
||||
CellSetExplicit.cxx
|
||||
CoordinateSystem.cxx
|
||||
StorageVirtual.cxx
|
||||
|
23
vtkm/cont/CellLocator.cxx
Normal file
23
vtkm/cont/CellLocator.cxx
Normal file
@ -0,0 +1,23 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||
// Copyright 2019 UT-Battelle, LLC.
|
||||
// Copyright 2019 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/CellLocator.h>
|
||||
|
||||
vtkm::cont::CellLocator::~CellLocator() = default;
|
@ -45,6 +45,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~CellLocator();
|
||||
|
||||
vtkm::cont::DynamicCellSet GetCellSet() const { return CellSet; }
|
||||
|
||||
void SetCellSet(const vtkm::cont::DynamicCellSet& cellSet)
|
||||
|
@ -238,6 +238,8 @@ VTKM_CONT IdArrayHandle CalculateSplitScatterIndices(const IdArrayHandle& cellId
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
VTKM_CONT CellLocatorBoundingIntervalHierarchy::~CellLocatorBoundingIntervalHierarchy() = default;
|
||||
|
||||
VTKM_CONT
|
||||
void CellLocatorBoundingIntervalHierarchy::Build()
|
||||
{
|
||||
|
@ -61,6 +61,8 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT ~CellLocatorBoundingIntervalHierarchy() override;
|
||||
|
||||
VTKM_CONT
|
||||
void SetNumberOfSplittingPlanes(vtkm::IdComponent numPlanes)
|
||||
{
|
||||
|
76
vtkm/cont/CellLocatorRectilinearGrid.cxx
Normal file
76
vtkm/cont/CellLocatorRectilinearGrid.cxx
Normal file
@ -0,0 +1,76 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||
// Copyright 2019 UT-Battelle, LLC.
|
||||
// Copyright 2019 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/CellLocatorRectilinearGrid.h>
|
||||
|
||||
#include <vtkm/exec/CellLocatorRectilinearGrid.h>
|
||||
|
||||
vtkm::cont::CellLocatorRectilinearGrid::CellLocatorRectilinearGrid() = default;
|
||||
|
||||
vtkm::cont::CellLocatorRectilinearGrid::~CellLocatorRectilinearGrid() = default;
|
||||
|
||||
void vtkm::cont::CellLocatorRectilinearGrid::Build()
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = this->GetCoordinates();
|
||||
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
|
||||
|
||||
if (!coords.GetData().IsType<RectilinearType>())
|
||||
throw vtkm::cont::ErrorInternal("Coordinates are not rectilinear.");
|
||||
if (!cellSet.IsSameType(StructuredType()))
|
||||
throw vtkm::cont::ErrorInternal("Cells are not 3D structured.");
|
||||
|
||||
vtkm::Vec<vtkm::Id, 3> celldims =
|
||||
cellSet.Cast<StructuredType>().GetSchedulingRange(vtkm::TopologyElementTagCell());
|
||||
|
||||
this->PlaneSize = celldims[0] * celldims[1];
|
||||
this->RowSize = celldims[0];
|
||||
}
|
||||
|
||||
struct vtkm::cont::CellLocatorRectilinearGrid::PrepareForExecutionFunctor
|
||||
{
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT bool operator()(DeviceAdapter,
|
||||
const vtkm::cont::CellLocatorRectilinearGrid& contLocator,
|
||||
HandleType& execLocator) const
|
||||
{
|
||||
using ExecutionType = vtkm::exec::CellLocatorRectilinearGrid<DeviceAdapter>;
|
||||
ExecutionType* execObject =
|
||||
new ExecutionType(contLocator.PlaneSize,
|
||||
contLocator.RowSize,
|
||||
contLocator.GetCellSet().template Cast<StructuredType>(),
|
||||
contLocator.GetCoordinates().GetData().template Cast<RectilinearType>(),
|
||||
DeviceAdapter());
|
||||
execLocator.Reset(execObject);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
const vtkm::cont::CellLocator::HandleType
|
||||
vtkm::cont::CellLocatorRectilinearGrid::PrepareForExecutionImpl(
|
||||
const vtkm::cont::DeviceAdapterId deviceId) const
|
||||
{
|
||||
const bool success =
|
||||
vtkm::cont::TryExecuteOnDevice(deviceId, PrepareForExecutionFunctor(), *this, this->ExecHandle);
|
||||
if (!success)
|
||||
{
|
||||
throwFailedRuntimeDeviceTransfer("CellLocatorRectilinearGrid", deviceId);
|
||||
}
|
||||
return this->ExecHandle;
|
||||
}
|
@ -22,10 +22,6 @@
|
||||
|
||||
#include <vtkm/cont/CellLocator.h>
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/ErrorBadDevice.h>
|
||||
|
||||
#include <vtkm/exec/CellLocatorRectilinearGrid.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -33,7 +29,7 @@ namespace vtkm
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class CellLocatorRectilinearGrid : public vtkm::cont::CellLocator
|
||||
class VTKM_CONT_EXPORT CellLocatorRectilinearGrid : public vtkm::cont::CellLocator
|
||||
{
|
||||
public:
|
||||
using StructuredType = vtkm::cont::CellSetStructured<3>;
|
||||
@ -41,64 +37,23 @@ public:
|
||||
using RectilinearType =
|
||||
vtkm::cont::ArrayHandleCartesianProduct<AxisHandle, AxisHandle, AxisHandle>;
|
||||
|
||||
VTKM_CONT
|
||||
CellLocatorRectilinearGrid() = default;
|
||||
VTKM_CONT CellLocatorRectilinearGrid();
|
||||
|
||||
VTKM_CONT
|
||||
void Build() override
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = this->GetCoordinates();
|
||||
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
|
||||
VTKM_CONT ~CellLocatorRectilinearGrid() override;
|
||||
|
||||
if (!coords.GetData().IsType<RectilinearType>())
|
||||
throw vtkm::cont::ErrorInternal("Coordinates are not rectilinear.");
|
||||
if (!cellSet.IsSameType(StructuredType()))
|
||||
throw vtkm::cont::ErrorInternal("Cells are not 3D structured.");
|
||||
|
||||
vtkm::Vec<vtkm::Id, 3> celldims =
|
||||
cellSet.Cast<StructuredType>().GetSchedulingRange(vtkm::TopologyElementTagCell());
|
||||
|
||||
this->PlaneSize = celldims[0] * celldims[1];
|
||||
this->RowSize = celldims[0];
|
||||
}
|
||||
|
||||
struct PrepareForExecutionFunctor
|
||||
{
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT bool operator()(DeviceAdapter,
|
||||
const vtkm::cont::CellLocatorRectilinearGrid& contLocator,
|
||||
HandleType& execLocator) const
|
||||
{
|
||||
using ExecutionType = vtkm::exec::CellLocatorRectilinearGrid<DeviceAdapter>;
|
||||
ExecutionType* execObject =
|
||||
new ExecutionType(contLocator.PlaneSize,
|
||||
contLocator.RowSize,
|
||||
contLocator.GetCellSet().template Cast<StructuredType>(),
|
||||
contLocator.GetCoordinates().GetData().template Cast<RectilinearType>(),
|
||||
DeviceAdapter());
|
||||
execLocator.Reset(execObject);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
VTKM_CONT void Build() override;
|
||||
|
||||
VTKM_CONT
|
||||
const HandleType PrepareForExecutionImpl(
|
||||
const vtkm::cont::DeviceAdapterId deviceId) const override
|
||||
{
|
||||
const bool success = vtkm::cont::TryExecuteOnDevice(
|
||||
deviceId, PrepareForExecutionFunctor(), *this, this->ExecHandle);
|
||||
if (!success)
|
||||
{
|
||||
throwFailedRuntimeDeviceTransfer("CellLocatorRectilinearGrid", deviceId);
|
||||
}
|
||||
return this->ExecHandle;
|
||||
}
|
||||
const vtkm::cont::DeviceAdapterId deviceId) const override;
|
||||
|
||||
private:
|
||||
vtkm::Bounds Bounds;
|
||||
vtkm::Id PlaneSize;
|
||||
vtkm::Id RowSize;
|
||||
mutable HandleType ExecHandle;
|
||||
|
||||
struct PrepareForExecutionFunctor;
|
||||
};
|
||||
|
||||
} //namespace cont
|
||||
|
82
vtkm/cont/CellLocatorUniformGrid.cxx
Normal file
82
vtkm/cont/CellLocatorUniformGrid.cxx
Normal file
@ -0,0 +1,82 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2019 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
||||
// Copyright 2019 UT-Battelle, LLC.
|
||||
// Copyright 2019 Los Alamos National Security.
|
||||
//
|
||||
// Under the terms of Contract DE-NA0003525 with NTESS,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/Algorithm.h>
|
||||
#include <vtkm/cont/CellLocatorUniformGrid.h>
|
||||
|
||||
#include <vtkm/exec/CellLocatorUniformGrid.h>
|
||||
|
||||
vtkm::cont::CellLocatorUniformGrid::CellLocatorUniformGrid() = default;
|
||||
|
||||
vtkm::cont::CellLocatorUniformGrid::~CellLocatorUniformGrid() = default;
|
||||
|
||||
void vtkm::cont::CellLocatorUniformGrid::Build()
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = this->GetCoordinates();
|
||||
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
|
||||
|
||||
if (!coords.GetData().IsType<UniformType>())
|
||||
throw vtkm::cont::ErrorBadType("Coordinate system is not uniform type");
|
||||
if (!cellSet.IsSameType(StructuredType()))
|
||||
throw vtkm::cont::ErrorBadType("Cell set is not 3D structured type");
|
||||
|
||||
Bounds = coords.GetBounds();
|
||||
CellDims = cellSet.Cast<StructuredType>().GetSchedulingRange(vtkm::TopologyElementTagCell());
|
||||
|
||||
RangeTransform[0] = static_cast<vtkm::FloatDefault>(CellDims[0]) /
|
||||
static_cast<vtkm::FloatDefault>(Bounds.X.Length());
|
||||
RangeTransform[1] = static_cast<vtkm::FloatDefault>(CellDims[1]) /
|
||||
static_cast<vtkm::FloatDefault>(Bounds.Y.Length());
|
||||
RangeTransform[2] = static_cast<vtkm::FloatDefault>(CellDims[2]) /
|
||||
static_cast<vtkm::FloatDefault>(Bounds.Z.Length());
|
||||
}
|
||||
|
||||
struct vtkm::cont::CellLocatorUniformGrid::PrepareForExecutionFunctor
|
||||
{
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT bool operator()(DeviceAdapter,
|
||||
const vtkm::cont::CellLocatorUniformGrid& contLocator,
|
||||
HandleType& execLocator) const
|
||||
{
|
||||
using ExecutionType = vtkm::exec::CellLocatorUniformGrid<DeviceAdapter>;
|
||||
ExecutionType* execObject =
|
||||
new ExecutionType(contLocator.Bounds,
|
||||
contLocator.RangeTransform,
|
||||
contLocator.CellDims,
|
||||
contLocator.GetCellSet().template Cast<StructuredType>(),
|
||||
contLocator.GetCoordinates().GetData(),
|
||||
DeviceAdapter());
|
||||
execLocator.Reset(execObject);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
const vtkm::cont::CellLocator::HandleType
|
||||
vtkm::cont::CellLocatorUniformGrid::PrepareForExecutionImpl(
|
||||
const vtkm::cont::DeviceAdapterId deviceId) const
|
||||
{
|
||||
const bool success =
|
||||
vtkm::cont::TryExecuteOnDevice(deviceId, PrepareForExecutionFunctor(), *this, this->ExecHandle);
|
||||
if (!success)
|
||||
{
|
||||
throwFailedRuntimeDeviceTransfer("CellLocatorUniformGrid", deviceId);
|
||||
}
|
||||
return this->ExecHandle;
|
||||
}
|
@ -22,10 +22,6 @@
|
||||
|
||||
#include <vtkm/cont/CellLocator.h>
|
||||
#include <vtkm/cont/CellSetStructured.h>
|
||||
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
|
||||
#include <vtkm/cont/ErrorBadDevice.h>
|
||||
|
||||
#include <vtkm/exec/CellLocatorUniformGrid.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -33,71 +29,25 @@ namespace vtkm
|
||||
namespace cont
|
||||
{
|
||||
|
||||
class CellLocatorUniformGrid : public vtkm::cont::CellLocator
|
||||
class VTKM_CONT_EXPORT CellLocatorUniformGrid : public vtkm::cont::CellLocator
|
||||
{
|
||||
public:
|
||||
VTKM_CONT
|
||||
CellLocatorUniformGrid() = default;
|
||||
VTKM_CONT CellLocatorUniformGrid();
|
||||
|
||||
VTKM_CONT
|
||||
void Build() override
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords = this->GetCoordinates();
|
||||
vtkm::cont::DynamicCellSet cellSet = this->GetCellSet();
|
||||
VTKM_CONT ~CellLocatorUniformGrid() override;
|
||||
|
||||
if (!coords.GetData().IsType<UniformType>())
|
||||
throw vtkm::cont::ErrorBadType("Coordinate system is not uniform type");
|
||||
if (!cellSet.IsSameType(StructuredType()))
|
||||
throw vtkm::cont::ErrorBadType("Cell set is not 3D structured type");
|
||||
|
||||
Bounds = coords.GetBounds();
|
||||
CellDims = cellSet.Cast<StructuredType>().GetSchedulingRange(vtkm::TopologyElementTagCell());
|
||||
|
||||
RangeTransform[0] = static_cast<vtkm::FloatDefault>(CellDims[0]) /
|
||||
static_cast<vtkm::FloatDefault>(Bounds.X.Length());
|
||||
RangeTransform[1] = static_cast<vtkm::FloatDefault>(CellDims[1]) /
|
||||
static_cast<vtkm::FloatDefault>(Bounds.Y.Length());
|
||||
RangeTransform[2] = static_cast<vtkm::FloatDefault>(CellDims[2]) /
|
||||
static_cast<vtkm::FloatDefault>(Bounds.Z.Length());
|
||||
}
|
||||
|
||||
struct PrepareForExecutionFunctor
|
||||
{
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT bool operator()(DeviceAdapter,
|
||||
const vtkm::cont::CellLocatorUniformGrid& contLocator,
|
||||
HandleType& execLocator) const
|
||||
{
|
||||
using ExecutionType = vtkm::exec::CellLocatorUniformGrid<DeviceAdapter>;
|
||||
ExecutionType* execObject =
|
||||
new ExecutionType(contLocator.Bounds,
|
||||
contLocator.RangeTransform,
|
||||
contLocator.CellDims,
|
||||
contLocator.GetCellSet().template Cast<StructuredType>(),
|
||||
contLocator.GetCoordinates().GetData(),
|
||||
DeviceAdapter());
|
||||
execLocator.Reset(execObject);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
VTKM_CONT void Build() override;
|
||||
|
||||
VTKM_CONT
|
||||
const HandleType PrepareForExecutionImpl(
|
||||
const vtkm::cont::DeviceAdapterId deviceId) const override
|
||||
{
|
||||
const bool success = vtkm::cont::TryExecuteOnDevice(
|
||||
deviceId, PrepareForExecutionFunctor(), *this, this->ExecHandle);
|
||||
if (!success)
|
||||
{
|
||||
throwFailedRuntimeDeviceTransfer("CellLocatorUniformGrid", deviceId);
|
||||
}
|
||||
return this->ExecHandle;
|
||||
}
|
||||
const vtkm::cont::DeviceAdapterId deviceId) const override;
|
||||
|
||||
private:
|
||||
using UniformType = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||
using StructuredType = vtkm::cont::CellSetStructured<3>;
|
||||
|
||||
struct PrepareForExecutionFunctor;
|
||||
|
||||
vtkm::Bounds Bounds;
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> RangeTransform;
|
||||
vtkm::Vec<vtkm::Id, 3> CellDims;
|
||||
|
@ -40,6 +40,8 @@ namespace exec
|
||||
class CellInterpolationHelper : public vtkm::VirtualObjectBase
|
||||
{
|
||||
public:
|
||||
VTKM_EXEC_CONT virtual ~CellInterpolationHelper() = default;
|
||||
|
||||
VTKM_EXEC
|
||||
virtual void GetCellInfo(const vtkm::Id& cellId,
|
||||
vtkm::UInt8& cellShape,
|
||||
@ -194,6 +196,8 @@ class CellInterpolationHelper : public vtkm::cont::ExecutionObjectBase
|
||||
public:
|
||||
using HandleType = vtkm::cont::VirtualObjectHandle<vtkm::exec::CellInterpolationHelper>;
|
||||
|
||||
VTKM_CONT virtual ~CellInterpolationHelper() = default;
|
||||
|
||||
template <typename DeviceAdapter>
|
||||
VTKM_CONT const vtkm::exec::CellInterpolationHelper* PrepareForExecution(
|
||||
DeviceAdapter device) const
|
||||
|
Loading…
Reference in New Issue
Block a user