Since pMesh does not support 2D meshes, here is a workflow for 2D polyhedral meshes.
Start with a *.stl
file of your domain
Generated with external software
Exported from OpenFOAM from a hexahedral blockMesh (useful for simple geometries, e.g. rectangular domains)
Utility to export a surface *.stl file:
?> foamToSurface -tri surfaceMesh.stl
Convert the *.stl
to *.fms
?> surfaceToFMS surfaceMesh.stl
and optionally edit the patch names in the *.fms
file.
Edit the system/meshDict file
Adapt the maximum cell size in m to your domain size and generate boundary layers for the “empty” patches
// mandatory settings
// - relative or absolute
surfaceFile "surfaceMesh.fms";
// - maximum cell size
maxCellSize 0.014;
// optional global options
// - refinement of cells at the boundaries
boundaryCellSize 0.014;
boundaryCellSizeRefinementThickness 0.014;
// - performs refinement where cells are larger than feature size
minCellSize 0.014;
boundaryLayers
{
// global options in dictionary (optional)
// - number of layers
nLayers 2;
// - thicknes ratio
thicknessRatio 1.1;
// - maximum thickness of first layer [m]
maxFirstLayerThickness 0.014;
// local settings
patchBoundaryLayers
{
"front.*"
{
// - number of layers (optional)
nLayers 2;
// - thickness ratio (optional)
thicknessRatio 1.1;
// - max thickness of first layer (optional) [m]
maxFirstLayerThickness 0.1;
// - active of inactive
allowDiscontinuity 0;
}
"back.*"
{
// - number of layers (optional)
nLayers 2;
// - thickness ratio (optional)
thicknessRatio 1.1;
// - max thickness of first layer (optional) [m]
maxFirstLayerThickness 0.1;
// - active of inactive
allowDiscontinuity 0;
}
}
optimiseLayer 1;
optimisationParameters
{
featureSizeFactor 0.3;
nSmoothNormals 20;
maxNumIterations 20;
reCalculateNormals 1;
relThicknessTol 0.01;
}
}
Generate the mesh with pMesh
Edit the system/extrudeMeshDict to extrude a 2D mesh from an empty patch
constructFrom patch;
// If construct from patch/mesh:
sourceCase "../meshTrg";
sourcePatches (front);
// If construct from patch: patch to use for back (can be same as sourcePatch)
exposedPatchName front;
// If construct from surface:
//surface "movingWall.stl";
// Flip surface normals before usage. Valid only for extrude from surface or
// patch.
flipNormals false;
// Linear extrusion in point-normal direction
extrudeModel linearNormal;
nLayers 1;
expansionRatio 1.0;
linearNormalCoeffs
{
thickness 0.06;
}
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces false;
// Merge small edges. Fraction of bounding box.
mergeTol 0;
Extrude the mesh
?> extrudeMesh
To obtain good polyhedral boundary faces it is sometimes useful to rotate the domain by 45° before pMesh is executed.
E.g. before exporting the surface file in step 1.b. execute
?> transformPoints -rotate-angle '((1 0 0) 45)'
and rotate the domain back before step 6.
?> transformPoints -rotate-angle '((1 0 0) -45)'