Viskores  1.0
Public Types | Public Member Functions | Private Attributes | List of all members
viskores::cont::Field Class Reference

A Field encapsulates an array on some piece of the mesh, such as the points, a cell set, a point logical dimension, or the whole mesh. More...

#include <Field.h>

Inheritance diagram for viskores::cont::Field:
viskores::cont::CoordinateSystem

Public Types

enum  Association {
  Association::Any, Association::WholeDataSet, Association::Points, Association::Cells,
  Association::Partitions, Association::Global
}
 Identifies what elements of a data set a field is associated with. More...
 

Public Member Functions

 Field ()=default
 
 Field (std::string name, Association association, const viskores::cont::UnknownArrayHandle &data)
 Create a field with the given name, association, and data. More...
 
template<typename T , typename Storage >
 Field (std::string name, Association association, const viskores::cont::ArrayHandle< T, Storage > &data)
 Create a field with the given name, association, and data. More...
 
 Field (const viskores::cont::Field &src)
 
 Field (viskores::cont::Field &&src) noexcept
 
virtual ~Field ()
 
Fieldoperator= (const viskores::cont::Field &src)
 
Fieldoperator= (viskores::cont::Field &&src) noexcept
 
bool IsCellField () const
 Return true if this field is associated with cells. More...
 
bool IsPointField () const
 Return true if this field is associated with points. More...
 
bool IsWholeDataSetField () const
 Return true if this field is associated with the whole data set. More...
 
bool IsPartitionsField () const
 Return true if this field is associated with partitions in a partitioned data set. More...
 
bool IsGlobalField () const
 Return true if this field is global. More...
 
bool IsSupportedType () const
 Returns true if the array of the field has a value type that matches something in VISKORES_FIELD_TYPE_LIST and a storage that matches something in VISKORES_FIELD_STORAGE_LIST. More...
 
viskores::Id GetNumberOfValues () const
 Return the number of values in the field array. More...
 
const std::string & GetName () const
 Return the name of the field. More...
 
Association GetAssociation () const
 Return the association of the field. More...
 
const viskores::cont::UnknownArrayHandleGetData () const
 Get the array of the data for the field. More...
 
viskores::cont::UnknownArrayHandleGetData ()
 Get the array of the data for the field. More...
 
const viskores::cont::ArrayHandle< viskores::Range > & GetRange () const
 Returns the range of each component in the field array. More...
 
void GetRange (viskores::Range *range) const
 Returns the range of each component in the field array. More...
 
viskores::cont::UnknownArrayHandle GetDataAsDefaultFloat () const
 Get the data as an array with viskores::FloatDefault components. More...
 
viskores::cont::UnknownArrayHandle GetDataWithExpectedTypes () const
 Get the data as an array of an expected type. More...
 
void ConvertToExpected ()
 Convert this field to use an array of an expected type. More...
 
void SetData (const viskores::cont::UnknownArrayHandle &newdata)
 
template<typename T , typename StorageTag >
void SetData (const viskores::cont::ArrayHandle< T, StorageTag > &newdata)
 
virtual void PrintSummary (std::ostream &out, bool full=false) const
 Print a summary of the data in the field. More...
 
virtual void ReleaseResourcesExecution ()
 Remove the data from the device memory (but preserve the data on the host). More...
 

Private Attributes

std::string Name
 name of field More...
 
Association FieldAssociation = Association::Any
 
viskores::cont::UnknownArrayHandle Data
 
viskores::cont::ArrayHandle< viskores::RangeRange
 
bool ModifiedFlag = true
 

Detailed Description

A Field encapsulates an array on some piece of the mesh, such as the points, a cell set, a point logical dimension, or the whole mesh.

Member Enumeration Documentation

◆ Association

Identifies what elements of a data set a field is associated with.

The Association enum is used by viskores::cont::Field to specify on what topological elements each item in the field is associated with.

Enumerator
Any 

Any field regardless of the association.

This is used when choosing a viskores::cont::Field that could be of any association. It is often used as the default if no association is given.

WholeDataSet 

A "global" field that applies to the entirety of a viskores::cont::DataSet.

Fields of this association often contain summary or annotation information. An example of a whole data set field could be the region that the mesh covers.

Points 

A field that applies to points.

