icoco.problem module

ICoCo file common to several codes Version 2 – 02/2021

WARNING: this file is part of the official ICoCo API and should not be modified. The official version can be found at the following URL:

https://github.com/cea-trust-platform/icoco-coupling

This module contains the API for ICoCo specifications

icoco.problem.ICOCO_VERSION = '2.0'

ICoCo version as ‘X.Y’.

icoco.problem.ICOCO_MAJOR_VERSION = 2

ICoCo version major X.

icoco.problem.ICOCO_MINOR_VERSION = 0

ICoCo version minor Y.

class icoco.problem.ValueType(value)[source]

Bases: Enum

The various possible types for fields or scalar values.

Double = 0

Double scalar value or field type

Int = 1

Int scalar value or field type

String = 2

String scalar value or field type

class icoco.problem.Problem[source]

Bases: ABC

API that a code has to implement in order to comply with the ICoCo (version 2) norm.

This abstract class represents the methods that a given code may implement to comply (partially or fully) to the ICoCo standard. For organization and documentation purposes the interface is separated into several sections but this does not correspond to any code constraint. Note that not all the methods need to be implemented! Notably the methods belonging to the sections

  • Restorable

  • Field I/O

  • Scalar values I/O

are not always needed since a code might not have any integer field to work with for example. Consequently, default implementation for all methods of this interface is to raise an icoco.exception.NotImplementedMethod exception.

Some of the methods may not be called when some conditions are not met (i.e. when not in the correct context). Thus in this documentation we define the “TIME_STEP_DEFINED context” as the context that the code finds itself, when the method initTimeStep() has been called, and the method validateTimeStep() (or abortTimeStep()) has not yet been called. This is the status in which the current computation time step is well defined.

Within the computation of a time step (so within TIME_STEP_DEFINED), the temporal semantic of the fields (and scalar values) is not imposed by the norm. Said differently, it does not require the fields to be defined at the start/middle/end of the current time step, this semantic must be agreed on between the codes being coupled. Fields and scalar values that are set within the TIME_STEP_DEFINED context are invalidated (undefined behavior) after a call to validateTimeStep() (or abortTimeStep()). They need to be set at each time step. However, fields and scalar values that are set outside of this context (before the first time step for example, or after the resolution of the last time step) are permanent (unless modified afterward within the TIME_STEP_DEFINED context).

Finally, the ICoCo interface may be wrapped in Python using SWIG or PyBind11. For an example of the former see the TRUST implementation of ICoCo. Notably the old methods returning directly MEDCoupling::MEDCouplingFieldDouble objects (version 1.x of ICoCo) are easily re-instanciated in Python SWIG.

Methods

GetICoCoMajorVersion()

Return ICoCo interface major version number.

abortTimeStep()

(Optional) Abort the computation on the current time step.

computeTimeStep()

(Mandatory) Return the next preferred time step (time increment) for this code, and whether the code wants to stop.

forget(label, method)

(Optional) Discard a previously saved state of the code.

getFieldType(name)

(Optional) Get the type of a field managed by the code (input or output)

getFieldUnit(name)

(Optional) Get the physical unit used for a given field.

getInputFieldsNames()

(Optional) Get the list of input fields accepted by the code.

getInputMEDDoubleFieldTemplate(name)

(Optional) Retrieve an empty shell for an input field.

getInputMEDIntFieldTemplate(name)

Similar to getInputMEDDoubleFieldTemplate() but for MEDIntField.

getInputMEDStringFieldTemplate(name)

Similar to getInputMEDDoubleFieldTemplate() but for MEDStringField.

getInputValuesNames()

(Optional) Get the list of input scalars accepted by the code.

getMEDCouplingMajorVersion()

(Optional) Get MEDCoupling major version, if the code was built with MEDCoupling support.

getMeshUnit()

(Optional) Get the (length) unit used to define the meshes supporting the fields.

getOutputDoubleValue(name)

(Optional) Retrieve a scalar double value from the code.

getOutputFieldsNames()

