Skip to content

Applications as python modules

Philipp Bucher edited this page Dec 3, 2018 · 8 revisions

https://github.com/KratosMultiphysics/Kratos/pull/3217/ enables the applications can be used as python-modules This requires the following adaptations: (using the StructuralMechanicsApplicaiton as example). Only two files have to be modified.

  1. Moving the StructuralMechanicsApplication.py from the root-folder into python_scripts and renaming to __init__.py

  2. In this file add a second dot . for importing the application_importer:

    • from: from . import application_importer
    • to: from .. import application_importer
  3. Also in this file, add the __path__ to the call of ImportApplication:

    • from: application_importer.ImportApplication(application,application_name,application_folder,caller)
    • to: application_importer.ImportApplication(application,application_name,application_folder,caller, __path__)
  4. In CMakeLists.txt: Change the location where the __init__.py (formerly StructuralMechanicsApplication.py) is being installed to:

    • from: install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/StructuralMechanicsApplication.py" DESTINATION KratosMultiphysics )
    • to install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/python_scripts/__init__.py" DESTINATION "KratosMultiphysics/StructuralMechanicsApplication")

This results in the following structure in the KratosMultiphysics-Folder: previously:file:///home/philippb/Pictures/Screenshot%20from%202018-12-03%2013-42-20.png

new:

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