|
Documentation for OpenFLUID
2.2.2
|
When working on several simulators, it often appears that parts are redundant between them. These identical codes can become a problem when a change is required, it has to be done in each simulator, which generates a real risk of discrepency.
For now, OpenFLUID environment support simple fragments with two constraints:
The current handling of fragments is sufficient for many use cases, such as:
Example of simulator structure including a fragment:
Source files import are slightly different when using a fragment, compilation system triggered by the user knows the location src/fragments/ and syntax such as #include <fragmentName/myCommonFunctions.hpp> can be used.
To add a new fragment or import one from a distant repository, right-click on the simulator and chose the wanted action in the "add fragment" submenu. If you want to add an existing fragment, you will then be able to add it from a Hub or from a direct git repository.
It is also possible to remove a submodule by doing a right-click on the targetted fragment and select the "remove fragment" option.
For operations such as:
To be able to create and share a code fragment between simulators, you can create its repository on a remote location (ask a FLUIDhub admin if you want to host the fragment on the instance, it will be stored as other "Wares"). If you create the fragment as part of a ware in DevStudio, it will give the option of generating default files such as metadata and README (see appendix for example of a fragment metadata file).
openfluid-fragment.json file should be added at root directory of the fragment to describe useful information, especially the field openfluid-components in fragment sub-dictionary to inform the simulator developer to add any required OpenFLUID components to ware CMakeLists.txt file.src/fragments/MyHydroFunctions/HydroFuncs.hpp: these function will then be usable in the simulator code as follows:
To solve these cases, we decided to use a git feature named Submodule that allows us to encapsulate this common code in a dedicated location with its own versioning history. This feature fits well our existing use of git as versioning control system and it can be integrated in our existing workflows.
openfluid-fragment.json file follows same structure than usual ware metadata file openfluid-ware.json (excepted the fragment block):