(Optional) Get the list of output fields that can be provided by the code.

getOutputIntValue(name)

(Optional) Retrieve a int value from the code.

getOutputMEDDoubleField(name)

(Optional) Retrieve output data from the code in the form of a MEDDoubleField.

getOutputMEDIntField(name)

Similar to getOutputMEDDoubleField() but for MEDIntField.

getOutputMEDStringField(name)

Similar to getOutputMEDDoubleField() but for MEDStringField.

getOutputStringValue(name)

(Optional) Retrieve a string value from the code.

getOutputValuesNames()

(Optional) Get the list of output scalars that can be provided by the code.

getStationaryMode()

(Mandatory) Indicate whether the code should compute a stationary solution or a transient one.

getValueType(name)

(Optional) Get the type of a scalar managed by the code (input or output)

getValueUnit(name)

(Optional) Get the physical unit used for a given value.

initTimeStep(dt)

(Mandatory) Provide the next time step (time increment) to be used by the code.

initialize()

(Mandatory) Initialize the current problem instance.

isMEDCoupling64Bits()

(Optional) (Optional) Indicate whether the code was built with a 64-bits version of MEDCoupling.

isStationary()

(Optional) Return whether the solution is constant on the computation time step.

iterateTimeStep()

(Optional) Perform a single iteration of computation inside the time step.

presentTime()

(Mandatory) Return the current time of the simulation.

resetTime(time)

(Optional) Reset the current time of the Problem to a given value.

restore(label, method)

(Optional) Restore the state of the code.

save(label, method)

(Optional) Save the state of the code.

setDataFile(datafile)

(Optional) Provide the relative path of a data file to be used by the code.

setInputDoubleValue(name, val)

(Optional) Provide the code with a scalar double data.

setInputIntValue(name, val)

(Optional) Provide the code with a int data.

setInputMEDDoubleField(name, afield)

(Optional) Provide the code with input data in the form of a MEDDoubleField.

setInputMEDIntField(name, afield)

Similar to setInputMEDDoubleField() but for MEDIntField.

setInputMEDStringField(name, afield)

Similar to setInputMEDDoubleField() but for MEDStringField.

setInputStringValue(name, val)

(Optional) Provide the code with a string data.

setMPIComm(mpicomm)

(Optional) Provide the MPI communicator to be used by the code for parallel computations.

setStationaryMode(stationaryMode)

(Mandatory) Set whether the code should compute a stationary solution or a transient one.

solveTimeStep()

(Mandatory) Perform the computation on the current time interval.

terminate()

(Mandatory) Terminate the current problem instance and release all allocated resources.

updateOutputMEDDoubleField(name, afield)

(Optional) Update a previously retrieved output field.

updateOutputMEDIntField(name, afield)

Similar to getInputMEDDoubleFieldTemplate() but for MEDStringField.

updateOutputMEDStringField(name, afield)

Similar to getInputMEDDoubleFieldTemplate() but for MEDStringField.

validateTimeStep()

(Mandatory) Validate the computation performed by solveTimeStep.

static GetICoCoMajorVersion() int[source]

Return ICoCo interface major version number.

Returns

ICoCo interface major version number (icoco.ICOCO_MAJOR_VERSION)

Return type

int

setDataFile(datafile: str) None[source]

(Optional) Provide the relative path of a data file to be used by the code.

This method must be called before initialize().

Parameters

datafile (str) – relative path to the data file.

Raises
  • WrongContext – exception if called multiple times or after initialize().

  • WrongArgument – exception if an invalid path is provided.

setMPIComm(mpicomm: MPIComm) None[source]

(Optional) Provide the MPI communicator to be used by the code for parallel computations.

This method must be called before initialize(). The communicator should include all the processes to be used by the code. For a sequential code, the call to setMPIComm is optional or mpicomm should be None.

Parameters

mpicomm (MPIComm) – MPI communicator. Dummy type for codes without mpi4py.

Raises
  • WrongContext – exception if called multiple times or after initialize().

  • WrongArgument – exception if an invalid path is provided.