There is a separate field value attached to each point. Point fields usually represent samples of continuous data that can be reinterpolated through cells. Physical properties such as temperature, pressure, density, velocity, etc. are usually best represented in point fields. Data that deals with the points of the topology, such as displacement vectors, are also appropriate for point data.

Cells 

A field that applies to cells.

There is a separate field value attached to each cell in a cell set. Cell fields usually represent values from an integration over the finite cells of the mesh. Integrated values like mass or volume are best represented in cell fields. Statistics about each cell like strain or cell quality are also appropriate for cell data.

Partitions 

A field that applies to partitions.

This type of field is attached to a viskores::cont::PartitionedDataSet. There is a separate field value attached to each partition. Identification or information about the arrangement of partitions such as hierarchy levels are usually best represented in partition fields.

Global 

A field that applies to all partitions.

This type of field is attached to a viskores::cont::PartitionedDataSet. It contains values that are "global" across all partitions and data therin.

Constructor & Destructor Documentation

◆ Field() [1/5]

viskores::cont::Field::Field ( )
default

◆ Field() [2/5]

viskores::cont::Field::Field ( std::string  name,
Association  association,
const viskores::cont::UnknownArrayHandle data 
)

Create a field with the given name, association, and data.

◆ Field() [3/5]

template<typename T , typename Storage >
viskores::cont::Field::Field ( std::string  name,
Association  association,
const viskores::cont::ArrayHandle< T, Storage > &  data 
)
inline

Create a field with the given name, association, and data.

◆ Field() [4/5]

viskores::cont::Field::Field ( const viskores::cont::Field src)

◆ Field() [5/5]

viskores::cont::Field::Field ( viskores::cont::Field &&  src)
noexcept

◆ ~Field()

virtual viskores::cont::Field::~Field ( )
virtual

Member Function Documentation

◆ ConvertToExpected()

void viskores::cont::Field::ConvertToExpected ( )

Convert this field to use an array of an expected type.

Copies the internal data, as necessary, to an array that (probably) has a value type that matches something in VISKORES_FIELD_TYPE_LIST and a storage that matches something in VISKORES_FIELD_STORAGE_LIST. If the field already has a value type and storage that match VISKORES_FIELD_TYPE_LIST and VISKORES_FIELD_STORAGE_LIST respectively, then nothing in the field is changed. If something does not match, then the data are copied to a viskores::cont::ArrayHandleBasic with a value type component of viskores::FloatDefault.

Note that the returned array is likely to be compatible with VISKORES_FIELD_TYPE_LIST, but not guaranteed. In particular, if this field contains Vecs, the returned array will also contain Vecs of the same size. For example, if the field contains viskores::Vec2i_16 values, they will (likely) be converted to viskores::Vec2f. Howver, viskores::Vec2f may still not be in VISKORES_FIELD_TYPE_LIST.

◆ GetAssociation()

Association viskores::cont::Field::GetAssociation ( ) const
inline

Return the association of the field.

◆ GetData() [1/2]

viskores::cont::UnknownArrayHandle& viskores::cont::Field::GetData ( )

Get the array of the data for the field.

◆ GetData() [2/2]

const viskores::cont::UnknownArrayHandle& viskores::cont::Field::GetData ( ) const

Get the array of the data for the field.

◆ GetDataAsDefaultFloat()

viskores::cont::UnknownArrayHandle viskores::cont::Field::GetDataAsDefaultFloat ( ) const

Get the data as an array with viskores::FloatDefault components.

Returns a viskores::cont::UnknownArrayHandle that contains an array that either contains values of type viskores::FloatDefault or contains Vecs with components of type viskores::FloatDefault. If the array has value types that do not match this type, then it will be copied into an array that does.

Additionally, the returned array will have a storage that is compatible with something in VISKORES_FIELD_STORAGE_LIST. If this condition is not met, then the array will be copied.

If the array contained in the field already matches the required criteria, the array will be returned without copying.

◆ GetDataWithExpectedTypes()

viskores::cont::UnknownArrayHandle viskores::cont::Field::GetDataWithExpectedTypes ( ) const

Get the data as an array of an expected type.

Returns a viskores::cont::UnknownArrayHandle that contains an array that (probably) has a value type that matches something in VISKORES_FIELD_TYPE_LIST and a storage that matches something in VISKORES_FIELD_STORAGE_LIST. If the array has a value type and storage that match VISKORES_FIELD_TYPE_LIST and VISKORES_FIELD_STORAGE_LIST respectively, then the same array is returned. If something does not match, then the data are copied to a viskores::cont::ArrayHandleBasic with a value type component of viskores::FloatDefault.

