-
Notifications
You must be signed in to change notification settings - Fork 261
Kratos input files and IO
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.
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.
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.
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
- link to existing Wiki
Exercise
- write small json setting
- read to Parameters object
- get a value from it
- change a value
without results, only geometry - no need to explain how to add variables or values to the model part...
- Getting Kratos (Last compiled Release)
- Compiling Kratos
- Running an example from GiD
- Kratos input files and I/O
- Data management
- Solving strategies
- Manipulating solution values
- Multiphysics
- Video tutorials
- Style Guide
- Authorship of Kratos files
- Configure .gitignore
- How to configure clang-format
- How to use smart pointer in Kratos
- How to define adjoint elements and response functions
- Visibility and Exposure
- Namespaces and Static Classes
Kratos structure
Conventions
Solvers
Debugging, profiling and testing
- Compiling Kratos in debug mode
- Debugging Kratos using GDB
- Cross-debugging Kratos under Windows
- Debugging Kratos C++ under Windows
- Checking memory usage with Valgind
- Profiling Kratos with MAQAO
- Creating unitary tests
- Using ThreadSanitizer to detect OMP data race bugs
- Debugging Memory with ASAN
HOW TOs
- How to create applications
- Python Tutorials
- Kratos For Dummies (I)
- List of classes and variables accessible via python
- How to use Logger
- How to Create a New Application using cmake
- How to write a JSON configuration file
- How to Access DataBase
- How to use quaternions in Kratos
- How to do Mapping between nonmatching meshes
- How to use Clang-Tidy to automatically correct code
- How to use the Constitutive Law class
- How to use Serialization
- How to use GlobalPointerCommunicator
- How to use PointerMapCommunicator
- How to use the Geometry
- How to use processes for BCs
- How to use Parallel Utilities in futureproofing the code
- Porting to Pybind11 (LEGACY CODE)
- Porting to AMatrix
- How to use Cotire
- Applications: Python-modules
- How to run multiple cases using PyCOMPSs
- How to apply a function to a list of variables
- How to use Kratos Native sparse linear algebra
Utilities
Kratos API
Kratos Structural Mechanics API