How to create a new component

In this tutorial we will show how to add a simple box-shaped object into the tungsten wheel of the ESS geometry

Everything you need to do is illustrated in this commit: #56dcbe0:

  1. Create the class header and implementation files:
  2. Declare your component in Model/essBuildInc/makeESS.h
  3. Create it in Model/essBuild/makeESS.cxx and define intersections with the other objects in the model.
  4. Define the variables of your component in Model/essBuild/essVariables.cxx (or more appropriate place depending on the component you are developing).

The first step can be done either manually or with the help of the cl-paster script. In our example the MyClass.h and MyClass.cxx files were generated by running

cl-paster -model essBuild -namespace essSystem -m "Description" MyClass

Add a variable

Now let's add a variable called mainTemp into our new model. What you need to do is illustrated in  #f0a58d2:

When you add many variables, these modifications can be time consuming and error-prone. Therefore you can choose to do the first two steps with the cl-add-variable script:

cl-add-variable -model essBuild -class MyClass -var mainTemp -type double -comment "main temperature" -name "MainTemp" -after mainMat

Note: this script supports the source code style generated by cl-paster, therefore you might have to do minor edits of the style of your code.

Update CMakeLists.txt

Add new files into corresponding CMakeLists.txt to include them into the build system.

Recompile

Since we have added new files in our model, we need to run cmake before recompiling, so that make is aware about these new files:

cmake .
make -j$(nproc)