Skip to main content

DPF C++ client library 2023 R2

ansys::dpf::Field Class Reference

Last update: 10.07.2023

Data for an entity. More...

#include <dpf_api.h>

Inheritance diagram for ansys::dpf::Field:
ansys::dpf::DpfTypes

Public Member Functions

 Field (int reserved_number_of_entity=0, const std::vector< int > &dimensions={ 1 }, const Location &loc=locations::nodal)
 
 Field (Client const *const client, int reserved_number_of_entity=0, const std::vector< int > &dimensions={ 1 }, const Location &loc=locations::nodal)
 
 Field (int id, Client const *const client)
 
 Field (Field const &)
 
 Field (Field &&)
 
Fieldoperator= (Field const &)
 
Fieldoperator= (Field &&)
 
bool identicalPointers (Field const &f) const
 
dp_int numberOfComponents () const
 
dp_int numberOfEntities () const
 
dp_int numberOfElementaryData () const
 
dp_int numberOfElementaryDataByEntityIndex (dp_int entityIndex) const
 
dp_int numberOfElementaryDataByEntityId (dp_int entityId) const
 
dp_int dataSize () const
 
std::string name () const
 
void setName (const std::string &name)
 
dp_double *const data (int &size) const
 
DpfVector< double > data () const
 
DpfVector< int > dataPointer () const
 
void getData (std::vector< dp_double > &data_to_fill) const
 
dp_double *const entityData (dp_index entity_index, dp_int &size) const
 
void entityData (dp_index entity_index, DpfVector< double > &data) const
 
dp_double *const entityDataById (dp_id entity_id, dp_int &size) const
 
void entityDataById (dp_id entity_id, DpfVector< double > &data) const
 
dp_id entityId (dp_index entity_index) const
 
Scoping scoping () const
 
FieldDefinition fieldDefinition () const
 
Support support () const
 
void setFieldDefinition (FieldDefinition const &f)
 
void setScoping (ansys::dpf::Scoping const &s)
 
void setData (std::vector< double > const &data)
 
void setData (double const *const data, int size)
 
void setDataPointer (std::vector< int > &data) const
 
void setDataPointer (int const *const data, int size) const
 
void setSupport (ansys::dpf::Support const &s)
 
void setSupport (ansys::dpf::TimeFreqSupport const &s)
 
void setSupport (ansys::dpf::MeshedRegion const &s)
 
void reserve (dp_int number_of_entities, dp_int overall_size=0)
 
void resize (dp_int number_of_entities, dp_int overall_size)
 
void fillCursor (dp_index index, FieldCursor &f) const
 
void push_back (dp_id entity_id, std::vector< dp_double > const &values)
 
void push_back (dp_id entity_id, const dp_double *values, int size)
 
void push_back (dp_id entity_id, dp_double *values, int size)
 
Field deep_copy (ansys::dpf::Client const *const client) const
 
Field deep_copy () const
 
- Public Member Functions inherited from ansys::dpf::DpfTypes
virtual bool empty () const
 
virtual std::string describe () const
 
so::API const * callAPI () const
 
bool isOnCommonAPI () const
 
bool getClient (Client &client) const
 
bool hasBeenMovedLocally () const
 
bool isSameObject (DpfTypes const &rhs) const
 

Static Public Member Functions

static Field emptyField ()
 

Detailed Description

Data for an entity.

The field is the main simulation data container. In numerical simulations, results data are defined by values associated to entities (scoping), and these entities are a subset of a model (support). In DPF, field data is always associated to its scoping and support, making the field a self-describing piece of data. A field is also defined by its dimensionnality, unit, location... A field can for example, describe a displacement vector or norm, stresses and strains tensors, stresses and strains equivalent, min max over time of any result... It can be defined on a complete model or just on certain entities of the model thanks to its scoping. The data is stored as a vector of double values and each elementary entity has a number of components (thanks to the dimensionality, a displacement will have 3 components, a symmetrical stress matrix 6...)

Examples
CompleteRST.cpp, DataApis.cpp, DataExport.cpp, ModelTest.cpp, OperatorsApis.cpp, and WorkflowExamples.cpp.

Constructor & Destructor Documentation

◆ Field() [1/3]

ansys::dpf::Field::Field ( int  reserved_number_of_entity = 0,
const std::vector< int > &  dimensions = { 1 },
const Location loc = locations::nodal 
)

Create a group of data with given dimensions and locations.

Parameters
[in]reserved_number_of_entityNumber of entities.
[in]dimensionsDimension of each entity.
[in]locLocation of entities.

