Difference between revisions of "Code coupling in Kraken"

From Kraken Wiki
Jump to: navigation, search
(Type 2 — Structured x-type 60 degree Hexagonal mesh)
(Basic "function calls")
 
(116 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
 +
The code coupling in Kraken is based on a "hub and spoke" approach where each solver module only needs to communicate with the central multi-physics driver Cerberus. The Cerberus multi-physics driver is responsible for starting up each solver module, exchanging field data with them and controlling the execution order of the different modules.
 +
 +
The individual solver modules should implement basic signalling capabilities so that they can accept signals from Cerberus as well as send messages back using the signalling syntax described below.
  
 
== Basics of signalling ==
 
== Basics of signalling ==
  
When the solver is executed from command line by Cerberus, the solver should read its own input, initialize the specified signalling mode via the specified greeting protocol.
+
When the solver is executed from command line by [[Cerberus]] when running a Python script such as
  
After the greeting and its own basic initialization, the solver should wait for further signals from Cerberus.
+
  # --- Initialize solvers
  
After each order received from Cerberus, the solver should fullfill the order and wait for further signals from Cerberus.
+
my_input = CodeInput("path_to_my_input")
 +
my_solver = Solver("my_solver_name", path_to_my_solver, ["--port",])
 +
my_solver.input = my_input
 +
my_solver.initialize()
  
 +
Cerberus will provide the port the solver should connect to as a pair of command line arguments '''"--port" <port_as_integer>'''. The solver should then read its own input, do whatever processing is required and open a socket on the indicated port for communication with Cerberus.
  
All numerical values will be passed as double precision integers or double precision floats.
+
After the port has been opened, Cerberus expects the following greeting process:
 +
 
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|Solver|tomato}}->{{highlight|Cerberus|PaleGreen}}
 +
| Lgreet
 +
| 1*integer
 +
| Length of greeting string in char excluding terminating character
 +
|-
 +
| {{highlight|Solver|tomato}}->{{highlight|Cerberus|PaleGreen}}
 +
|
 +
| Lgreet*char
 +
| A freely chosen greeting string (will be read and can be printed out by Cerberus).
 +
|-
 +
| {{highlight|Cerberus|PaleGreen}}->{{highlight|Solver|tomato}}
 +
| Lgreet
 +
| 1*integer
 +
| Length of greeting string in char excluding terminating character
 +
|-
 +
| {{highlight|Cerberus|PaleGreen}}->{{highlight|Solver|tomato}}
 +
|
 +
| Lgreet*char
 +
| Some greeting string sent by Cerberus.
 +
|}
 +
 
 +
After the greeting and its own basic initialization, the solver should wait for further signals from Cerberus.
 +
 
 +
After each order received from Cerberus, the solver should fulfill the order and wait for further signals from Cerberus.
 +
 
 +
All numerical values will be passed as double precision integers (8 bytes) or double precision floats (8 bytes).
  
 
== Basic "function calls" ==
 
== Basic "function calls" ==
Line 15: Line 56:
 
When the solvers have completed their previous order and are waiting for the next signal from Cerberus, Cerberus will initiate the communication with a single integer indicating which "function call" should be processed.   
 
When the solvers have completed their previous order and are waiting for the next signal from Cerberus, Cerberus will initiate the communication with a single integer indicating which "function call" should be processed.   
  
The function calls that should be supported by the solvers are:  
+
The function calls and the integers representing them in the communication syntax are listed in a table below. When coupling a solver to Cerberus, they are typically listed in some centrally located header (or some such) files for C and Fortran. These can be also checked from [https://serpent.vtt.fi/pythonapi/generated/cerberus.commons.KrakenSignals.html cerberus.commons.KrakenSignals].
  
*'''terminate'''
+
{|class="wikitable" style="text-align: left;"
*'''giveInputFieldTemplates'''
+
!Function name
*'''giveOutputFieldTemplates'''
+
!Integer value
*'''giveFieldData'''
+
|-
*'''takeFieldData'''
+
| terminate
*'''solveSteadyState'''
+
| 0
*returnPresentTime
+
|-
*suggestTimeStep
+
| returnCurrentTime
*setTimeStep
+
| 1
*solveTimeStep
+
|-
*validateTimeStep
+
| setCurrentTime
*abortTimeStep
+
| 2
 
+
|-
Each of these function calls corresponds to a certain integer, that are listed in some centrally located header (or some such) files for C and Fortran.
+
| suggestNextTime
 +
| 3
 +
|-
 +
| advanceToTime
 +
| 4
 +
|-
 +
| solveCurrentTime
 +
| 5
 +
|-
 +
| giveInputFieldNames
 +
| 6
 +
|-
 +
| giveOutputFieldNames
 +
| 7
 +
|-
 +
| giveFieldTemplate
 +
| 8
 +
|-
 +
| giveMeshData
 +
| 9
 +
|-
 +
| giveIndexingArray
 +
| 10
 +
|-
 +
| giveFieldData
 +
| 11
 +
|-
 +
| takeFieldData
 +
| 12
 +
|-
 +
| giveOutputVariableDefs
 +
| 13
 +
|-
 +
| giveVariableData
 +
| 14
 +
|-
 +
| giveInputVariableDefs
 +
| 15
 +
|-
 +
| takeVariableData
 +
| 16
 +
|-
 +
| writeRestart
 +
| 17
 +
|-
 +
| readRestart
 +
| 18
 +
|-
 +
| returnCurrentTimeInterval
 +
| 19
 +
|-
 +
| setCurrentTimeInterval
 +
| 20
 +
|-
 +
| suggestNextTimeInterval
 +
| 21
 +
|-
 +
| advanceToTimeInterval
 +
| 22
 +
|-
 +
| correctPreviousStep
 +
| 23
 +
|}
  
 
The following sections will go through the signalling for each of the function calls  
 
The following sections will go through the signalling for each of the function calls  
Line 40: Line 143:
 
No further signalling takes place after the {{highlight|C|PaleGreen}}->{{highlight|S|tomato}} signal to terminate.
 
No further signalling takes place after the {{highlight|C|PaleGreen}}->{{highlight|S|tomato}} signal to terminate.
  
=== giveInputFieldTemplates ===
+
=== giveInputFieldNames ===
  
The solver should communicate, which sorts of fields it is expecting to receive from Cerberus. The communication syntax is as follows:  
+
The solver should communicate the names of the fields it is expecting to receive from Cerberus. The communication syntax is as follows:  
  
 
{|class="wikitable" style="text-align: left;"
 
{|class="wikitable" style="text-align: left;"
Line 52: Line 155:
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
| NF  
 
| NF  
| 1*integer  
+
| 1*integer  
 
| Number of fields to be provided  
 
| Number of fields to be provided  
 
|-
 
|-
Line 68: Line 171:
 
|
 
|
 
| Lname*char  
 
| Lname*char  
| Name of the field  
+
| Name of the field
 +
|}
 +
 
 +
=== giveOutputFieldNames  ===
 +
 
 +
The solver should communicate the names of the fields it is expecting to provide to Cerberus. The communication syntax is as follows:
 +
 
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
| NF
 +
| 1*integer
 +
| Number of fields to be provided
 +
|-
 +
| The following repeats  NF times:
 +
|
 +
|
 +
|
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
| Lname
 +
| 1*integer
 +
| Length of field name in char excluding terminating character
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
|
 +
| Lname*char
 +
| Name of the field
 +
|}
 +
 
 +
=== giveFieldTemplate ===
 +
 
 +
The solver should provide basic information on the field requested by Cerberus.
 +
 
 +
The communication syntax is as follows:
 +
 
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 +
| LnameF
 +
| 1*integer
 +
| Length of name of requested field (in char excluding terminating character).
 +
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 +
|
 +
| LnameF*char
 +
| Name of the requested field
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
|
 +
| 1*integer
 +
| Data type (FLOAT = '''1''', INT = '''2''', STRING = '''3''')
 
|-
 
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}  
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}  
Line 78: Line 240:
 
