How to create a new application

From KratosWiki
Jump to: navigation, search

KratosMultiphysics provides an utility to create new application and add them to the source easily. This script is located in kratos/python_scripts/application_generator

To create a new application using the generator you must create a python file that contains the information about your app. the script must follow this skeleton:

#file: exampleWiki.py
import sys

from classes.variableCreator import VariableCreator

from applicationGenerator import ApplicationGenerator

# Read the application name and generate Camel, Caps and Low
appNameCamel = sys.argv[1]

# Fetch the applications directory
exampleApp = ApplicationGenerator(appNameCamel)

# Add KratosVariables
exampleApp.AddVariables([
    VariableCreator(name='1DVariable', vtype='double'),
    VariableCreator(name='3DVariable', vtype='int', is3D=True),
])

exampleApp.Generate()

print("Your application has been generated in: applications/{}Application".format(appNameCamel))

Once the file is created just call it with the name of your application in cammelCase ( do not add the word "application", the generator will handle this)

python exampleWiki.py Test

Once it finish correctly, it will:

  • Generate a new "TestApplication" under kratos/applications
  • Add the application to the interface in "kratos/applications/application_interface.py"
  • Add the application to the compile list in "kratos/applications/CMakeList.txt"

To compile your application, just add:

-DYOURAPPNAME=ON

In the configure.


The generator also has support to automatically initialize you application with some common elements in Kratos, which will be extended in the future. Currently it supports:

  • Adding 1D variables
  • Adding 3D variables

Yo can find a more complete example with some of the upcoming features in the application_generator folder.

Personal tools
Categories