Skip to content

Kratos input files and IO

armingeiser edited this page Mar 24, 2019 · 6 revisions

1. Introduction

In the first tutorial you have successfully used Kratos to solve a few simple problems. The GiD preprocessor was used to create the input files for Kratos and the execution was also triggered via the GUI. In this tutorial we will have a closer look at the input files for Kratos and how to create and manipulate them. Also we will use Kratos without GUI but directly from the command line.

The goal of this tutorial is to explain the main IO functionalities in order to prepare for the following tutorials and the more sofisticated usage of Kratos beyond the GUI.

If you did not follow the first tutorial, you can download the input files for a simple structural mechanics case here.

2. The Kratos python script

The main file of a Kratos simulation is a python script. It is responsible to load the required Kratos applications and to call the main Kratos functionalities as desired by the user. As a first task you will create a minimalistic python script that simply loads the Kratos core.

Create a file named e.g. my_python_script.py and write the following line to import the Kratos core module.

import KratosMultiphysics

Use the Kratos command prompt from your Kratos installation, navigate to the folder where your script is located and execute:

kratos my_python_script.py

you should see the following output in the terminal:

 |  /           |
 ' /   __| _` | __|  _ \   __|
 . \  |   (   | |   (   |\__ \
_|\_\_|  \__,_|\__|\___/ ____/
           Multi-Physics 7.0.0
KRATOS TERMINATED CORRECTLY

The MainKratos.py file from the test case is such a python script for Kratos. The name MainKratos.py is a convention for all Kratos analysis, so you can easily identify the main script in any Kratos case you see. In our example a structural mechanics analysis is created and runned. This Kratos python script is the place for user defined - case specific - customizations, as you will see in the next tutorials.

Pro Tip: If you built Kratos yourself and set the paths properly as explained in the Building Kratos section of the Wiki, you can directly use python to execute your script.

3. The Model part file

The .mdpa file contains the model information in Kratos specific syntax. It contains blocks for the nodes, elements and conditions. In addition the mesh entities can be grouped into sub model parts and data values can be assigned to the entities. A detailed description of the syntax is given here.

3.1 Read a model part

The following exercise is a short version of a more detailed tutorial.

A ModelPart has to be created via a Model object, which can contain several ModelParts. The empty ModelPart is then filled using the ModelPartIO that reads the informatison from an .mdpa file.

# Create a Model and an empty ModelPart
this_model = Model()
this_model_part = this_model.CreateModelPart("MyModelPart")


model_part_io = KratosMultiphysics.ModelPartIO("KratosWorkshop2019_high_rise_building_CSM") #path to file without ".mdpa"
model_part_io.ReadModelPart(this_model_part)

Hint: You can >>> print(this_model_part) to see its content.

  • create model part
  • read model part and print it

4. The project parameters file

Syntax

  • link to existing Wiki

Read parameters

Exercise

  • write small json setting
  • read to Parameters object
  • get a value from it
  • change a value

5. Output

without results, only geometry - no need to explain how to add variables or values to the model part...

GiD

VTK

Project information

Getting Started

Tutorials

Developers

Kratos structure

Conventions

Solvers

Debugging, profiling and testing

HOW TOs

Utilities

Kratos API

Kratos Structural Mechanics API

Clone this wiki locally