|
 
|
 
| 1*float  
 
| 1*float  
| Multiplier used to convert from the base unit type specified by the unit array to the actual unit used by the solver.
+
| Multiplier ''a'' used to convert from the base unit type specified by the unit array to the actual unit used by the solver (a*x + b).
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
|
 +
| 1*float
 +
| Offset ''b'' used to convert from the base unit type specified by the unit array to the actual unit used by the solver (a*x + b).
 
|-
 
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
|
+
| LnameM
 
| 1*integer  
 
| 1*integer  
| Type of the mesh that the field is on (see [[Code coupling in Kraken#Mesh types|Mesh types]]).
+
| Length of mesh name in char excluding terminating character
 
|-
 
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
|
 
|
| <depends on mesh>
+
| LnameM*char
| Mesh data, see subsection Mesh types
+
| Name of the mesh
 
|-
 
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
|
 
|
 
| 1*integer  
 
| 1*integer  
| Indexing flag: '''0''' if solver uses the default indexing of the mesh. '''1''' if solver uses some other indexing.  
+
| Indexing flag: '''0''' if solver uses the default indexing of the mesh. '''1''' if solver uses some other indexing: [[Mesh types#Indexing array|Indexing array]]
 +
|-
 +
| [{{highlight|S|tomato}}->{{highlight|C|PaleGreen}}]
 +
| LnameI
 +
| 1*integer
 +
| Only if  indexing flag was given as '''1''' (use custom indexing). Length of indexing array name in char excluding terminating character.  
 
|-
 
|-
 
| [{{highlight|S|tomato}}->{{highlight|C|PaleGreen}}]
 
| [{{highlight|S|tomato}}->{{highlight|C|PaleGreen}}]
 
|
 
|
| [number of cells in the mesh]
+
| LnameI*char
| Only if  indexing flag was given as '''1''' (use custom indexing): [[#Indexing information|Indexing information]]
+
| Only if  indexing flag was given as '''1''' (use custom indexing). Name of the indexing array.
 
|}
 
|}
  
After the solver has finished sending data to Cerberus, it should wait for further signals from Cerberus.
+
=== giveMeshData ===
  
=== giveOutputFieldTemplates  ===
+
The solver should provide information on the mesh requested by Cerberus.
  
The solver should communicate, which sorts of fields it is expecting to provide to Cerberus. The communication syntax is as follows:  
+
The communication syntax is as follows:  
  
 
{|class="wikitable" style="text-align: left;"
 
{|class="wikitable" style="text-align: left;"
Line 113: Line 285:
 
!Content  
 
!Content  
 
|-
 
|-
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
| NF
 
| 1*integer
 
| Number of fields to be provided
 
|-
 
| The following repeats  NF times:
 
|
 
|
 
|
 
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
 
| Lname  
 
| Lname  
 
| 1*integer  
 
| 1*integer  
| Length of field name in char excluding terminating character  
+
| Length of name of requested mesh (in char excluding terminating character).
 
|-
 
|-
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 
|
 
|
 
| Lname*char  
 
| Lname*char  
| Name of the field
+
| Name of the requested mesh
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
|
 
| 5*integer
 
| Unit of the field in an OpenFOAMish array (see [[Code coupling in Kraken#Field unit array|Field unit array]])
 
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
|
 
| 1*float
 
| Multiplier used to convert from the base unit type specified by the unit array to the actual unit used by the solver.
 
 
|-
 
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
|
 
|
 
| 1*integer  
 
| 1*integer  
| Type of the mesh that the field is on (see [[Code coupling in Kraken#Mesh types|Mesh types]]).  
+
| Type of the mesh (see [[Mesh types]]).  
 
|-
 
|-
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
Line 152: Line 304:
 
| <depends on mesh>  
 
| <depends on mesh>  
 
| Mesh data, see subsection Mesh types  
 
| Mesh data, see subsection Mesh types  
 +
|}
 +
 +
=== giveIndexingArray ===
 +
 +
The solver should provide information on the indexing array requested by Cerberus.
 +
 +
The communication syntax is as follows:
 +
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 +
| Lname
 +
| 1*integer
 +
| Length of name of requested indexing array (in char excluding terminating character).
 
|-
 
|-
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 
|
 
|
 +
| Lname*char
 +
| Name of the requested indexing array
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
| NV
 
| 1*integer  
 
| 1*integer  
| Indexing flag: '''0''' if solver uses the default indexing of the mesh. '''1''' if solver uses some other indexing.  
+
| Number of values to be passed.
 
|-
 
|-
| [{{highlight|S|tomato}}->{{highlight|C|PaleGreen}}]
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}  
 
|
 
|
| [number of cells in the mesh]
+
| NV*value
| Only if  indexing flag was given as '''1''' (use custom indexing): [[#Indexing information|Indexing information]]
+
| Indices: [[Mesh types#Indexing array|Indexing array]]
 
|}
 
|}
 
After the solver has finished sending data to Cerberus, it should wait for further signals from Cerberus.
 
  
 
=== giveFieldData ===
 
=== giveFieldData ===
Line 195: Line 368:
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}  
 
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}  
 
|
 
|
| NV*float
+
| NV*value
| The values for the field.
+
| The values for the field (float, integer or strings).
 
|}
 
|}
 
After the solver has finished passing data to Cerberus, it should wait for further signals from Cerberus.
 
  
 
=== takeFieldData ===
 
=== takeFieldData ===
Line 230: Line 401:
 
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 
|
 
|
| NV*float
+
| NV*value
| The values for the field.
+
| The values for the field (float, integer or strings).
 
|}
 
|}
  
After the solver has finished receiving data from Cerberus, it should wait for further signals from Cerberus.
+
=== giveOutputVariableDefs ===
 
 
=== solveSteadyState ===
 
 
 
The solver should simply execute the next steady state solution using the current input fields.
 
 
 
After the solver has finished the steady state solution, it should wait for further signals from Cerberus.
 
 
 
=== returnPresentTime  ===
 
 
 
The solver should return the time corresponding to the current time point as a float.
 
 
 
After the {{highlight|S|tomato}}->{{highlight|C|PaleGreen}} communication of the value. The solver should wait for further signals from Cerberus.
 
 
 
=== suggestTimeStep  ===
 
 
 
The solver should return a preferred length for the next time step as a float.
 
 
 
After the {{highlight|S|tomato}}->{{highlight|C|PaleGreen}} communication of the value. The solver should wait for further signals from Cerberus.
 
 
 
=== setTimeStep  ===
 
 
 
The solver should receive a length for the next time step as a float.
 
 
 
After the {{highlight|C|PaleGreen}}->{{highlight|S|tomato}} communication of the value. The solver should wait for further signals from Cerberus.
 
 
 
=== solveTimeStep  ===
 
 
 
The solver should execute the solution for the next time step. This can include some initialization and post-processing for the current solution if needed.
 
 
 
After the solution has completed. The solver should wait for further signals from Cerberus.
 
 
 
=== validateTimeStep ===
 
  
The solver should accept the previous solution as the final solution for the previous time step. The previous time step will not be calculated again.
+
The solver should communicate names of the variables it is expecting to provide to Cerberus. The communication syntax is as follows:
 
 
After any necessary processing has completed. The solver should wait for further signals from Cerberus.
 
 
 
=== abortTimeStep  ===
 
 
 
The solver should reload the solution from the beginning of the previously solved time step, discarding the end-of-timestep solution. The previous time step will most likely be calculated again. The solver should update its internal time to reflect this change.
 
 
 
After any necessary processing has completed. The solver should wait for further signals from Cerberus.
 
 
 
== Field unit array ==
 
 
 
The field unit array consists of 5 integers (e.g. <tt>&#160;1 -3 &#160;0 &#160;0 &#160;0</tt> for mass density) specifying the dimension for each of the 5 SI base units for the field
 
  
 
{|class="wikitable" style="text-align: left;"
 
{|class="wikitable" style="text-align: left;"
! No.
+
!Direction
! Property
+
!Name
! Unit
+
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
| NV
 +
| 1*integer
 +
| Number of variable definitions to be provided
 
|-
 
|-
| 1
+
| The following repeats  NV times:
| Mass
+
|
| kilogram (kg)
+
|
 +
|
 
|-
 
|-
| 2
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| Length
+
| Lname
| metre (m)  
+
| 1*integer
 +
| Length of name of variable to be passed (in char excluding terminating character).
 
|-
 
|-
| 3
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| Time
+
|
| second (s)
+
| Lname*char
 +
| Name of the variable to be passed
 
|-
 
|-
| 4
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| Temperature
+
|
| Kelvin (K)  
+
| 1*integer
 +
| Data type (FLOAT = '''1''', INT = '''2''', STRING = '''3''')  
 
|-
 
|-
| 5
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| Quantity
+
|
| mole (mol)
+
| 1*integer
 +
| Number of values to be passed.
 
|}
 
|}
  
This means that some of the basic fields that we might transfer will have types of
+
=== giveVariableData ===
 +
 
 +
The solver should provide the variable requested by Cerberus.
 +
 
 +
The communication syntax is as follows:
  
 
{|class="wikitable" style="text-align: left;"
 
{|class="wikitable" style="text-align: left;"
! Field name
+
!Direction
! SI unit
+
!Name
! Basic unit
+
!Size and type
! Unit array
+
!Content
 +
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 +
| Lname
 +
| 1*integer
 +
| Length of name of variable to be passed (in char excluding terminating character).
 
|-
 
|-
| Mass density
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
| kg/m3
+
|
| kg*m-3
+
| Lname*char
| <tt>&#160;1 -3 &#160;0 &#160;0 &#160;0</tt>
+
| Name of the variable to be passed
 
|-
 
|-
| Temperature
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| K
+
| NV
| K
+
| 1*integer
| <tt>&#160;0 &#160;0 &#160;0 &#160;1 &#160;0</tt>
+
| Number of values to be passed.
 
|-
 
|-
| Power (integral)
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| W
+
|
| kg*m2*s-3
+
| NV*value
| <tt>&#160;1 &#160;2 -3 &#160;0 &#160;0</tt>
+
| Variable values (float, integer or strings).
 
|-
 
|-
| Power density
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| W/m3
+
|
| kg*m-1*s-3
+
| NV*float
| <tt>&#160;1 -1 -3 &#160;0 &#160;0</tt>
+
| Only if statistics flag was given as '''1'''. Relative errors.
 
|}
 
|}
  
== Mesh types ==
+
=== giveInputVariableDefs  ===
Each physical data field consists of values on a specific mesh. Whereas several mesh types should be supported by Cerberus, the individual solvers typically only need to support their own mesh types. This section describes the geometry of the different mesh types supported by Cerberus and the mesh-data (the ordered list of values exactly specifying the mesh) associated with each mesh type.
 
  
=== Type 1 &mdash; Structured Cartesian mesh ===
+
The solver should communicate names of the variables it is expecting to accept from Cerberus. The communication syntax is as follows:
 
 
Structured Cartesian meshes (in Kraken) are 3D meshes that cover a cuboid volume ([x<sub>min</sub>, x<sub>max</sub>]*[y<sub>min</sub>, y<sub>max</sub>]*[z<sub>min</sub>, z<sub>max</sub>]) and have a fixed number of cells in the x-, y- and z-direction (N<sub>x</sub>, N<sub>y</sub>, N<sub>z</sub>). The total number of cells is the product of the number of cells in each of the three coordinate directions. The size/spacing of the cells need not be constant.
 
 
 
The mesh data for structured Cartesian meshes is as follows
 
  
 
{|class="wikitable" style="text-align: left;"
 
{|class="wikitable" style="text-align: left;"
! Data type/size
+
!Direction
! Data content (explanation)
+
!Name
! Data content (example)
+
!Size and type
! Notes
+
!Content
 
|-
 
|-
| 1*integer
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| Mesh type
+
| NV
| '''1'''
+
| 1*integer
|
+
| Number of variable definitions to be provided
 
|-
 
|-
 +
| The following repeats  NV times:
 
|
 
|
| ''Information on mesh size''
 
 
|
 
|
 
|
 
|
 
|-
 
|-
| 1*integer
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| N<sub>x</sub>
+
| Lname
| '''2'''
+
| 1*integer
| Positive value indicates regular spacing, negative indicates variable spacing.
+
| Length of the name of the variable to be passed (in char excluding terminating character).
 
|-
 
|-
| 1*integer
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| N<sub>y</sub>
+
|
| '''1'''
+
| Lname*char
| Positive value indicates regular spacing, negative indicates variable spacing.
+
| Name of the variable to be passed
|-
 
| 1*integer
 
| N<sub>z</sub>
 
| '''4'''
 
| Positive value indicates regular spacing, negative indicates variable spacing.
 
 
|-
 
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 
|
 
|
| ''Information on mesh boundaries''
+
| 1*integer
|
+
| Data type (FLOAT = '''1''', INT = '''2''', STRING = '''3''')
|
 
 
|-
 
|-
| '''either''' 2*float
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| x<sub>min</sub>, x<sub>max</sub>
+
|
| '''-10.0''', '''10.0'''
+
| 1*integer
| Simply the outer limits in case of regular spacing.
+
| Number of values to be passed.
 +
|}
 +
 
 +
=== takeVariableData ===
 +
 
 +
The solver should receive the data for the variable indicated by Cerberus.
 +
 
 +
The communication syntax is as follows:
 +
 
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 
|-
 
|-
| '''or''' (N<sub>x</sub>+1)*float
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
| x<sub>0</sub>, x<sub>1</sub>, ..., x<sub>N<sub>x</sub>+1</sub>
+
| Lname
| '''-10.0''', '''-5.0''', '''10.0'''
+
| 1*integer
| The cell boundaries in case of variable spacing.
+
| Length of the name of the variable to be passed (in char excluding terminating character).
 
|-
 
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 
|
 
|
|
+
| Lname*char
|
+
| Name of the variable to be passed
|
 
 
|-
 
|-
| '''either''' 2*float
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
| y<sub>min</sub>, y<sub>max</sub>
+
| NV
| '''-5.0''', '''5.0'''
+
| 1*integer
| Simply the outer limits in case of regular spacing.
+
| Number of values to be passed.
|-
 
| '''or''' (N<sub>y</sub>+1)*float
 
| y<sub>0</sub>, y<sub>1</sub>, ..., y<sub>N<sub>y</sub>+1</sub>
 
| '''-5.0''', '''5.0'''
 
| The cell boundaries in case of variable spacing.
 
 
|-
 
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 
|
 
|
|
+
| NV*value
|
+
| Variable values (float, integer or strings).
|
+
|}
 +
 
 +
=== returnCurrentTime  ===
 +
 
 +
The solver should return the time corresponding to the current time point as a float in seconds. This can be used to check that all solvers proceed at the same time points in burnup calculations.
 +
 
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 
|-
 
|-
| '''either''' 2*float
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| z<sub>min</sub>, z<sub>max</sub>
+
| t1
| '''0.0''', '''100.0'''
+
| 1*float
| Simply the outer limits in case of regular spacing.
+
| Current time point of the solver (seconds).
 +
|}
 +
 
 +
=== setCurrentTime  ===
 +
 
 +
This method is usually called in the beginning of burnup calculations to set the starting time of the simulation. The solver should store the received time (a float in seconds) as the current time point and conduct any additional processing required.  
 +
 
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 
|-
 
|-
| '''or''' (N<sub>z</sub>+1)*float
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
| z<sub>0</sub>, z<sub>1</sub>, ..., z<sub>N<sub>z</sub>+1</sub>
+
| t1
| '''0.0''', '''35.0''', '''50.0''', '''65.0''', '''100.0'''
+
| 1*float
| The cell boundaries in case of variable spacing.
+
| Time point to be set (seconds).
 
|}
 
|}
  
==== Default indexing ====
+
=== suggestNextTime  ===
  
x runs fastest, then y and finally z slowest.
+
The solver should return a preferred length for the next time point (end of next timestep) as a float in seconds.  
  
All indices increase from minimum coordinate to maximum coordinate.
+
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
| t1
 +
| 1*float
 +
| Suggested next time point (seconds).
 +
|}
  
=== Type 2 &mdash; Structured x-type 60 degree hexagonal mesh ===
+
=== advanceToTime  ===
  
[[File:hexx60.png|frameless|350px|Indexing in a single layer of a structured x-type 60 degree hexagonal mesh.]]
+
The solver should advance to the next time point (time step), with the given value in seconds. This process may involve storing final results for the previous time point (time step), time integration of some data forwards to the next time point (e.g. burnup accumulation) etc.  
  
=== Type 3 &mdash; Structured y-type 60 degree hexagonal mesh ===
+
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 +
| t1
 +
| 1*float
 +
| Next time point (seconds).
 +
|}
  
=== Type 4 &mdash; Structured x-type 120 degree hexagonal mesh ===
+
=== returnCurrentTimeInterval  ===
  
[[File:hexx120.png|frameless|350px|Indexing in a single layer of a structured x-type 120 degree hexagonal mesh.]]
+
The solver should provide information on the time interval it is currently solving to Cerberus (used in '''transient calculations'''):
  
=== Type 5 &mdash; Structured y-type 120 degree hexagonal mesh ===
+
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
| t0
 +
| 1*float
 +
| Beginning time of current interval (seconds).
 +
|-
 +
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
 +
| t1
 +
| 1*float
 +
| End time of current interval (seconds).
 +
|}
  
=== Type 6 &mdash; Structured axial, radial mesh ===
+
=== setCurrentTimeInterval  ===
  
=== Type 7 &mdash; Unstructured mesh ===
+
Cerberus provides the solver information on the time interval to be solved and the solver should adjust itself accordingly (used in '''transient calculations'''):
  
=== Type 8 &mdash; Nested mesh ===
+
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 +
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 +
| t0
 +
| 1*float
 +
| Beginning time of current interval (seconds).
 +
|-
 +
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
 +
| t1
 +
| 1*float
 +
| End time of current interval (seconds).
 +
|}
 +
 
 +
=== suggestNextTimeInterval  ===
 +
 
 +
The solver should provide its suggestion for the next time interval to be solved (used in '''transient calculations'''):
  
 
{|class="wikitable" style="text-align: left;"
 
{|class="wikitable" style="text-align: left;"
! Data type/size
+
!Direction
! Data content (explanation)
+
!Name
! Data content (example)
+
!Size and type
! Notes
+
!Content
 
|-
 
|-
| 1*integer
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| Mesh type
+
| t0
| '''5'''
+
| 1*float
|
+
| Suggested beginning time of next time interval (seconds).
 
|-
 
|-
| 1*integer
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| N<sub>m</sub>
+
| t1
| '''2'''
+
| 1*float
| Number of nested meshes.
+
| Suggested end time of next time interval (seconds).
 +
|}
 +
 
 +
The beginning time of the next time interval should be equal to the end time of the current time interval.
 +
 
 +
=== advanceToTimeInterval  ===
 +
 
 +
Cerberus provides the solver information on the next time interval to be solved. The solver should prepare itself for solving the new time interval next (e.g. by setting the end-of-interval data of the previous time-interval to be used as beginning-of-interval data for the upcoming one). Used in '''transient calculations'''.
 +
 
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 
|-
 
|-
|  
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
| ''Information on'' N<sub>m</sub> ''nested meshes''
+
| t0
|
+
| 1*float
|
+
| Beginning time of the next time interval (seconds).
 
|-
 
|-
|
+
| {{highlight|C|PaleGreen}}->{{highlight|S|tomato}}
|
+
| t1
|
+
| 1*float
|
+
| End time of the next time interval (seconds).
 +
|}
 +
 
 +
The beginning time of the next interval is more or less guaranteed to be the end time of the current interval.
 +
 
 +
=== solveCurrentTime  ===
 +
 
 +
The solver should execute the solution for the current time point (time step). This can include some initialization and post-processing for the current solution if needed.
 +
 
 +
After the solution has completed, the solver should send Cerberus an integer value indicating that the solution has been completed and to give some information on the potential convergence of the solution (as judged by the solver):
 +
{|class="wikitable" style="text-align: left;"
 +
!Direction
 +
!Name
 +
!Size and type
 +
!Content
 
|-
 
|-
| 1*integer
+
| {{highlight|S|tomato}}->{{highlight|C|PaleGreen}}
| Mesh 1 type (top level)
+
| NV
| '''1'''
+
| 1*integer  
|
+
| A single integer 1, 2 or 3 (see below)
 
|-
 
|-
 
|  
 
|  
| ... ''The rest of the mesh 1 data.''
 
 
|  
 
|  
 
|  
 
|  
|-
+
| 1 = solution complete
|
 
|
 
|
 
|
 
|-
 
|
 
| Mesh 2 type (second highest level)
 
| '''1'''
 
|
 
 
|-
 
|-
 
|  
 
|  
| ... ''The rest of the mesh 2 data.''
 
|
 
|
 
|-
 
|
 
|
 
|
 
|
 
|-
 
 
|  
 
|  
| Mesh  N<sub>m</sub> type (lowest level)
 
| '''1'''
 
 
|  
 
|  
 +
| 2 = solution complete and convergence reached
 
|-
 
|-
 
|  
 
|  
| ... ''The rest of the mesh'' N<sub>m</sub> ''data.''
 
 
|  
 
|  
 
|  
 
|  
 +
| 3 = solution complete but diverged or other problems
 
|}
 
|}
  
