Skip to main content

DPF C++ client library 2023 R2

ansys::dpf::FieldsContainer Class Reference

Last update: 10.07.2023

Contains a group of fields. More...

#include <dpf_api.h>

Inheritance diagram for ansys::dpf::FieldsContainer:
ansys::dpf::DpfTypes

Public Member Functions

 FieldsContainer (Client const *const client)
 
 FieldsContainer (Client const *const client, std::vector< std::string > const &labels)
 
 FieldsContainer (int id, Client const *const client)
 
 FieldsContainer (const std::vector< std::string > &labels)
 
 FieldsContainer (FieldsContainer const &)
 
 FieldsContainer (FieldsContainer &&)
 
FieldsContaineroperator= (FieldsContainer const &)
 
FieldsContaineroperator= (FieldsContainer &&)
 
Field operator[] (dp_int index)
 
dp_int size () const
 
Field at (dp_index index)
 
const Field at (dp_index index) const
 
void update (Field &f, dp_index index)
 
void reserve (dp_int size)
 
void resize (dp_int size)
 
void addLabel (std::string const &label)
 
void addLabel (std::string const &label, dp_id default_value)
 
void addLabels (std::vector< std::string > const &labels)
 
void add (LabelSpace const &lab_space, Field const &f)
 
dp_int getSizeFor (LabelSpace const &lab_space) const
 
std::vector< FieldgetFields (LabelSpace const &lab_space) const
 
Field getField (LabelSpace const &lab_space) const
 
std::vector< int > getFieldsIndeces (LabelSpace const &lab_space) const
 
std::vector< std::string > labels () const
 
LabelSpace getLabelSpace (dp_index index) const
 
Scoping labelScoping (std::string const &label) const
 
std::vector< FieldgetFieldsForTimeId (dp_int time_id, dp_int complex_id=0) const
 
bool hasLabel (std::string const &label) const
 
Support support (std::string const &label=labels::time) const
 
void setSupport (ansys::dpf::Support const &support, std::string const &label=labels::time)
 
void setSupport (ansys::dpf::TimeFreqSupport const &support, std::string const &label=labels::time)
 
FieldsContainer createSubFieldsContainer (LabelSpace const &lab_space) const
 
std::string name () const
 
void setName (std::string name)
 
dp_id id () const
 
void setId (dp_id id)
 
FieldsContainer deep_copy (ansys::dpf::Client const *const client=nullptr) 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 FieldsContainer emptyFieldsContainer ()
 

Detailed Description

Contains a group of fields.

FieldsContainer is a group of fields, used mainly in transient, harmonic, modal or multi-steps static analysis, where we can have a field for each time step or for each frequency. Consequently the fields container can describle a complete analysis with all its details.

The fields container is designed as a set of fields ordered through labels and ids. Labels identify how the fields are filtered. The most common fields container have the label "time" with ids corresponding to each time sets, the label "complex" will allow to separate real parts (id=0) from imaginary parts (id=1) in a harmonic analysis.

See also
Using collections and labels
Examples
AveragingTest.cpp, CompleteRST.cpp, DataApis.cpp, DataExport.cpp, ModelTest.cpp, OperatorsApis.cpp, and WorkflowExamples.cpp.

Constructor & Destructor Documentation

◆ FieldsContainer() [1/4]

ansys::dpf::FieldsContainer::FieldsContainer ( Client const *const  client)

Create a new fields container on a server.

Parameters
[in]clientClient instance designating the IP, port and protocol to use.

◆ FieldsContainer() [2/4]

ansys::dpf::FieldsContainer::FieldsContainer ( Client const *const  client,
std::vector< std::string > const &  labels 
)

Create a collection of fields with the given labels on a server.

Parameters
[in]clientClient instance designating the IP, port and protocol to use.
[in]labelsLabels for fields.

◆ FieldsContainer() [3/4]

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

Retrieve an existing instance of FieldsContainer on a server.

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

◆ FieldsContainer() [4/4]

ansys::dpf::FieldsContainer::FieldsContainer ( const std::vector< std::string > &  labels)

Create a collection of fields with the given labels.

Parameters
[in]labelsLabels for fields.

Member Function Documentation

◆ add()

void ansys::dpf::FieldsContainer::add ( LabelSpace const &  lab_space,
Field const &  f 
)

Add Field to LabelSpace.

Parameters
[in]lab_spaceLabelSpace to which to add Field.
[in]fField to add to LabelSpace.
Examples
DataApis.cpp, and DataExport.cpp.

◆ addLabel() [1/2]

void ansys::dpf::FieldsContainer::addLabel ( std::string const &  label)

Add new label to field.

Parameters
[in]labelNew label.
Examples
DataExport.cpp.

◆ addLabel() [2/2]

void ansys::dpf::FieldsContainer::addLabel ( std::string const &  label,
dp_id  default_value 
)

Add new label with value.

Parameters
[in]labelNew label.
[in]default_valueValue of label.

◆ addLabels()

void ansys::dpf::FieldsContainer::addLabels ( std::vector< std::string > const &  labels)

Add vector of labels to field.

Parameters
[in]labelsVector of labels to add.
Examples
DataApis.cpp.

◆ at() [1/2]

Field ansys::dpf::FieldsContainer::at ( dp_index  index)

Get field at index.

Returns
Field given by index.
Parameters
[in]indexIndex of field within container.
Examples
AveragingTest.cpp, and CompleteRST.cpp.

◆ at() [2/2]

