-
Notifications
You must be signed in to change notification settings - Fork 247
How to Create a New Application using cmake
This method is outdated. Please go to https://github.com/KratosMultiphysics/Kratos/wiki/Creating-a-base-application for the newer version of creating a new application.
Using Cmake the creation of new application is a straightforward task. As an example we will create here an app that is empty.
- Downloading the 'TESTAPPLICATION.zip files to create your standard directories
- Modifying and renaming the test_files into the desired name
- Editing other files to include the test application
- Importing the new application from the scripts ( .py files)
You can find a model for the structure of your application inside the Test_application.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.
To begin with uncompress this folder into the applications folder. Inside of it you will find the following main parts:
- TestApplication.py : This file will be copied later to the KratosMultyphisics folder so that the application can be run when called in the script of your problem.
- TestApplication.cpp and TestApplication.h plus several folders including the utilities, elements, etc.
- cMakeLists.txt : Here you must include the source files that you want to be compiled.
The next step is telling Kratos that we want to include and compile this 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_cmake.sh.zip into the same directory
- Extract the zip files
- Edit the file "prepare_cmake.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_cmake.sh" at the command line (under Windows you can use the Subsystem for Linux)
- Copy the modified application directory in "kratos/applications"
- Compile and go!
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 CMakeLists.txt
KRATOS_TEST_APPLICATION_SOURCES ----> #KRATOS_NEWNAME_APPLICATION_SOURCES
test_application.cpp ----> newname_application.cpp
test_python_application.cpp ----> newname_python_application.cpp
TestApplication.py ----> NewNameApplication.py
To begin with me must include the folder we have just created so that it can be compiled: in the first line, next to the other messages we add:
message("TEST_APPLICATION.....................${TEST_APPLICATION}")
and scrolling a bit below we add the new directory:
if(${TEST_APPLICATION} MATCHES ON)
add_subdirectory(test_application)
endif(${TEST_APPLICATION} MATCHES ON)
Finally you have to edit your .sh file (the one that was example_configure.sh.do_not_touch) so that your application is compiled too.
to do so, simply add the line:
-DTEST_APPLICATION=ON \
among the other applications and you are ready. The new application should be compiled.
NOTE: It is important that the last thing on the line must be the \ . If you add spaces or other characters cmake will not be able to read the file correctly.
To do so, if the Kratos path was set correctly, you only need to import KratosMultyphisics and then the test app:
#including kratos path
from KratosMultiphysics import *
from KratosMultiphysics.TestApplication import *
#and any other apps that you need to help solving your problem
- 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