◆ Field() [2/3]

ansys::dpf::Field::Field ( Client const *const  client,
int  reserved_number_of_entity = 0,
const std::vector< int > &  dimensions = { 1 },
const Location loc = locations::nodal 
)

Create a group of data with given dimensions and locations on a server.

Parameters
[in]clientRemote client.
[in]reserved_number_of_entityNumber of entities.
[in]dimensionsDimension of each entity.
[in]locLocation of entities.

◆ Field() [3/3]

ansys::dpf::Field::Field ( int  id,
Client const *const  client 
)

Retrieve an existing instance of Field on a server.

Parameters
[in]idId of the Field object on the server's database.
[in]clientClient instance designating the IP, port and protocol to use.

Member Function Documentation

◆ data() [1/2]

DpfVector< double > ansys::dpf::Field::data ( ) const
Returns
DpfVector of data array.

◆ data() [2/2]

dp_double *const ansys::dpf::Field::data ( int &  size) const
Returns
Pointer to data array.
Parameters
[out]sizeSize of returned data array.
Examples
DataApis.cpp, DataExport.cpp, ModelTest.cpp, and OperatorsApis.cpp.

◆ dataPointer()

DpfVector< int > ansys::dpf::Field::dataPointer ( ) const
Returns
DpfVector of data pointer array.

◆ dataSize()

dp_int ansys::dpf::Field::dataSize ( ) const
Returns
Size of the data container.
Examples
DataExport.cpp, and ModelTest.cpp.

◆ deep_copy() [1/2]

Field ansys::dpf::Field::deep_copy ( ) const

Make a deep copy locally.

◆ deep_copy() [2/2]

Field ansys::dpf::Field::deep_copy ( ansys::dpf::Client const *const  client) const

Make a deep copy on a given client.

Parameters
[in]clientRemote client

◆ emptyField()

static Field ansys::dpf::Field::emptyField ( )
static

Create an empty Field.

Returns
Empty Field.

◆ entityData() [1/2]

dp_double *const ansys::dpf::Field::entityData ( dp_index  entity_index,
dp_int size 
) const
Returns
Pointer to data array of an entity, by index.
Parameters
[in]entity_indexIndex of entity for which to get data.
[out]sizeSize of returned data array.
Examples
DataApis.cpp.

◆ entityData() [2/2]

void ansys::dpf::Field::entityData ( dp_index  entity_index,
DpfVector< double > &  data 
) const
Returns
DpfVector of data array of an entity, by index.
Parameters
[in]entity_indexIndex of entity for which to get data.
[out]dataPointer to the data.

◆ entityDataById() [1/2]

dp_double *const ansys::dpf::Field::entityDataById ( dp_id  entity_id,
dp_int size 
) const
Returns
Pointer to data array of an entity, by id.
Parameters
[in]entity_idId of entity for which to get data.
[out]sizeSize of returned data array.
Examples
DataApis.cpp.

◆ entityDataById() [2/2]

void ansys::dpf::Field::entityDataById ( dp_id  entity_id,
DpfVector< double > &  data 
) const
Returns
DpfVector of data array of an entity, by id.
Parameters
[in]entity_idId of entity for which to get data.
[out]dataPointer to the data.

◆ entityId()

dp_id ansys::dpf::Field::entityId ( dp_index  entity_index) const
Returns
Entity id corresponding to a given entity index
Parameters
[in]entity_indexIndex of entity for which to get Id.

◆ fieldDefinition()

FieldDefinition ansys::dpf::Field::fieldDefinition ( ) const
Returns
FieldDefinition of the field.
Examples
AveragingTest.cpp, DataApis.cpp, and DataExport.cpp.

◆ fillCursor()

void ansys::dpf::Field::fillCursor ( dp_index  index,
FieldCursor f 
) const

Get data at a given index.

Parameters
[in]indexIndex of entity for which to get data.
[out]fFieldCursor with which to contain data.
Examples
DataApis.cpp.

◆ getData()

void ansys::dpf::Field::getData ( std::vector< dp_double > &  data_to_fill) const

Copy the data for all entities in a vector of double.

Parameters
[out]data_to_fillVector of data for all entities.

◆ identicalPointers()

bool ansys::dpf::Field::identicalPointers ( Field const &  f) const

Compare field with input field f.

Parameters
[in]fField with which to compare.

◆ name()

std::string ansys::dpf::Field::name ( ) const
Returns
Name of Field.

◆ numberOfComponents()

dp_int ansys::dpf::Field::numberOfComponents ( ) const
Returns
Number of components in the elementary data.
Examples
DataApis.cpp.

