- Relevant concepts
- Data access functions
- Supported heavyweight data formats
- Array data access structures
Relevant concepts
- Input data Input data is for input variables provided to the participant by System Coupling. The participant library needs to have read and write access to this data.
- Output data Output data is for output variables provided to System Coupling by the participant, including mesh data. The participant library needs to have read-only access to this data.
- Scalar and Vector Data Scalar data has one component. Temperature values are an example of scalar data. Vector data has the same number of components as there are dimensions, that is three components in 3-D cases and two components in 2-D cases. Nodal coordinates values are an example of vector data.
- Real and Complex Data Types System Coupling supports for real- and complex-valued variables. Complex values have real and imaginary components. Term real is usually omitted, so unless data is specifically referred to as complex, real-valued data should be assumed.
- Integer Integer data contains integers. An array of mesh node ids is an example of integer data.
- Data access function A data access function is a callback function implemented by the participant solver and registered with the participant library. The participant library will call this function when it needs to access the heavyweight data. For a coupled analysis, all required data access functions must be registered prior to *coupled analysis initialization*. For mapping, all required data access functions must be registered prior to *inputs update*.
Data access functions
To provide access to the heavyweight data, the participant must also implement data access functions which return the data access structures and register them with the participant library. These functions are called from within the participant library, that is they are callback functions. The following functions may need to be implemented:- Function to access input scalar data (input scalar data access)
- Function to access input vector data (input vector data access)
- Function to access output scalar data (output scalar data access)
- Function to access output vector data (output vector data access)
- Function to access input complex scalar data (input complex scalar data access)
- Function to access input complex vector data (input complex vector data access)
- Function to access output complex scalar data (output complex scalar data access)
- Function to access output complex vector data (output complex vector data access)
- Function to access surface mesh (surface mesh access)
- Function to access volume mesh (volume mesh access)
- Function to access point cloud (point cloud access)
C++
Data access function prototypes are defined in the following header file:SystemCouplingParticipant/FunctionTypes.hpp
C
Data access function prototypes are defined in the following header file:syscFunctionTypes.h
Fortran
Data access function interfaces are defined in the following header file (located either in FortranFreeForm or FortranFixedForm sub-directory, depending on desired Fortran layout):syscFunctionTypesF.fi
Python
Data access function prototypes closely follow those in C++.Supported heavyweight data formats
The compatible formats for heavyweight data are:-
Integer arrays
-
32-bit signed integer arrays (for mesh connectivity information)
- C/C++
int32_t - FORTRAN
integer(kind=4) - Python numpy arrays with datatype
int32
- C/C++
-
64-bit signed integer arrays (for mesh connectivity information)
- C/C++
int64_t - FORTRAN
integer(kind=8) - Python numpy arrays with datatype
int64
- C/C++
-
16-bit unsigned integer arrays (for mesh connectivity information)
- C/C++
uint16_t - Python numpy arrays with datatype
uint16
- C/C++
-
64-bit unsigned integer arrays (for mesh connectivity information)
- C/C++
uint64_t - Python numpy arrays with datatype
uint64
- C/C++
-
32-bit signed integer arrays (for mesh connectivity information)
-
Scalar arrays
-
64-bit floating point arrays (for scalar variable field values)
- C/C++
double - FORTRAN
real(kind=8) - Python numpy arrays with datatype
float64
- C/C++
-
32-bit floating point arrays (for scalar variable field values)
- C/C++
float - FORTRAN
real(kind=4) - Python numpy arrays with datatype
float32
- C/C++
-
64-bit floating point arrays (for scalar variable field values)
-
Vector arrays
-
32-bit floating point arrays (for vector variable field values and for mesh node coordinates)
- C/C++
float - FORTRAN
real(kind=4) - Python numpy arrays with datatype
float32
- C/C++
-
64-bit floating point arrays (for vector variable field values and for mesh node coordinates)
- C/C++
double - FORTRAN
real(kind=8) - Python numpy arrays with datatype
float64
- C/C++
-
32-bit floating point arrays (for vector variable field values and for mesh node coordinates)
-
Complex scalar arrays
-
64-bit floating point complex number arrays (for complex scalar variable field values)
- C++
std::complex<double> - C/C++
double - Python numpy arrays with datatype
complex128
- C++
-
32-bit floating point complex number arrays (for complex scalar variable field values)
- C++
std::complex<float> - C/C++
float - Python numpy arrays with datatype
complex64
- C++
-
Compact layout
(for example, a single array storing each vector one after another)
-
Three dimensional vector
[x0, y0, z0, x1, y1, z1, ..., xN, yN, zN]
-
Two dimensional vector
[x0, y0, x1, y1, ..., xN, yN]
-
Three dimensional vector
-
Split layout
(for example, a separate array for each vector component)
[x0, x1, .., xN][y0, y1, .., yN][z0, z1, .., zN](Not required for split vector in 2D)
-
Compact complex scalar layout
(for example, a single array storing each real and imaginary component one after another)
[real_0, imag_0, real_1, imag_1, ..., real_N, imag_N]
-
Split complex scalar layout
(for example, two separate arrays, one for real and one for imaginary components)
[real_0, real_1, ..., real_N][imag_0, imag_1, ..., imag_N]
-
Compact complex compact vector layout
(for example, a single array storing each real and imaginary component one after another) Note that this is the only layout currently supported in Fortran.
-
Three dimensional vector
[x0_real, x0_imag, y0_real, y0_imag, z0_real,z0_imag, ..., xN_real, xN_imag, yN_real, yN_imag, zN_real, zN_imag]
-
Two dimensional vector
[x0_real, x0_imag, y0_real, y0_imag, ..., xN_real, xN_imag, yN_real, yN_imag]
-
Three dimensional vector
-
Split complex compact vector layout
(for example, a separate array for real and imaginary components)
[x0_real, y0_real, z0_real, x1_real, y1_real, z1_real, ..., xN_real, yN_real, zN_real][x0_imag, y0_imag, z0_imag, x1_imag, y1_imag, z1_imag, ..., xN_imag, yN_imag, zN_imag]
-
Compact complex split vector layout
(for example, a separate array for each vector component)
[x0_real, x0_imag, x1_real, x1_imag, x2_real, x2_imag, ..., xN_real, xN_imag][y0_real, y0_imag, y1_real, y1_imag, y2_real, y2_imag, ..., yN_real, yN_imag][z0_real, z0_imag, z1_real, z1_imag, z2_real, z2_imag, ..., zN_real, zN_imag]
-
Compact complex split vector layout
(for example, separate arrays vector components and complex components)
[x0_real, x1_real, x2_real, ..., xN_real][x0_imag, x1_imag, x2_imag, ..., xN_imag][y0_real, y1_real, y2_real, ..., yN_real][y0_imag, y1_imag, y2_imag, ..., yN_imag][z0_real, z1_real, z2_real, ..., zN_real][z0_imag, z1_imag, z2_imag, ..., zN_imag]
-
64-bit floating point complex number arrays (for complex scalar variable field values)
Note:If the participant solver stores heavyweight data in a format compatible with the participant library, then this reduces the need to make unnecessary copies of the data and thus improves the memory efficiency. The participant solver should implement and register data access functions that provide direct access to that heavyweight data. If the data is stored in a format that is not directly compatible with the participant library, then the participant solver should create compatible heavyweight data structures and register data access functions that provide access to that heavyweight data. In such a case, the participant solver should make sure that this heavyweight data and the original data are synchronized at certain steps. For mapping, the heavyweight data and the original data should be synchronized at certain steps during mapping:
- If vector data is stored in a single array where the vector components are separated (for example,
[x0, x1, ..., y0, y1, ..., z0, z1, zN]), then it can be handled as a special case of split layout.- If vector data is stored in a two-dimensional array, then it can be handled as a special case of one of the above layouts.
- Before inputs update, the heavyweight input and output data are expected to be available. Output data, including the mesh data, should contain valid up-to-date values.
- After inputs update completes, all input variable values will be up-to-date in the heavyweight data. The participant should make sure that the latest input values are available in the original data structures before processing that data.
- Before coupled analysis initialization is entered, the heavyweight input and output data are expected to be available. Output data, including the mesh data, should contain valid initial values.
- After inputs update completes, all input variable values will be up-to-date in the heavyweight data. The participant should make sure that the latest input values are available in the original data structures before doing solver iterations.
- Before outputs update is entered, the participant should make sure that the heavyweight data contains the updated values for all the output variables, as well as for the mesh.
Array data access structures
Access to heavyweight data is provided via creating data access data structures and implementing data access functions (callback functions) that provide these structures to the participant library. This section discusses the following data access structures:OutputIntegerDataOutputScalarDataOutputVectorDataInputScalarDataInputVectorDataOutputComplexScalarDataOutputComplexVectorDataInputComplexScalarDataInputComplexVectorData
- Primitive type of data (for example, float, double, unsigned 16-bit integer, etc.)
- Access to the heavyweight data (for example, array pointers).
- Extents of the data (for example, array sizes)
Integer data structure examples
Example: Output integer data
In this example, the mesh node ids are stored as an array of unsigned 64-bit integer values. To provide access to this variable, create theOutputIntegerData structure as shown below.
C++
C
For C, a helper functionsyscGetOutputIntegerDataUInt64 is provided for this case.
Fortran
For Fortran, a helper functionsyscGetOutputIntegerDataF is provided for this case.
Python
For Python, any C-style array can be used to createOutputIntegerData object, with the help of ctypes module.
Scalar data structure examples
Example: Input scalar data
In this example, the participant solver has values of an input scalar variable stored in memory as a double-precision array. To provide access to this variable, create theInputScalarData structure as shown below.
C++
C
For C, a helper functionsyscGetInputScalarDataDouble is provided for this case.
Fortran
For Fortran, a helper functionsyscGetInputScalarDataF is provided for this case.
Python
For Python, numpy arrays can be passed in to createInputScalarData object.
Example: Output scalar data
In this example, the participant solver has values of an output scalar variable stored in memory as a single-precision array. To provide access to this variable, create theOutputScalarData structure as shown below.
C++
C
For C, a helper functionsyscGetOutputScalarDataFloat is provided for this case.
Fortran
For Fortran, a helper functionsyscGetOutputScalarDataF is provided for this case.
Python
For Python, numpy arrays can be passed in to createOutputScalarData object.
Vector data structure examples
Vector data storage can be categorized as either compact or split storage. Examples are provided for both categories.Example: Compact input vector data in a one-dimensional array
In this example, the participant solver has values of an input vector variable stored in memory as a compact one-dimensional array. To provide access to this variable, create theInputVectorData structure as shown below.
Note that the size provided is 10 — there are 10 vectors, each with 3 components. So, the total size of the array in memory is 30, but the size passed in here must be 10, not 30.
C++
C
For C, a helper functionsyscGetInputVectorDataCompactDouble is provided for this case.
Fortran
For Fortran, a helper functionsyscGetInputVectorDataCompactF is provided for this case.
Python
For Python, numpy arrays can be passed in to createInputVectorData object.
Example: Compact output vector data in a two-dimensional array
In this example, the participant solver has values of an output vector variable stored in memory as a compact two-dimensional array. To provide access to this variable, create theOutputVectorData structure as shown below.
Note that the size provided is 2 — there are 2 vectors, each with 3 components.
C++
C
For C, a helper functionsyscGetOutputVectorDataCompactFloat is provided for this case.
Fortran
For Fortran, a helper functionsyscGetOutputVectorDataCompactF is provided for this case.
Note that Fortran stores data in column-major order, so compactly stored two-dimensional array has component as first index and vector as second index.
Python
For Python, numpy arrays can be passed in to createOutputVectorData object.
Example: Split input vector data in separate arrays
In this example, the participant solver has values of an input vector variable stored in memory as three separate arrays, one array per component. To provide access to this variable, create theInputVectorData structure as shown below.
Note that the size provided is 4 — there are 4 vectors, each with 3 components.
C++
C
For C, a helper functionsyscGetInputVectorDataSplitFloat is provided for this case.
Fortran
For Fortran, a helper functionsyscGetInputVectorDataSplitF is provided for this case.
Python
For Python, numpy arrays can be passed in to createInputVectorData object.
Example: Split output vector data in a two-dimensional array
In this example, the participant solver has values of an output vector variable stored in memory as a split two-dimensional array. To provide access to this variable, create theOutputVectorData structure as shown below.
Note that the size provided is 2 — there are 2 vectors, each with 3 components.
C++
C
For C, a helper functionsyscGetOutputVectorDataSplitDouble is provided for this case.
Fortran
For Fortran, a helper functionsyscGetOutputVectorDataSplitF is provided for this case.
Note that Fortran stores data in column-major order, so non-compactly stored two-dimensional array has the vector as the first index and the vector component as the second index.
Python
For Python, numpy arrays can be passed in to createOutputVectorData object.
Example: Compact output complex vector data in a two-dimensional array, compact layout
In this example, the participant solver has values of an output vector variable stored in memory as a split two-dimensional array. To provide access to this variable, create theOutputComplexVectorData structure as shown below.
Note that the size provided is 2 — there are 2 vectors, each with 3 components, and each component is a complex number.
C++
C
For C, a helper functionsyscGetOutputCompactComplexCompactVectorDataDouble is provided for this case.
Fortran
For Fortran, a helper functionsyscGetOutputComplexVectorDataCompactF is provided for this case.
Note that Fortran stores data in column-major order, so compactly stored two-dimensional array has the vector component as the first index and the vector as the second index.
Python
For Python, numpy arrays can be passed in to createOutputComplexVectorData object.
Other Examples
Example input scalar in an STL vector container (C++ only)
In this example, the participant solver has an input scalar variable stored in memory as an STL vector. To provide access to this array, create theInputScalarData structure as shown below.
Note that the size does not need to be provided because it can be automatically deduced from the STL vector size.
C++
Example output integer data in a numpy array container (Python only)
In this example, the participant solver has an output integer data stored in memory as a numpy array. To provide access to this array, create theOutputIntegerData structure as shown below.
Note that the size does not need to be provided because it can be automatically deduced from the Numpy array size.
Python
Example: 2D input vector data in a one-dimensional array (C++ only)
In this example, the participant solver has values of an input vector variable stored in memory as a compact one-dimensional array. To provide access to this variable, create the 2DInputVectorData structure as shown below.
Note that the size provided is 15 for 2D vector data — there are 15 vectors, each with 2 components. The total size of the array in memory is 30, but the size passed in here must be 15, not 30.
Example: 2D compact output vector data in a two-dimensional array (C only)
In this example, the participant solver has values of an output vector variable stored in memory as a compact two-dimensional array. To provide access to this variable, create the 2DOutputVectorData structure as shown below.
Note for 2D vector, the size provided is 2 — there are 2 vectors, each with 2 components.
A helper C function syscGetOutputVectorDataCompactFloat is provided for either 2D and 3D vector case depending on the dimension value.
Example: Split input vector data in separate arrays (Fortran only)
In this example, the participant solver has values of an input vector variable stored in memory as three separate arrays, one array per component. To provide access to this variable, create the 2DInputVectorData structure as shown below.
Note that for 2D vector the size provided is 4 — there are 4 vectors, each with 2 components.
A helper Fortran function syscGetInput2DVectorDataSplitF is provided for 2D vector case.
Example: 2D split output vector data in a two-dimensional array (Python only)
In this example, the participant solver has values of an output vector variable stored in memory as a split two-dimensional array. To provide access to this variable, create the 2DOutputVectorData structure as shown below.
Note that for 2D vector the size provided is 2 — there are 2 vectors, each with 2 components.
For Python, numpy arrays can be passed in to create 2D OutputVectorData object.
Example: 2D compact output complex vector data in a two-dimensional array, compact layout (C++ only)
In this example, the participant solver has values of an output vector variable stored in memory as a split two-dimensional array. To provide access to this variable, create the 2DOutputComplexVectorData structure as shown below.
Note that for 2D complex vector the size provided is 2 — there are 2 vectors, each with 2 components, and each component is a complex number.