2015-06-03 19:06:43 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-06-03 19:06:43 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
2015-04-15 16:43:12 +00:00
|
|
|
#ifndef vtk_m_cont_CellSetStructured_h
|
|
|
|
#define vtk_m_cont_CellSetStructured_h
|
|
|
|
|
2016-12-16 22:04:58 +00:00
|
|
|
#include <vtkm/cont/vtkm_cont_export.h>
|
|
|
|
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/TopologyElementTag.h>
|
2015-04-15 16:43:12 +00:00
|
|
|
#include <vtkm/cont/CellSet.h>
|
2015-08-02 21:59:44 +00:00
|
|
|
#include <vtkm/cont/DeviceAdapter.h>
|
|
|
|
#include <vtkm/exec/ConnectivityStructured.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/internal/ConnectivityStructuredInternals.h>
|
2015-04-15 16:43:12 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2015-04-15 16:43:12 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <vtkm::IdComponent DIMENSION>
|
2018-06-15 14:49:59 +00:00
|
|
|
class VTKM_ALWAYS_EXPORT CellSetStructured final : public CellSet
|
2015-04-15 16:43:12 +00:00
|
|
|
{
|
2015-08-02 21:59:44 +00:00
|
|
|
private:
|
2017-08-16 15:34:21 +00:00
|
|
|
using Thisclass = vtkm::cont::CellSetStructured<DIMENSION>;
|
|
|
|
using InternalsType = vtkm::internal::ConnectivityStructuredInternals<DIMENSION>;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2015-05-15 17:15:11 +00:00
|
|
|
public:
|
2017-05-18 14:29:41 +00:00
|
|
|
static const vtkm::IdComponent Dimension = DIMENSION;
|
2015-05-12 18:57:18 +00:00
|
|
|
|
2017-08-16 15:34:21 +00:00
|
|
|
using SchedulingRangeType = typename InternalsType::SchedulingRangeType;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2018-06-15 14:49:59 +00:00
|
|
|
vtkm::Id GetNumberOfCells() const override { return this->Structure.GetNumberOfCells(); }
|
2015-05-12 18:57:18 +00:00
|
|
|
|
2018-06-15 14:49:59 +00:00
|
|
|
vtkm::Id GetNumberOfPoints() const override { return this->Structure.GetNumberOfPoints(); }
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2018-06-15 14:49:59 +00:00
|
|
|
vtkm::Id GetNumberOfFaces() const override { return -1; }
|
2016-12-16 22:04:58 +00:00
|
|
|
|
2018-06-15 14:49:59 +00:00
|
|
|
vtkm::Id GetNumberOfEdges() const override { return -1; }
|
2016-12-16 22:04:58 +00:00
|
|
|
|
2018-05-30 18:32:06 +00:00
|
|
|
// Since the entire topology is defined by by three integers, nothing to do here.
|
2018-06-15 14:49:59 +00:00
|
|
|
void ReleaseResourcesExecution() override {}
|
2018-05-30 18:32:06 +00:00
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
void SetPointDimensions(SchedulingRangeType dimensions)
|
|
|
|
{
|
|
|
|
this->Structure.SetPointDimensions(dimensions);
|
|
|
|
}
|
2015-07-28 23:33:52 +00:00
|
|
|
|
2018-12-03 20:56:45 +00:00
|
|
|
void SetGlobalPointIndexStart(SchedulingRangeType start)
|
|
|
|
{
|
|
|
|
this->Structure.SetGlobalPointIndexStart(start);
|
|
|
|
}
|
|
|
|
|
2017-05-23 19:13:30 +00:00
|
|
|
SchedulingRangeType GetPointDimensions() const { return this->Structure.GetPointDimensions(); }
|
2015-10-22 21:18:33 +00:00
|
|
|
|
2017-05-23 19:13:30 +00:00
|
|
|
SchedulingRangeType GetCellDimensions() const { return this->Structure.GetCellDimensions(); }
|
2016-01-20 16:24:31 +00:00
|
|
|
|
2018-12-03 20:56:45 +00:00
|
|
|
SchedulingRangeType GetGlobalPointIndexStart() const
|
|
|
|
{
|
|
|
|
return this->Structure.GetGlobalPointIndexStart();
|
|
|
|
}
|
|
|
|
|
2019-03-19 18:08:29 +00:00
|
|
|
vtkm::IdComponent GetNumberOfPointsInCell(vtkm::Id vtkmNotUsed(cellIndex) = 0) const override
|
2015-05-15 17:15:11 +00:00
|
|
|
{
|
2015-08-03 16:06:59 +00:00
|
|
|
return this->Structure.GetNumberOfPointsInCell();
|
2015-05-18 15:04:15 +00:00
|
|
|
}
|
|
|
|
|
2019-03-19 18:08:29 +00:00
|
|
|
vtkm::UInt8 GetCellShape(vtkm::Id vtkmNotUsed(cellIndex) = 0) const override
|
|
|
|
{
|
|
|
|
return static_cast<vtkm::UInt8>(this->Structure.GetCellShape());
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetCellPointIds(vtkm::Id id, vtkm::Id* ptids) const override
|
|
|
|
{
|
|
|
|
auto asVec = this->Structure.GetPointsOfCell(id);
|
|
|
|
for (vtkm::IdComponent i = 0; i < InternalsType::NUM_POINTS_IN_CELL; ++i)
|
|
|
|
{
|
|
|
|
ptids[i] = asVec[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-02 20:23:51 +00:00
|
|
|
std::shared_ptr<CellSet> NewInstance() const override
|
2019-03-19 18:08:29 +00:00
|
|
|
{
|
|
|
|
return std::make_shared<CellSetStructured>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeepCopy(const CellSet* src) override
|
|
|
|
{
|
|
|
|
const auto* other = dynamic_cast<const CellSetStructured*>(src);
|
|
|
|
if (!other)
|
|
|
|
{
|
|
|
|
throw vtkm::cont::ErrorBadType("CellSetStructured::DeepCopy types don't match");
|
|
|
|
}
|
|
|
|
|
|
|
|
this->Structure = other->Structure;
|
|
|
|
}
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename TopologyElement>
|
2016-12-16 22:04:58 +00:00
|
|
|
SchedulingRangeType GetSchedulingRange(TopologyElement) const;
|
2015-08-02 21:59:44 +00:00
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology>
|
2017-05-18 14:29:41 +00:00
|
|
|
struct ExecutionTypes
|
|
|
|
{
|
2015-08-02 21:59:44 +00:00
|
|
|
VTKM_IS_DEVICE_ADAPTER_TAG(DeviceAdapter);
|
2019-07-30 16:53:51 +00:00
|
|
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology);
|
|
|
|
VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology);
|
|
|
|
using ExecObjectType =
|
|
|
|
vtkm::exec::ConnectivityStructured<VisitTopology, IncidentTopology, Dimension>;
|
2015-08-02 21:59:44 +00:00
|
|
|
};
|
|
|
|
|
2019-07-30 16:53:51 +00:00
|
|
|
template <typename DeviceAdapter, typename VisitTopology, typename IncidentTopology>
|
|
|
|
typename ExecutionTypes<DeviceAdapter, VisitTopology, IncidentTopology>::ExecObjectType
|
|
|
|
PrepareForInput(DeviceAdapter, VisitTopology, IncidentTopology) const;
|
2015-05-15 17:15:11 +00:00
|
|
|
|
2018-06-15 14:49:59 +00:00
|
|
|
void PrintSummary(std::ostream& out) const override;
|
2015-05-20 19:26:10 +00:00
|
|
|
|
2019-12-09 22:56:08 +00:00
|
|
|
// Cannot use the default implementation of the destructure because the CUDA compiler
|
|
|
|
// will attempt to create it for device, and then it will fail when it tries to call
|
|
|
|
// the destructor of the superclass.
|
|
|
|
~CellSetStructured() override {}
|
|
|
|
|
2020-01-13 20:54:59 +00:00
|
|
|
CellSetStructured() = default;
|
|
|
|
CellSetStructured(const CellSetStructured& src) = default;
|
|
|
|
CellSetStructured(CellSetStructured&& src) noexcept = default;
|
|
|
|
|
|
|
|
CellSetStructured& operator=(const CellSetStructured& src) = default;
|
|
|
|
CellSetStructured& operator=(CellSetStructured&& src) noexcept = default;
|
|
|
|
|
2015-08-02 21:59:44 +00:00
|
|
|
private:
|
|
|
|
InternalsType Structure;
|
2015-04-15 16:43:12 +00:00
|
|
|
};
|
|
|
|
|
2016-12-16 22:04:58 +00:00
|
|
|
#ifndef vtkm_cont_CellSetStructured_cxx
|
|
|
|
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<1>;
|
|
|
|
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<2>;
|
|
|
|
extern template class VTKM_CONT_TEMPLATE_EXPORT CellSetStructured<3>;
|
|
|
|
#endif
|
2015-04-15 16:43:12 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|
|
|
|
|
2018-06-18 17:56:38 +00:00
|
|
|
//=============================================================================
|
|
|
|
// Specializations of serialization related classes
|
2019-09-12 21:19:36 +00:00
|
|
|
/// @cond SERIALIZATION
|
2018-06-18 17:56:38 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
|
|
|
|
template <vtkm::IdComponent DIMENSION>
|
2019-02-28 18:15:27 +00:00
|
|
|
struct SerializableTypeString<vtkm::cont::CellSetStructured<DIMENSION>>
|
2018-06-18 17:56:38 +00:00
|
|
|
{
|
|
|
|
static VTKM_CONT const std::string& Get()
|
|
|
|
{
|
|
|
|
static std::string name = "CS_Structured<" + std::to_string(DIMENSION) + ">";
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
} // vtkm::cont
|
|
|
|
|
2019-02-05 16:02:29 +00:00
|
|
|
namespace mangled_diy_namespace
|
2018-06-18 17:56:38 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
template <vtkm::IdComponent DIMENSION>
|
|
|
|
struct Serialization<vtkm::cont::CellSetStructured<DIMENSION>>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
using Type = vtkm::cont::CellSetStructured<DIMENSION>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static VTKM_CONT void save(BinaryBuffer& bb, const Type& cs)
|
|
|
|
{
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::save(bb, cs.GetPointDimensions());
|
|
|
|
vtkmdiy::save(bb, cs.GetGlobalPointIndexStart());
|
2018-06-18 17:56:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static VTKM_CONT void load(BinaryBuffer& bb, Type& cs)
|
|
|
|
{
|
2018-12-03 20:56:45 +00:00
|
|
|
typename Type::SchedulingRangeType dims, start;
|
2019-02-05 16:02:29 +00:00
|
|
|
vtkmdiy::load(bb, dims);
|
|
|
|
vtkmdiy::load(bb, start);
|
2018-12-03 20:56:45 +00:00
|
|
|
|
2019-08-13 21:28:37 +00:00
|
|
|
cs = Type{};
|
2018-06-18 17:56:38 +00:00
|
|
|
cs.SetPointDimensions(dims);
|
2018-12-03 20:56:45 +00:00
|
|
|
cs.SetGlobalPointIndexStart(start);
|
2018-06-18 17:56:38 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // diy
|
2019-09-12 21:19:36 +00:00
|
|
|
/// @endcond SERIALIZATION
|
2018-06-18 17:56:38 +00:00
|
|
|
|
2016-12-16 22:04:58 +00:00
|
|
|
#include <vtkm/cont/CellSetStructured.hxx>
|
|
|
|
|
2015-04-15 16:43:12 +00:00
|
|
|
#endif //vtk_m_cont_CellSetStructured_h
|