This document gives an overview of the CMake infrastructure of the MFrontGallery and MFrontMaterials projects.

This infrastructure is fully contained in the cmake/modules directory, the file cmake/modules/mfm.cmake being the main entry point.

Section 1 describes the main cmake functions provided by this infrastructure from the point of view of the maintainer and developper of a material knowledge management project. It mostly convers:

Section ¿sec:mfm:cmake:cmake_modules? describes the contents of the cmake/modules directory.

1 Main functions

1.1 The mfront_properties_library function

The mfront_behaviours_library function adds shared libraries to the project related to MFront’ behaviours. The number of added shared libraries depends on the number of (material properties) interfaces selected when the project is configured (see the install page for details).

1.1.1 Usage

The following example shows how to create libraries associated with a material called VanadiumAlloy from a single MFront source file named VanadiumAlloy_YoungModulus_SRMA.mfront:

mfront_properties_library(VanadiumAlloy
  VanadiumAlloy_YoungModulus_SRMA)

Note that the .mfront suffix has been omitted in this declaration.

Internally, the mfront_properties_library function forward is arguments to the parse_mfront_library_sources function and use its results to add the shared libraries properly. See Section 1.3 for the available options.

The output generated by this function during the cmake configuration process is similar to the following:

-- Treating interface cyrano
-- Adding library : VanadiumAlloyMaterialProperties-cyrano (/home/th202608/codes/MFrontGallery/master/src/build/materials/VanadiumAlloy/properties/cyrano/src/VanadiumAlloy_YoungModulus_SRMA-mfront.cxx)
-- Treating interface castem
-- Adding library : VanadiumAlloyMaterialProperties-castem (/home/th202608/codes/MFrontGallery/master/src/build/materials/VanadiumAlloy/properties/castem/src/VanadiumAlloy_YoungModulus_SRMA-mfront.cxx)
....

which lists the shared libraries that will be compiled and the sources that will be generated by MFront. One may notice that each shared library is compiled in its own directory.

Internally, the mfront_properties_library relies on the mfront-query to get the list generated sources and handle dependencies to other MFront files and so on.

Regarding dependencies to other MFront files, the current directory ${CMAKE_SOURCE_DIR}/materials/${mat}/properties is automatically added to the MFront search paths, where:

Other search paths can be added by using any of the options SEARCH_PATH or SEARCH_PATHS, as described in Section 1.3.

1.2 The mfront_behaviours_library function

The mfront_behaviours_library function adds shared libraries to the project related to MFront’ behaviours. The number of added shared libraries depends on the number of (behaviour) interfaces selected when the project is configured (see the install page for details).

1.2.1 Usage

A typical usage of the mfront_behaviours_library is the following:

mfront_behaviours_library(Concrete
  ConcreteBurger_EDF_CIWAP_2021
  ConcreteBurger_EDF_CIWAP_2021_v2)

which declares a set of shared libraries associated with the Concrete material. Those shared libraries are generated using two MFront files named respectively ConcreteBurger_EDF_CIWAP_2021.mfront and ConcreteBurger_EDF_CIWAP_2021_v2.mfront (See Section 1.2.2 for details).

Note that the .mfront suffix has been omitted in this declaration.

