Skip to main content

Common Fluids Format 2024 R1

ansys::Project::Run Class Reference

Last update: 16.07.2025

Subfolder of a Simulation, regrouping Output/Result for a step. More...

#include "Run.hpp"

Inheritance diagram for ansys::Project::Run:
ansys::Project::SimBaseansys::Project::RunOutputAttransys::Project::RunGroup

Public Member Functions

 Run (Iterator pIter)
 Constructor from Iterator.
More...
 
virtual Error isValid () const
 Returns error with message if invalid.
 
bool addVariable (const std::string &pVar)
 Register an input variable for this run. More...
 
bool setVariables (const std::vector< std::string > &pVars)
 Set/replace the list of variables for this run. More...
 
bool removeVariable (const std::string &pVar)
 Remove a variable from the list of inputs. More...
 
std::vector< std::string > getVariables () const
 Return the list of input variables for this Run.
 
std::vector< std::vector< std::string > > getValues (const std::vector< std::string > &pVars) const
 Return the list of values -one per output- for a list of variables.
 
bool addOutputVariable (const std::string &pVar)
 Register an output variable for this run. More...
 
bool setOutputVariables (const std::vector< std::string > &pVars)
 Set/replace the list of output variables.
 
bool removeOutputVariable (const std::string &pVar)
 Remove an output variable.
 
std::vector< std::string > getOutputVariables () const
 Returns the list of output variables.
 
std::vector< std::string > getAllVariables () const
 Returns the list of all variables ( input and output )
 
void addVarIndex ()
 Add the Index variable (not required if mandatory for the run type)
 
void addVarTime ()
 Add the Time variable (not required if mandatory for the run type)
 
void addVarSolverIteration ()
 Add the SolverIteration variable (not required if mandatory for the run type)
 
void addVarCrankAngle ()
 Add the built-in variable.
 
void addVarMeshId ()
 Add the MeshId variable - Id should be incremented when the mesh has changed.
 
void addVarDomainTransformationId ()
 Add the DomainTransformationId variable - Id should be incremented when the mesh transformation metadata has changed.
 
void addVarPhysicsId ()
 Add the PhysicsId variable - Id should be incremented when the physics settings have changed.
 
void addVarTopologyId ()
 Add the TopologyId variable - Id should be incremented when the topology (list of boundaries, domains) has changed.
 
void addVarCoordinatesId ()
 Add the CoordinatesId variable - Id should be incremented when the node locations of a mesh have changed.
 
void addVarLocationId ()
 Add the LocationId variable - Id should be incremented when the node locations of a mesh have changed.
 
void addVarConnectivityId ()
 Add the ConnectivityId variable - Id should be incremented when the cells of a mesh are changed (number changed, connectivity changed, ...)
 
void addVarCaseId ()
 Add the CaseId variable - Id is incremented when the case settings are changed.
 
void addVarInputSettingsId ()
 Add the InputSettings variable - Id is incremented when the input case settings are changed. More...
 
void addVarOutputSettingsId ()
 Add the OutputSettings variable - Id is incremented when the case output settings are changed.
 
Error computeIds ()
 Compute missing ids (CaseId, MeshId, InputSettingsId) from their dependencies.
 
virtual bool hasValue (const std::string &pVar, bool pFlagInherited) const
 Search the metadata (local and inherited) for the specified key. More...
 
Iterator getValueIter (const std::string &pVar) const
 Search the metadata (local and inherited) for the specified metadata link and return the value as an iterator. More...
 
virtual std::string getValue (const std::string &pVar, bool pFlagInherited) const
 Search the metadata (local and inherited) for the specified key and return the value as string. More...
 
virtual int getValueInt (const std::string &pVar, bool pFlagInherited) const
 Search the metadata (local and inherited) for the specified key and return the value as integer. More...
 
virtual double getValueDouble (const std::string &pVar, bool pFlagInherited) const
 Search the metadata (local and inherited) for the specified key and return the value as double. More...
 
virtual MetaVariableType getValueType (const std::string &pVar, bool pFlagInherited) const
 Search the metadata (local and inherited) for the specified key and return the its data type. More...
 
