Skip to main content

DPF C++ Client Library 2025 R2

ansys::dpf::FieldsContainer Class Reference

Last update: 16.07.2025

Contains a group of fields. More...

#include <dpf_api.h>

Inherits ansys::dpf::CollectionBase.

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 &&) noexcept
 
FieldsContaineroperator= (FieldsContainer const &)
 
FieldsContaineroperator= (FieldsContainer &&) noexcept
 
Field operator[] (dp_int index)
 
Field at (dp_index index)
 
const Field at (dp_index index) const
 
void update (Field &f, dp_index index)
 
void add (LabelSpace const &lab_space, Field const &f)
 
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< FieldgetFieldsForTimeId (dp_int time_id, dp_int complex_id=0) const
 
FieldsContainer createSubFieldsContainer (LabelSpace const &lab_space) const
 
FieldsContainer deep_copy (ansys::dpf::Client const *const client=nullptr) 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, ResultTest.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.

◆ 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.

◆ 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.

◆ 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.

Connect with Ansys