2015-05-11 20:54:16 +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.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
|
2015-05-11 20:54:16 +00:00
|
|
|
// Copyright 2015 UT-Battelle, LLC.
|
|
|
|
// Copyright 2015 Los Alamos National Security.
|
|
|
|
//
|
2017-09-20 21:33:44 +00:00
|
|
|
// Under the terms of Contract DE-NA0003525 with NTESS,
|
2015-05-11 20:54:16 +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.
|
|
|
|
//============================================================================
|
2016-12-16 22:04:58 +00:00
|
|
|
|
|
|
|
#include <vtkm/cont/Field.h>
|
2015-05-11 20:54:16 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
2015-05-11 20:54:16 +00:00
|
|
|
|
2018-11-02 18:18:09 +00:00
|
|
|
/// constructors for points / whole mesh
|
|
|
|
VTKM_CONT
|
|
|
|
Field::Field(std::string name, Association association, const vtkm::cont::DynamicArrayHandle& data)
|
|
|
|
: Name(name)
|
|
|
|
, FieldAssociation(association)
|
|
|
|
, AssocCellSetName()
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->FieldAssociation == Association::WHOLE_MESH ||
|
|
|
|
this->FieldAssociation == Association::POINTS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// constructors for cell set associations
|
|
|
|
VTKM_CONT
|
|
|
|
Field::Field(std::string name,
|
|
|
|
Association association,
|
|
|
|
const std::string& cellSetName,
|
|
|
|
const vtkm::cont::DynamicArrayHandle& data)
|
|
|
|
: Name(name)
|
|
|
|
, FieldAssociation(association)
|
|
|
|
, AssocCellSetName(cellSetName)
|
|
|
|
, AssocLogicalDim(-1)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->FieldAssociation == Association::CELL_SET);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// constructors for logical dimension associations
|
|
|
|
VTKM_CONT
|
|
|
|
Field::Field(std::string name,
|
|
|
|
Association association,
|
|
|
|
vtkm::IdComponent logicalDim,
|
|
|
|
const vtkm::cont::DynamicArrayHandle& data)
|
|
|
|
: Name(name)
|
|
|
|
, FieldAssociation(association)
|
|
|
|
, AssocCellSetName()
|
|
|
|
, AssocLogicalDim(logicalDim)
|
|
|
|
, Data(data)
|
|
|
|
, Range()
|
|
|
|
, ModifiedFlag(true)
|
|
|
|
{
|
|
|
|
VTKM_ASSERT(this->FieldAssociation == Association::LOGICAL_DIM);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-24 21:39:37 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void Field::PrintSummary(std::ostream& out) const
|
2016-12-16 22:04:58 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
out << " " << this->Name;
|
|
|
|
out << " assoc= ";
|
2017-02-24 21:39:37 +00:00
|
|
|
switch (this->GetAssociation())
|
|
|
|
{
|
2018-05-18 20:10:15 +00:00
|
|
|
case Association::ANY:
|
2017-05-18 14:29:41 +00:00
|
|
|
out << "Any ";
|
|
|
|
break;
|
2018-05-18 20:10:15 +00:00
|
|
|
case Association::WHOLE_MESH:
|
2017-05-18 14:29:41 +00:00
|
|
|
out << "Mesh ";
|
|
|
|
break;
|
2018-05-18 20:10:15 +00:00
|
|
|
case Association::POINTS:
|
2017-05-18 14:29:41 +00:00
|
|
|
out << "Points ";
|
|
|
|
break;
|
2018-05-18 20:10:15 +00:00
|
|
|
case Association::CELL_SET:
|
2017-05-18 14:29:41 +00:00
|
|
|
out << "Cells ";
|
|
|
|
break;
|
2018-05-18 20:10:15 +00:00
|
|
|
case Association::LOGICAL_DIM:
|
2017-05-18 14:29:41 +00:00
|
|
|
out << "LogicalDim ";
|
|
|
|
break;
|
2017-02-24 21:39:37 +00:00
|
|
|
}
|
|
|
|
this->Data.PrintSummary(out);
|
2016-12-16 22:04:58 +00:00
|
|
|
}
|
|
|
|
|
2018-05-02 14:02:39 +00:00
|
|
|
VTKM_CONT
|
|
|
|
Field::~Field()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-24 21:39:37 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Range>& Field::GetRange() const
|
2017-02-24 21:39:37 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
return this->GetRange(VTKM_DEFAULT_TYPE_LIST_TAG(), VTKM_DEFAULT_STORAGE_LIST_TAG());
|
2017-02-24 21:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
void Field::GetRange(vtkm::Range* range) const
|
2017-02-24 21:39:37 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
this->GetRange(range, VTKM_DEFAULT_TYPE_LIST_TAG(), VTKM_DEFAULT_STORAGE_LIST_TAG());
|
2017-02-24 21:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::DynamicArrayHandle& Field::GetData() const
|
2015-05-11 20:54:16 +00:00
|
|
|
{
|
2017-02-24 21:39:37 +00:00
|
|
|
return this->Data;
|
2016-12-16 22:04:58 +00:00
|
|
|
}
|
2015-05-11 20:54:16 +00:00
|
|
|
|
2017-02-24 21:39:37 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::cont::DynamicArrayHandle& Field::GetData()
|
2016-12-16 22:04:58 +00:00
|
|
|
{
|
2017-02-24 21:39:37 +00:00
|
|
|
this->ModifiedFlag = true;
|
|
|
|
return this->Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::ArrayHandle<vtkm::Range>& Field::GetRange(VTKM_DEFAULT_TYPE_LIST_TAG,
|
|
|
|
VTKM_DEFAULT_STORAGE_LIST_TAG) const
|
2017-02-24 21:39:37 +00:00
|
|
|
{
|
|
|
|
return this->GetRangeImpl(VTKM_DEFAULT_TYPE_LIST_TAG(), VTKM_DEFAULT_STORAGE_LIST_TAG());
|
2016-12-16 22:04:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::cont
|