virtual void setValue (const std::string &pVar, const std::string &pValue)
 Sets the local metadata to the specified key/value.
 
virtual void setValueInt (const std::string &pVar, int pValue)
 Sets the local metadata to the specified key/value.
 
virtual void setValueDouble (const std::string &pVar, double pValue)
 Sets the local metadata to the specified key/value.
 
bool setRunOutputType (RunOutputType pType)
 Set the run output type, will add automatically the mandatory variables (if any)
 
RunOutputType getRunOutputType () const
 Return the RunOutputType as the enum.
 
std::string getRunOutputTypeAsString () const
 Return the RunOutputType as a string.
 
Iterator getCase () const
 Returns the case file associated with this run (if any, see setCase())
 
Iterator newOutput (std::string pName="")
 Create a Output folder in the current Run folder. More...
 
std::vector< IteratorgetResultIterators (const std::string &pType, const std::string &pSubtype) const
 Return the list of results in the current Run and Output subfolders, as vector of Iterator. More...
 
std::vector< ResultgetResults (const std::string &pType, const std::string &pSubtype) const
 Return the list of results in the current Run and Output subfolders. More...
 
std::vector< IteratorgetOutputIterators () const
 Return the list of Output in the current Run, as a vector of Iterator.
 
std::vector< OutputgetOutputs () const
 Return the list of Output in the current Run.
 
Iterator getData ()
 Returns the default latest data file (from the current output, main data type)
 
Iterator getResult (const std::string &pDataType)
 Returns the current data file of specified type.
 
void setCurrentOutput (Iterator pOutput)
 Set the current output link for this run, typically the latest output is the current.
 
Iterator getCurrentOutput () const
 Return the current output link for this run, typically the latest output is the current.
 
std::vector< std::string > getResultTypes () const
 Returns the list of available output types listed in the run Outputs.
 
Error getTransientOutputs (const std::string &pResultType, std::vector< Iterator > &pOutIterators, std::vector< double > &pOutTimeval) const
 For transient runs - return the list of output results and their time values. More...
 
Error getOutputSequence (OutputSequenceOrder pOrder, std::string pVariable, std::vector< Output > &pOutputs) const
 Get the Output sequence, ordered by the specified parameter. More...
 
std::vector< OutputgetOutputsMatching (std::string pVariable, OutputMatchOperator pOperator, double pValue) const
 Get the list of outputs matching the specified condition. More...
 
Error removeOutputs (const std::vector< Output > &pOut, bool pEraseFiles)
 Remove the specified list of Output from the children of this run. More...
 
void setRunStatus (RunStatus pStatus)
 Set the RunStatus state for this Run. More...
 
RunStatus getRunStatus () const
 Returns the RunStatus state for this Output. See setRunStatus()
 
- Public Member Functions inherited from ansys::Project::SimBase
std::string getName () const
 Returns the object name in the project.
 
Iterator setCase (Iterator pCaseFile)
 Set the case file associated with this item. More...
 
void setMainDataType (const std::string &pDataType)
 Set the result type expected as default output for runs. More...
 
std::string getMainDataType () const
 Returns the result type expected as default output for runs (see: setMainDataType() )
 
Iterator copyInput (Path pPath, bool pInInputFolder=false)
 Copy the specified project file into the current folder. More...
 
Iterator setInput (Path pPath)
 Register a files as Input/ to this folder. More...
 
std::vector< IteratorgetInputs (Error *pErrorPtr=0) const
 Return the list of registered inputs for this simulation. More...
 
Iterator getInputByType (const std::string &pType, std::string pSubtype="") const
 Search for a -single- input of the specified type (and optionally, subtype) More...
 
std::vector< IteratorgetInputsByType (const std::string &pType, std::string pSubtype="", Error *pErrorPtr=0) const
 Search for one or multiple input of the specified type (and optionally, subtype) More...
 
MetadatagetMeta ()
 Access the Iterator Metadata, equivalent to getIterator().getMeta()
 
const MetadatagetMeta () const
 Access the Iterator Metadata, equivalent to getIterator().getMeta()
 
