3.1.14. c3po.DataAccessor module
Contain the class DataAccessor.
- class c3po.DataAccessor.DataAccessor
Bases:
objectDataAccessoris an abstract class which standardizes I/O (in/out) methods.It follows the ICOCO V2 standard. See also
PhysicsDriver.- class ValueType
Bases:
objectThe various possible types for fields or scalar values.
- Double = 'Double'
- Int = 'Int'
- String = 'String'
- getFieldType(name)
(Optional) Get the type of a field managed by the code.
(New in version 2) The three possible types are ‘Double’, ‘Int’ and ‘String’, as defined by
ValueType.- Parameters:
name (str) – Field name.
- Returns:
‘Double’, ‘Int’ or ‘String’, as defined by
ValueType.- Return type:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the field
nameis invalid.
- getFieldUnit(name)
(Optional) Get the physical unit used for a given field.
(New in version 2)
- Parameters:
name (str) – Field name.
- Returns:
Unit in which the field values should be understood (e.g. ‘W’, ‘J’, ‘Pa’, …).
- Return type:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the field
nameis invalid.
- getInputFieldsNames()
(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:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().
- getInputMEDDoubleFieldTemplate(name)
(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
setInputMEDDoubleField().The code returns a field 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
setInputMEDDoubleField(). This method is not mandatory but is useful to know the mesh, discretization… on which an input field is expected. Is is required by C3PO remapping functionalities.See
PhysicsDriverdocumentation 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 with all the contextual information.
- Return type:
medcoupling.MEDCouplingFieldDouble
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the field
nameis invalid.
- getInputMEDIntFieldTemplate(name)
Similar to
getInputMEDDoubleFieldTemplate()but forMEDCouplingFieldInt.
- getInputMEDStringFieldTemplate(name)
Similar to
getInputMEDDoubleFieldTemplate()but forMEDCouplingFieldString.Warning
At the time of writing,
MEDCouplingFieldStringare not yet implemented anywhere.
- getInputValuesNames()
(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:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().
- getMPIComm()
(Optional) Return the MPI communicator used by the code for parallel computations.
- Returns:
mpi4py communicator.
- Return type:
- getMeshUnit()
(Optional) Get the (length) unit used to define the meshes supporting the fields.
(New in version 2)
- Returns:
Length unit in which the mesh coordinates should be understood (e.g. ‘m’, ‘cm’, …).
- Return type:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().
- getOutputDoubleValue(name)
(Optional) Retrieve a scalar
floatvalue from the code.See
PhysicsDriverdocumentation 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 value read from the code.
- Return type:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the scalar name is invalid.
- getOutputFieldsNames()
(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:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().
- getOutputIntValue(name)
(Optional) Similar to
getOutputDoubleValue()but for anintvalue.
- getOutputMEDDoubleField(name)
(Optional) Return output data from the code in the form of a
MEDCouplingFieldDouble.See
PhysicsDriverdocumentation 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 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.
- Return type:
medcoupling.MEDCouplingFieldDouble
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the field
nameis invalid.
- getOutputMEDIntField(name)
Similar to
getOutputMEDDoubleField()but forMEDCouplingFieldInt.
- getOutputMEDStringField(name)
Similar to
getOutputMEDDoubleField()but forMEDCouplingFieldString.Warning
At the time of writing,
MEDCouplingFieldStringare not yet implemented anywhere.
- getOutputStringValue(name)
(Optional) Similar to
getOutputDoubleValue()but for anstrvalue.
- getOutputValuesNames()
(Optional) Get the list of output scalars that can be provided by the code.
- Returns:
The list of scalar names that can be returned by the code.
- Return type:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().
- getValueType(name)
(Optional) Get the type of a scalar managed by the code.
(New in version 2) The three possible types are ‘Double’, ‘Int’ and ‘String’, as defined by
ValueType.- Parameters:
name (str) – Scalar value name.
- Returns:
‘Double’, ‘Int’ or ‘String’, as defined by
ValueType.- Return type:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the scalar name is invalid.
- getValueUnit(name)
(Optional) Get the physical unit used for a given value.
(New in version 2)
- Parameters:
name (str) – Scalar value name.
- Returns:
Unit in which the scalar value should be understood (e.g. ‘W’, ‘J’, ‘Pa’, …).
- Return type:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the scalar name is invalid.
- setInputDoubleValue(name, value)
(Optional) Provide the code with a scalar
floatdata.See
PhysicsDriverdocumentation for more details on the time semantic of a scalar value.- Parameters:
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the scalar name is invalid.
- setInputIntValue(name, value)
(Optional) Similar to
setInputDoubleValue()but for anintvalue.
- setInputMEDDoubleField(name, field)
(Optional) Provide the code with input data in the form of a
MEDCouplingFieldDouble.The method
getInputMEDDoubleFieldTemplate(), if implemented, may be used first to prepare an empty shell of the field to pass to the code.See
PhysicsDriverdocumentation for more details on the time semantic of a field.- Parameters:
name (str) – Name of the field that is given to the code.
field (medcoupling.MEDCouplingFieldDouble) – Field containing the input data to be read by the code. The name of the field set on this instance (with the
Field::setNamemethod) should not be checked. However its time value should be to ensure it is within the proper time interval]t, t+dt].
- Raises:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the field
name(‘name’ parameter) is invalid.ValueError – If the time property of
fielddoes not belong to the currently computed time step]t, t + dt].
- setInputMEDIntField(name, field)
Similar to
setInputMEDDoubleField()but forMEDCouplingFieldInt.
- setInputMEDStringField(name, field)
Similar to
setInputMEDDoubleField()but forMEDCouplingFieldString.Warning
At the time of writing,
MEDCouplingFieldStringare not yet implemented anywhere.
- setInputStringValue(name, value)
(Optional) Similar to
setInputDoubleValue()but for anstrvalue.
- updateOutputMEDDoubleField(name, field)
(Optional) Update a previously retrieved output field.
(New in version 2) This method 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 togetOutputMEDDoubleField()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
PhysicsDriverdocumentation for more details on the time semantic of a field.- Parameters:
name (str) – Name of the field that the caller requests from the code.
field (medcoupling.MEDCouplingFieldDouble) – Object 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:
AssertionError – If implemented in a
PhysicsDriverand called beforeinitialize()or afterterminate().ValueError – If the field name (
nameparameter) is invalid.ValueError – If the field object is inconsistent with the field being requested.
- updateOutputMEDIntField(name, field)
Similar to
updateOutputMEDDoubleField()but forMEDCouplingFieldInt.
- updateOutputMEDStringField(name, field)
Similar to
updateOutputMEDDoubleField()but forMEDCouplingFieldString.Warning
At the time of writing,
MEDCouplingFieldStringare not yet implemented anywhere.