vtk-m2/vtkm/cont/MultiBlock.h

142 lines
5.3 KiB
C
Raw Normal View History

2017-05-10 00:27:03 +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 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
2017-05-10 00:27:03 +00:00
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
2017-05-10 00:27:03 +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.
//============================================================================
2017-08-01 23:38:35 +00:00
#ifndef vtk_m_cont_MultiBlock_h
2017-05-10 00:27:03 +00:00
#define vtk_m_cont_MultiBlock_h
2017-08-18 20:28:33 +00:00
#include <limits>
2017-05-10 00:27:03 +00:00
#include <vtkm/StaticAssert.h>
#include <vtkm/cont/ArrayHandle.h>
2017-05-11 19:25:08 +00:00
#include <vtkm/cont/DataSet.h>
2017-05-10 00:27:03 +00:00
#include <vtkm/cont/DeviceAdapterAlgorithm.h>
2017-08-18 20:28:33 +00:00
#include <vtkm/cont/DynamicArrayHandle.h>
#include <vtkm/cont/Field.h>
2017-05-10 00:27:03 +00:00
2017-08-18 20:28:33 +00:00
namespace vtkm
{
namespace cont
{
2017-05-10 00:27:03 +00:00
2017-08-18 20:28:33 +00:00
class VTKM_CONT_EXPORT MultiBlock
2017-05-10 00:27:03 +00:00
{
public:
2017-08-21 17:11:04 +00:00
/// creat a new MultiBlcok containng a single DataSet "ds"
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
MultiBlock(const vtkm::cont::DataSet& ds);
2017-08-21 17:11:04 +00:00
/// creat a new MultiBlcok with the exisiting one "src"
2017-08-18 20:28:33 +00:00
VTKM_CONT
MultiBlock(const vtkm::cont::MultiBlock& src);
2017-08-21 17:11:04 +00:00
/// creat a new MultiBlcok with a DataSet vector "mblocks"
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
MultiBlock(const std::vector<vtkm::cont::DataSet>& mblocks);
2017-08-21 17:11:04 +00:00
/// creat a new MultiBlcok with the capacity set to be "size"
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
MultiBlock(vtkm::Id size);
2017-08-02 19:18:55 +00:00
VTKM_CONT
2017-08-02 03:15:41 +00:00
MultiBlock();
2017-08-18 20:28:33 +00:00
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
MultiBlock& operator=(const vtkm::cont::MultiBlock& src);
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-02 03:15:41 +00:00
~MultiBlock();
2017-08-21 17:11:04 +00:00
/// get the field "field_name" from blcok "block_index"
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-21 17:11:04 +00:00
vtkm::cont::Field GetField(const std::string& field_name, const int& block_index);
2017-08-18 20:28:33 +00:00
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-07-20 19:11:12 +00:00
vtkm::Id GetNumberOfBlocks() const;
2017-08-18 20:28:33 +00:00
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
const vtkm::cont::DataSet& GetBlock(vtkm::Id blockId) const;
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
const std::vector<vtkm::cont::DataSet>& GetBlocks() const;
2017-08-21 17:11:04 +00:00
/// add DataSet "ds" to the end of the contained DataSet vector
2017-08-18 20:28:33 +00:00
VTKM_CONT
void AddBlock(vtkm::cont::DataSet& ds);
2017-08-21 17:11:04 +00:00
/// add DataSet "ds" to position "index" of the contained DataSet vector
2017-08-18 20:28:33 +00:00
VTKM_CONT
void InsertBlock(vtkm::Id index, vtkm::cont::DataSet& ds);
2017-08-21 17:11:04 +00:00
/// replace the "index" positioned element of the contained DataSet vector with "ds"
2017-08-18 20:28:33 +00:00
VTKM_CONT
2017-08-24 14:50:14 +00:00
void ReplaceBlock(vtkm::Id index, vtkm::cont::DataSet& ds);
2017-08-21 17:11:04 +00:00
/// append the DataSet vector "mblocks" to the end of the contained one
2017-08-18 20:28:33 +00:00
VTKM_CONT
void AddBlocks(std::vector<vtkm::cont::DataSet>& mblocks);
2017-08-21 17:11:04 +00:00
/// get the unified bounds of the same indexed coordinate system within all contained DataSet
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-07-20 19:11:12 +00:00
vtkm::Bounds GetBounds(vtkm::Id coordinate_system_index = 0) const;
2017-08-18 20:28:33 +00:00
template <typename TypeList>
VTKM_CONT vtkm::Bounds GetBounds(vtkm::Id coordinate_system_index, TypeList) const;
template <typename TypeList, typename StorageList>
VTKM_CONT vtkm::Bounds GetBounds(vtkm::Id coordinate_system_index, TypeList, StorageList) const;
2017-08-21 17:11:04 +00:00
/// get the bounds of a coordinate system within a given DataSet
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
vtkm::Bounds GetBlockBounds(const std::size_t& block_index,
vtkm::Id coordinate_system_index = 0) const;
template <typename TypeList>
VTKM_CONT vtkm::Bounds GetBlockBounds(const std::size_t& block_index,
vtkm::Id coordinate_system_index,
TypeList) const;
template <typename TypeList, typename StorageList>
VTKM_CONT vtkm::Bounds GetBlockBounds(const std::size_t& block_index,
vtkm::Id coordinate_system_index,
TypeList,
StorageList) const;
2017-08-21 17:11:04 +00:00
/// get the unified range of the same feild within all contained DataSet
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
vtkm::cont::ArrayHandle<vtkm::Range> GetGlobalRange(const std::string& field_name) const;
template <typename TypeList>
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> GetGlobalRange(const std::string& field_name,
TypeList) const;
template <typename TypeList, typename StorageList>
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> GetGlobalRange(const std::string& field_name,
TypeList,
StorageList) const;
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
vtkm::cont::ArrayHandle<vtkm::Range> GetGlobalRange(const int& index) const;
template <typename TypeList>
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> GetGlobalRange(const int& index, TypeList) const;
template <typename TypeList, typename StorageList>
VTKM_CONT vtkm::cont::ArrayHandle<vtkm::Range> GetGlobalRange(const int& index,
TypeList,
StorageList) const;
2017-08-02 02:11:17 +00:00
VTKM_CONT
2017-08-18 20:28:33 +00:00
void PrintSummary(std::ostream& stream) const;
2017-05-10 00:27:03 +00:00
private:
2017-08-02 20:17:31 +00:00
std::vector<vtkm::cont::DataSet> blocks;
2017-05-10 00:27:03 +00:00
};
}
} // namespace vtkm::cont
2017-08-02 19:18:55 +00:00
#endif