abstract initialize() bool[source]

(Mandatory) Initialize the current problem instance.

In this method the code should allocate all its internal structures and be ready to execute. File reads, memory allocations, and other operations likely to fail should be performed here, and not in the constructor (and not in the setDataFile() or in the setMPIComm() methods either). This method must be called only once (after a potential call to setMPIComm() and/or setDataFile()) and cannot be called again before terminate() has been performed.

Returns

true if all OK, otherwise false.

Return type

bool

Raises

WrongContext – exception if called multiple times or after initialize().

abstract terminate() None[source]

(Mandatory) Terminate the current problem instance and release all allocated resources.

Terminate the computation, free the memory and save whatever needs to be saved. This method is called once at the end of the computation or after a non-recoverable error. No other ICoCo method except setDataFile(), setMPIComm() and initialize() may be called after this.

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called inside the TIME_STEP_DEFINED context (see Problem documentation).

abstract presentTime() float[source]

(Mandatory) Return the current time of the simulation.

Can be called any time between initialize() and terminate(). The current time can only change during a call to validateTimeStep() or to resetTime().

Returns

the current (physical) time of the simulation

Return type

float

Raises

WrongContext – exception if called before initialize() or after terminate().

abstract computeTimeStep() Tuple[float, bool][source]

(Mandatory) Return the next preferred time step (time increment) for this code, and whether the code wants to stop.

Both data are only indicative, the supervisor is not required to take them into account. This method is however marked as mandatory, since most of the coupling schemes expect the code to provide this information (those schemes then typically compute the minimum of the time steps of all the codes being coupled). Hence a possible implementation is to return a huge value, if a precise figure can not be computed.

Can be called whenever the code is outside the TIME_STEP_DEFINED context (see Problem documentation).

Returns

  • the preferred time step for this code (only valid if stop is false).

  • stop set to true if the code wants to stop. It can be used for example to indicate that, according to a certain criterion, the end of the transient computation is reached from the code point of view.

Return type

Tuple[float, bool]

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called inside the TIME_STEP_DEFINED context (see Problem documentation).

abstract initTimeStep(dt: float) bool[source]

(Mandatory) Provide the next time step (time increment) to be used by the code.

After this call (if successful), the computation time step is defined to ]t, t + dt] where t is the value returned by presentTime(). The code enters the TIME_STEP_DEFINED context.

A time step = 0.0 may be used when the stationaryMode is set to true for codes solving directly for the steady-state.

Parameters

dt (float) – dt the time step to be used by the code

Returns

false means that given time step is not compatible with the code time scheme.

Return type

bool

Raises
  • WrongContext – exception if called before initialize() or after terminate(). exception if called inside the TIME_STEP_DEFINED context (see Problem documentation). exception if called several times without resolution.

  • WrongArgument – exception if dt is invalid (dt < 0.0).

abstract solveTimeStep() bool[source]

(Mandatory) Perform the computation on the current time interval.

Can be called whenever the code is inside the TIME_STEP_DEFINED context (see Problem documentation).

Returns

true if computation was successful, false otherwise.

Return type

bool

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called outside the TIME_STEP_DEFINED context (see Problem documentation). exception exception if called several times without a call to validateTimeStep() or to abortTimeStep().

abstract validateTimeStep() None[source]

(Mandatory) Validate the computation performed by solveTimeStep.

Can be called whenever the code is inside the TIME_STEP_DEFINED context (see Problem documentation).

After this call: - the present time has been advanced to the end of the computation time step - the computation time step is undefined (the code leaves the TIME_STEP_DEFINED context).

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called outside the TIME_STEP_DEFINED context (see Problem documentation). exception if called before the solveTimeStep() method.

abstract setStationaryMode(stationaryMode: bool) None[source]

(Mandatory) Set whether the code should compute a stationary solution or a transient one.

