vtk-m/vtkm/exec/ConnectivityStructured.h
Allison Vacanti 5db762ee71 Refactor topology mappings to clarify meaning.
The `From` and `To` nomenclature for topology mapping has been confusing for
both users and developers, especially at lower levels where the intention of
mapping attributes from one element to another is easily conflated with the
concept of mapping indices (which maps in the exact opposite direction).

These identifiers have been renamed to `VisitTopology` and `IncidentTopology`
to clarify the direction of the mapping. The order in which these template
parameters are specified for `WorkletMapTopology` have also been reversed,
since eventually there may be more than one `IncidentTopology`, and having
`IncidentTopology` at the end will allow us to replace it with a variadic
template parameter pack in the future.

Other implementation details supporting these worklets, include `Fetch` tags,
`Connectivity` classes, and methods on the various `CellSet` classes (such as
`PrepareForInput` have also reversed their template arguments. These will need
to be cautiously updated.

The convenience implementations of `WorkletMapTopology` have been renamed for
clarity as follows:

```
WorkletMapPointToCell --> WorkletVisitCellsWithPoints
WorkletMapCellToPoint --> WorkletVisitPointsWithCells
```

The `ControlSignature` tags have been renamed as follows:

```
FieldInTo --> FieldInVisit
FieldInFrom --> FieldInMap
FromCount --> IncidentElementCount
FromIndices --> IncidentElementIndices
```
2019-08-06 11:27:26 -04:00

128 lines
3.4 KiB
C++

//============================================================================
// 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.
//============================================================================
#ifndef vtk_m_exec_ConnectivityStructured_h
#define vtk_m_exec_ConnectivityStructured_h
#include <vtkm/TopologyElementTag.h>
#include <vtkm/Types.h>
#include <vtkm/internal/ConnectivityStructuredInternals.h>
namespace vtkm
{
namespace exec
{
template <typename VisitTopology, typename IncidentTopology, vtkm::IdComponent Dimension>
class ConnectivityStructured
{
VTKM_IS_TOPOLOGY_ELEMENT_TAG(VisitTopology);
VTKM_IS_TOPOLOGY_ELEMENT_TAG(IncidentTopology);
using InternalsType = vtkm::internal::ConnectivityStructuredInternals<Dimension>;
using Helper =
vtkm::internal::ConnectivityStructuredIndexHelper<VisitTopology, IncidentTopology, Dimension>;
public:
using SchedulingRangeType = typename InternalsType::SchedulingRangeType;
VTKM_EXEC_CONT
ConnectivityStructured()
: Internals()
{
}
VTKM_EXEC_CONT
ConnectivityStructured(const InternalsType& src)
: Internals(src)
{
}
VTKM_EXEC_CONT
ConnectivityStructured(const ConnectivityStructured& src)
: Internals(src.Internals)
{
}
VTKM_EXEC_CONT
ConnectivityStructured(
const ConnectivityStructured<IncidentTopology, VisitTopology, Dimension>& src)
: Internals(src.Internals)
{
}
VTKM_EXEC
vtkm::Id GetNumberOfElements() const { return Helper::GetNumberOfElements(this->Internals); }
using CellShapeTag = typename Helper::CellShapeTag;
VTKM_EXEC
CellShapeTag GetCellShape(vtkm::Id) const { return CellShapeTag(); }
template <typename IndexType>
VTKM_EXEC vtkm::IdComponent GetNumberOfIndices(const IndexType& index) const
{
return Helper::GetNumberOfIndices(this->Internals, index);
}
using IndicesType = typename Helper::IndicesType;
template <typename IndexType>
VTKM_EXEC IndicesType GetIndices(const IndexType& index) const
{
return Helper::GetIndices(this->Internals, index);
}
VTKM_EXEC_CONT
SchedulingRangeType FlatToLogicalFromIndex(vtkm::Id flatFromIndex) const
{
return Helper::FlatToLogicalFromIndex(this->Internals, flatFromIndex);
}
VTKM_EXEC_CONT
vtkm::Id LogicalToFlatFromIndex(const SchedulingRangeType& logicalFromIndex) const
{
return Helper::LogicalToFlatFromIndex(this->Internals, logicalFromIndex);
}
VTKM_EXEC_CONT
SchedulingRangeType FlatToLogicalToIndex(vtkm::Id flatToIndex) const
{
return Helper::FlatToLogicalToIndex(this->Internals, flatToIndex);
}
VTKM_EXEC_CONT
vtkm::Id LogicalToFlatToIndex(const SchedulingRangeType& logicalToIndex) const
{
return Helper::LogicalToFlatToIndex(this->Internals, logicalToIndex);
}
VTKM_EXEC_CONT
vtkm::Vec<vtkm::Id, Dimension> GetPointDimensions() const
{
return this->Internals.GetPointDimensions();
}
VTKM_EXEC_CONT
SchedulingRangeType GetGlobalPointIndexStart() const
{
return this->Internals.GetGlobalPointIndexStart();
}
friend class ConnectivityStructured<IncidentTopology, VisitTopology, Dimension>;
private:
InternalsType Internals;
};
}
} // namespace vtkm::exec
#endif //vtk_m_exec_ConnectivityStructured_h