vtk-m2/vtkm/cont/DataSetFieldAdd.h

162 lines
6.3 KiB
C
Raw Normal View History

2015-11-03 03:24:57 +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 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
2015-11-03 03:24:57 +00:00
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
2015-11-03 03:24:57 +00:00
// 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.
//============================================================================
#ifndef vtk_m_cont_DataSetFieldAdd_h
#define vtk_m_cont_DataSetFieldAdd_h
#include <vtkm/cont/DataSet.h>
#include <vtkm/cont/Field.h>
2017-05-18 14:29:41 +00:00
namespace vtkm
{
namespace cont
{
2015-11-03 03:24:57 +00:00
class DataSetFieldAdd
{
public:
2017-05-18 14:29:41 +00:00
VTKM_CONT
DataSetFieldAdd() {}
//Point centered fields.
VTKM_CONT
static void AddPointField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const vtkm::cont::VariantArrayHandle& field)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(Field(fieldName, vtkm::cont::Field::Association::POINTS, field));
2017-05-18 14:29:41 +00:00
}
template <typename T, typename Storage>
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
2017-05-18 14:29:41 +00:00
const vtkm::cont::ArrayHandle<T, Storage>& field)
{
dataSet.AddField(Field(fieldName, vtkm::cont::Field::Association::POINTS, field));
2017-05-18 14:29:41 +00:00
}
template <typename T>
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
2017-05-18 14:29:41 +00:00
const std::vector<T>& field)
{
dataSet.AddField(
make_Field(fieldName, vtkm::cont::Field::Association::POINTS, field, vtkm::CopyFlag::On));
2017-05-18 14:29:41 +00:00
}
template <typename T>
VTKM_CONT static void AddPointField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const T* field,
const vtkm::Id& n)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(
make_Field(fieldName, vtkm::cont::Field::Association::POINTS, field, n, vtkm::CopyFlag::On));
2017-05-18 14:29:41 +00:00
}
//Cell centered field
VTKM_CONT
static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const vtkm::cont::VariantArrayHandle& field,
2017-05-18 14:29:41 +00:00
const std::string& cellSetName)
{
dataSet.AddField(
Field(fieldName, vtkm::cont::Field::Association::CELL_SET, cellSetName, field));
2017-05-18 14:29:41 +00:00
}
template <typename T, typename Storage>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
2017-05-18 14:29:41 +00:00
const vtkm::cont::ArrayHandle<T, Storage>& field,
const std::string& cellSetName)
{
dataSet.AddField(
Field(fieldName, vtkm::cont::Field::Association::CELL_SET, cellSetName, field));
2017-05-18 14:29:41 +00:00
}
template <typename T>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const std::vector<T>& field,
const std::string& cellSetName)
2017-05-18 14:29:41 +00:00
{
dataSet.AddField(make_Field(
fieldName, vtkm::cont::Field::Association::CELL_SET, cellSetName, field, vtkm::CopyFlag::On));
2017-05-18 14:29:41 +00:00
}
template <typename T>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const T* field,
const vtkm::Id& n,
2017-05-18 14:29:41 +00:00
const std::string& cellSetName)
{
dataSet.AddField(make_Field(fieldName,
vtkm::cont::Field::Association::CELL_SET,
cellSetName,
field,
n,
vtkm::CopyFlag::On));
2017-05-18 14:29:41 +00:00
}
VTKM_CONT
static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const vtkm::cont::VariantArrayHandle& field,
vtkm::Id cellSetIndex = 0)
2017-05-18 14:29:41 +00:00
{
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
}
template <typename T, typename Storage>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
2017-05-18 14:29:41 +00:00
const vtkm::cont::ArrayHandle<T, Storage>& field,
vtkm::Id cellSetIndex = 0)
{
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
}
template <typename T>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const std::vector<T>& field,
vtkm::Id cellSetIndex = 0)
2017-05-18 14:29:41 +00:00
{
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, cellSetName);
}
template <typename T>
VTKM_CONT static void AddCellField(vtkm::cont::DataSet& dataSet,
const std::string& fieldName,
const T* field,
const vtkm::Id& n,
vtkm::Id cellSetIndex = 0)
2017-05-18 14:29:41 +00:00
{
std::string cellSetName = dataSet.GetCellSet(cellSetIndex).GetName();
DataSetFieldAdd::AddCellField(dataSet, fieldName, field, n, cellSetName);
}
2015-11-03 03:24:57 +00:00
};
}
2017-05-18 14:29:41 +00:00
} //namespace vtkm::cont
2015-11-03 03:24:57 +00:00
#endif //vtk_m_cont_DataSetFieldAdd_h