Published April 3, 2026 | Version v1.0.2

MATLAB-based OpenFOAM mesh and data dictionary generator

  • 1. ROR icon University of Neuchâtel

Description

Code description

This repository contains a set of MATLAB scripts designed to generate the blockMeshDict file required for the OpenFOAM mesh generation utility blockMesh, along with additional mesh-related dictionaries (e.g., topoSetDict, refineMeshDict and createPatchDict) and input data files (e.g., setFieldsDict) associated with the resulting 3D structured mesh.

The developed MATLAB scripts are organized in the following directories:

+ mesh_and_data_dicts:

  • mesh_and_data_dicts.m: main script for the generation of geometric-based OpenFOAM dictionaries.
  • _externalFunctions: contains standard MATLAB functions.
  • _myFunctions: includes newly implemented functions designed to be used together with mesh_and_data_dicts.m.

To run the code, the user must define:

  • an input directory for all the data files required to generate the mesh and input data OpenFOAM dictionaries (default: input_files).
  • an output directory for the MATLAB-generated OpenFOAM dictionaries (default: output_files).

+ inletOutlet_yc_and_yn:

  • Froude_no_yc.m: supplementary script of mesh_and_data_dicts.m that determines the critical flow depth (yc, m) of a user-specified channel cross-section based on the Froude number (Fr). Additionally, it calculates various geometric variables (e.g., flow area (A, m2), wetted perimeter (P, m)) and flow parameters (e.g., total pressure (p0, Pa), velocity (U, m/s)) using yc.
  • Manning_eqn_yn.m: supplementary script of mesh_and_data_dicts.m that computes the normal flow depth (yn, m) of a user-specified channel cross-section using Manning's equation. Similarly to Froude_no_yc.m, it also calculates various geometric variables and flow parameters using yn.

Analogously to mesh_and_data_dicts, an output directory must be specified for the resulting p0 and/or U profiles, if exported (default: output_profiles).

This approach streamlines the OpenFOAM case preparation, allowing for quicker and more efficient mesh configurations, customizations and initial condition setups. Further description of the different actions enabled by the newly implemented scripts and their related output files is provided in the OpenFOAM_dict_generator.pdf file.

Files

OpenFOAM_dict_generator-v1.0.zip

Files (783.9 kB)

Name Size Download all
md5:473776f1f24d4c6c6a94ecba0e15e46c
783.9 kB Preview Download

Additional details

Related works

Funding

European Commission
ENIGMA - European training Network for In situ imaGing of dynaMic processes in heterogeneous subsurfAce environments 722028

Software

Repository URL
https://github.com/alvpardo/OpenFOAM_dict_generator
Programming language
MATLAB
Development Status
Active