- Public Member Functions inherited from ansys::Project::RunOutputAttr
std::vector< std::string > getValues (const std::vector< std::string > &pVars, bool pFlagInherited) const
 Returns the values for a list of variables.
 
int getIndex () const
 Returns the output index (incremental id in a run) - always available.
 
int getSolverIteration () const
 Returns the number of solver iterations (if available)
 
double getTime () const
 Returns the transient time value (if available)
 
void setIndex (int pValue)
 Changes the specified variable.
 
void setSolverIteration (int pValue)
 Changes the specified variable.
 
void setTime (double pValue)
 Changes the specified variable.
 
double getCrankAngle () const
 Returns the specified variable (if available)
 
void setCrankAngle (double pValue)
 Changes the specified variable.
 
int getCaseId () const
 Returns the specified variable (if available)
 
int getInputSettingsId () const
 Returns the specified variable (if available) More...
 
int getDomainTransformationId () const
 Returns the specified variable (if available) More...
 
int getPhysicsId () const
 Returns the specified variable (if available) More...
 
int getOutputSettingsId () const
 Returns the specified variable (if available)
 
int getMeshId () const
 Returns the specified variable (if available)
 
int getTopologyId () const
 Returns the specified variable (if available) More...
 
int getConnectivityId () const
 Returns the specified variable (if available) More...
 
int getCoordinatesId () const
 Returns the specified variable (if available) More...
 
int getLocationId () const
 Returns the specified variable (if available) More...
 
void setCaseId (int pValue)
 Changes the specified variable.
 
void setInputSettingsId (int pValue)
 Changes the specified variable.
 
void setDomainTransformationId (int pValue)
 Changes the specified variable.
 
void setPhysicsId (int pValue)
 Changes the specified variable.
 
void setOutputSettingsId (int pValue)
 Changes the specified variable.
 
void setMeshId (int pValue)
 Changes the specified variable.
 
void setTopologyId (int pValue)
 Changes the specified variable.
 
void setConnectivityId (int pValue)
 Changes the specified variable.
 
void setCoordinatesId (int pValue)
 Changes the specified variable.
 
void setLocationId (int pValue)
 Changes the specified variable.
 
Iterator getFirstIteratorForCurrentCaseId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrentPhysicsId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrentInputSettingsId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrentDomainTransformationId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrentMeshId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrentTopologyId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrentConnectivityId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrentCoordinatesId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrentLocationId () const
 See getFirstIterator(const std::string&)
 
Iterator getFirstIteratorForCurrent (const std::string &pVar) const
 Return the first entry in the current Run, with same variable value. More...
 

Detailed Description

Subfolder of a Simulation, regrouping Output/Result for a step.

Subclass of Iterator, can be constructed from an Iterator, the Run is ok() only if the provided iterator is of the appropriate subclass.

  Iterator it = prj.get("/Sim1/Run1/");
  Run run(it);
    run.ok()

In a Simulation, one or multiple Run are created, to store the simulation Results, organized in Output subfolders. The Run might have Metatada assigned from the settings for this computation ( reference conditions, etc. )

The expected amount of Output in a run, and the variables expected to be defined for each Output depends of the RunOutputType.

  • Simple : Single Output
  • Transient : One or more Output. variable : Time
  • Steady : One or more Output. variable : SolverIteration
  • Sequence : One or more Output. variable : Index
  • Parametric : One or more Output, for a sweep of values across a list of variables.

A variable (addVariable(), addVar*()) enabled in a Run, is expected to be changed across all Output subfolders. Its related to the input settings, or the context of a result (for example, the solver iteration or time step) Additional variables can be added, in addition to the mandatory variables from the RunOutputType

Output variables (addOutputVariable()) are values computed from that result, they might be from monitors or probe points.

 Run run(it);
 run.setRunOutputType(Run::Transient);
 // Time is the automatic -mandatory- variable for Transient run type
 run.addOutputVariable("probe-temperature");
 Output o = run.newOutput("")
 o.setTime(0.);
 o.newResult("out.00000001.dat","","Result","fluent-dat");
 o.setValue("probe-temperature",277.64);
 o = run.newOutput("")
 o.setTime(0.1);
 o.newResult("out.00000002.dat","","Result","fluent-dat");
 o.setValue("probe-temperature",278.822);