New in version 2 of ICoCo. By default the code is assumed to be in stationary mode False (i.e. set up for a transient computation). If set to True, solveTimeStep() can be used either to solve a time step in view of an asymptotic solution, or to solve directly for the steady-state. In this last case, a time step = 0. can be used with initTimeStep() (whose call is always needed). The stationary mode status of the code can only be modified by this method (or by a call to terminate() followed by initialize()).

Parameters

stationaryMode (bool) – true if the code should compute a stationary solution.

Raises

WrongContext – called inside the TIME_STEP_DEFINED context (see Problem documentation). called before initialize() or after terminate().

abstract getStationaryMode() bool[source]

(Mandatory) Indicate whether the code should compute a stationary solution or a transient one.

See also setStationaryMode().

Can be called whenever the code is outside the TIME_STEP_DEFINED context (see Problem documentation).

Returns

true if the code has been set to compute a stationary solution.

Return type

bool

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called inside the TIME_STEP_DEFINED context (see Problem documentation).

isStationary() bool[source]

(Optional) Return whether the solution is constant on the computation time step.

Used to know if the steady-state has been reached. This method can be called whenever the computation time step is not defined.

Returns

true if the solution is constant on the computation time step.

Return type

bool

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called inside the TIME_STEP_DEFINED context (see Problem documentation), meaning we shouldn’t request this information while the computation of a new time step is in progress.

abortTimeStep() None[source]

(Optional) Abort the computation on the current time step.

Can be called whenever the computation time step is defined, instead of validateTimeStep(). After this call, the present time is left unchanged, and the computation time step is undefined (the code leaves the TIME_STEP_DEFINED context).

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called outside the TIME_STEP_DEFINED context (see Problem documentation).

resetTime(time: float) None[source]

(Optional) Reset the current time of the Problem to a given value.

New in version 2 of ICoCo. Particularly useful for the initialization of complex transients: the starting point of the transient of interest is computed first, the time is reset to 0, and then the actual transient of interest starts with proper initial conditions, and global time 0.

Can be called outside the TIME_STEP_DEFINED context (see Problem documentation).

Parameters

time (float) – the new current time.

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called inside the TIME_STEP_DEFINED context (see Problem documentation)

iterateTimeStep() Tuple[bool, bool][source]

(Optional) Perform a single iteration of computation inside the time step.

This method is relevant for codes having inner iterations for the computation of a single time step. Calling iterateTimeStep() until converged is true is equivalent to calling solveTimeStep(), within the code’s convergence threshold.

Can be called (potentially several times) inside the TIME_STEP_DEFINED context (see Problem documentation).

Returns

  • false if the computation failed.

  • true if the solution is not evolving any more.

Return type

Tuple[bool, bool]

Raises

WrongContext – exception if called before initialize() or after terminate(). exception if called outside the TIME_STEP_DEFINED context (see Problem documentation)

save(label: int, method: str) None[source]

(Optional) Save the state of the code.

The saved state is identified by the combination of label and method arguments. If save() has already been called with the same two arguments, the saved state is overwritten. This method is const indicating that saving the state of the code should not change its behaviour with respect to all other ICoCo methods. Implementation may rely on a mutable attribute (e.g. if saving to memory is desired).

Parameters
  • label (int) – a user- (or code-) defined value identifying the state.

  • method (str) – a string specifying which method is used to save the state of the code. A code can provide different methods (for example in memory, on disk, etc.).

Raises
  • WrongContext – exception if called before initialize() or after terminate(). exception if called inside the TIME_STEP_DEFINED context (see Problem documentation) meaning we shouldn’t save a previous time step while the computation of a new time step is in progress.

  • WrongArgument – exception if the method or label argument is invalid.

restore(label: int, method: str) None[source]

(Optional) Restore the state of the code.

After restore, the code should behave exactly like after the corresponding call to save (except of course for save/restore methods, since the list of saved states may have changed). The state to be restored is identified by the combination of label and method arguments. The save() method must have been called at some point or in some previous run with this combination.

Parameters
  • label (int) – a user- (or code-) defined value identifying the state.

  • method (str) – a string specifying which method is used to save the state of the code. A code can provide different methods (for example in memory, on disk, etc.).

