How to Create New Application
Three are the basic steps you have to follow to create your own kratos application.
Contents |
1. Use the TESTAPPLICATION.zip files to create your standard directories
You can file a model for the structure of your application inside the TestApplication.zip file. You just have to take care to change the name of your application in the files it appears in and to start inserting your own elements, utilities etc. like in a standard, already existing application.
We created a simple linux script to make automatic the name change (see lines below).
In order to use the script follow the following steps
- download and extract the TestApplication.zip file into a temporary directory (say /home/username/temp)
- download and extract the script Prepare.sh.zip into the same directory
- extract the zip files
- edit the file "prepare.sh" and select the name you want to provide. You need to provide lowercase,uppercase and mixed versions of the name
- launch the ".sh" file by typing "sh prepare.sh" at the command line
- copy the modified application directory in "kratos/applications"
- compile and go!
understanding what is automatically performed
In order to understand what is done by the automatic script, we should consider that the following operations are needed to change the name:
If your new application name is newname you have firstly to change the name of the following files:
test_application.h ----> newname_application.h test_application.cpp ----> newname_application.cpp test_python_application.cpp ----> newname_python_application.cpp
Then you have to look inside the following files: test_application.h test_application.cpp test_python_application.cpp
and perform the following substitutions:
KRATOS_TEST_APPLICATION_H_INCLUDED ----> KRATOS_NEWNAME_APPLICATION_H_INCLUDED
KratosTestApplication ----> KratosNewNameApplication
#include test_application.h ----> #include newname_application.h
and in the jamfile
test_application.cpp ----> newname_application.cpp
test_python_application.cpp ----> newname_python_application.cpp
2. Modify the APPLICATION_INTERFACE.PY
You have to insert your application in the application_interface.py file that you find in /kratos/applications/
import sys ... Import_NewNameApplication = False print "Applications Available:" ... print "Import_NewNameApplication: False"
def ImportApplications(kernel, applications_path): ########################################################################## ##importing the applications print "Applications Available:" ... print "Import_NewNameApplication: "+str(Import_NewNameApplication)
if(Import_NewNameApplication == True): print "importing KratosNewNameApplication ..." sys.path.append(applications_path + '/NewNameApplication/python_scripts') from KratosNewNameApplication import * newname_application = KratosNewNameApplication() kernel.AddApplication(newname_application) print "Kratos NewNameApplication1 sucessfully imported"
##dynamic renumbering of variables to ensure the consistency kernel.Initialize() ... if(Import_NewNameApplication == True): kernel.InitializeApplication(newname_application);
3. Modify the JAMROOT
Remember to add your application to the Jamroot making kratos to include it
##applications included in the compilation use-project /kratos-prj/NewNameApplication : $(TOP)/applications/NewNameApplication ;
and to install it
## installation alias install :
/kratos-prj/NewNameApplication//install ;