Variable values assigned to the Run will be inherited by all underlying Output and Result children.

Constructor & Destructor Documentation

◆ Run()

ansys::Project::Run::Run ( Iterator  pIter)

Constructor from Iterator.

The input Iterator must be of subclass Run If the subclass is not Run, the Run object is invalid ( !ok() )

Member Function Documentation

◆ addOutputVariable()

bool ansys::Project::Run::addOutputVariable ( const std::string &  pVar)

Register an output variable for this run.

All Output subfolders should define a specific value for this variable.

◆ addVariable()

bool ansys::Project::Run::addVariable ( const std::string &  pVar)

Register an input variable for this run.

This registration is not required for automatic variables (Transient=Time, etc.)

All Output subfolders should define a specific value for this variable.

◆ addVarInputSettingsId()

void ansys::Project::Run::addVarInputSettingsId ( )

Add the InputSettings variable - Id is incremented when the input case settings are changed.

If provided, this should be incremented when any of the dependent input settings are changed, such as PhysicsId or DomainTransformationId

◆ getOutputSequence()

Error ansys::Project::Run::getOutputSequence ( OutputSequenceOrder  pOrder,
std::string  pVariable,
std::vector< Output > &  pOutputs 
) const

Get the Output sequence, ordered by the specified parameter.

Retrieve the output list, as ordered by a specific recipe and based on the value of a variable.

The default getOutput() will return the outputs as ordered by their creation order. In a simple transient or steady run, this will be sufficient to get the ordered datasets. Transient postprocessing typically assumes a monotonic (increasing, unique values) sequence. Parametric runs might have their dataset generated in any order, and a sorted list of outputs might be desirable.

Parameters
pOrcer: Indicate the order of the outputs
  • CreationID : Order by creation index, the pVariable argument is unused
  • MonotonicIncreasing : Strictly increating sequence of values for the specified variable. If the sequence reverts to a prior step, only the newer values are returned. 1,2,[3,4,5]{3,4,5,6} -> 1,2,{3,4,5,6}
  • Increasing : Outputs are sorted by the specified variable low to high value
  • IncreasingUnique : As Increasing, but duplicates are removed in case of duplicate, the newest entry is kept.
  • Decreasing : Outputs are sorted by the specified variable high to low value
  • DecreasingUnique : As Increasing, but duplicates are removed in case of duplicate, the newest entry is kept.
pVariable: Variable name to use in comparison Must be an integer or floating point property. The variable must be defined for all outputs.

RunOutputAttr contains the list of standard variable names See: RunOutputAttr::sVarTime, RunOutputAttr::sVarSolverIteration, etc.

Parameters
pOutputs: Array with Output ordered as specified
Returns
: Error in case of unknown variable or invalid parameters

◆ getOutputsMatching()

std::vector< Output > ansys::Project::Run::getOutputsMatching ( std::string  pVariable,
OutputMatchOperator  pOperator,
double  pValue 
) const

Get the list of outputs matching the specified condition.

Returns the subset of outputs matching the specified condition, the outputs will not have any specified order. See also getOutputSequence()

Parameters
pVariable: Name of the variable to check
pOperator: Operator to use
pValue: Value for comparison

◆ getResultIterators()

std::vector< Iterator > ansys::Project::Run::getResultIterators ( const std::string &  pType,
const std::string &  pSubtype 
) const

Return the list of results in the current Run and Output subfolders, as vector of Iterator.

Parameters
pTypeThe type queried. Typically "Result"
pSubtypeThe ResultType queried (for example "fluent-dat")

◆ getResults()

std::vector< Result > ansys::Project::Run::getResults ( const std::string &  pType,
const std::string &  pSubtype 
) const

Return the list of results in the current Run and Output subfolders.

Parameters
pTypeThe type queried. Typically "Result"
pSubtypeThe ResultType queried (for example "fluent-dat")

◆ getTransientOutputs()