== Indexing array ==
+
=== correctPreviousStep ===
  
Each of the mesh types described in the previous section have their own ''default indexing'' sometimes referred to as ''global indexing''.
+
The solver may consider the current coupled solution converged and use this information to correct the previous time-integral that took the solver to the current time/time interval. If the solver cannot correct its previous time-integration or does not deem it necessary, it can simply ignore the signal.
  
Sometimes the data accepted or provided by a solver may lie on a specific mesh type but follow an indexing that is different from this default. Consider the situation in the following figure:
+
Intended especially for burnup calculations but might be useful in some transient simulations also.
  
[[File:2x2remap.png|frameless|200px|2x2 rod indexing information.]]
+
=== writeRestart ===
  
The red numbers indicate the default indexing in this 2x2x1 regular Cartesian mesh. If our coupled solver would have the inverse indexing shown in white, we would have to account for that fact in the data transfer. The idea in the Cerberus coupling is to allow the coupled solvers to send and receive data in their preferred indexing, so that the coupled solvers do not have to rearrange data when sending or receiving it. This is achieved by the option to provide an indexing array as a part of a field template.
+
The solver should write its current state as a restart file. The path to the restart file may be fixed, given as a part of the solver input or as an input variable through Cerberus.  
  
The indexing array, which needs to be sent if the indexing flag in the sent field template is set to '''1''' is simply an array of integers with the length of the array corresponding to the number of cells in the mesh and the contents of the array describing which solver index (white) corresponds to which global index (red). The first value of the array indicates the solver index corresponding to global index '''1''' and so on.
+
The contents of the restart file can be freely chosen by the developer and may be context dependent, e.g. on the simulation type that is being executed (stationary, burnup, transient etc.)
  
