Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gnikit/gmsh-fpm

Gmsh API using the Fortran Package Manager (fpm)
https://github.com/gnikit/gmsh-fpm

finite-element-mesh fortran fortran-package-manager gmsh mesh mesh-generation

Last synced: about 2 months ago
JSON representation

Gmsh API using the Fortran Package Manager (fpm)

Awesome Lists containing this project

README

        

# gmsh-fpm

![GitHub Release](https://img.shields.io/github/v/release/gnikit/gmsh-fpm?logo=github&label=Release)
[![Examples](https://github.com/gnikit/gmsh-fpm/actions/workflows/examples.yml/badge.svg)](https://github.com/gnikit/gmsh-fpm/actions/workflows/examples.yml)
[![Update API](https://github.com/gnikit/gmsh-fpm/actions/workflows/main.yml/badge.svg)](https://github.com/gnikit/gmsh-fpm/actions/workflows/main.yml)

Adds the [Gmsh](https://gmsh.info/) finite element mesh generator library to the
[Fortran Package Manager (fpm)](https://fpm.fortran-lang.org/en/index.html).

> This repository automatically downloads the Gmsh API every hour from the upstream repo
> .
> Releases are automatically authored based on the upstream repository.

## Features

The repository provides:

- Access to the Fortran F2018 API of Gmsh
- Examples of how to use the Fortran API
- A Fortran compiled executable for Gmsh itself

## Usage

To use `gmsh-fpm` within your fpm project, add the following to your `fpm.toml` file:

Pin to a specific version **(Recommended)**:

```toml
[dependencies]
gmsh = { git="https://github.com/gnikit/gmsh-fpm.git", tag = "4.12.2" }
```

or live at head:

```toml
[dependencies]
gmsh = { git="https://github.com/gnikit/gmsh-fpm.git" }
```

## Build

To build the `gmsh` executable and all the examples, run:

```bash
fpm build --link-flag "-L/path/to/gmsh/lib"
```

or by setting the `FPM_LDFLAGS=-L/path/to/gmsh-sdk/lib` environment variable.

To run any of the examples or the Gmsh executable itself, you need to add the `lib`
directory to the `LD_LIBRARY_PATH`.
You can do that only for `fpm` via:

```bash
export FPM_LDFLAGS="-L/path/to/gmsh/lib -Wl,-rpath,/path/to/gmsh/lib"
fpm run
```

### Running the examples

With `FPM_LDFLAGS` defined as above, normally one can run the examples in the usual way:

```bash
fpm run --example t1
```

If the example requires input files, one will need to change to the
example directory and run the executable from there:

```bash
fpm run --example t13 --runner cp -- example/fortran/; pushd example/fortran/; ./t13; rm t13; popd
```

For the fpm feature request that would simplify the above command see Issue
[#410](https://github.com/fortran-lang/fpm/issues/410).

## Requirements

- `libgmsh.so` or `libgmsh.a`, see [Installing Gmsh](#installing-gmsh)
- A Fortran compiler with F2018 support, [Compiler](#compiler) section

### Installing Gmsh

This `fpm` package requires `libgmsh` to be already installed on your system.
You can download relevant Software Development Kit (SDK) from the [Gmsh website](https://gmsh.info/#Download).

| ❗ Important | Download the same Gmsh SDK version as the one used in `gmsh-fpm` |
| ------------ | ---------------------------------------------------------------- |

For building Gmsh from source, instead of downloading an SDK, checkout the Gmsh
[repository](https://gitlab.onelab.info/gmsh/gmsh) or
[source distributions](https://gmsh.info/src/) and follow the relevant instructions.

### Compiler

The API uses `optional` arguments in C interoperable procedures, a feature available
in the F2018 standard. The following Fortran compilers are known to work:

| Vendor | Compiler |
| --------------------------------------------------------------------------------------------- | -------------- |
| [GNU](https://gcc.gnu.org/wiki/GFortran) | `gfortran` |
| [Intel](https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html) | `ifort`, `ifx` |
| [NAG](https://www.nag.com/) | `nagfor` |