Skip to main content

System Coupling Python library 2023 R2

Debugging Tools

Last update: 10.07.2023

The participant library includes the following tools to help with debugging:

  • Code tracing
  • Standalone Mode (for co-simulation only)
  • Mesh Validity Check

Code tracing

Code tracing allows to log function calls into a text file, that can be used to identify source of a given problem. To enable code tracing, set SYSC_PARTLIB_DEBUG environment variable to 1, 2, 3, 4, or 5. The higher the value, the more details will be printed to the text files. When running in parallel, each parallel process will print its own text file. The files will be named SyC_Log_CNode*.txt.

Standalone Mode (for co-simulation only)

Once the APIs are implemented, you can use the standalone mode to run the participant solver without connecting to System Coupling. When running in standalone mode, the participant solver will run for a few coupling coupling time steps (if transient) and coupling iterations.

If SYSC_PARTLIB_DEBUG environment variable to set to 5 then at each iteration in standalone mode, all registered data access functions will be called and the contents of heavyweight data will be printed into a text file sysc_*.debug.

The standalone mode allows you to check for run-time issues more quickly and can help to provide a measure of confidence that the APIs are implemented correctly. Before running a solver as part of an overall coupled analysis, you should first confirm that the participant solver can run successfully in standalone mode.

To run in standalone mode, provide an empty host name when the connection to System Coupling would be typically established. No other changes are required to run in standalone mode. For a demonstration of how to run a participant solver in standalone mode, see Tutorial: Heat Transfer in Square Channel Air Flow.

C++

std::string scHost;
unsigned short int scPort;
std::string partName;
std::string buildInfo;
...
scHost = "";
sysc::System Coupling sc(scHost, scPort, partName, buildInfo);

C

char scHost[256];
unsigned short scPort;
char partName[256];
char buildInfo[256];
...
scHost[0] = '\0';
SyscError ret = syscConnect(scHost, scPort, partName, buildInfo);

Fortran

character(len=256) :: scHost
integer :: scPort = 0
character(len=256) :: partName
character(len256) :: buildInfo
...
scHost = ""
ret = syscConnectF(scHost, scPort, partName, buildInfo)

Python

from pyExt import SystemCouplingParticipant as sysc
scHost = ""
scPort = 0
partName = ""
buildInfo = ""
...
sc = sysc.SystemCouplingParticipant(scHost, scPort, scName, buildInfo)

Mesh Validity Check

A mesh validity check is available as a debugging tool. This is a function that can be called to detect problems in the mesh that is provided to the participant library. It returns the mesh validity status and a message containing information about a problem that was detected.

For example, it will check whether the array sizes are consistent — that the element node ids array contains only ids that are found in the node ids array, etc.

Note:

  • This is not an exhaustive validity check — the mesh can still have problems even if all checks pass. However, it can provide a measure of confidence that the mesh being provided to System Coupling is correct.
  • To ensure optimal performance, this function should not be called in production workflows.

C++

sysc::SurfaceMesh surfaceMesh(...);
...
sysc::MeshValidityStatus meshStatus = surfaceMesh.checkMeshValidity();
if (meshStatus.isInvalid) {
std::cout << meshStatus.message;
}

C

SyscSurfaceMesh surfaceMesh = syscGetSurfaceMesh...;
...
SyscError ret = syscCheckSurfaceMeshValidity(surfaceMesh);
if (ret.retcode != 0) {
printf(ret.message);
}

Fortran

type(SyscSurfaceMeshF) :: surfaceMesh
type(SyscErrorF) :: ret
...
ret = syscCheckSurfaceMeshValidityF(surfaceMesh)
if (ret%retcode .NE. SyscStatusOk) then
print *, trim(ret%message)
endif

Python

from pyExt import SystemCouplingParticipant as sysc
surfaceMesh = sysc.SurfaceMesh(...)
...
meshStatus = surfaceMesh.checkMeshValidity()
if meshStatus.isInvalid:
print(meshStatus.message)