Before discussing what each kind of plugin actually has to implement (see the next subsection), let us briefly go over what you actually have to do when implementing a new plugin. Essentially, the following steps are all you need to do:
As discussed above, it is possible – but not necessary – to split this file into two: a header file, say my_plugin.h, and the my_plugin.cc file (or, if you prefer, into multiple source files). We do this for all the existing plugins in ASPECT so that the documentation of these plugins shows up in the doxygen-generated documentation. However, for your own plugins, there is typically no need for this split. The only occasion where this would be useful is if some plugin actually makes use of a different plugin (e.g., the implementation of a gravity model of your own may want to query some specifics of a geometry model you also implemented); in that case the using plugin needs to be able to see the declaration of the class of the used plugin, and for this you will need to put the declaration of the latter into a header file.
on Linux, but the command may be different on other systems. Now you only need to tell ASPECT to load this shared library at startup so that the plugin becomes available at run time and can be selected from the input parameter file. This is done using the Additional shared libraries parameter in the input file, see Section ??. This approach has the upside that you can keep all files that define new plugins in your own directories where you also run the simulations, also making it easier to keep around your plugins as you upgrade your ASPECT installation. On the other hand, compiling the file into a shared library is a bit more that you need to do yourself. Nevertheless, this is the preferred approach.
In practice, the compiler line above can become tedious because it includes paths to the ASPECT and deal.II header files, but possibly also other things such as Trilinos headers, etc. Having to remember all of these pieces is a hassle, and a much easier way is in fact to set up a mini-CMake project for this. To this end, simply copy the file doc/plugin-_CMakeLists.txt to the directory where you have your plugin source files and rename it to CMakeLists.txt.
You can then just run the commands
and it should compile your plugin files into a shared library my_plugin.so. A concrete example of this process is discussed in Section 5.4.1. Of course, you may want to choose different names for the source files source_1.cc, source_2.cc or the name of the plugin my_plugin.
In essence, what these few lines do is that they find an ASPECT installation (i.e., the directory where you configured and compiled it, which may be the same directory as where you keep your sources, or a different one, as discussed in Section 3) in either the directory explicitly specified in the Aspect_DIR variable passed to cmake, the shell environment variable ASPECT_DIR, or just one directory up. It then sets up compiler paths and similar, and the following lines simply define the name of a plugin, list the source files for it, and define everything that’s necessary to compile them into a shared library. Calling make on the command line then simply compiles everything.