Raises
  • WrongContext – exception if called before initialize() or after terminate(). exception if called inside the TIME_STEP_DEFINED context (see Problem documentation) meaning we shouldn’t restore while the computation of a new time step is in progress.

  • WrongArgument – exception if the method or label argument is invalid.

forget(label: int, method: str) None[source]

(Optional) Discard a previously saved state of the code.

After this call, the save-point cannot be restored anymore. This method can be used to free the space occupied by unused saved states. This method is const indicating that forgeting a previous state of the code should not change its behaviour with respect to all other ICoCo methods. Implementation may rely on a mutable attribute (e.g. if saving to memory is desired).

Parameters
  • label (int) – a user- (or code-) defined value identifying the state.

  • method (str) – a string specifying which method is used to save the state of the code. A code can provide different methods (for example in memory, on disk, etc.).

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the method or label argument is invalid.

getInputFieldsNames() List[str][source]

(Optional) Get the list of input fields accepted by the code.

Returns

the list of field names that represent inputs of the code

Return type

List[str]

Raises

WrongContext – exception if called before initialize() or after terminate().

getOutputFieldsNames() List[str][source]

(Optional) Get the list of output fields that can be provided by the code.

Returns

the list of field names that can be produced by the code

Return type

List[str]

Raises

WrongContext – exception if called before initialize() or after terminate().

getFieldType(name: str) ValueType[source]

(Optional) Get the type of a field managed by the code (input or output)

The three possible types are int, double and string, as defined in the ValueType enum.

Parameters

name (str) – field name

Returns

one of ValueType.Double, ValueType.Int or ValueType.String

Return type

ValueType

Raises
  • WrongArgument – exception if the field name is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

getMeshUnit() str[source]

(Optional) Get the (length) unit used to define the meshes supporting the fields.

Returns

length unit in which the mesh coordinates should be understood (e.g. “m”, “cm”, …)

Return type

str

Raises

WrongContext – exception if called before initialize() or after terminate().

getFieldUnit(name: str) str[source]

(Optional) Get the physical unit used for a given field.

Parameters

name (str) – field name

Returns

unit in which the field values should be understood (e.g. “W”, “J”, “Pa”, …)

Return type

str

Raises
  • WrongArgument – exception if the field name is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

getInputMEDDoubleFieldTemplate(name: str) MEDCouplingFieldDouble[source]

(Optional) Retrieve an empty shell for an input field. This shell can be filled by the caller and then be given to the code via setInputField(). The field has the MEDDoubleField format.

The code uses this method to populate ‘afield’ with all the data that represents the context of the field (i.e. its support mesh, its discretization – on nodes, on elements, …). The remaining job for the caller of this method is to fill the actual values of the field itself. When this is done the field can be sent back to the code through the method setInputField(). This method is not mandatory but is useful to know the mesh, discretization… on which an input field is expected.

See Problem documentation for more details on the time semantic of a field.

Parameters

name (str) – name of the field for which we would like the empty shell

Returns

field object (in MEDDoubleField format) that will be populated with all the contextual information. Any previous information in this object will be discarded.

Return type

medcoupling.MEDCouplingFieldDouble

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name is invalid.

setInputMEDDoubleField(name: str, afield: MEDCouplingFieldDouble) None[source]

(Optional) Provide the code with input data in the form of a MEDDoubleField.

The method getInputFieldTemplate(), if implemented, may be used first to prepare an empty shell of the field to pass to the code.

See Problem documentation for more details on the time semantic of a field.

Parameters
  • name (str) – name of the field that is given to the code.

  • afield (medcoupling.MEDCouplingFieldDouble) – field object (in MEDDoubleField format) containing the input data to be read by the code. The name of the field set on this instance (with the Field::setName() method) should not be checked. However its time value should be to ensure it is within the proper time interval ]t, t+dt].

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid. exception if the time property of ‘afield’ does not belong to the currently computed time step ]t, t + dt]