const Field ansys::dpf::FieldsContainer::at ( dp_index  index) const

Get field at index.

Returns
Field given by index.
Parameters
[in]indexIndex of field.

◆ createSubFieldsContainer()

FieldsContainer ansys::dpf::FieldsContainer::createSubFieldsContainer ( LabelSpace const &  lab_space) const

Create a new fields container with all the fields corresponding to the label space in input.

Returns
Created fields container.
Parameters
[in]lab_spaceLabelSpace from which to get fields.

◆ deep_copy()

FieldsContainer ansys::dpf::FieldsContainer::deep_copy ( ansys::dpf::Client const *const  client = nullptr) const

Create a new FieldsContainer on a server by copying all the data of this FieldsContainer.

Parameters
[in]clientClient instance designating the IP, port and protocol to use.

◆ emptyFieldsContainer()

static FieldsContainer ansys::dpf::FieldsContainer::emptyFieldsContainer ( )
static

Create an empty fields container.

Returns
Empty FieldsContainer.
Examples
DataExport.cpp.

◆ getField()

Field ansys::dpf::FieldsContainer::getField ( LabelSpace const &  lab_space) const
Returns
First Field given by LabelSpace
Parameters
[in]lab_spaceLabelSpace for which to get field.
Examples
DataExport.cpp.

◆ getFields()

std::vector< Field > ansys::dpf::FieldsContainer::getFields ( LabelSpace const &  lab_space) const
Returns
Fields given by LabelSpace
Parameters
[in]lab_spaceLabelSpace for which to get fields.

◆ getFieldsForTimeId()

std::vector< Field > ansys::dpf::FieldsContainer::getFieldsForTimeId ( dp_int  time_id,
dp_int  complex_id = 0 
) const
Returns
Real or imaginary (by default real) Fields at given time set.
Parameters
[in]time_idTime Set Id (1 to # of time sets).
[in]complex_idFlag indicating to return imaginary part of result (0 = real part, 1 = imaginary part).

◆ getFieldsIndeces()

std::vector< int > ansys::dpf::FieldsContainer::getFieldsIndeces ( LabelSpace const &  lab_space) const
Returns
Field indices for field given by LabelSpace
Parameters
[in]lab_spaceLabelSpace defining field for which to get indices.

◆ getLabelSpace()

LabelSpace ansys::dpf::FieldsContainer::getLabelSpace ( dp_index  index) const
Returns
LabelSpace for given field index.
Parameters
[in]indexIndex of field.

◆ getSizeFor()

dp_int ansys::dpf::FieldsContainer::getSizeFor ( LabelSpace const &  lab_space) const
Returns
Number of fields for given LabelSpace.
Parameters
[in]lab_spaceLabelSpace for which to get number of fields.

◆ hasLabel()

bool ansys::dpf::FieldsContainer::hasLabel ( std::string const &  label) const
Returns
Indication that FieldsContainer has field given by label.
Parameters
[in]labelField label.

◆ id()

dp_id ansys::dpf::FieldsContainer::id ( ) const
Returns
Id of FieldsContainer.

◆ labels()

std::vector< std::string > ansys::dpf::FieldsContainer::labels ( ) const
Returns
Vector of labels of fields container.

◆ labelScoping()

Scoping ansys::dpf::FieldsContainer::labelScoping ( std::string const &  label) const
Returns
Scoping for field given by label.
Parameters
[in]labelField for which to get scoping.

◆ name()

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

◆ operator[]()

Field ansys::dpf::FieldsContainer::operator[] ( dp_int  index)

Get field at index.

Returns
Field given by index.
Parameters
[in]indexIndex of field within container.

◆ reserve()

void ansys::dpf::FieldsContainer::reserve ( dp_int  size)

Reserve space for fields

Parameters
[in]sizeNumber of fields for which to reserve space.

◆ resize()

void ansys::dpf::FieldsContainer::resize ( dp_int  size)

Resize container to given size.

Parameters
[in]sizeSet container to number of fields.

◆ setId()

void ansys::dpf::FieldsContainer::setId ( dp_id  id)

Set Id of FieldsContainer.

Parameters
[in]idNew id.

◆ setName()

void ansys::dpf::FieldsContainer::setName ( std::string  name)

Set name of FieldsContainer.

Parameters
[in]nameNew name.

◆ setSupport() [1/2]

void ansys::dpf::FieldsContainer::setSupport ( ansys::dpf::Support const &  support,
std::string const &  label = labels::time 
)

Set Support for given label.

Parameters
[in]supportSupport value.
[in]labelLabel for which to set support.

◆ setSupport() [2/2]

void ansys::dpf::FieldsContainer::setSupport ( ansys::dpf::TimeFreqSupport const &  support,
std::string const &  label = labels::time 
)

Set TimeFreqSupport for given label.

Parameters
[in]supportSupport value.
[in]labelLabel for which to set support.

◆ size()

dp_int ansys::dpf::FieldsContainer::size ( ) const

Get Number of fields in container.

Returns
Number of fields.
Examples
AveragingTest.cpp, DataExport.cpp, and ModelTest.cpp.

◆ support()

Support ansys::dpf::FieldsContainer::support ( std::string const &  label = labels::time) const
Returns
Support for given label.
Parameters
[in]labelLabel for which to get Support.

◆ update()

void ansys::dpf::FieldsContainer::update ( Field f,
dp_index  index 
)

Update Field at index

Parameters
[in]fNew field data.
[in]indexIndex of field within container.