Note that the returned array is likely to be compatible with VISKORES_FIELD_TYPE_LIST, but not guaranteed. In particular, if this field contains Vecs, the returned array will also contain Vecs of the same size. For example, if the field contains viskores::Vec2i_16 values, they will (likely) be converted to viskores::Vec2f. Howver, viskores::Vec2f may still not be in VISKORES_FIELD_TYPE_LIST.

◆ GetName()

const std::string& viskores::cont::Field::GetName ( ) const
inline

Return the name of the field.

◆ GetNumberOfValues()

viskores::Id viskores::cont::Field::GetNumberOfValues ( ) const
inline

Return the number of values in the field array.

◆ GetRange() [1/2]

const viskores::cont::ArrayHandle<viskores::Range>& viskores::cont::Field::GetRange ( ) const

Returns the range of each component in the field array.

The ranges of each component are returned in an ArrayHandle containing viskores::Range values. So, for example, calling GetRange on a scalar field will return an ArrayHandle with exactly 1 entry in it. Calling GetRange on a field of 3D vectors will return an ArrayHandle with exactly 3 entries corresponding to each of the components in the range.

◆ GetRange() [2/2]

void viskores::cont::Field::GetRange ( viskores::Range range) const

Returns the range of each component in the field array.

A C array of viskores::Range objects is passed in as a place to store the result. It is imperative that the array be allocated to be large enough to hold an entry for each component.

◆ IsCellField()

bool viskores::cont::Field::IsCellField ( ) const
inline

Return true if this field is associated with cells.

◆ IsGlobalField()

bool viskores::cont::Field::IsGlobalField ( ) const
inline

Return true if this field is global.

A global field is applied to a viskores::cont::PartitionedDataSet to refer to data that applies across an entire collection of data.

◆ IsPartitionsField()

bool viskores::cont::Field::IsPartitionsField ( ) const
inline

Return true if this field is associated with partitions in a partitioned data set.

◆ IsPointField()

bool viskores::cont::Field::IsPointField ( ) const
inline

Return true if this field is associated with points.

◆ IsSupportedType()

bool viskores::cont::Field::IsSupportedType ( ) const

Returns true if the array of the field has a value type that matches something in VISKORES_FIELD_TYPE_LIST and a storage that matches something in VISKORES_FIELD_STORAGE_LIST.

◆ IsWholeDataSetField()

bool viskores::cont::Field::IsWholeDataSetField ( ) const
inline

Return true if this field is associated with the whole data set.

◆ operator=() [1/2]

Field& viskores::cont::Field::operator= ( const viskores::cont::Field src)

◆ operator=() [2/2]

Field& viskores::cont::Field::operator= ( viskores::cont::Field &&  src)
noexcept

◆ PrintSummary()

virtual void viskores::cont::Field::PrintSummary ( std::ostream &  out,
bool  full = false 
) const
virtual

Print a summary of the data in the field.

Reimplemented in viskores::cont::CoordinateSystem.

◆ ReleaseResourcesExecution()

virtual void viskores::cont::Field::ReleaseResourcesExecution ( )
inlinevirtual

Remove the data from the device memory (but preserve the data on the host).

Reimplemented in viskores::cont::CoordinateSystem.

◆ SetData() [1/2]

template<typename T , typename StorageTag >
void viskores::cont::Field::SetData ( const viskores::cont::ArrayHandle< T, StorageTag > &  newdata)
inline

◆ SetData() [2/2]

void viskores::cont::Field::SetData ( const viskores::cont::UnknownArrayHandle newdata)

Member Data Documentation

◆ Data

viskores::cont::UnknownArrayHandle viskores::cont::Field::Data
private

◆ FieldAssociation

Association viskores::cont::Field::FieldAssociation = Association::Any
private

◆ ModifiedFlag

bool viskores::cont::Field::ModifiedFlag = true
mutableprivate

◆ Name

std::string viskores::cont::Field::Name
private

name of field

◆ Range

viskores::cont::ArrayHandle<viskores::Range> viskores::cont::Field::Range
mutableprivate

The documentation for this class was generated from the following file: