Open-source CFD toolbox: OpenFOAM is now a mature open-source CFD program with reliability matching that of commercial products. This page describes summary of utilities and dictionaries used in OpenFOAM meshing and visualization such as (blockMesh, snappyHexMesh, ParaView) and OpenFOAM CFD codes and pre-processors such as (simpleFoam, pimpleFoam, engineFoam...).
runApplication blockMesh \cp system/decomposeParDict.hierarchical system/decomposeParDict runApplication decomposePar \cp system/decomposeParDict.ptscotch system/decomposeParDict runParallel snappyHexMesh -overwrite find . -type f -iname "*level*" -exec rm {} \; # - set the initial fields restore0Dir -processor runParallel topoSet runParallel $(getApplication) runApplication reconstructParMesh -constant runApplication reconstructParHowever, if one does not want to run parallel version (using more than 1 processor), simply use blockMesh and then snappyHexMesh on the command prompt to get the desired mesh, thus skipping the utilities decomposePar, reconstructParMesh and reconstructPar.
The properties of fluid defied in constant/thermophysicalProperties:
thermoType hThermo<pureMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>>;The meaning of each term is as follows:
No blockMeshDict available in tutorial folder. polyMesh data available for simulation. Typically, the information is provided in utility file Allrun. If there is no mention of mesh in this file, there is not one. For example, in problem case 'flange' under laplacianFoam, there is neither blockMeshDict nor polyMesh. But there is a file 'flange.ans'. Inside 'Allrun' it is explained that flange.ans is ANSYS file.
This is one of the test cases described in user guide. There are two simulation cases - they differ mainly between the turbulence model used and the way input boundary conditions are specified. "pitzDailyExptInlet" demonstrate how to interpolate or apply non-uniform boundary conditions at the inlet. The differences in U sub-dictionaries are shown below.
wmakeLnInclude: linking include files to ./lnInclude ln: creating symbolic link './codeStreamTemplate.C': Protocol error Making dependency list for source file codeStreamTemplate.C Creating new library in "dynamicCode/_9273df81ebe52476e105ce9128b702a57ad95417/platforms/ linux64GccDPInt32Opt/lib/libcodeStream_9273df81ebe52476e105ce9128b702a57ad95417.so"
Go to top
sHM requires other utilities such as surfaceCheck which can check the input STL geometry and prints overall size (bounding box) of the geometry. Output from surfaceCheck utility:
Reading surface from "constant/triSurface/Fan_in_Duct.stl" ... Statistics: Triangles : 23474 Vertices : 11749 Bounding Box : (-550 -185 -185) (540 185 185) Region Size ------ ---- patch0 23474 Surface has no illegal triangles. Triangle quality (equilateral=1, collapsed=0): 0.00 .. 0.05 : 0.1744 0.05 .. 0.10 : 0.1612 ... min 4.76e-06 for triangle 19519 max 0.999899 for triangle 11050 Edges: min 0.00290 for edge 352 points (-22.92 108.37 143.69)(-22.9 108.37 143.7) max 500.073 for edge 101 points (-550.0 152.62 104.55)(-50.0 157.29 97.39) Checking for points less than 1e-6 of bounding box ((1090 370 370) metre) apart. Found 0 nearby points. Surface is not closed since not all edges connected to two faces: connected to one face : 24 connected to >2 faces : 8 Conflicting face labels:48 Dumping conflicting face labels to "problemFaces" Paste this into the input for surfaceSubset Number of unconnected parts : 2 Splitting surface into parts ... Writing zoning to "zone_Fan_in_Duct.vtk"... writing part 0 size 1084 to "Fan_in_Duct_0.obj" writing part 1 size 2239 to "Fan_in_Duct_1.obj" Number of zones (connected area with consistent normal) : 10 More than one normal orientation.The command surfaceFeatureExtract creates the *.eMesh files from the *.stl files with the geometry data. Folder extendedFeatureEdgeMesh is created in the constant directory. The creation of eMesh files with the command surfaceFeatureExtract is not mandatory stops to use sHM. This step isnecessary only if edges need to be refined.
Rotating Walls and Domains
mixerVessel2D - simpleFoam This case can be obtained by adding baffles to the case 2D rotor. However, note that 2D rotor case uses simpleFoam and not SRFSimpleFoam.
snappyHexMesh [sHM]
This utility is used to create high quality hex-dominant [cut-cell] meshes [similar to but not exactly Cartesian Mesh in ICEM CFD] based on arbitrary geometry, the controlling dictionary is system/snappyHexMeshDict. Requires a starting [hexahedral] mesh created by blockMesh [designated as base mesh or level 0 mesh] and geometry data in STL and Nastran (.nas) files format.A snappyHexMeshDict file created after reading through such files used in various tutorial application can be found here. This is a generic dictionary which demonstrates all the features of this utility.
Different stages of mesh generation in snappyHexMesh utility is shown in following images.
Note - By default, each phases of snappyHexMesh i.e castellation, snapping and layer addition will write a complete mesh in time folders. This behaviour can be suppressed by using the option -overwrite: "snappyHexMesh -overwrite"
Examples of snappyHexMesh application can be found in tutorial cases:Steps for snappyHexMesh (sHM) when a CAD data is available in STEP format.
Step-1: Convert to STL - sHM reads CAD geometry that is boundary of computational domain in STL format. This can be accomplished by importing the geometry into FreeCAD and then using File -> Export utility to save the geometry as STL file. Even latest versions of STAR-CCM+ and FLUENT Mesher converts the CAD into faceted (STL) form before meshing operations can be performed. Make sure that the model is in [m] as OpenFOAM operates on [m] as default unit.
Step-2: check the dimensions of a bounding box - this is required to create a bounding box for background mesh encompassing entire STL geometry. Use surfaceCheck utility as described in ealier section.
Step-3: Update the dimensions of bounding box in blokcMeshDict - reference dictionary can be found here. Geneate blockMesh and open it along with STL file in ParaView to ensure the blockMesh covers the STL geometry.
Step-4: Extract edges of from STL geometry - use surfaceFeatures [surfaceFeatureExtract is obsolte in V8] to create feature edges such sharp corners, intersections... This will create a geomData.eMesh file in the folder where geomData.stl file is located.
Step-5: Estimate a point inside the computational domain in the CAD environment - This is required to tell sHM which region of mesh to be retained - inside STL geometry or outside it. Use "Hover Points On" feature in ParaView to get approximate coordinates.
Step-6: Update snappyHexMeshDict - update the name of STL file in this dictionary, specify a material point in the fluid region (domain to be meshed), create BOdy-of-Influence (BOI), define patches.
Step-7: Create patches using topoSet utility - update the topoSetDict to create patches from cell faces. This is required to specify boundary conditions. You may need to use "Hover Points On" feature in ParaView to get approximate bounding box of the patches.
The background mesh or base mesh can be generated using blockMesh or an external mesher with following constraints:
Error in topoSet utility: "Cannot find directory "polyMesh/sets" in times "0" down to constant" - this error occurs when topoSet cannot find the faceSet or cellSet. Check for entry "action new;" in topoSetDict. Additional Check - Note size of faceSet outletFaces is '0' which implies the box specified is not correct and does not encompass any cell.
Created faceSet inletFaces Applying source boxToFace Adding faces with centre within boxes 1((-0.02 -0.02 -0.025) (0.02 0.02 -0.0195)) faceSet inletFaces now size 2272 Created faceSet outletFaces Applying source boxToFace Adding faces with centre within boxes 1((0.11 -0.025 -0.025) (0.09905 0.025 0.025)) faceSet outletFaces now size 0
Errors in createPatch: Use -overwrite option to avoid creation of a new time directory.
Face 29163 specified in set inletFaces is not an external face of the mesh. This application can only repatch existing boundary faces.This error implies that few internal faces got selected to define a boundary patch and box defined to select faces needs to be corrected.
Conductive heat transfer using laplacianFoam in openFOAM
Go to top
Adjoint Solvers: adjointShapeOptimizationFoam
Optimization of shape and size in CFD simulations require incremental change in geometry and re-meshing. The CFD programs are now incroporating adjoint solvers which runs in addition to the fuid solver to find an optimum geometry to minimize (e.g. pressure drop) or maximize (e.g. flow uniformity) specified field variables. Both the Single Object Optimization (SOO) and Multiple Objectives Optimization are possible.Similar concepts Full Order Modeling (FOM) and Reduced Order Modeling (ROM) which are based on mathematical concepts such as Higher Dimension Model (HDM), Proper Orthogonal Decomposition (POD) or Singular Value Decomposition (SVD).
Excerpts from "Topology Optimisation of Fluids Through the Continuous Adjoint Approach in OpenFOAM" by Prof. Hakan Nilsson - "The Topology Optimization Method (TOM) consists in determine the material distribution in a design domain to maximize or minimize an objective function subject to certain constraints. To maximize/minimize the objective function at flow devices is done by adding the velocity field u multiplied by a scalar field α to the momentum equations, so regions with a high value of α determine a low permeability area (solid portion) and regions with a low value of α determine a high permeability area (fluid portion)."
For incompressible steady state Navier-Stokes equations, the problem can be written as:minimize cost function J = J(U, p, α)
such that (U . ∇)U + ∇p − ∇.[2μD(U)] + αU = 0, strain rate tensor D(ν) = ∇U + (∇U)T
∇.U = 0
In OpenFOAM, adjointShapeOptimizationFoam solves both the primal flow (U) and the adjoint flow (Ua) and at the same time optimizes the geometry for minimized cost function say pressure loss. The solver is built around a case of optimization of a duct shape by applying blockage in regions causing pressure loss which are estimated using the adjoint method. The solver is also programmed for shape optimization with respect to pressure loss. The redundant material is shown by high value of α (closer to alphaMax specified in transportProperties dictionary. The pitzDaily case (flow over a back step with pinched outlet) gives following output:Initial Velocity
Optimized Porosity
Optimized Velocity
'Ua' and 'pa' are the adjoint velocity and the adjoint pressure. The adjointShapeOptimization solver file structure is described below.
adjointShapeOptimizationFoam ,--adjointOutletPressure |--|--adjointOutletPressureFvPatchScalarField.C |--|--adjointOutletPressureFvPatchScalarField.H |--adjointOutletVelocity |--|--adjointOutletVelocityFvPatchVectorField.C |--|--adjointOutletVelocityFvPatchVectorField.H |--adjointContinuityErrs.H |--adjointShapeOptimizationFoam.C |--createFields.H |--createPhia.H '--initAdjointContinuityErrs.H
The content on CFDyna.com is being constantly refined and improvised with on-the-job experience, testing, and training. Examples might be simplified to improve insight into the physics and basic understanding. Linked pages, articles, references, and examples are constantly reviewed to reduce errors, but we cannot warrant full correctness of all content.
Template by OS Templates