v0.15.0
Loading...
Searching...
No Matches
Installation with Spack (Scripts)

We recommend using the scripts provided below to install either the user version or the developer version of MoFEM, using Spack as the package manager.

‍Although we suggest using these scripts for simplicity and consistency, you can also explore other installation methods by visiting Installation with Spack.

User Version

The user version of MoFEM installs only binary files (not source code) and allows you to run analyses immediately. This includes compiled versions of the Basic User Module and the Fracture Module.

To install the user version, follow these steps:

  1. Choose the directory where you want to install MoFEM.
  2. Download the installation script to that directory: installation_ubuntu.sh
  3. (Optional) Make the script executable:
    chmod +x installation_ubuntu.sh
  4. Run the script (you may need sudo privileges):
    ./installation_ubuntu.sh

How to Compile a Program

This tutorial explains how to compile MoFEM. It assumes that you have installed the developer version of MoFEM, either using the instructions in Installation with Docker - JupyterHub or the installation script described in Installation with Spack (Scripts).

After installation, you should have the source code and corresponding binary build directories located as follows:

  • Core Library
    • Source code: $HOME/mofem_install/mofem-cephas/
    • Build directory (for example, for the Release build type): $HOME/mofem_install/mofem-cephas/build-*/core-*

‍The asterisk * in the build path stands for the hash of the particular build, e.g. build-5sehreo/core-Release-5sehreo.

You need to recompile the Core Library whenever you change any source files located in:

$HOME/mofem_install/mofem-cephas/mofem/

There are two main ways to compile: using Spack’s automated process, or manually after the CMake configuration step.

Option 1: Compile using Spack (automated)

If you want Spack to handle the entire compilation process:

spack env activate mofem
spack concretize -f
spack install -v test=root mofem-cephas@0.15.0

This approach detects what needs to be rebuilt and compiles it.

Option 2: Compile manually after CMake configuration

If you prefer to run the build process manually after configuration:

spack env activate mofem
spack concretize -f
spack install -v test=root --until cmake mofem-cephas@0.15.0

Then change to the appropriate build directory and run:

cd $HOME/mofem_install/mofem-cephas/core-build-Release-*
make -j4
ctest -VV
make -j4 install

The -j4 flag means to use four processor threads; you can adjust this depending on your hardware. The ctest -VV command runs the test suite in verbose mode.

Note: If you have several builds of the Core Library (for example, both Debug and Release), make sure to replace the asterisk * in the path with the actual hash corresponding to the build you want to compile. All build directories are located under:

$HOME/mofem_install/mofem-cephas/

How to Add a New Module and Program

This tutorial assumes that you have installed the developer version of MoFEM using either the instructions in Installation with Docker - JupyterHub or the script provided in Installation with Spack (Scripts). You should have the source and binary files (e.g. for the Release build type) for the Core Library and User Modules as follows:

  • Core Library
    • Source code: $HOME/mofem_install/mofem-cephas/
    • Binary files: $HOME/mofem_install/mofem-cephas/core-build-Release-*

‍In build directories described above, symbol * stands for the hash of the particular build, e.g. 5sehreo.

How to Add an Existing Module

To add a MoFEM module that already exists, for example the Basic Finite Elements, follow these steps:

  1. Navigate to the User Modules source directory:
    cd $HOME/mofem_install/mofem-cephas/mofem/users_modules
  2. Clone the Solid Shell Module:
    git clone https://likask@bitbucket.org/mofem/basic_finite_elements.git
  3. Compile code for all modules:
    cd $HOME/mofem_install/mofem-cephas/build-*/core-*/mofem/users_modules/basic_finite_elements
    make -j4 install

‍If you have multiple builds (e.g. Debug and Release), replace the asterisk * with the correct hash for the build you want to recompile.

If everything was successful, the paths for the MoFEM Solid Shell Module should be:

  • Source code: $HOME/mofem_install/mofem-cephas/mofem/users_modules/basic_finite_elements
  • Binary files: $HOME/mofem_install/mofem-cephas/build-*/core-*/mofem/users_modules/basic_finite_elements

How to Create a New Module

To create your own module, the simplest way is to replicate an existing one and modify it. For example, copy the Solid Shell Module and then:

  • Move the copied module to a directory outside your MoFEM installation.
  • Change file and folder names, and update all descriptions.
  • Edit CMakeLists.txt and InstalledAddModule.cmake to reflect your new module name and structure.
  • Remove unnecessary source files.
  • Create a new remote Git repository on GitHub or Bitbucket.
  • Upload your modified module to the repository.
  • Clone and build the module following the same procedure as for an existing module.

‍If you have trouble creating a module, feel free to contact us via MoFEM Q&A.

How to Add a New Program

To add a new program within an existing module, the simplest approach is to copy an existing program and modify it. For example, copy the vec-0 tutorial:

  1. Go to:
    $HOME/mofem_install/mofem-cephas/mofem/tutorials/
  2. Copy the vec-0 program and rename it.
  3. Change filenames and descriptions.
  4. Edit the CMakeLists.txt file to ensure it matches the new program's structure.
  5. Remove unused files.
  6. Build the program:
    cd $HOME/mofem_install/mofem-cephas/build-*/core-*/mofem/tutorials
    make -j4
  7. Your new program will appear in a newly created subdirectory.

‍If you have difficulty creating a program, please contact us at MoFEM Q&A.