3.1.6.4. c3po.physicsDrivers.CATHARE3Driver module
Contain the class CATHARE3Driver.
- class c3po.physicsDrivers.CATHARE3Driver.CATHARE3Driver(*args: Any, **kwargs: Any)
Bases:
CATHARE3,PhysicsDriverThis is the implementation of
PhysicsDriverfor CATHARE3.- __init__(dtPost=0.0)
Default constructor.
Internal set up and initialization of the code should not be done here, but rather in
initialize().
- abortTimeStep()
(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 theTIME_STEP_DEFINEDcontext).- Raises:
AssertionError – If called outside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).
- computeTimeStep()
(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_DEFINEDcontext (seePhysicsDriverdocumentation).- Returns:
A tuple
(dt, stop).dtis the preferred time step for this code (only valid ifstopis False).stopis 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:
- Raises:
AssertionError – If called inside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).AssertionError – If called before
initialize()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.
- getMEDCouplingMajorVersion()
(Optional) Get MEDCoupling major version, if the code was built with MEDCoupling support.
Mandatory if the code is 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:
- 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.
- getOutputMEDFieldDriver(name)
INTERNAL
- getRowland(cname, loc)
INTERNAL
- getStationaryMode()
(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_DEFINEDcontext (seePhysicsDriverdocumentation).- Returns:
True if the code has been set to compute a stationary solution.
- Return type:
- Raises:
AssertionError – If called inside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).AssertionError – If called before
initialize()or afterterminate().
- getWeightedVolume(cname, loc, irad=-1)
INTERNAL
- initTimeStep(dt)
(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]wheretis the value returned bypresentTime(). The code enters theTIME_STEP_DEFINEDcontext. A timestep = 0. may be used when the stationaryMode is set to True for codes solving directly for the steady-state.- Parameters:
dt (float) – The time step to be used by the code.
- Returns:
False means that the given time step is not compatible with the code time scheme.
- Return type:
- Raises:
AssertionError – If called inside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).AssertionError – If called before
initialize()or afterterminate().ValueError – If
dtis invalid (dt < 0.0).
- initialize()
(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 thesetMPIComm()methods either). This method must be called only once (after a potential call tosetMPIComm()and/orsetDataFile()) and cannot be called again beforeterminate()has been performed.Warning
This method is not adapted to MPI Master-Workers paradigm.
init()andgetInitStatus()methods should be used in C3PO instead.- Returns:
True if all OK, otherwise False.
- Return type:
- Raises:
AssertionError – If called multiple times.
- isMEDCoupling64Bits()
(Optional) Indicate whether the code was built with a 64-bits version of MEDCoupling.
Mandatory if the code is built with MEDCoupling support. This can be used to assess compatibility between codes when coupling them.
- Returns:
True if the code was built with a 64-bits version of MEDCoupling.
- Return type:
- post(postMED)
INTERNAL
- presentTime()
(Mandatory) Return the current time of the simulation.
Can be called any time between
initialize()andterminate(). The current time can only change during a call tovalidateTimeStep()or toresetTime().- Returns:
The current (physical) time of the simulation.
- Return type:
- Raises:
AssertionError – If called before
initialize()or afterterminate().
- resetTime(time_)
(Optional) Reset the current time of the
PhysicsDriverto 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_DEFINEDcontext (seePhysicsDriverdocumentation).- Parameters:
time_ (float) – The new current time.
- Raises:
AssertionError – If called inside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).AssertionError – If called before
initialize()or afterterminate().
- 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].
- setStationaryMode(stationaryMode)
(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 withinitTimeStep()(whose call is always needed). The stationary mode status of the code can only be modified by this method (or by a call toterminate()followed byinitialize()).Can be called whenever the code is outside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).- Parameters:
stationaryMode (bool) – True if the code should compute a stationary solution.
- Raises:
AssertionError – If called outside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).AssertionError – If called before
initialize()or afterterminate().
- solveTimeStep()
(Mandatory) Perform the computation on the current time interval.
Can be called whenever the code is inside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).Warning
This method is not adapted to MPI Master-Workers paradigm.
solve()andgetSolveStatus()methods should be used with C3PO instead.- Returns:
True if computation was successful, False otherwise.
- Return type:
- Raises:
AssertionError – If called outside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).AssertionError – If called several times without a call to
validateTimeStep()or toabortTimeStep().
- terminate()
(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()andinitialize()may be called after this.- Raises:
AssertionError – If called before
initialize()or afterterminate().AssertionError – If called inside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).
- validateTimeStep()
(Mandatory) Validate the computation performed by
solveTimeStep().Can be called whenever the code is inside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation). 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_DEFINEDcontext).
- Raises:
AssertionError – If called outside the
TIME_STEP_DEFINEDcontext (seePhysicsDriverdocumentation).AssertionError – If called before the
solveTimeStep()method.
- c3po.physicsDrivers.CATHARE3Driver.buildName(keyword, cname, loc, irad=-1)
INTERNAL
- c3po.physicsDrivers.CATHARE3Driver.shortName(name)
INTERNAL