2015-02-10 17:36:10 +00:00
|
|
|
//============================================================================
|
|
|
|
// 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 2014 Sandia Corporation.
|
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-06-03 19:06:43 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2015-02-10 17:36:10 +00:00
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
|
|
// 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.
|
|
|
|
//============================================================================
|
2015-05-29 13:51:11 +00:00
|
|
|
#ifndef vtk_m_cont_Field_h
|
|
|
|
#define vtk_m_cont_Field_h
|
2015-02-10 17:36:10 +00:00
|
|
|
|
2016-12-16 22:04:58 +00:00
|
|
|
#include <vtkm/cont/vtkm_cont_export.h>
|
|
|
|
|
2016-05-26 22:02:30 +00:00
|
|
|
#include <vtkm/Range.h>
|
|
|
|
#include <vtkm/Types.h>
|
2015-07-16 19:10:01 +00:00
|
|
|
|
2015-02-10 17:36:10 +00:00
|
|
|
#include <vtkm/cont/ArrayHandle.h>
|
2017-02-24 21:39:37 +00:00
|
|
|
#include <vtkm/cont/ArrayPortalToIterators.h>
|
2017-05-18 14:51:24 +00:00
|
|
|
#include <vtkm/cont/ArrayRangeCompute.h>
|
2015-02-10 17:36:10 +00:00
|
|
|
#include <vtkm/cont/DynamicArrayHandle.h>
|
2015-05-29 13:44:57 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2015-02-10 17:36:10 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace internal
|
|
|
|
{
|
2015-07-16 19:10:01 +00:00
|
|
|
|
2016-05-26 22:02:30 +00:00
|
|
|
class ComputeRange
|
2015-07-16 19:10:01 +00:00
|
|
|
{
|
2016-05-26 12:40:26 +00:00
|
|
|
public:
|
2017-05-18 14:29:41 +00:00
|
|
|
ComputeRange(ArrayHandle<vtkm::Range>& range)
|
|
|
|
: Range(&range)
|
|
|
|
{
|
|
|
|
}
|
2015-07-16 19:10:01 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename ArrayHandleType>
|
|
|
|
void operator()(const ArrayHandleType& input) const
|
2016-05-26 12:40:26 +00:00
|
|
|
{
|
2017-02-24 00:12:14 +00:00
|
|
|
*this->Range = vtkm::cont::ArrayRangeCompute(input);
|
2015-07-16 19:10:01 +00:00
|
|
|
}
|
2016-05-26 12:40:26 +00:00
|
|
|
|
|
|
|
private:
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::ArrayHandle<vtkm::Range>* Range;
|
2015-07-16 19:10:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
2015-02-10 17:36:10 +00:00
|
|
|
/// A \c Field encapsulates an array on some piece of the mesh, such as
|
2015-08-03 16:06:59 +00:00
|
|
|
/// the points, a cell set, a point logical dimension, or the whole mesh.
|
2015-02-10 17:36:10 +00:00
|
|
|
///
|
2016-12-16 22:04:58 +00:00
|
|
|
class VTKM_CONT_EXPORT Field
|
2015-02-10 17:36:10 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-07-12 16:05:47 +00:00
|
|
|
enum AssociationEnum
|
2015-07-13 19:50:07 +00:00
|
|
|
{
|
2015-08-12 15:51:14 +00:00
|
|
|
ASSOC_ANY,
|
2015-07-12 16:05:47 +00:00
|
|
|
ASSOC_WHOLE_MESH,
|
|
|
|
ASSOC_POINTS,
|
|
|
|
ASSOC_CELL_SET,
|
|
|
|
ASSOC_LOGICAL_DIM
|
|
|
|
};
|
2015-07-13 19:50:07 +00:00
|
|
|
|
2015-07-12 16:05:47 +00:00
|
|
|
/// constructors for points / whole mesh
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
Field(std::string name, AssociationEnum association, const vtkm::cont::DynamicArrayHandle& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName()
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-07-30 14:22:25 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_WHOLE_MESH || this->Association == ASSOC_POINTS);
|
2015-07-30 14:22:25 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T, typename Storage>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_CONT Field(std::string name,
|
|
|
|
AssociationEnum association,
|
2017-05-18 14:29:41 +00:00
|
|
|
const ArrayHandle<T, Storage>& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName()
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-11 20:15:58 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_ASSERT((this->Association == ASSOC_WHOLE_MESH) || (this->Association == ASSOC_POINTS));
|
2015-05-11 20:15:58 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2015-05-19 20:49:17 +00:00
|
|
|
template <typename T>
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_CONT Field(std::string name, AssociationEnum association, const std::vector<T>& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName()
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-19 20:49:17 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_ASSERT((this->Association == ASSOC_WHOLE_MESH) || (this->Association == ASSOC_POINTS));
|
2015-07-12 16:05:47 +00:00
|
|
|
this->CopyData(&data[0], static_cast<vtkm::Id>(data.size()));
|
2015-05-19 20:49:17 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2015-05-19 20:49:17 +00:00
|
|
|
template <typename T>
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_CONT Field(std::string name, AssociationEnum association, const T* data, vtkm::Id nvals)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName()
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-19 20:49:17 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_ASSERT((this->Association == ASSOC_WHOLE_MESH) || (this->Association == ASSOC_POINTS));
|
2015-07-13 19:17:03 +00:00
|
|
|
this->CopyData(data, nvals);
|
2015-05-19 20:49:17 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2015-05-19 20:49:17 +00:00
|
|
|
/// constructors for cell set associations
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-26 17:53:28 +00:00
|
|
|
Field(std::string name,
|
|
|
|
AssociationEnum association,
|
|
|
|
const std::string& cellSetName,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::DynamicArrayHandle& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName(cellSetName)
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-07-13 19:50:07 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_CELL_SET);
|
2015-07-13 19:50:07 +00:00
|
|
|
}
|
|
|
|
|
2015-07-30 14:22:25 +00:00
|
|
|
template <typename T, typename Storage>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_CONT Field(std::string name,
|
|
|
|
AssociationEnum association,
|
|
|
|
const std::string& cellSetName,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T, Storage>& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName(cellSetName)
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-11 20:15:58 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_CELL_SET);
|
2015-05-11 20:15:58 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2015-05-19 20:49:17 +00:00
|
|
|
template <typename T>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_CONT Field(std::string name,
|
|
|
|
AssociationEnum association,
|
|
|
|
const std::string& cellSetName,
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::vector<T>& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName(cellSetName)
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-19 20:49:17 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_CELL_SET);
|
2015-07-12 16:05:47 +00:00
|
|
|
this->CopyData(&data[0], static_cast<vtkm::Id>(data.size()));
|
2015-05-19 20:49:17 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2015-05-19 20:49:17 +00:00
|
|
|
template <typename T>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_CONT Field(std::string name,
|
|
|
|
AssociationEnum association,
|
|
|
|
const std::string& cellSetName,
|
|
|
|
const T* data,
|
|
|
|
vtkm::Id nvals)
|
2017-05-18 14:29:41 +00:00
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName(cellSetName)
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-19 20:49:17 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_CELL_SET);
|
2015-07-13 19:17:03 +00:00
|
|
|
this->CopyData(data, nvals);
|
2015-05-19 20:49:17 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2015-05-19 20:49:17 +00:00
|
|
|
/// constructors for logical dimension associations
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-26 17:53:28 +00:00
|
|
|
Field(std::string name,
|
|
|
|
AssociationEnum association,
|
|
|
|
vtkm::IdComponent logicalDim,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::DynamicArrayHandle& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocCellSetName()
|
|
|
|
, AssocLogicalDim(logicalDim)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-07-13 19:50:07 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_LOGICAL_DIM);
|
2015-07-13 19:50:07 +00:00
|
|
|
}
|
|
|
|
|
2015-07-30 14:22:25 +00:00
|
|
|
template <typename T, typename Storage>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_CONT Field(std::string name,
|
|
|
|
AssociationEnum association,
|
|
|
|
vtkm::IdComponent logicalDim,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<T, Storage>& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocLogicalDim(logicalDim)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-11 20:15:58 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_LOGICAL_DIM);
|
2015-05-11 20:15:58 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2015-05-19 20:49:17 +00:00
|
|
|
template <typename T>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_CONT Field(std::string name,
|
|
|
|
AssociationEnum association,
|
|
|
|
vtkm::IdComponent logicalDim,
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::vector<T>& data)
|
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocLogicalDim(logicalDim)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-19 20:49:17 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_LOGICAL_DIM);
|
2015-07-12 16:05:47 +00:00
|
|
|
this->CopyData(&data[0], static_cast<vtkm::Id>(data.size()));
|
2015-05-19 20:49:17 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2015-05-19 20:49:17 +00:00
|
|
|
template <typename T>
|
2017-05-26 17:53:28 +00:00
|
|
|
VTKM_CONT Field(std::string name,
|
|
|
|
AssociationEnum association,
|
|
|
|
vtkm::IdComponent logicalDim,
|
|
|
|
const T* data,
|
|
|
|
vtkm::Id nvals)
|
2017-05-18 14:29:41 +00:00
|
|
|
: Name(name)
|
|
|
|
, Association(association)
|
|
|
|
, AssocLogicalDim(logicalDim)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2015-05-19 20:49:17 +00:00
|
|
|
{
|
2016-04-20 21:41:14 +00:00
|
|
|
VTKM_ASSERT(this->Association == ASSOC_LOGICAL_DIM);
|
2015-07-12 16:05:47 +00:00
|
|
|
CopyData(data, nvals);
|
2015-05-19 20:49:17 +00:00
|
|
|
}
|
2015-06-04 13:06:47 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2016-01-04 20:40:37 +00:00
|
|
|
Field()
|
2017-05-18 14:29:41 +00:00
|
|
|
: Name()
|
|
|
|
, Association(ASSOC_ANY)
|
|
|
|
, AssocCellSetName()
|
|
|
|
, AssocLogicalDim()
|
|
|
|
, Data()
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
2016-01-04 20:40:37 +00:00
|
|
|
{
|
|
|
|
//Generate an empty field
|
|
|
|
}
|
|
|
|
|
2017-01-18 14:10:11 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
Field& operator=(const vtkm::cont::Field& src) = default;
|
2017-01-18 14:10:11 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const std::string& GetName() const { return this->Name; }
|
2015-05-19 20:21:15 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
AssociationEnum GetAssociation() const { return this->Association; }
|
2015-05-11 20:15:58 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
std::string GetAssocCellSet() const { return this->AssocCellSetName; }
|
2015-05-11 20:15:58 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::IdComponent GetAssocLogicalDim() const { return this->AssocLogicalDim; }
|
2015-05-11 20:15:58 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename TypeList, typename StorageList>
|
|
|
|
VTKM_CONT const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(TypeList, StorageList) const
|
2015-07-16 19:10:01 +00:00
|
|
|
{
|
2017-02-24 21:39:37 +00:00
|
|
|
VTKM_IS_LIST_TAG(TypeList);
|
|
|
|
VTKM_IS_LIST_TAG(StorageList);
|
2015-07-16 19:10:01 +00:00
|
|
|
|
2017-02-24 21:39:37 +00:00
|
|
|
return this->GetRangeImpl(TypeList(), StorageList());
|
2015-07-16 19:10:01 +00:00
|
|
|
}
|
|
|
|
|
2017-02-24 21:39:37 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(VTKM_DEFAULT_TYPE_LIST_TAG,
|
|
|
|
VTKM_DEFAULT_STORAGE_LIST_TAG) const;
|
2017-02-24 21:39:37 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename TypeList, typename StorageList>
|
|
|
|
VTKM_CONT void GetRange(vtkm::Range* range, TypeList, StorageList) const
|
2015-07-16 19:10:01 +00:00
|
|
|
{
|
2017-02-24 21:39:37 +00:00
|
|
|
VTKM_IS_LIST_TAG(TypeList);
|
|
|
|
VTKM_IS_LIST_TAG(StorageList);
|
|
|
|
|
|
|
|
this->GetRange(TypeList(), StorageList());
|
2015-07-16 19:10:01 +00:00
|
|
|
|
2016-05-26 22:02:30 +00:00
|
|
|
vtkm::Id length = this->Range.GetNumberOfValues();
|
2015-07-16 19:10:01 +00:00
|
|
|
for (vtkm::Id i = 0; i < length; ++i)
|
|
|
|
{
|
2016-05-26 22:02:30 +00:00
|
|
|
range[i] = this->Range.GetPortalConstControl().Get(i);
|
2015-07-16 19:10:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename TypeList>
|
|
|
|
VTKM_CONT const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange(TypeList) const
|
2015-07-16 19:10:01 +00:00
|
|
|
{
|
2017-02-24 21:39:37 +00:00
|
|
|
VTKM_IS_LIST_TAG(TypeList);
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
return this->GetRange(TypeList(), VTKM_DEFAULT_STORAGE_LIST_TAG());
|
2015-07-16 19:10:01 +00:00
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename TypeList>
|
|
|
|
VTKM_CONT void GetRange(vtkm::Range* range, TypeList) const
|
2015-07-16 19:10:01 +00:00
|
|
|
{
|
2017-02-24 21:39:37 +00:00
|
|
|
VTKM_IS_LIST_TAG(TypeList);
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
this->GetRange(range, TypeList(), VTKM_DEFAULT_STORAGE_LIST_TAG());
|
2015-07-16 19:10:01 +00:00
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-02-24 21:39:37 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Range>& GetRange() const;
|
2015-07-16 19:10:01 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void GetRange(vtkm::Range* range) const;
|
2015-07-16 19:10:01 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::DynamicArrayHandle& GetData() const;
|
2015-07-30 14:22:25 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::DynamicArrayHandle& GetData();
|
2015-02-10 17:36:10 +00:00
|
|
|
|
2015-05-11 20:15:58 +00:00
|
|
|
template <typename T>
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_CONT void SetData(const vtkm::cont::ArrayHandle<T>& newdata)
|
2016-01-21 20:51:36 +00:00
|
|
|
{
|
|
|
|
this->Data = newdata;
|
|
|
|
this->ModifiedFlag = true;
|
|
|
|
}
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void SetData(const vtkm::cont::DynamicArrayHandle& newdata)
|
2015-02-10 17:36:10 +00:00
|
|
|
{
|
2015-07-13 19:17:03 +00:00
|
|
|
this->Data = newdata;
|
2015-07-16 19:10:01 +00:00
|
|
|
this->ModifiedFlag = true;
|
2015-02-10 17:36:10 +00:00
|
|
|
}
|
|
|
|
|
2015-05-19 20:21:15 +00:00
|
|
|
template <typename T>
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_CONT void CopyData(const T* ptr, vtkm::Id nvals)
|
2015-02-10 17:36:10 +00:00
|
|
|
{
|
2015-05-29 13:44:57 +00:00
|
|
|
//allocate main memory using an array handle
|
|
|
|
vtkm::cont::ArrayHandle<T> tmp;
|
|
|
|
tmp.Allocate(nvals);
|
|
|
|
|
|
|
|
//copy into the memory owned by the array handle
|
2017-05-26 17:53:28 +00:00
|
|
|
std::copy(ptr,
|
|
|
|
ptr + static_cast<std::size_t>(nvals),
|
2015-05-29 13:44:57 +00:00
|
|
|
vtkm::cont::ArrayPortalToIteratorBegin(tmp.GetPortalControl()));
|
|
|
|
|
|
|
|
//assign to the dynamic array handle
|
2015-07-13 19:17:03 +00:00
|
|
|
this->Data = tmp;
|
2015-07-16 19:10:01 +00:00
|
|
|
this->ModifiedFlag = true;
|
2015-02-10 17:36:10 +00:00
|
|
|
}
|
2015-05-20 19:26:10 +00:00
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
virtual void PrintSummary(std::ostream& out) const;
|
2015-05-29 13:44:57 +00:00
|
|
|
|
2015-02-10 17:36:10 +00:00
|
|
|
private:
|
2017-05-18 14:29:41 +00:00
|
|
|
std::string Name; ///< name of field
|
2015-05-19 20:21:15 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
AssociationEnum Association;
|
|
|
|
std::string AssocCellSetName; ///< only populate if assoc is cells
|
2015-07-12 16:05:47 +00:00
|
|
|
vtkm::IdComponent AssocLogicalDim; ///< only populate if assoc is logical dim
|
2015-05-11 20:15:58 +00:00
|
|
|
|
2015-07-13 19:17:03 +00:00
|
|
|
vtkm::cont::DynamicArrayHandle Data;
|
2016-05-26 22:02:30 +00:00
|
|
|
mutable vtkm::cont::ArrayHandle<vtkm::Range> Range;
|
2015-07-16 19:10:01 +00:00
|
|
|
mutable bool ModifiedFlag;
|
2017-02-24 21:39:37 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename TypeList, typename StorageList>
|
|
|
|
VTKM_CONT const vtkm::cont::ArrayHandle<vtkm::Range>& GetRangeImpl(TypeList, StorageList) const
|
2017-02-24 21:39:37 +00:00
|
|
|
{
|
|
|
|
VTKM_IS_LIST_TAG(TypeList);
|
|
|
|
VTKM_IS_LIST_TAG(StorageList);
|
|
|
|
|
|
|
|
if (this->ModifiedFlag)
|
|
|
|
{
|
|
|
|
internal::ComputeRange computeRange(this->Range);
|
2017-05-18 14:29:41 +00:00
|
|
|
this->Data.ResetTypeAndStorageLists(TypeList(), StorageList()).CastAndCall(computeRange);
|
2017-02-24 21:39:37 +00:00
|
|
|
this->ModifiedFlag = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->Range;
|
|
|
|
}
|
2015-02-10 17:36:10 +00:00
|
|
|
};
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename Functor>
|
|
|
|
void CastAndCall(const vtkm::cont::Field& field, const Functor& f)
|
2016-08-05 18:47:19 +00:00
|
|
|
{
|
|
|
|
field.GetData().CastAndCall(f);
|
|
|
|
}
|
2016-08-03 18:38:25 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace internal
|
|
|
|
{
|
|
|
|
template <>
|
2016-08-03 18:38:25 +00:00
|
|
|
struct DynamicTransformTraits<vtkm::cont::Field>
|
|
|
|
{
|
|
|
|
typedef vtkm::cont::internal::DynamicTransformTagCastAndCall DynamicTag;
|
|
|
|
};
|
2015-02-10 17:36:10 +00:00
|
|
|
|
2016-08-03 18:38:25 +00:00
|
|
|
} // namespace internal
|
2015-02-10 17:36:10 +00:00
|
|
|
} // namespace cont
|
|
|
|
} // namespace vtkm
|
|
|
|
|
2015-05-29 13:51:11 +00:00
|
|
|
#endif //vtk_m_cont_Field_h
|