generateMesh2D
generateMesh2D overview
generateMesh2D builds a 2D OpenFOAM-ready mesh from three user-controlled
input groups. Geometry defines the contours, fluid_boundaries_parameters controls boundary-level meshing behaviour, and robustMeshDict controls the
global meshing pipeline and export.
| Input | Purpose |
|---|
| constant/geometry/<name>.dat | Closed 2D contours described by point coordinates. |
| constant/fluid_boundaries_parameters | Patch roles, contour resampling, prismatic-layer settings and local boundary controls. |
| system/robustMeshDict | Input paths, pipeline settings, core mesh sizing, local size zones and OpenFOAM export. |
Quick start
For a standard case, place the three input groups in the recommended locations, start
the RobustMesh environment from the case directory, then run generateMesh2D.
$ cd /path/to/myCase
$ RobustMesh010
RobustMesh010> generateMesh2D
The default command reads system/robustMeshDict. Use interactive mode when
you want to inspect intermediate states, rerun individual stages or export temporary
meshes for ParaView and checkMesh.
RobustMesh010> generateMesh2D --interactive
THREE INPUT GROUPS constant/geometry/*.dat defines the contours, constant/fluid_boundaries_parameters defines boundary-level controls, and system/robustMeshDict defines the global mesh-generation workflow.
Recommended case layout
myCase/
├── 0/ # Solver boundary conditions
├── constant/
│ ├── geometry/ # RobustMesh geometry inputs
│ │ ├── boundaries.dat
│ │ └── body.dat
│ ├── fluid_boundaries_parameters # Boundary-level meshing controls
│ └── polyMesh/ # Generated OpenFOAM mesh
└── system/
├── robustMeshDict # Global RobustMesh configuration
├── controlDict # Used by checkMesh / OpenFOAM
├── fvSchemes # Used by checkMesh / OpenFOAM
└── fvSolution # Used by checkMesh / OpenFOAM Paths inside robustMeshDict are interpreted relative to the directory
containing that dictionary. controlDict, fvSchemes and fvSolution are not mesh-generation inputs; they are only required when
the interactive workflow launches checkMesh.
Meshing pipeline
The same pipeline is used in automatic and interactive mode. Interactive mode exposes
the intermediate states without changing the underlying meshing stages.
INPUT FILES
constant/geometry/<name>.dat constant/fluid_boundaries_parameters system/robustMeshDict
↓
CREATE FLUID BOUNDARIES
↓
RESAMPLE
↓
EXTRACT PRISMATIC LAYERS
↓
CORE MESH GENERATION
↓
OPENFOAM EXPORT
↓
OUTPUT constant/polyMesh
Geometry files
Each .dat file contains exactly one closed 2D contour. Each useful line
contains two finite coordinates:
x y
Clockwise outer-boundary example
-2.2 5.0
10.0 5.0
10.0 -5.0
-2.2 -5.0
DO NOT REPEAT THE FIRST POINT Do not repeat the first point on the last line: RobustMesh closes the contour
automatically. A contour must contain at least three points and must not self-intersect.
Empty lines and // ... or /* ... */ comments are accepted.
Domain boundary and fluid orientation
The order of the points tells RobustMesh which side of a contour contains the fluid.
When writing a .dat file by hand, list the points in the order you would
trace the contour with a pen: clockwise for an outer domain, and counter-clockwise for
a solid object inside it.
| Point order | Contour role | Fluid location |
|---|
| Clockwise (CW) | Outer domain boundary | Inside the contour |
| Counter-clockwise (CCW) | Solid obstacle, such as an airfoil, wall or wing element | Outside the contour |
The geometry directory must contain at least one clockwise contour. Without one,
RobustMesh has no domain to fill and stops before generating the mesh. Several
clockwise contours are allowed when the outer domain contains multiple disjoint parts.
IMPORTANT Every .dat file found in the configured geometry directory is treated as
an input contour. Do not leave backup .dat files in the production folder.
fluid_boundaries_parameters
fluid_boundaries_parameters assigns CFD meaning to each contour,
selected points and selected segment ranges. The file must define the two global
default blocks shown
below; it cannot be loaded without them.
Top-level structure
segment_defaults { ... } // required
point_defaults { ... } // required; all three fields must be set
geometry_files { ... } // optional
point_junctions { ... } // optional A geometry omitted from geometry_files inherits the global segment_defaults and point_defaults blocks.
CONTOUR ROLE COMES FROM ORIENTATION There is no hole_of, is_boundary or manual hole-marking key.
RobustMesh identifies outer domains and solid obstacles from contour orientation:
clockwise (CW) for a domain and counter-clockwise (CCW) for an obstacle.
segment_defaults
This block defines the CFD and meshing parameters applied to segments. The global
block is required, but values may be completed or replaced at geometry and segment level.
| Parameter | Type and rules |
|---|
| patch_name | Name token. Accepts any identifier. If omitted globally and everywhere else,
it defaults to the geometry's .dat filename stem. |
| patch_type | Name token. Only wall and patch are accepted. If omitted
globally and everywhere else, it defaults to wall. |
| resample | Boolean. Accepts true or false; an unset value is treated
as false. |
| s_min | Positive float. Required when the effective resample value is true. |
| s_max | Positive float with s_min <= s_max. Required when the effective resample value is true. |
| dtheta_max | Angle in degrees in the range (0, 180]. Required when the effective resample value is true. |
| prismatic_layer_extract | Boolean. Accepts true or false; an unset value is treated
as false. |
| n_layer | Integer greater than or equal to 0. Required when extraction is
enabled. A value of 0 is valid and produces no layers. |
| thickness_first_layer | Positive float. Required when the effective prismatic_layer_extract value is true. |
| expansion_ratio | Float greater than or equal to 1.0. Required when the effective prismatic_layer_extract value is true. |
A segment with patch_type patch always forces resample false and prismatic_layer_extract false, regardless of the configured values.
Use patch for far-field, inlet or outlet segments that need no mesh control.
Use wall whenever resampling or prismatic layers are required.
point_defaults
The global point_defaults block is mandatory and must set all three fields:
point_defaults
{
min_angle_corner 30;
min_angle_concave 45;
min_angle_fan 180;
} Values are expressed in degrees. Use -1 to disable a test. Otherwise, min_angle_corner and min_angle_concave must be in [0, 180], while min_angle_fan must be in [0, 360].
RobustMesh compares each vertex's local turning angle with these thresholds to mark it
as a corner, concave point or fan. These flags determine whether the resampler pins the
point or allows it to move. A fan flag is automatically cleared unless both adjacent
segments use patch_type wall.
segments_overrides
Segment overrides belong to a geometry and target inclusive edge-index ranges in the
original .dat point order, before resampling.
geometry_files
{
airfoil
{
segment_defaults { ... }
segments_overrides
{
(0 0) { patch_name airfoilLeadingEdge; }
(12 20) { prismatic_layer_extract false; }
}
}
} - Edge
k runs from points[k] to points[(k + 1) % n]. (i0 i1) includes both endpoints; (i0) is shorthand for (i0 i0). - Any
segment_defaults field may be set inside an override. Other fields
continue to inherit their effective values. - If ranges overlap, the first range declared in the file wins for the shared edge.
Overlap is not reported as an error.
- Out-of-range indices are accepted while parsing and simply match no edge.
point_overrides
Point overrides are available only inside a geometry and use indices from that
geometry's original .dat file.
geometry_files
{
airfoil
{
point_overrides
{
0 { corner true; }
5 { keep_in_resample true; concave false; }
}
}
} The fields corner, concave and fan replace
angle-based detection for that point. keep_in_resample pins it as a
resampling anchor even when no shape flag is active. corner false cannot
be combined with concave true or fan true, and a point cannot
have both concave true and fan true.
point_junctions
The optional global point_junctions block controls the shape flags created
where two different source geometries intersect or touch and are boolean-unioned.
point_junctions
{
(left middle) { corner true; }
} Each key is an unordered pair of geometry names. Use it to override angle-based
classification at the point where edges from the merged geometries meet.
Precedence
Each field is resolved independently, from highest to lowest priority:
- A matching
segments_overrides range or point_overrides entry. - The geometry's own
segment_defaults or point_defaults. - The global top-level
segment_defaults or point_defaults.
Complete example
segment_defaults
{
patch_type wall;
resample false;
prismatic_layer_extract false;
}
point_defaults
{
min_angle_corner 30;
min_angle_concave 45;
min_angle_fan 180;
}
geometry_files
{
airfoil
{
segment_defaults
{
patch_name airfoilWall;
resample true;
s_min 0.0002;
s_max 0.005;
dtheta_max 15.0;
prismatic_layer_extract true;
n_layer 25;
thickness_first_layer 0.00001;
expansion_ratio 1.12;
}
}
boundaries
{
segment_defaults { patch_type patch; }
segments_overrides
{
(0 0) { patch_name inlet; }
(1 1) { patch_name outlet; }
}
}
} In this example, boundaries.dat must be clockwise and airfoil.dat counter-clockwise. The parameter file does not assign those
roles; the orientation of each geometry does.
robustMeshDict
The main dictionary defines the input paths, near-wall extraction controls, central
triangle mesh sizing and OpenFOAM export settings. It contains six top-level sections. general is optional; the other five sections, including resample, are required.
general
{
verbose true;
}
create_fluid_boundaries
{
verbose true;
path_folder_geometry "../constant/geometry";
path_fluid_boundaries_parameters "../constant/fluid_boundaries_parameters";
}
resample
{
verbose true;
}
extract_prismatic_layer
{
verbose true;
n_ortho_layer 5;
patch_junction_angle 10.0;
gap_factor 1.0;
}
core_mesh_generation
{
verbose true;
core_mesh_type triangle;
triangle_core
{
verbose true;
edge_size_max 0.7;
growth_ratio 1.2;
size_zones
{
near_wake
{
edge_size_max 0.05;
polygon
(
(0.5 -0.5)
(6.0 -0.5)
(6.0 0.5)
(0.5 0.5)
);
}
}
}
}
export_to_openfoam_2d
{
verbose true;
path_of_polyMesh "../constant";
z_length 1.0;
scale 1.0;
front_patch_name front;
back_patch_name back;
} general
This optional section accepts only verbose, a Boolean that defaults to true. Other sections inherit general.verbose when their own
value is omitted. If general is absent, the fallback is true.
create_fluid_boundaries
This section accepts exactly three parameters. All three are optional because each
has a default or inherited value.
| Parameter | Type, default and constraints |
|---|
| verbose | Optional. Boolean. Inherits general.verbose, otherwise defaults to true. Accepted values are true and false. |
| path_folder_geometry | Optional. Path. Defaults to "../constant/geometry". Specifies the
path to the geometry folder. |
| path_fluid_boundaries_parameters | Optional. Path. Defaults to "../constant/fluid_boundaries_parameters". Specifies the path to
the fluid-boundary parameter files. |
ACCEPTED KEYS No other keys are accepted in create_fluid_boundaries.
resample
The resample section is required in robustMeshDict, but all of
its parameters are optional.
| Parameter | Type, default and constraints |
|---|
| verbose | Boolean. Optional. Inherits general.verbose, otherwise defaults to true. |
| best_effort | Boolean. Optional. Defaults to true. If certification fails, keeps
the bounded but uncertified resampling candidate. When set to false,
the original geometry is retained. |
| automatic_fan_resampling | Boolean. Optional. Defaults to true. Enables automatic resampling
around fan points. |
| max_grading_ratio | Float. Optional. Defaults to 1.2. Must be strictly greater than 1.1. Defines the maximum allowed length ratio between two
consecutive resampled edges. |
ACCEPTED KEYS No other keys are accepted in resample.
The extract_prismatic_layer section is required in robustMeshDict. The n_ortho_layer parameter is required; all
other parameters are optional.
| Parameter | Type, default and constraints |
|---|
| verbose | Boolean. Optional. Inherits general.verbose, otherwise defaults to true. |
| n_ortho_layer | Integer. Required. Must be greater than or equal to 1. Defines the
number of near-wall layers that remain orthogonal. |
| patch_junction_angle | Float in degrees. Optional. Defaults to 10. Must be between 0 and 60, inclusive. Defines the maximum allowed
extrusion angle at patch junctions. |
| gap_factor | Float. Optional. Defaults to 1.0. Must be strictly greater than 0.6. Defines the clearance multiplier used when exposed mesh fronts
approach each other. |
| fan_step_deg | Float in degrees. Optional. Defaults to 30. Must be between 10 and 180, inclusive. Defines the maximum angular
spacing between consecutive fan rays. |
ACCEPTED KEYS No other keys are accepted in extract_prismatic_layer.
core_mesh_generation
The core_mesh_generation section is required in robustMeshDict, but all of its parameters are optional.
| Parameter | Type, default and constraints |
|---|
| verbose | Boolean. Optional. Inherits general.verbose, otherwise defaults to true. |
| core_mesh_type | String. Optional. Defaults to triangle. Currently, triangle is the only accepted value. |
| triangle_core | Dictionary. Optional. Contains the parameters used to generate a triangular
core mesh. When omitted, all triangle_core defaults are used. |
ACCEPTED KEYS No other keys are accepted in core_mesh_generation.
triangle_core
| Parameter | Type, default and constraints |
|---|
| verbose | Boolean. Optional. Inherits core_mesh_generation.verbose. |
| edge_size_max | Float. Optional. Defaults to 0.7. Must not be equal to 0. Defines the global maximum edge size of the triangular core mesh.
A negative value disables this global size ceiling. |
| growth_ratio | Float. Optional. Defaults to 1.2. Must be strictly greater than 1.01. Controls how quickly the target edge size may increase away
from the boundaries. |
| size_zones | Dictionary. Optional. Defaults to an empty dictionary. Contains named
polygonal refinement zones that impose local maximum edge sizes. |
ACCEPTED KEYS No other keys are accepted in triangle_core.
size_zones
size_zones may be empty and may contain multiple zones with different
names. Every entry inside size_zones is a user-defined zone name
containing exactly the following parameters.
| Parameter | Type, default and constraints |
|---|
| edge_size_max | Float. Required. Must not be equal to 0. Defines the maximum edge
size inside the zone. A negative value disables the local size ceiling. |
| polygon | List of 2D coordinate pairs. Required. Must contain at least three vertices.
Defines the polygonal boundary of the size zone. Vertices may be provided
clockwise or counter-clockwise. |
ACCEPTED KEYS No other keys are accepted inside a named size zone.
export_to_openfoam_2d
The export_to_openfoam_2d section is required in robustMeshDict, but all of its parameters are optional.
| Parameter | Type, default and constraints |
|---|
| verbose | Boolean. Optional. Inherits general.verbose, otherwise defaults to true. |
| path_of_polyMesh | Path. Optional. Defaults to "../constant". Must be a non-empty path
enclosed in quotes. Relative paths are resolved from the directory containing robustMeshDict. If the path already exists, it must be a directory. |
| z_length | Float. Optional. Defaults to 1.0. Must be strictly greater than 0. Defines the distance between the back and front planes before
scaling. |
| scale | Float. Optional. Defaults to 1.0. Must be strictly greater than 0. Defines the scale factor applied to all exported coordinates. |
| front_patch_name | String. Optional. Defaults to front. Accepts a bare or quoted,
non-empty patch name. Defines the name of the front empty patch. |
| back_patch_name | String. Optional. Defaults to back. Accepts a bare or quoted,
non-empty patch name. Defines the name of the back empty patch. |
ACCEPTED KEYS No other keys are accepted in export_to_openfoam_2d.
Interactive mode
Controls
| Key | Action |
|---|
| N | Next step; on the final screen, write the final OpenFOAM mesh. |
| R | Reload files and rerun the current step. |
| B | Return to the previous step. |
| G | Select a previous state that is still valid. |
| A | Return to the initial screen. |
| E | Export the current state for ParaView inspection. |
| V | Open a state previously exported with E in ParaView. |
| C | Run checkMesh when available for the current state. |
| CC | Run a comprehensive mesh check with checkMesh -allGeometry -allTopol. |
| F | Inspect or reconfigure the OpenFOAM environment. |
| Q | Quit interactive mode. |
In interactive mode, use CC to run a comprehensive mesh check with:
checkMesh -allGeometry -allTopol
Recomputing a step invalidates that step and all states that depend on it. After a
configuration change, rerun from the modified stage before producing the final export.
Validation
ParaView inspection
Check contour placement, requested near-wall layers, leading/trailing-edge resolution,
narrow gaps, mesh-size progression and coverage of refinement zones.
checkMesh
Interactive checkMesh requires a detected OpenFOAM environment, the checkMesh executable, and system/controlDict, system/fvSchemes and system/fvSolution in the case.
$ checkMesh -case /path/to/myCase
Before running a solver, verify the exported patch names and types, map them to the
boundary conditions in 0/, confirm units after scale, and
confirm the 2D front/back setup.
WARNING checkMesh may report concavity errors when very small prismatic layers
are generated. Inspect every cell reported as concave, especially when its edge sizes
are close to 10^-6 m. At this scale, numerical calculations may fall below checkMesh thresholds even when the cells are not necessarily
non-orthogonal.