-- ConcreteBurger_EDF_CIWAP_2021 has been discarded for interface calculix (behaviours with external state variable other  than the temperature are not supported)
-- ConcreteBurger_EDF_CIWAP_2021_v2 has been discarded for interface calculix (behaviours with external state variable other  than the temperature are not supported)
-- No sources selected for library CONCRETECALCULIXBEHAVIOURS for interface calculix
-- ConcreteBurger_EDF_CIWAP_2021 has been discarded for interface ansys (behaviours with external state variable other  than the temperature are not supported)
-- ConcreteBurger_EDF_CIWAP_2021_v2 has been discarded for interface ansys (behaviours with external state variable other  than the temperature are not supported)
-- No sources selected for library CONCRETEANSYSBEHAVIOURS for interface ansys
-- Adding library : CONCRETEABAQUSBEHAVIOURS (/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/abaqus/src/abaqusConcreteBurger_EDF_CIWAP_2021.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/abaqus/src/ConcreteBurger_EDF_CIWAP_2021.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/abaqus/src/abaqusConcreteBurger_EDF_CIWAP_2021_v2.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/abaqus/src/ConcreteBurger_EDF_CIWAP_2021_v2.cxx)
-- Adding library : ConcreteBehaviours-cyrano (/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/cyrano/src/cyranoConcreteBurger_EDF_CIWAP_2021.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/cyrano/src/ConcreteBurger_EDF_CIWAP_2021.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/cyrano/src/cyranoConcreteBurger_EDF_CIWAP_2021_v2.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/cyrano/src/ConcreteBurger_EDF_CIWAP_2021_v2.cxx)
-- ConcreteBurger_EDF_CIWAP_2021 has been discarded for interface epx (small strain behaviours are not supported)
-- ConcreteBurger_EDF_CIWAP_2021_v2 has been discarded for interface epx (small strain behaviours are not supported)
-- No sources selected for library ConcreteBehaviours-epx for interface epx
-- ConcreteBurger_EDF_CIWAP_2021 has been discarded for interface dianafea (behaviours with external state variable other  than the temperature are not supported)
-- ConcreteBurger_EDF_CIWAP_2021_v2 has been discarded for interface dianafea (behaviours with external state variable other  than the temperature are not supported)
-- No sources selected for library ConcreteDianaFEABehaviours for interface dianafea
-- Adding library : ConcreteBehaviours-aster (/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/aster/src/asterConcreteBurger_EDF_CIWAP_2021.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/aster/src/ConcreteBurger_EDF_CIWAP_2021.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/aster/src/asterConcreteBurger_EDF_CIWAP_2021_v2.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/aster/src/ConcreteBurger_EDF_CIWAP_2021_v2.cxx)
-- Adding library : ConcreteBehaviours (/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/castem/src/umatConcreteBurger_EDF_CIWAP_2021.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/castem/src/ConcreteBurger_EDF_CIWAP_2021.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/castem/src/umatConcreteBurger_EDF_CIWAP_2021_v2.cxx;/home/th202608/codes/MFrontGallery/master/src/build/materials/Concrete/behaviours/castem/src/ConcreteBurger_EDF_CIWAP_2021_v2.cxx)
....

which lists the shared libraries that will be compiled and the sources that will be generated by MFront. One may notice that each shared library is compiled in its own directory.

One may also notice that the behaviours considered are not compatible with some of the selected behaviour interfaces and are thus discarded:

In this example, no shared libraries for the Concrete material will be generated for the interfaces dianafea, calculix, ansys and epx interfaces since no MFront are compatible with them.

Internally, the mfront_behaviours_library function forward is arguments to the parse_mfront_library_sources function and use its results to add the shared libraries properly. See Section 1.3 for the available options.

1.2.2 Treatment of the sources

For each shared library to be added, each source returned in the mfront_sources variable by the parse_mfront_library_sources is treated as follows:

MFront source files are treated by:

1.3 The parse_mfront_library_sources function

The parse_mfront_library_sources function set the following variables on output:

The parse_mfront_library_sources function allows the following options:

1.4.1 The add_mtest function (defined in behaviours.cmake)

The add_mtest function allows to declare a test on behaviours based on the MTest solver. The add_mtest function is used by wrappers such as genericmtest (for tests associated with the generic interface) or castemmest (for tests associated with the Cast3M interface) and not used directly (see below).

This function takes two mandatory arguments:

This function may take optional arguments introduced by the following keywords:

Several test names and several MTest scripts can be declared through the TEST_NAME and MTEST_FILE keywords respectively. The number of test names must match the number of scripts.

A script is generally run several times with different rounding modes (see the MTest documentation for details).

1.4.2 Wrappers around the add_mtest functions

The add_mtest function does not check if the interface used by the test has been selected and is not able to deduce the name of the library associated with an interface from the name of a material (Bentonite for instance) or the name of the class of behaviours considered (Plasticity for instance).

MFrontGallery thus provides several wrappers, such as: castemmtest, astermtest, europlexusmtest abaqusmtest, abaqusexplicitmtest, ansysmtest, calculixmtest dianafeamtest, cyranomtest and genericmtest.

For instance, one can call the castemmtest function even if the Cast3M interface for behaviours has not been selected: in this case, the associated test is just not declared.

1.4.2.1 Example of usage

The following code declares a test based on the asteriwan.mtest script if the aster interface has been selected:

mfront_behaviours_library(Plasticity
  ${MFRONT_BEHAVIOURS_PLASTICITY_SOURCES})

astermtest(Plasticity asteriwan)

1.5 The pandoc_html function

The pandoc_html function can be used to generate an html page from a markdow file using pandoc. This function takes the name of a markdown file a argument. All the other options are passed verbatim to pandoc.

The following options are automatically passed to pandoc:

1.5.1 HTML template

If a file named mfm-template.html is found in the directory docs/web (from the root of the sources of the project), this file is used as a template for generating the web pages (see pandoc’s --template option).

1.5.2 Bibliography

If a biblatex file named bibliography.bib is found in the directory docs/web (from the root of the sources of the project), the generation of a bibliography is automatically enabled (see pandoc’s --bibliography option).

1.5.3 Citation Style Language (CSL) file

If a file named iso690-numeric-en.csl is found in the directory docs/web (from the root of the sources of the project), this file is used to define the reference style used (see pandoc’s --csl option).