View on GitHub

CoSimIO

Small standalone tool for interprocess communication in CoSimulation contexts for coupling and exchanging data between different solvers or other software-tools.

Tutorial for performing coupled simulations with the remote control approach

Main Page of Documentation

Table of Contents


This tutorial shows how to perform coupled simulations with the Kratos CoSimulationApplication using the remoted control approach. This means that the coupling sequence is not implemented in the application side, only functions that are required for CoSimulation are defined by the application and registered in the CoSimIO. See here for more details on the different approaches.

Note that this page shows the Kratos side, please refer to the corresponding tutorials for the application side, depending on the language.

Setup

The following setup is used:

Input files for Kratos

Kratos requires 2 input files (see the README):

Aside from the input files, we need two more files in order to integrate the solver into the CoSimulationApplication:

The SolverWrapper

Before setting up the configuration file we need to create the SolverWrapper for our solver such that it can be used in the CoSimulationApplication workflow.

Based on our setup from above, we can directly use the RemoteControlledSolverWrapper.py which implements the functionalities that we need:

The ProjectParameters file

The configuration file for a basic FSI example can be found here. For our example we will arrive to a very similar setup, we only need to modify the solvers section in the solver_settings.

There we need to use the SolverWrapper which we implemented before. In this case the RemoteControlledSolverWrapper is being used for both solvers, i.e. the type is "solver_wrappers.external.remote_controlled_solver_wrapper"

In the data section we have to specify the fields that are being used. E.g. field_A and field_B as well as the meshes they belong to:

"data" : { // definition of interfaces used in the simulation
    "field_A" : {
        "model_part_name" : "mesh_1",
        "variable_name" : "MESH_DISPLACEMENT"
    },
    "field_B" : {
        "model_part_name" : "mesh_1",
        "variable_name" : "REACTION"
    }
}

The solver_wrapper_settings contain the following settings:

"solver_wrapper_settings" : {
    "import_meshes" : ["mesh_1"],
    "import_data"   : ["field_A"],
    "export_data"   : ["field_B"]
}

Each of them has to be set to the data that should be used in the coupling.

Lastly the io_settings have to be specified. Since we use the CoSimIO, we can use the already existing kratos_co_sim_io

"io_settings" : {
    "type" : "kratos_co_sim_io"
}

This completes the setup of one of the solvers:

"solver_s" : {
    "type" : "solver_wrappers.external.remote_controlled_solver_wrapper",
    "data" : {
        "field_A" : {
            "model_part_name" : "mesh_1",
            "variable_name" : "MESH_DISPLACEMENT"
        },
        "field_B" : {
            "model_part_name" : "mesh_1",
            "variable_name" : "REACTION"
        }
    }
    "solver_wrapper_settings" : {
        "import_meshes" : ["mesh_1"],
        "import_data"   : ["field_A"],
        "export_data"   : ["field_B"]
    }
    "io_settings" : {
        "type" : "kratos_co_sim_io"
    }
}

On the application side the functions required for CoSimulation have to be registered. Check the small test for the syntax.

Now the Kratos side is ready to perform coupled simulations.