-
Notifications
You must be signed in to change notification settings - Fork 247
Common Python Interface of Applications for Users
See current pull requests:
- https://github.com/KratosMultiphysics/Kratos/pull/2068
- https://github.com/KratosMultiphysics/Kratos/pull/2135
Solving a problem with Kratos is divided into two Python-objects : The AnalysisStage and the PythonSolver.
The PythonSolver
is responsible for everything related to the physics of the problem (e.g. how to setup the system of equations), whereas the AnalysisStage
is related to everything that is not related to the physics (e.g. when and what output to write).
The PythonSolver
is a member of the AnalysisStage
, therefore the AnalysisStage
can be seen as "outer" layer and the PythonSolver
as "inner" layer.
The AnalysisStage
is a python class located in the KratosCore, that serves as a common interface for the applications. The idea is that the applications derive from this object to implement things specific to each application. These derived classes replace the previously used MainKratos.py
. This way the interface to the applications is unified.
Responsibilities of the AnalysisStage
: Basically everything that is not related to the physics of a problem.
Everything related to the physics of the problem is handled by the PythonSolver
(see below)
This includes e.g.
- Managing and calling the
PythonSolver
- Construction and handling of the Processes
- Managing the output (post-processing in GiD/h5, saving restart, ...)
as well as the User Scripting: Formerly the user-scripting was done directly in the MainKratos.py
file. This had the disadvantage that it became outdated with internal updates of Kratos.
Now the intended use is that users derive their scripts from the AnalysisStage
classes in the applications and override the functions in which they want to change/add some self-defined things.
This way the user-scripts are less likely to become outdated since they only override a small portion of the entire class.
The implementation of the AnalysisStage
can be found here. It shall be referred to the implementation for an exact description of what the individual functions are doing, see their docstrings.
The implementation of the PythonSolver
can be found here. It shall be referred to the implementation for an exact description of what the individual functions are doing, see their docstrings.
The responsibility of the PythonSolver
is to solve the physical problem. This also involves the coupling of two or more PythonSolver
s. I.e. and FSISolver
would have a Fluid and a Structural solver as well as the data exchange (mapping) and the coupling logic.
The AnalysisStage
Object is designed to solve an entire Simulation. This means that it sets up the Boundary conditions, IO, reading of the ModelPart and Materials, controlling the time-stepping etc.
It does not know abt how to solve the physical problem. This is the task of the PythonSolver
.
This class implements everything that is related to solve the physical problem, e.g. it constructs Strategy, BuilderAndSolver,... Everything else (e.g. reading the ModelPart) is excluded form the Solver and part of the AnalysisStage.
Furthermore, it knows abt which Variables and DOFs it needs and adds them to the ModelPart It does NOT read the ModelPart, this is task of the AnalysisStage. After the ModelPart is read, the solver might need to perform some operations on it (e.g. create the ComputingModelPart), this is done with PrepareModelPartForSolver.
Note This is a collection of ideas, to be done AFTER AnalysisStage and Solver are implemented in a first version. Please note that the following is in a very early design phase.
In the future the objects presented here can be used in a larger context, e.g. a Multi-Stage Analysis. This means that e.g. a FormFinding Analysis can be performed with doing a FSI-simulation afterwards. The above mentioned objects are already designed for this, e.g. a ModelPart can be passed from outside to the AnalysisStage, this means that it can be used in severals AnalysisStages.
The idea is that in the beginning all AnalysisStages are constructed (i.e. all necessary Variables are added to the ModelPart), then the ModelPart is being read. This can be done e.g. by a global ModelManager. For this to work the Model
has to be enhanced, therefore it should be done later.
This could look like this:
import KratosMultiphysics
##construct all the stages
Model = KratosMultiphysics.Kernel().GetModel() #if we want it to be somewhere else more than fine
list_of_analysis_stages = GenerateStages(Model, "ProjectParameters.json") #internally loads the applications needed
model_manager.Read(list_of_analysis_stages, Model)
for solver in list_of_solvers:
solver.Initialize()
solver.Run()
solver.Finalize()
- 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