getOutputMEDDoubleField(name: str) MEDCouplingFieldDouble[source]

(Optional) Retrieve output data from the code in the form of a MEDDoubleField.

Gets the output field corresponding to name from the code into the afield argument.

See Problem documentation for more details on the time semantic of a field.

Parameters

name (str) – name of the field that the caller requests from the code.

Returns

field object (in MEDDoubleField format) populated with the data read by the code. The name and time properties of the field should be set in accordance with the ‘name’ parameter and with the current time step being computed. Any previous information in this object will be discarded.

Return type

medcoupling.MEDCouplingFieldDouble

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid.

updateOutputMEDDoubleField(name: str, afield: MEDCouplingFieldDouble) None[source]

(Optional) Update a previously retrieved output field.

(New in version 2) This methods allows the code to implement a more efficient update of a given output field, thus avoiding the caller to invoke getOutputMEDDoubleField() each time. A previous call to getOutputMEDDoubleField() with the same name must have been done prior to this call. The code should check the consistency of the field object with the requested data (same support mesh, discretization – on nodes, on elements, etc.).

See Problem documentation for more details on the time semantic of a field.

Parameters
  • name (str) – name of the field that the caller requests from the code.

  • afield (medcoupling.MEDCouplingFieldDouble) – field object (in MEDDoubleField format) updated with the data read from the code. Notably the time indicated in the field should be updated to be within the current time step being computed.

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid. exception if the field object is inconsistent with the field being requested.

getInputMEDIntFieldTemplate(name: str) MEDCouplingFieldInt[source]

Similar to getInputMEDDoubleFieldTemplate() but for MEDIntField.

Parameters

name (str) – name of the field for which we would like the empty shell

Returns

object

Return type

medcoupling.MEDCouplingFieldInt

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name is invalid.

setInputMEDIntField(name: str, afield: MEDCouplingFieldInt) None[source]

Similar to setInputMEDDoubleField() but for MEDIntField.

Parameters
Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid. exception if the time property of ‘afield’ does not belong to the currently computed time step ]t, t + dt]

getOutputMEDIntField(name: str) MEDCouplingFieldInt[source]

Similar to getOutputMEDDoubleField() but for MEDIntField.

Parameters

name (str) – name of the field that the caller requests from the code.

Returns

field object

Return type

medcoupling.MEDCouplingFieldInt

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid.

updateOutputMEDIntField(name: str, afield: MEDCouplingFieldInt) None[source]

Similar to getInputMEDDoubleFieldTemplate() but for MEDStringField.

Parameters
Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid. exception if the field object is inconsistent with the field being requested.

getInputMEDStringFieldTemplate(name: str) MEDCouplingField[source]

Similar to getInputMEDDoubleFieldTemplate() but for MEDStringField.

Warning

at the time of writing, MEDStringField are not yet implemented anywhere.

Parameters

name (str) – name of the field for which we would like the empty shell

Returns

field object

Return type

medcoupling.MEDCouplingField

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name is invalid.

setInputMEDStringField(name: str, afield: MEDCouplingField) None[source]

Similar to setInputMEDDoubleField() but for MEDStringField.

Warning

at the time of writing, MEDStringField are not yet implemented anywhere.

Parameters
Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid. exception if the time property of ‘afield’ does not belong to the currently computed time step ]t, t + dt]

getOutputMEDStringField(name: str) MEDCouplingField[source]

Similar to getOutputMEDDoubleField() but for MEDStringField.

Warning

at the time of writing, MEDStringField are not yet implemented anywhere.

Parameters

name (str) – name of the field that the caller requests from the code.

Returns

field object

Return type

medcoupling.MEDCouplingField

Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid.

updateOutputMEDStringField(name: str, afield: MEDCouplingField) None[source]

Similar to getInputMEDDoubleFieldTemplate() but for MEDStringField.

Warning

at the time of writing, MEDStringField are not yet implemented anywhere.