The indexing array for our 2x2 example above would thus be
+
=== readRestart ===
  
'''4 3 2 1'''
+
The solver should set its internal state based on a restart file. The path to the restart file may be fixed, given as a part of the solver input or as an input variable through Cerberus.
  
The indexing array can also account for the fact that the coupled solver will not accept or provide data for specific cell index/indices. If the coupled solver would only provide data for fuel rods and the geometry for the simulation would be as follows:
+
Along with the [[#writeRestart|writeRestart]] method, this one should allow e.g. for initializing a transient simulation based on a stationary state or continuing a previous calculation in another manner. The exact functionality can be chosen by the developer.
  
[[File:3x3remap.png|frameless|300px|3x3 rod indexing information with one non-indexed position.]]
+
== Field unit array ==
  
In this case the coupled solver does not consider the global cell '''5''' to be a part of its solution domain and thus will not provide or accept field data for that cell. Global cell '''5''' can be left un-indexed by setting the value '''0''' for it in the indexing array, which would now be
+
The field unit array consists of 5 integers (e.g. <tt>&#160;1 -3 &#160;0 &#160;0 &#160;0</tt> for mass density) specifying the dimension for each of the 5 SI base units for the field
  
'''8 7 6 5 0 4 3 2 1'''
+
{|class="wikitable" style="text-align: left;"
 +
! No.
 +
! Property
 +
! Unit
 +
|-
 +
| 1
 +
| Mass
 +
| kilogram (kg)
 +
|-
 +
| 2
 +
| Length
 +
| metre (m)
 +
|-
 +
| 3
 +
| Time
 +
| second (s)
 +
|-
 +
| 4
 +
| Temperature
 +
| Kelvin (K)
 +
|-
 +
| 5  
 +
| Quantity
 +
| mole (mol)
 +
|}
  
In such cases where some mesh cells are not indexed, the number of values for the field transferred between Cerberus and the solver will be reduced. In this case only 8 values would be transferred in the [[#giveFieldData|giveFieldData]] and [[#takeFieldData|takeFieldData]] calls.
+
This means that some of the basic fields that we might transfer will have types of
  
Extending the previous example from 3x3x1 to 3x3x2 the indexing array might be
+
{|class="wikitable" style="text-align: left;"
 
+
! Field name
'''8 7 6 5 0 4 3 2 1 16 15 14 13 0 12 11 10 9'''
+
! SI unit
 
+
! Basic unit
assuming that the indexing of the coupled solver on the upper axial layer is similar to that in the lower axial layer shown in the previous figure.
+
! Unit array  
 +
|-
 +
| Mass density
 +
| kg/m3
 +
| kg*m-3
 +
| <tt>&#160;1 -3 &#160;0 &#160;0 &#160;0</tt>
 +
|-
 +
| Temperature
 +
| K
 +
| K
 +
| <tt>&#160;0 &#160;0 &#160;0 &#160;1 &#160;0</tt>
 +
|-
 +
| Power (integral)
 +
| W
 +
| kg*m2*s-3  
 +
| <tt>&#160;1 &#160;2 -3 &#160;0 &#160;0</tt>
 +
|-
 +
| Power density
 +
| W/m3
 +
| kg*m-1*s-3
 +
| <tt>&#160;1 -1 -3 &#160;0 &#160;0</tt>
 +
|}

Latest revision as of 12:28, 3 February 2024

The code coupling in Kraken is based on a "hub and spoke" approach where each solver module only needs to communicate with the central multi-physics driver Cerberus. The Cerberus multi-physics driver is responsible for starting up each solver module, exchanging field data with them and controlling the execution order of the different modules.

The individual solver modules should implement basic signalling capabilities so that they can accept signals from Cerberus as well as send messages back using the signalling syntax described below.

Basics of signalling

When the solver is executed from command line by Cerberus when running a Python script such as

# --- Initialize solvers
my_input = CodeInput("path_to_my_input")
my_solver = Solver("my_solver_name", path_to_my_solver, ["--port",])
my_solver.input = my_input
my_solver.initialize()

Cerberus will provide the port the solver should connect to as a pair of command line arguments "--port" <port_as_integer>. The solver should then read its own input, do whatever processing is required and open a socket on the indicated port for communication with Cerberus.

After the port has been opened, Cerberus expects the following greeting process:

Direction Name Size and type Content
Solver->Cerberus Lgreet 1*integer Length of greeting string in char excluding terminating character
Solver->Cerberus Lgreet*char A freely chosen greeting string (will be read and can be printed out by Cerberus).
Cerberus->Solver Lgreet 1*integer Length of greeting string in char excluding terminating character
Cerberus->Solver Lgreet*char Some greeting string sent by Cerberus.

After the greeting and its own basic initialization, the solver should wait for further signals from Cerberus.

After each order received from Cerberus, the solver should fulfill the order and wait for further signals from Cerberus.

All numerical values will be passed as double precision integers (8 bytes) or double precision floats (8 bytes).

Basic "function calls"

When the solvers have completed their previous order and are waiting for the next signal from Cerberus, Cerberus will initiate the communication with a single integer indicating which "function call" should be processed.

The function calls and the integers representing them in the communication syntax are listed in a table below. When coupling a solver to Cerberus, they are typically listed in some centrally located header (or some such) files for C and Fortran. These can be also checked from cerberus.commons.KrakenSignals.

Function name Integer value
terminate 0
returnCurrentTime 1
setCurrentTime 2
suggestNextTime 3
advanceToTime 4
solveCurrentTime 5
giveInputFieldNames 6
giveOutputFieldNames 7
giveFieldTemplate 8
giveMeshData 9
giveIndexingArray 10
giveFieldData 11
takeFieldData 12
giveOutputVariableDefs 13
giveVariableData 14
giveInputVariableDefs 15
takeVariableData 16
writeRestart 17
readRestart 18
returnCurrentTimeInterval 19
setCurrentTimeInterval 20
suggestNextTimeInterval 21
advanceToTimeInterval 22
correctPreviousStep 23

The following sections will go through the signalling for each of the function calls

terminate

When Cerberus sends the signal for a solver to terminate. The solver simply exits gracefully. Final results can be collected, processed and printed out. Memory should be freed, and the process should be terminated in the end.

No further signalling takes place after the C->S signal to terminate.

giveInputFieldNames

The solver should communicate the names of the fields it is expecting to receive from Cerberus. The communication syntax is as follows:

Direction Name Size and type Content
S->C NF 1*integer Number of fields to be provided
The following repeats NF times:
S->C Lname 1*integer Length of field name in char excluding terminating character
S->C Lname*char Name of the field

giveOutputFieldNames

The solver should communicate the names of the fields it is expecting to provide to Cerberus. The communication syntax is as follows:

Direction Name Size and type Content
S->C NF 1*integer Number of fields to be provided
The following repeats NF times:
S->C Lname 1*integer Length of field name in char excluding terminating character
S->C Lname*char Name of the field

giveFieldTemplate

The solver should provide basic information on the field requested by Cerberus.

The communication syntax is as follows:

Direction Name Size and type Content
C->S LnameF 1*integer Length of name of requested field (in char excluding terminating character).
C->S LnameF*char Name of the requested field
S->C 1*integer Data type (FLOAT = 1, INT = 2, STRING = 3)
S->C 5*integer Unit of the field in an OpenFOAMish array (see Field unit array)
S->C 1*float Multiplier a used to convert from the base unit type specified by the unit array to the actual unit used by the solver (a*x + b).
S->C 1*float Offset b used to convert from the base unit type specified by the unit array to the actual unit used by the solver (a*x + b).
S->C LnameM 1*integer Length of mesh name in char excluding terminating character
S->C LnameM*char Name of the mesh
S->C 1*integer Indexing flag: 0 if solver uses the default indexing of the mesh. 1 if solver uses some other indexing: Indexing array
[S->C] LnameI 1*integer Only if indexing flag was given as 1 (use custom indexing). Length of indexing array name in char excluding terminating character.
[S->C] LnameI*char Only if indexing flag was given as 1 (use custom indexing). Name of the indexing array.

giveMeshData

The solver should provide information on the mesh requested by Cerberus.

The communication syntax is as follows:

Direction Name Size and type Content
C->S Lname 1*integer Length of name of requested mesh (in char excluding terminating character).
C->S Lname*char Name of the requested mesh
S->C 1*integer Type of the mesh (see Mesh types).
S->C <depends on mesh> Mesh data, see subsection Mesh types

giveIndexingArray

The solver should provide information on the indexing array requested by Cerberus.

The communication syntax is as follows:

Direction Name Size and type Content
C->S Lname 1*integer Length of name of requested indexing array (in char excluding terminating character).
C->S Lname*char Name of the requested indexing array
S->C NV 1*integer Number of values to be passed.
S->C NV*value Indices: Indexing array

giveFieldData

The solver should provide the data for the field requested by Cerberus.

The communication syntax is as follows:

Direction Name Size and type Content
C->S Lname 1*integer Length of name of field to be passed (in char excluding terminating character).
C->S Lname*char Name of the field to be passed
S->C NV 1*integer Number of values to be passed.
S->C NV*value The values for the field (float, integer or strings).

takeFieldData

The solver should receive the data for the field indicated by Cerberus.

The communication syntax is as follows:

Direction Name Size and type Content
C->S Lname 1*integer Length of name of field to be passed (in char excluding terminating character).
C->S Lname*char Name of the field to be passed
C->S NV 1*integer Number of values to be passed.
C->S NV*value The values for the field (float, integer or strings).

giveOutputVariableDefs

The solver should communicate names of the variables it is expecting to provide to Cerberus. The communication syntax is as follows:

Direction Name Size and type Content
S->C NV 1*integer Number of variable definitions to be provided
The following repeats NV times:
S->C Lname 1*integer Length of name of variable to be passed (in char excluding terminating character).
S->C Lname*char Name of the variable to be passed
S->C 1*integer Data type (FLOAT = 1, INT = 2, STRING = 3)
S->C 1*integer Number of values to be passed.

giveVariableData

The solver should provide the variable requested by Cerberus.

The communication syntax is as follows:

Direction Name Size and type Content
C->S Lname 1*integer Length of name of variable to be passed (in char excluding terminating character).
C->S Lname*char Name of the variable to be passed
S->C NV 1*integer Number of values to be passed.
S->C NV*value Variable values (float, integer or strings).
S->C NV*float Only if statistics flag was given as 1. Relative errors.

giveInputVariableDefs

The solver should communicate names of the variables it is expecting to accept from Cerberus. The communication syntax is as follows:

Direction Name Size and type Content
S->C NV 1*integer Number of variable definitions to be provided
The following repeats NV times:
S->C Lname 1*integer Length of the name of the variable to be passed (in char excluding terminating character).
S->C Lname*char Name of the variable to be passed
S->C 1*integer Data type (FLOAT = 1, INT = 2, STRING = 3)
S->C 1*integer Number of values to be passed.

takeVariableData

The solver should receive the data for the variable indicated by Cerberus.

The communication syntax is as follows:

Direction Name Size and type Content
C->S Lname 1*integer Length of the name of the variable to be passed (in char excluding terminating character).
C->S Lname*char Name of the variable to be passed
C->S NV 1*integer Number of values to be passed.
C->S NV*value Variable values (float, integer or strings).

returnCurrentTime

The solver should return the time corresponding to the current time point as a float in seconds. This can be used to check that all solvers proceed at the same time points in burnup calculations.

Direction Name Size and type Content
S->C t1 1*float Current time point of the solver (seconds).

setCurrentTime

This method is usually called in the beginning of burnup calculations to set the starting time of the simulation. The solver should store the received time (a float in seconds) as the current time point and conduct any additional processing required.

Direction Name Size and type Content
C->S t1 1*float Time point to be set (seconds).

suggestNextTime

The solver should return a preferred length for the next time point (end of next timestep) as a float in seconds.

Direction Name Size and type Content
S->C t1 1*float Suggested next time point (seconds).

advanceToTime

The solver should advance to the next time point (time step), with the given value in seconds. This process may involve storing final results for the previous time point (time step), time integration of some data forwards to the next time point (e.g. burnup accumulation) etc.

Direction Name Size and type Content
C->S t1 1*float Next time point (seconds).

returnCurrentTimeInterval

The solver should provide information on the time interval it is currently solving to Cerberus (used in transient calculations):

Direction Name Size and type Content
S->C t0 1*float Beginning time of current interval (seconds).
S->C t1 1*float End time of current interval (seconds).

setCurrentTimeInterval

Cerberus provides the solver information on the time interval to be solved and the solver should adjust itself accordingly (used in transient calculations):

Direction Name Size and type Content
C->S t0 1*float Beginning time of current interval (seconds).
C->S t1 1*float End time of current interval (seconds).

suggestNextTimeInterval

The solver should provide its suggestion for the next time interval to be solved (used in transient calculations):

Direction Name Size and type Content
S->C t0 1*float Suggested beginning time of next time interval (seconds).
S->C t1 1*float Suggested end time of next time interval (seconds).

The beginning time of the next time interval should be equal to the end time of the current time interval.

advanceToTimeInterval

Cerberus provides the solver information on the next time interval to be solved. The solver should prepare itself for solving the new time interval next (e.g. by setting the end-of-interval data of the previous time-interval to be used as beginning-of-interval data for the upcoming one). Used in transient calculations.

Direction Name Size and type Content
C->S t0 1*float Beginning time of the next time interval (seconds).
C->S t1 1*float End time of the next time interval (seconds).

The beginning time of the next interval is more or less guaranteed to be the end time of the current interval.

solveCurrentTime

The solver should execute the solution for the current time point (time step). This can include some initialization and post-processing for the current solution if needed.

After the solution has completed, the solver should send Cerberus an integer value indicating that the solution has been completed and to give some information on the potential convergence of the solution (as judged by the solver):

Direction Name Size and type Content
S->C NV 1*integer A single integer 1, 2 or 3 (see below)
1 = solution complete
2 = solution complete and convergence reached
3 = solution complete but diverged or other problems

correctPreviousStep

The solver may consider the current coupled solution converged and use this information to correct the previous time-integral that took the solver to the current time/time interval. If the solver cannot correct its previous time-integration or does not deem it necessary, it can simply ignore the signal.

Intended especially for burnup calculations but might be useful in some transient simulations also.

writeRestart

The solver should write its current state as a restart file. The path to the restart file may be fixed, given as a part of the solver input or as an input variable through Cerberus.

The contents of the restart file can be freely chosen by the developer and may be context dependent, e.g. on the simulation type that is being executed (stationary, burnup, transient etc.)

readRestart

The solver should set its internal state based on a restart file. The path to the restart file may be fixed, given as a part of the solver input or as an input variable through Cerberus.

Along with the writeRestart method, this one should allow e.g. for initializing a transient simulation based on a stationary state or continuing a previous calculation in another manner. The exact functionality can be chosen by the developer.

Field unit array

The field unit array consists of 5 integers (e.g.  1 -3  0  0  0 for mass density) specifying the dimension for each of the 5 SI base units for the field

No. Property Unit
1 Mass kilogram (kg)
2 Length metre (m)
3 Time second (s)
4 Temperature Kelvin (K)
5 Quantity mole (mol)

This means that some of the basic fields that we might transfer will have types of

Field name SI unit Basic unit Unit array
Mass density kg/m3 kg*m-3  1 -3  0  0  0
Temperature K K  0  0  0  1  0
Power (integral) W kg*m2*s-3  1  2 -3  0  0
Power density W/m3 kg*m-1*s-3  1 -1 -3  0  0