Error ansys::Project::Run::getTransientOutputs ( const std::string &  pResultType,
std::vector< Iterator > &  pOutIterators,
std::vector< double > &  pOutTimeval 
) const

For transient runs - return the list of output results and their time values.

The output runs are processed to return a monotonic (increasing, unique values) sequence (see getOutputSequence()). For each output of that sequence, if a result of the specified type exist, its returned alongside with the time value.

Parameters
pResultTypeFile type (ResultType metadata) of the result query
pOutIterators(output)
pOutTimeval(output)

◆ getValue()

std::string ansys::Project::Run::getValue ( const std::string &  pVar,
bool  pFlagInherited 
) const
virtual

Search the metadata (local and inherited) for the specified key and return the value as string.

Parameters
pFlagInherited: If true, the parent Run/Simulation are searched for the metadata entry, if not defined locally

Implements ansys::Project::RunOutputAttr.

◆ getValueDouble()

double ansys::Project::Run::getValueDouble ( const std::string &  pVar,
bool  pFlagInherited 
) const
virtual

Search the metadata (local and inherited) for the specified key and return the value as double.

Parameters
pFlagInherited: If true, the parent Run/Simulation are searched for the metadata entry, if not defined locally

Implements ansys::Project::RunOutputAttr.

◆ getValueInt()

int ansys::Project::Run::getValueInt ( const std::string &  pVar,
bool  pFlagInherited 
) const
virtual

Search the metadata (local and inherited) for the specified key and return the value as integer.

Parameters
pFlagInherited: If true, the parent Run/Simulation are searched for the metadata entry, if not defined locally

Implements ansys::Project::RunOutputAttr.

◆ getValueIter()

Iterator ansys::Project::Run::getValueIter ( const std::string &  pVar) const

Search the metadata (local and inherited) for the specified metadata link and return the value as an iterator.

Parameters
pFlagInherited: If true, the parent Run/Simulation are searched for the metadata entry, if not defined locally

◆ getValueType()

MetaVariableType ansys::Project::Run::getValueType ( const std::string &  pVar,
bool  pFlagInherited 
) const
virtual

Search the metadata (local and inherited) for the specified key and return the its data type.

Parameters
pFlagInherited: If true, the parent Run/Simulation are searched for the metadata entry, if not defined locally

Implements ansys::Project::RunOutputAttr.

◆ hasValue()

bool ansys::Project::Run::hasValue ( const std::string &  pVar,
bool  pFlagInherited 
) const
virtual

Search the metadata (local and inherited) for the specified key.

Parameters
pFlagInherited: If true, the parent Run/Simulation are searched for the metadata entry, if not defined locally

Implements ansys::Project::RunOutputAttr.

◆ newOutput()

Iterator ansys::Project::Run::newOutput ( std::string  pName = "")

Create a Output folder in the current Run folder.

The Output folder is by default a virtual (project-only) folder and no folder is created in the filesystem. By default, all Result owned by a Run/Output are stored in the same disk folder, but the Project structure regroup each group of Result in an Output block.

Parameters
pName: Name of the output folder , use "" to have a default automatic name generated ( o###### )

◆ removeOutputs()

Error ansys::Project::Run::removeOutputs ( const std::vector< Output > &  pOut,
bool  pEraseFiles 
)

Remove the specified list of Output from the children of this run.

Parameters
pEraseFilesIf true, the associated files to the outputs will be erased

◆ removeVariable()

bool ansys::Project::Run::removeVariable ( const std::string &  pVar)

Remove a variable from the list of inputs.

Mandatory variables cannot be removed

◆ setRunStatus()

void ansys::Project::Run::setRunStatus ( RunStatus  pStatus)

Set the RunStatus state for this Run.

(Optional API) The run status permits to indicate if a Run is running, completed, waiting for execution, etc. This status can also be defined at the Output level

◆ setVariables()

bool ansys::Project::Run::setVariables ( const std::vector< std::string > &  pVars)

Set/replace the list of variables for this run.

The operation will fail if the list of variables does not contain the mandatory variable for the RunOutputType

All Output subfolders should define a specific value for each variable.

Connect with Ansys