Parameters
Raises
  • WrongContext – exception if called before initialize() or after terminate().

  • WrongArgument – exception if the field name (‘name’ parameter) is invalid. exception if the field object is inconsistent with the field being requested.

getMEDCouplingMajorVersion() int[source]

(Optional) Get MEDCoupling major version, if the code was built with MEDCoupling support.

This can be used to assess compatibility between codes when coupling them.

Returns

the MEDCoupling major version number (typically 7, 8, 9, …)

Return type

int

isMEDCoupling64Bits() bool[source]

(Optional) (Optional) Indicate whether the code was built with a 64-bits version of MEDCoupling.

Implemented if the code was built with MEDCoupling support. This can be used to assess compatibility between codes when coupling them.

Returns

True if it is 64-bits

Return type

bool

getInputValuesNames() List[str][source]

(Optional) Get the list of input scalars accepted by the code.

Returns

the list of scalar names that represent inputs of the code

Return type

List[str]

Raises

WrongContext – exception if called before initialize() or after terminate().

getOutputValuesNames() List[str][source]

(Optional) Get the list of output scalars that can be provided by the code.

Returns

the list of scalars names that can be produced by the code

Return type

List[str]

Raises

WrongContext – exception if called before initialize() or after terminate().

getValueType(name: str) ValueType[source]

(Optional) Get the type of a scalar managed by the code (input or output)

The three possible types are int, double and string, as defined in the ValueType enum.

Parameters

name (str) – scalar value name

Returns

one of ValueType.Double, ValueType.Int or ValueType.String

Return type

ValueType

Raises
  • WrongArgument – exception if the field name is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

getValueUnit(name: str) str[source]

(Optional) Get the physical unit used for a given value.

Parameters

name (str) – scalar value name

Returns

unit in which the field values should be understood (e.g. “W”, “J”, “Pa”, …)

Return type

str

Raises
  • WrongArgument – exception if the field name is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

setInputDoubleValue(name: str, val: float) None[source]

(Optional) Provide the code with a scalar double data.

See Problem documentation for more details on the time semantic of a scalar value.

Parameters
  • name (str) – name of the scalar value that is given to the code.

  • val (float) – value passed to the code.

Raises
  • WrongArgument – exception if the scalar name (‘name’ parameter) is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

getOutputDoubleValue(name: str) float[source]

(Optional) Retrieve a scalar double value from the code.

See Problem documentation for more details on the time semantic of a scalar value.

Parameters

name (str) – name of the scalar value to be read from the code.

Returns

the double value read from the code.

Return type

float

Raises
  • WrongArgument – exception if the scalar name (‘name’ parameter) is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

setInputIntValue(name: str, val: int) None[source]

(Optional) Provide the code with a int data.

See Problem documentation for more details on the time semantic of a int value.

Parameters
  • name (str) – name of the int value that is given to the code.

  • val (int) – value passed to the code.

Raises
  • WrongArgument – exception if the int name (‘name’ parameter) is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

getOutputIntValue(name: str) int[source]

(Optional) Retrieve a int value from the code.

See Problem documentation for more details on the time semantic of a int value.

Parameters

name (str) – name of the int value to be read from the code.

Returns

the double value read from the code.

Return type

int

Raises
  • WrongArgument – exception if the int name (‘name’ parameter) is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

setInputStringValue(name: str, val: str) None[source]

(Optional) Provide the code with a string data.

See Problem documentation for more details on the time semantic of a string value.

Parameters
  • name (str) – name of the string value that is given to the code.

  • val (str) – value passed to the code.

Raises
  • WrongArgument – exception if the string name (‘name’ parameter) is invalid.

  • WrongContext – exception if called before initialize() or after terminate().

getOutputStringValue(name: str) str[source]

(Optional) Retrieve a string value from the code.

See Problem documentation for more details on the time semantic of a string value.

Parameters

name (str) – name of the string value to be read from the code.

Returns

the string value read from the code.

Return type

str

Raises
  • WrongArgument – exception if the string name (‘name’ parameter) is invalid.

  • WrongContext – exception if called before initialize() or after terminate().