◆ numberOfElementaryData()

dp_int ansys::dpf::Field::numberOfElementaryData ( ) const
Returns
Number of elementary data (size = number of components) contained in the Field.

◆ numberOfElementaryDataByEntityId()

dp_int ansys::dpf::Field::numberOfElementaryDataByEntityId ( dp_int  entityId) const
Returns
Number of elementary data by entity id.

◆ numberOfElementaryDataByEntityIndex()

dp_int ansys::dpf::Field::numberOfElementaryDataByEntityIndex ( dp_int  entityIndex) const
Returns
Number of elementary data by entity index.

◆ numberOfEntities()

dp_int ansys::dpf::Field::numberOfEntities ( ) const
Returns
Number of entities in the Field. Only implemented for in process udage. For gRPC usage, use scoping().size().

◆ push_back() [1/3]

void ansys::dpf::Field::push_back ( dp_id  entity_id,
const dp_double values,
int  size 
)

Push back the entity data.

Parameters
[in]entity_idIndex of entity for which to push data.
[in]valuesPtr on data for entity.
[in]sizeNumber of entities.

◆ push_back() [2/3]

void ansys::dpf::Field::push_back ( dp_id  entity_id,
dp_double values,
int  size 
)

Push back the entity data.

Parameters
[in]entity_idIndex of entity for which to push data.
[in]valuesPtr on data for entity.
[in]sizeNumber of entities.

◆ push_back() [3/3]

void ansys::dpf::Field::push_back ( dp_id  entity_id,
std::vector< dp_double > const &  values 
)

Push back the entity data.

Parameters
[in]entity_idIndex of entity for which to push data.
[in]valuesVector of data for entity.
Examples
DataApis.cpp.

◆ reserve()

void ansys::dpf::Field::reserve ( dp_int  number_of_entities,
dp_int  overall_size = 0 
)

Reserve the Field. Only implemented for in process udage. To reserve the size for gRPC usage, use the constructor.

Parameters
[in]number_of_entitiesNumber of entities.
[in]overall_sizeTotal size of entity data.

◆ resize()

void ansys::dpf::Field::resize ( dp_int  number_of_entities,
dp_int  overall_size 
)

Reserve the Field.

Parameters
[in]number_of_entitiesNumber of entities.
[in]overall_sizeTotal size of entity data.

◆ scoping()

Scoping ansys::dpf::Field::scoping ( ) const
Returns
Scoping of the field.
Examples
DataApis.cpp, and DataExport.cpp.

◆ setData() [1/2]

void ansys::dpf::Field::setData ( double const *const  data,
int  size 
)

Set the data of the field.

Parameters
[in]dataList of data.
[in]sizeSize of list.

◆ setData() [2/2]

void ansys::dpf::Field::setData ( std::vector< double > const &  data)

Set the data of the field.

Parameters
[in]dataVector of data.
Examples
DataApis.cpp, and OperatorsApis.cpp.

◆ setDataPointer() [1/2]

void ansys::dpf::Field::setDataPointer ( int const *const  data,
int  size 
) const

Set the data pointer of the field.

Parameters
[in]dataList of data.
[in]sizeSize of list.

◆ setDataPointer() [2/2]

void ansys::dpf::Field::setDataPointer ( std::vector< int > &  data) const

Set the data pointer of the field.

Parameters
[in]dataVector of data.

◆ setFieldDefinition()

void ansys::dpf::Field::setFieldDefinition ( FieldDefinition const &  f)

Set the FieldDefinition.

Examples
DataApis.cpp.

◆ setName()

void ansys::dpf::Field::setName ( const std::string &  name)

Set name of Field.

Parameters
[in]nameNew name.

◆ setScoping()

void ansys::dpf::Field::setScoping ( ansys::dpf::Scoping const &  s)

set the Scoping of the Field.

◆ setSupport() [1/3]

void ansys::dpf::Field::setSupport ( ansys::dpf::MeshedRegion const &  s)

Set the support of the Field.

Parameters
[in]sMeshedRegion to support.

◆ setSupport() [2/3]

void ansys::dpf::Field::setSupport ( ansys::dpf::Support const &  s)

Set the support of the Field.

Parameters
[in]sField to support.

◆ setSupport() [3/3]

void ansys::dpf::Field::setSupport ( ansys::dpf::TimeFreqSupport const &  s)

Set the support of the Field.

Parameters
[in]sTimeFreqSupport to support.

◆ support()

Support ansys::dpf::Field::support ( ) const
Returns
Support of the field.