Acta Polytechnica CTU Proceedings doi:10.14311/APP.2020.26.0107 Acta Polytechnica CTU Proceedings 26:107–111, 2020 © Czech Technical University in Prague, 2020 available online at https://ojs.cvut.cz/ojs/index.php/app MUPIF WORKFLOW EDITOR AND AUTOMATIC CODE GENERATOR Stanislav Šulc∗, Vít Šmilauer, Bořek Patzák Czech Technical University in Prague, Faculty of Civil Engineering, Department of Mechanics, Thákurova 7, 166 29 Prague 6, Czech Republic ∗ corresponding author: stanislav.sulc@fsv.cvut.cz Abstract. Integrating applications or codes into MuPIF API Model enables easy integration of such APIs into any workflow representing complex multiphysical simulation. This concept of MuPIF also enables automatic code generation of the computational code for given workflow structure. This article describes a ’workflow generator’ tool for the code generation together with ’workflow editor’ graphical interface for interactive definition of the workflow structure and the inner data dependencies. The usage is explained on a thermo-mechanical simulation. Keywords: MuPIF, workflow editor, code generator. 1. Introduction Complex physical tasks often need integration of very different models or solvers. Since there exist models solving the particular tasks, it is a very effective ap- proach to connect the existing software tools together to solve the complex tasks. A MuPIF platform [1] is a Python [2] tool for such interconnection of several models together to compute coupled or linked mul- tiphysical simulation. Note that in our terminology a model can be some software, application or code. Each model is covered in a Python API derived from MuPIF class Model, which has the following functions: __init__() # Creates an instance of the class Model. initialize() # Initializes the Model instance for a specific usecase. solveStep() # Solves a computational step with defined length. terminate() # Cleans all resources of the Model instance. set() # Sets inputs of the model, e.g. MuPIF Field or Property. get() # Returns outputs of the model, e.g. MuPIF Field or Property. getCriticalTimeStep() # Returns maximum time step length These seven functions suffice for full control of a basic computation. The communication between models is realized with exchanging instances of MuPIF classes Field or Prop- erty. These instances can be obtained from a model by calling its get() method with appropriate parameters, and can be sent to a model by calling its set() method. Both Field and Property instances keep their values, but they also have attributes describing their type, units and some additional info for unique identifica- tion. Then, a Property can be sent to a Model and the Model decides what to do with it. This concept creates environment for easy interconnection of even completely different codes, which can also be based on different programming languages. The value of a Property is a tuple of any value types. A Field has a tuple of nodal or cell values for each entity, according to the field type, while each value can be a tuple. A Field is always linked with a MuPIF Mesh, which gives the Field space definition, interpolation and portability to tasks with different discretization. Several models together create a workflow, which can be executed or added into another workflow, as it can behave like a model from outer scope, see Fig. 1. The MuPIF class Workflow is derived from class Model and is extended with the following function: solve() # Calls solveStep() until the target time is reached. which solves the whole simulation. A simplified Python code of a simulation with two models can look like this: tm = thermal_model() mm = mechanical_model() tm.initialize(’input_t.in’, ...) mm.initialize(’input_m.in’, ...) while time