0% found this document useful (0 votes)
308 views102 pages

OpenFoam Tutorial Basico

Tutorial de open foam

Uploaded by

Paco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
308 views102 pages

OpenFoam Tutorial Basico

Tutorial de open foam

Uploaded by

Paco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 102
CFD Direct ‘ Essential CFD ( OpenFOAM Training CJ. Greenshields Notes v3.0.1 rev 1. 29/1/2016 Copyright © 2015-2016 CFD Direct Ltd CFD Direct Essential CFD | Copyright and Disclaimer 2/102 Copyright © 2015-2016 CFD Direct Ltd All rights reserved. Any unauthorised reproduction of any form will constitute an infringement of the copyright. The right of C.J. Greenshields to be identified as the author of this work has been asserted CFD Direct Ltd makes no warranty, express or implied, to the accuracy or completeness of the information in this guide and therefore the information in this guide should not be relied upon. CFD Direct Ltd disclaims liability for any loss, howsoever caused, arising directly or indirectly from reliance on the information in this guide. Copyright © 2015-2016 CFD Direct Ltd CFD Direct Essential CFD | Contents = Visualisation 11.1 Introduction to visualization 1.2 Data formats 1 Start running cases 2.1 Introduction to meshing 2.2 Numerical solution overview = Start engineering meshing 3.1 Geometry generation 3.2 snappyHexMesh: introduction = Initialising cases 4.1 Field initialization 4.2 Initial & boundary conditions 4.3 Introduction to physical modelling 1m Further meshing 5.1 snappyHexMesh: enhancements 5.2 snappyHexMesh: mesh refinement m= Analysing results 6.1 Objective data 6.2 Graphs = Turbulence modelling 7.1 Turbulence: introduction 7.2 Turbulence modelling essentials = Setting numerical schemes 8.1 Discretisation: introduction 8.2 Discretisation: diffusion 8.3 Discretisation: advection 3/102 Copyright © 2015-2016 CFD CFD Direct Introduction to visualization | Wind around buildings 4/102 = Task: visualize simulation of wind around buildings m Existing tutorial > copy the tutorial and execute the Allrun script >> run >> cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/windAroundBuildings >> ed windAroundBuildings >> /Airun & Don’t forget this — means: Runs in terminal “backsrcund” “the current directory” = Run paraFoam: ParaView for OpenFOAM case data Apply changes >> paraFoan & | rae 28) \ est | peta | P| ™ Check Use VIKPolyhedron | a ... better display of polyhedral cells (non-hex, tet, etc.) Mesh cells 1 Load data: all mesh parts; all fields Boundary patches { = Orientate image with mouse BD BG sts. ecty 0 { pan zoom rotate | roll (hold shir CFD Direct Copyright © 2015-2016 CFD Direct Ltd Introduction to visualization | Geometry visualization 5/102 = Need to visualize the buildings surface = buildings patch hidden behind internal mesh (cells) and far-field patches (inlet, etc.) = Menu Bar + Filters — Recent/Alphabetical -> Extract Block eee Filters move from Alphabetical to Recent — check both u In Properties, select buildings Color selection Standard orientations (ie Heir | RR aR aa Choose solid color Resets display Geometry representation Copyright © 2015-2016 CFD Direct Ltd CFD Direct Introduction to visualization | General controls 6/102 = Base object properties repenies oS) RR oe oe) Check when 0 dir does not match (Geach use Esctocieartet) +i) mesh, e.g. during mesh generation Loads new time directories created by running solver —-> Refresh Times | sepzereTime | Keeps mesh fixed — uncheck when ___»-i cache Mesh ‘monitoring mesh generation and Crease: Di érups ony for moving mesh cases Di inctude Zones: Patch Names: interpolate volFields (_) Extrapolate Patches m= Edit + Settings m ...set default Color Palette = ...set default Scalar Bar Mode |F66G Toggle axes’ Image centre controls CFD Direct Copyright © 2015-2016 CFD Direct Ltd Introduction to visualization | Default Settings 7/102 1 ParaView Properties window contains Display and View panels CEBRo we | ome |__t_) Search fue Eve To ear eat ‘Show Advanced age ee Stas @ Properties Exractalockd) —_ |()(6)(@)( ‘PDIP iceometyrepresenta |(9}(@](C] (Si) “=a render View) ©) © }—Save Default . aisle) Settings Display scale—s- | eaeanesoid canter axes Visity Crtantation axes Display w/y/z axes —am orientation Axes Visibility Moveable :1/y/z axXeS —a orientation Axes interactivty [Wovientationares tabelcowr (W@ o7ertaton Ares Ouine coor SY wa Control lighting—»~ ix] Set parallel projection ba camera Paral Projection OY toggle offfon 11! a Background Configure in—w{singlecoioe Settings mend (0 cavr ~ [reser atu Copyright © 2015-2016 CFD Direct Ltd CFD Direct Introduction to visualization | Mesh visualization 8/102 = Need to visualize internal mesh structure @ Slice (cutting plane) includes options that help visualize mesh = Filters — Recent/Common -> Slice |_ ree wa) reece: oa Select the base module: contains internalMesh (whose cells we slice) Copyright © 2015-2016 CFD Direct Ltd CFD Direct 4999907990037 Cro RK RAR RR RAR RRA Introduction to visualization | Displaying fields 9/102 1 Any image object in Pipeline Browser can be colored by field data, eg. U, p 1 Display p field on buildings Select extracted building patches color by U {9 3 |meT) Forward to last solution step (400) Copyright © 2015-2016 CFD Direct Ltd HH CFD Direct Introduction to visualization | Color controls 10/102 r, y, 2 components 3 Seleu |) (Wagnte=] <—o7- magnitude Toggle legend U Set manual data range Rescale colors to data range Cate Mop Ear oa Edit legend parameters, e.g. PELE B— title and label fontrtormat Scale colors to data range Set data range Scale to data range of all timesteps ic) Invert color map {x Set color map, e.g. blue +> red 6: — Save map as preset Search | Use log scale when mapping data to colors <———— Enable opacty mapping for surfaces (8 Automatically rescale transfer functions to fit data Color transter function values Set log range — useful for fields with sharp peaks Copyright © 2015-2016 CFD Direct Ltd CFD Direct Introduction to visualization | Velocity vectors 11/102 = Velocity U can be displayed as vectors 1 Avoid vectors on boundaries = display vectors at cell centres @ @windAroundBuldings.openFoam Loaded data Extract buildings Extract internalMesh filter cells y = 65 filter cell centres and display arrows: i Copyright © 2015-2016 CFD Direct Ltd CFD Direct Data formats | OpenFOAM format 12/102 m We can visualize OpenFOAM data in ParaView = ...using OpenFOAM's reader module built in a customised ParaView ™ Run ParaView >> paraview & File — Open: cannot load in an OpenFOAM case because ParaView expects a single file, with an extension = paraFoam: creates dummy file . OpenFOAM Passed to ParaView at startup (no need for File —> Open) = If ParaView is running, generate dummy file for a case by, e.g. >> run >> cd windAroundBuildings >> paraFoan touch = In ParaView, File > Open > windAroundBuildings .OpenFOAM ™ Case opens — OpenFOAM format data Copyright © 2015-2016 CFD Direct Ltd CFD Direct Data formats | Surface formats: OBJ and STL 13/102 ( m Task: visualize the buildings geometry f ™ Surface geometry file: OBJ format in constant/triSurface directory ¢ = Compressed data: ParaView cannot read it (QpenFOAM can) = Unzip the geometry file ( >> gunzip constant /triSurface/buildings..obj .gz ( = Open the buildings. obj file 4 = Filter Feature Edges; display Wireframe; Line Width = 2 CFD Direct (Copyright © 2015-2016 CFD Direct Ltd Data formats | ParaView native format: VTK 14/102 = OB] and STL formats describe surface geometry ™ surfaceConvert utility can convert between formats >> (ed constant/triSurface ; surfaceConvert buildings.obj buildings.stl ) = VTK format describes geometry and field data = Convert the tutorial motorBike surface into VTK >> FOAM_GEOMETRY=$FOAM_TUTORIALS/resources/geometry >> surfaceConvert $FOAN_GEOMETRY/notorBike.obj.gz motorBike.vtk = Open the motorBike.vtk file in ParaView C010" by region index Reset (Wesee Lo & ‘Copia ay only motorbike Copyright © 2015-2016 CFD Direct Ltd CFD Direct Data formats | OpenFOAM to VTK conversion 15/102 = foamToVTK converts geometry/field data into VTK format, see: >> foamToVTK -help m Run with -latestTime option; data written into VTK directory >> foamToVTK -latestTime = Open the internal (cell) data windAroundBuildings_400.vtk m Apply Stream Tracer filter ————————> -_— = Then Tube filter; radius 0.4; colored by U Copyright © 2015-2016 CFD Direct Ltd Data formats | Other formats 16/102 m surfaceFeatureExtract extracts surface features + . eMesh files ™ ...not supported by ParaView; so optionally writes additional obj files @ foamToEnsight and foamDataToFluent data converters exist ™ ParaView can read many formats, including image formats, e.g. PNG ™ ...Export Scene in formats such as PDF, SVG, etc. Save Screenshot in PNG, PDF, JPEG, etc. Copyright © 2015-2016 CFD Direct Ltd CFD Direct Introduction to meshing | Optimal meshing fo! Modelling Complexity (baffles, regions, rotating geometry, 2D ————> 3D) ——> BH snappyHexMesh Bi blockMesh rr OpenFOAM Geometric Complexity 17/102 Copyright © 2015-2016 CFD Direct Ltd Introduction to meshing | Introduction to blockMesh $FOAM_TUTORIALS <> incompressible simpleFoam ‘SFOAM_RUN \pitzDaily—_}) Copy (ep -r) | pitzDaily Usysten “ blockMeshDict 2) Edit (gedit) “constant “polyMesh 4) blockMesh 18/102 3) paraFoam -block Copyright © 2015-2016 CFD Direct Ltd CFD Direct Introduction to meshing | blockMesh configuration system UblockMeshDict vertices ¢ (-20.6 0 -8) (-20.6 3-5) (-20.6 12.7 -5) 3 blocks a nox (0 6 7 1 22 28 29 23) ag 7 1) simpleGrading (0.5 1.8 1) di boundary ce inlet { upperwall type patchs faces to (0 22 23 17 lowerWall 19/102 outlet ) Copyright © 2015-2016 CFD Direct Ltd CFD Direct Introduction to meshing | Meshes in OpenFOAM 20/102” = 3D, Cartesian = Any shape cells and faces = Internal face intersects 2 cells = Boundary face attached to 1 cell 1 Files in polyMesh directory } Internal faces Boundary faces Boundary patch name standard patch wall boundary for 2D cases periodic cases for axisymi symmetry: slip boundary Patches can be grouped This patch belongs to a group named wall. Copyright © 2015-2016 CFD Direct Ltd Introduction to meshing | General meshing using snappyHexMesh 21/102 Modelling Complexity (baffles, regions, rotating geometry, ...) 2D» 30 > _ Geometric Complexity IB snappyttexMesh (3D) I snappyHexMesh + extrudeMesh (2D) Copyright © 2015-2016 CFD Direct Ltd Numerical solution overview | Solving in CFD 22/102 inlet outlet SU, =10 — = m™ Run the pitzDaily case >> run >> cp -r $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily . >> cd pitzDaily >> blockMesh >> simpleFoam @ Terminal output: sees: Bion fs 9 aut ee Sstving for Op; fetal resitual > Ecteiag for Se tase Copyright © 2015-2016 CFD Direct Ltd = CFD Direct Numerical solution overview | Solving equations 23/102 Physics Equations Discrete Solution Sy simpleFoam f(Uy,P) Momentum x V.UU+V+R=—Vp “aistiute \ f(Uz,p) \ Mass xt [a]= EF \ v-U=0 ule | . FU) 1S ** pl= iF iS V2p+V+(V-UU) =0 * : a. 3 Is % kEpsilon| Turbulence VeUe — V+ D.Ve = f(e,k,G) V-+Uk— V+ Dy Vk = G(U) -¢ SUeUye) J ra 7 4 =Cyk/e; VeR= f(%,U) | | mes eu [lbl-[ | baleen | ell Copyright © 2015-2016 CFD Direct Ltd CFD Direct Numerical solution overview | Case directories and files 24/102 fvSchenes file controls discretisation | | fvSolution file controls solving of matrix of equations, affecting solution equations, and algorithm parameters accuracy and stability affecting solution speed/accuracy Momentum a 4 FUusP) V-UU+V-R=-Vp (*8s:] [v.| = Ae ~ tehd-P" A ToAanjos controlDict file controls solution (time) steps and reading/writing solution data turbulenceProperties file specifies RAS turbulence model — kEpsilon system directory “controlDict \ £vSchemes \fvSolution Copyright © 2015-2016 CFD Direct Ltd CFD Direct Numerical solution overview | Matrix solution f(Oy,p) [e]- EF Time = 100 Time = 101 Uy, Initial residual |p, Initial residual = Matrix solver applied to each equation w First calculates residual, r = MAH] — [IL IP] alll 1m Matrix solver stops iterating when r < tolerance; set in fvSolution dual = 25/102 ++ Ux, Initial residual = 0.00316, Final residual = 0.000190 | Uy, Initial residual = 0.00842, Final residual + py Initial residual = 0.02319, Final r 0.000852 -002035, - Ux, Initial residual = 0.00311, Final residual = 0.000187 00843, Final residual = 0.000551 0.02810, Final residual = 002140 m Convergence of equation set: all (initial) r + 107- 10-5 — Judgment required Copyright © 2015-2016 CFD Direct Ltd CFD Direct Numerical solution overview | Convergence control 26/102 m Steady-state solvers (with SIMPLE algorithm) have convergence control m Solver (e.g. simpleFoam) stops when r < residualControl for all equations fvSolution file > SIMPLE sub-dict > residualControl sub-dict Reduce all convergence control residuals by 1 order (divide by 10) m In controlDict, extend endTime to 2000; re-start simpleFoam Time = 386 pe for p eqn, < 10™ for other eqns ++. Solving for Ux, Initial residual = 1.8920-05, Final residual = 7.022e-06, Wo Iterations 2 ++. Solving for Uy, Initial residual = 9.977e-05, Final residual = 8.133e-06, No Iterations 5 +++ Solving for p, Initial residual = 0.00018177, Final residual = 1.193e-05, No Iterations 3 ‘time step continuity errors : sum local = 0.000567752, global = -3.023980-05, ... Solving for epsilon, Initial residual = 3.90756e-05, Final residual = 8.39367e-06, . Solving for x, Initial residual = 2.821e-05, Final residual = 5.6970-06, No Iterations 2 Copyright © 2015-2016 CFD Direct Ltd CFD Direct Geometry generation | Creating a cyclone geometry 27/102 m Need to create representative geometries ™ Generate solid model of cyclone = Export a triangulated surface file = Dimensions in metres ™ Note the axes origin location Copyright © 2015-2016 CFD Direct Ltd Geometry generation | FreeCAD 28/102 m™ Open source parametric 3D CAD modeler http: //iww.freecadweb.org m Standard package for Ubuntu/Debian http: //packages .ubuntu.com/freecad ™ Resources http: //wuw. freecadveb.org/wiki/index.php?title=Getting_started http://www. freecadveb.org/wiki /index. php?title=Workbenches http://www. freecadueb.org/wiki/index.php?title-Basic_modeling tutorial http://www. freecadueb.org/wiki/index.php?title-Part_Module http: //hackaday .com/2014/02/08/3d-printering-making-a-thing-in-freecad-part-i Copyright © 2015-2016 CFD Direct Ltd CFD Direct Geometry generation | Getting started 29/102 1) launch FreeCAD 2) select Part workbench 3} open New file ars ‘= a @ 4 & @ ® 4) Create Part — Primitives (cylinder, cone, box) @ G Wd HH % 5) Set View — Standard Views @ & @Y & © & 6) Do Part + Boolean operations (cut, union) 5658 pan zoom rotate (hold middle) — CFD Direct Copyright © 2015-2016 CFD Direct Ltd Geometry generation | Creating the solid model 30/102 2)copyipaste 3) copy/paste eaaseua oN sbox height 05 length 08 Gian 6 6 width 0.2 «18 7) select all height 0.6 7 sie radius 0.25 coe (OC CORES Lownie | eee (3) and (21 sex height 0.7 radius 0.2 placement height 1.75 radius 0.5, 4) cone height 2.0 radius 0.2 radius2 0.5 place. 2-3.75 B@eoesees saacees Note: FreeCAD displays ‘mm’ but simply stores numeric values Inthis example, enter values in ‘m’ units, so resulting geometry Is in ‘m’ CFD Direct Copyright © 2015-2016 CFD Direct Ltd COCA OACANANIANIIIINAAIAA cr Geometry generation | Exporting the triangulated surface 31/102 m Save the solid model —> cyclone. festd = For meshing, we need to export a tri-surface > .obj or .st1 file Set triangulation accuracy (one-off) and export surface Set triangulation accuracy inte AE Copyright © 2015-2016 CFD Direct Ltd CFD Direct snappyHexMesh: introduction | Creating a cyclone mesh 32/102 outlet inlet q m Create a basic mesh for cyclone m ...with inlet and outlet patches m Run steady-state, air, inflow 20 m/s .- Start from inflowOutf low template case >> run >> cp -r $FOAM.ETC/templates/inflow0utflow cyclone m Start from cyclone. obj surface file >> ed cyclone >> ep /cyclone.obj constant/trisurfa: CFD Direct Copyright © 2015-2016 CFD Direct Ltd a 7 ~yNIIIF snappyHexMesh: introduction | Creating boundary patches 33/102 cyclone.obj m surfacedutoPatch breaks surface Into regions = New region begins where change in angle between faces < specified internal angle ‘= Run with 100° creating new CAD. obj file CAD. vtk >> cd constant/triSurface >> surfaceAutoPatch cyclone.obj GAD.obj 100 mm Convert to CAD. vtk file to visualize >> surfaceConvert CAD.obj CAD.vtk m In ParaView, open CAD. vtk m= Color by Region number; display legend EH) aa m Identify region number (n) for inlet and outlet m Region name is patch, e.g. inlet is patchO im Why 100°?; to separate all boundary faces, e.g. cone base . otherwise the edge around cone base may be lost during layer insertion Copyright © 2015-2016 CFD Direct Ltd CFD Direct snappyHexMesh: introduction | Background mesh 34/102 1) In ParaView, View —+ Information —+ Spatial Bounds 2) Set background mesh size eras ~0.1 m beyond the bounds Xrange: 051008 (deta: 13) Yrange: 051005 (dena: 1) Z range: 375 00: (deta: 3.85) blockMeshDict 3) Set no of cells in each directio for ~10,000 cube-shaped cells 4) Run blockMesh 5) Show mesh in ParaView Display + Surface with Edges. Copyright © 2015-2016 CFD Direct Ltd CFD Direct snappyHexMesh: introduction | Castellated mesh 35/102 m Edit system/snappyHexMeshDict, then run snappyHexMesh >> snappyHexMesh -overwrite geometry castellatedMesh @iip { snap off; CAD. obj addLayers off; t type triSurfaceMesh; refinementSurfaces name CAD; { regions cap t t PatchO){ name inlet; } level (2 2); { name outlet; } patchInfo { type wall; } + regions oa { refinementRegions ED * ca level (2 2); { patchInfo { type patch; } mode inside; as levels ((1E16 2)); e ‘patch9 } t JocationIntiesh (POO): Copyright © 2015-2016 CFD Direct Ltd CFD Direct snappyHexMesh: introduction | Snapped mesh 36/102 = Meshes refined by 2x2x2 splitting m Mesh refined from level 0 to level 2 if Cente = Note number of cells reported in log Onmsse — Cemmany Cells per refinement level: | 0 ratte le Cart ce to 2 142248 | me VIET ton = Unwanted cells (outside cyclone) removed = Mesh is castellated at surface 1 Switch on snapping in snappyHexMeshDict View snapped mesh = Run snappyHexMesh in ParaView Copyright © 2015-2016 CFD Direct Ltd CFD Direct Field initialization | Internal field 37/102 m Field data (e.g. p, U, T) are stored in time directories, e.g. 0, 0.1, 100 m Directory name, e.g. 0.1 —» simulated time, t = 0.1 = A simulation can (re-start from data in any time directory 7 7 . but simulations typically start from 0 directory, i.e. t = 0 see pitzDaily backward facing step 0 dir. contains: pressure p; velocity U; turbulence fields k, epsilon, nut /U file; dimensions f0i-10000]; \ internalField sets initial field data All cells initialised internalField (0 0 0)5 with same value — = Typical internal field initialization: 1) uniform zero; 2) uniform inlet value 9 (0 0 0) = Both violate mass/volume conservation Copyright © 2015-2016 CFD Direct Ltd CFD Direct Field initialization | Boundary field 38/102 = boundaryField —+ boundary condition for every patch, e.g. pitzDaily/0/U boundaryField requires ‘one entry for every patch starting with the patch name. ..including a type .and other data required for that specified type Copyright © 2015-2016 CFD Direct Ltd ( Field initialization | Common boundary conditions 39/102 inlet outlet U = (10, 0, 0) U/An = (0, 0, 0) Op/an=O p=0 _k=0.38 Ok/On =0 Le e=14.9 lowerWall de/On =0 cloak = glatite de U=(0,0,0) & roe oe ap/an < pWall functions i u fixedValue,eg.U=....p=...,k= = zeroGradient: gradient normal (n) to patch = 0, e.g. dp/dn = 0 ® Subsonic flow: inlet/walls fixedValue; outlet zeroGradient . except for p: outlet fixedValue; inlet/walls zeroGradient = Turbulent fields use special treatment at walls m Task: in pitzDaily, switch boundary type for inlet and outlet in 0/p = Run simulation; look at p field in ParaView Copyright © 2015-2016 CFD Direct Ltd Field initialization | Dimensional units 40/102 Stoonsions — (OEEEAIONONONED; denotes L'T™ internalField uniform (0 0 0); ms” in SI units ay = units of velocity eg. = Square brackets syntax [...] reserved for dimensional units = Dimensional units are specified by exponents of 7 fundamental units = Ordered list of exponents [ML T K QC I] M=mass, = length, T = time, K = temperature, --Q = quantity (e.g. moles), C = current, I = luminous intensity = Example: Gas constant R = work / temperature increment / quantity (mole) m= (MELT? L)K7Q7 = MUT?K1Q7 [1 2-2-1 -10 0] = OpenFOAM checks matching dimensions on left/right of +, -, = Adjusts dimensions for other operations, e.g. x, /, + CFD Direct Copyright © 2015-2016 CFD Direct Ltd Field initialization | Units of pressure 41/102 In pitzDaily example, see 0/p UT? for kinematic pressure ® pis kinematic pressure, i.e. represents (pressure, p/ density p) m= Occurs in single-phase, incompressible (p = const) solvers a +V«(pUU) -V+ pen VU = —Vp, standard p Bay +.V+(fUU) -V+ preg VU = -V (2) % .v.(uv) Ver VU = —Vp, kinematic PY nes = Solver is independent of p = no rho case data required Copyright © 2015-2016 CFD Direct Ltd CFD Direct Field initialization | From kinematic to ‘real’ pressure 42/102 = For solvers with kinematic pressure, real ‘static’ pressure can be output 1m ...using the pressureTools function object . included in the controlDict file using configured staticPressure m= Run the pitzDaily case Each time directory contains a static(p) field m ...as well as the kinematic p file = Confirm static(p) = rhoInf x p Copyright © 2015-2016 CFD Direct Ltd CFD Direct cr 7 ic c ie ¢ c c C ( c ( ( ¢ ( ( ( ( ( ( ( ( ( ( fi ( ( ( ( ( ( r Initial & boundary conditions | Initialisation with setFields 43/102 = Some fields must be initialised non-uniform = ...e.g. phase fraction « which specifies liquid/gas distribution = See waterChannel example >> run >> op -r $FOAM_TUTORIALS/multiphase/interFoam/ras/waterChannel . >> ed waterChannel ™ Generate the mesh m setFieldsDict is configured to set alpha. water — initial water level = Run setFields; check water level +20 m Task: add fluid ‘hump’ @ Cylinder, axis x = 10, radius 4 m Set writeInterval to 2; endTime to 50 = Run interFoam ') Alles CYlndurre Cel Aug 2) ga pla .waler.ovy A) a(hnweter %) sk Field sPict get Ken sD rebhells Claro dubs cr opt-forrnn Copyright © 2015-2016 CFD Direct Ltd Initial & boundary conditions | Entrainment BC 44/102 atmosphere ‘experiences inflow and outflow = entrainment BC o/u~, 0/p_rgh: = Outflow: U: zeroGradient p: fixedValue — normal behaviour inflow, U;=0,0U,/n=0 =po- wre — self-stabilising ae problem eo en prvbublean ale la Mucor wren ype Stn Cun age o por ble nO canoeeY le cock com Le erode. Copyright © 2015-2026 CFD Direct Ltd Cc c 999909090 etatetetatotatatatatatatatatatatatetatatele| Gc Initial & boundary conditions | More inlets and outlets 45/102 = inletOQutlet BC used for other fields, e.g. alpha.water, on atmosphere patch 0/alpha.water: Inflow: Owater = 0 (inletValue) Outflow: Jawater/On = 0 = fixedFluxPressure: substitute for zeroGradient but where the normal gradient Op/On #0 and is evaluated to balance body forces, e.g. gravity, surface tension 0/p_rgh: regular expression meaning “all patches": catch-all for all patches except those explicitly named in boundaryField, i.e. atmosphere Copyright © 2015-2016 CFD Direct Ltd Initial & boundary conditions | Time-varying inlets 46/102 = Some BCs have DataEntry inputs/parameters that can be time-varying i List these BCs by searching for DataEntry private data in BC classes >> cd dreads Sate T Noroe ceee ol Beeeee >> find name "*.H" | xarge grep -1 Databn ./derived/fan/fanFvPatchField.H ‘ived/uniformInletOutlet/uniformInletOutletFvPatchField.H = flowRateIuletVelocity uses ‘DataEntry’ on volumetricFlowRate inline table timet flow rate m Run case; check 100/U = Apply table data to volumetricFlowRate, ramping to 50 from t = 0 + 10 m Re-run case; check inlet flow rate at intermediate times, e.g. 4s Copyright © 2015-2016 CFD Direct Ltd CFD Direct Initial & boundary conditions | Other DataEntry functions 47/102 m Other DataEntry functions exist m Examples for uniformFixedValue BC, for the uniformValue m= OpenFOAM table file uniformValue —_tableFile; tableFileCoeffs t fileName "$FOAM_CASE/DataFile" outOfBounds clamp; = CSV file uniformValue _—csvFile; csvFileCoeffs fileName "$FOAM_CASE/DataFile" outOfBounds clamp; hasHicaderLine trues refColumn 4 componenticozumns (642); // vector example = polynomial uniformValue polynomial // y = 0.5 + 1.4% + 2.3t73 < 0.5 0) (1.4 4) (2.3 3) 4 (ealawiterto 240 x Axio’ cds CFD Direct Copyright © 2015-2016 CFD Direct Ltd Introduction to physical modelling | Buoyancy-driven flow 48/102 = Task: simulate natural convection in closed geometry = Go to run directory m Run FreeCAD, Part workbench 1) Open new file 2) Create 10x10x5 box @ 3) Create 1x1x0.01 box @ «+.placement (4.5, 4.5, 0) 4) Select box 0 and 1 and cut © 5) Export as hotRoom. obj height = 0.01 T =600°C = Copy closedVolume template case, rename hotRoom >> cp -r SFOAM_ETC/templates/closedVolume hotRoom ™ Patch geometry surface wirth surfaceAutoPatch, renaming CAD. obj >> surfaceAutoPatch hotRoom.obj hotRoom/constant/triSurface/CAD.obj 100 Copyright © 2015-2016 CFD Direct Ltd CFD Direct 997990000009 f - ie Introduction to physical modelling | hotRoom mesh generation ® Go into the hotRoom case directory = Set background mesh in the blockMeshDict file —> = Run blockMesh i Name hotSpot patch in snappyHexMeshDict (patch10 in CAD. obj file) 1 Set refinement level to 1 in snappyHexMeshDict = Run snappyHexMesh with snap on. >> snappyHexMesh -overwrite 49/102 Copyright © 2015-2016 CFD Direct Ltd CFD Direct Introduction to physical modelling | Physical modelling input files 50/102 = Each solver application uses particular collections of physical modelling m ...that require models/coefficients in particular files in the constant directory = The buoyantBoussinesqSimpleFoam solver requires the following files constant \transportProperties —» General transport modelling \ turbulenceProperties > Turbulence modelling Lg — Gravitational acceleration, g m= buoyantBoussinesqSimpleFoam treats p as uniform, except in pg, where Px = P/ Pret = [1 = B(T ~ Teet)] ‘transportProperties file: a Newtoni: onstant { ™ Thermal diffusivity a = v/Pr @ Turbulent a = U¢/Pre. { { SS Keybord Data: dimensions, value Copyright © 2015-2016 CFD Direct Ltd CFD Direct ‘Introduction to physical modelling | Setting models 51/102 Cc = constant/turbulenceProperties: select the kEpsilon RAS model = constant/g: set g to be in the -z-direction = 0/T: set temperature of hotSpot patch = Run the buoyantBoussinesqSimpleFoam solver >> buoyantBoussinesqSimpleFoam > log & Ic \— Copyright © 2015-2016 CFD Direct Ltd ‘CFD Direct Introduction to physical modelling | Running the case 52/102 = Problem is naturally transient with complex 3D recirculations = = residuals converge only to 10-10 in 1000 steps = Lower residuals possible with more diffusive numerical schemes, e.g. upwind = Velocity vectors at step 1000: CFD Direct Copyright © 2015-2016 CFD Direct Ltd snappyHexMesh: enhancements | Inspection of cyclone mesh 53/102 1) Apply Slice to inspect mesh = Popetestsieny) ——~=S*«d;SC«) Run checkMesh sieve (ines) (>> checkMesh Overall number of cells... hexahedra: 135170 prisms: 5240 tet wedges: 12 polyhedra: 1826 non-orthogonality Max: W Internal cells regular, good quality ® Non-hexahedral cells near wall = Variation in near wall cell height m= Task: improve mesh with layer insertion QD earte sen Vt Panedas @) “pron -np P evrogvonslihy CGO wef ele bod Ane colanor Stmple Foamy up ve = pevalle | oahe ar regulaw Shappyliaeda event !e "ange tener . any Vow el ‘ony exnacee? Copyright © 2015-2016 CFD Direct Ltd woh cthawe: “AVA snappyHexMesh: enhancements | Layer insertion_ 54/102. = Switch on layer addition m Set layers to 4 = Run snappyHexesh = Run checkMesh >> checkMesh Mesh non-orthogonality Max: 64.76 m= View mesh in ParaView Use Slice CFD Direct Copyright © 2015-2016 CFD Direct Ltd snappyHexMesh: enhancements | Layer quality 55/102 1) Delete existing mesh and create new snapped mesh Deletes mesh files in >> foanCleanPolyMesh <— castellatedtesti constant/polyMesh dir. >> blockMesh ronstantipoly snap addLayers 2) Run snappyHexMesh without -overwrite >> snappyHexMesh Mesh written to time directories, e.g. 1, 2, 3, ... 3) Improve layer quality by relaxing minTetQuality Acell can decomposed into tets. tetQuality Oneeded peter uetiy hers0; pon mesereny 4) View changes to base and layers in ParaView (oc K@> 0@s ™c 71s pews per perherles prede de Preblewey Copyright © 2015-2016 CFD Direct Ltd CFD Direct snappyHexMesh: enhancements | Layer thickness_ 56/102 1) Modify layer thickness and max ratio (layer thickness)/(distance to medial axis) iffes 0.005 m ‘wall cell height isa 2) Delete time directory 3 and re-run layer meshing 3) View changes to layers in Paraview a fi Z| Desens ehe eh eye ¥ la pened Al espero sa peepee pom qe cl aglubsuects de ley feldas bees Jebenmnedo pou waver © empecray ler walle D species b cypornr ke le walta de cep \ontel wees bole Lhuckwesr pen se Le mle he capa inde wore Wed & HIE yo se legve heh. bh gece! dave MIS Ter age Muckne O5 ee 5] velehee size ee fobo ~ SBF Meche Ges eheapeany date D cabrloy ed neav wall Hackuesy Trnpansen ceOS Y Fe et re eh oper (meh. (ay cede om Cer aby MT pes

> foamCleanPolyMesh >> blockMesh J >> snappyllexMesh -overwrite 3) View final mesh (see above) Copyright © 2015-2016 CFD Direct Ltd CFD Direct snappyHexMesh: mesh refinement | Tri-surface manipulation 58/102 Task: mesh vehicle geometry for external aerodynamics, max 600k cells m Create a new estateMesh case from inflowOutflow template case >> run >> ep -r $FOAM_ETC/templates/inflow0utflow estateMesh m Copy the estate. obj geometry >> cp $FOAM_RUI/resources/geometry/estate.obj . Find its location, orientation and size ™ Create CAD. obj: front axle at « = 0, vertical z-axis, metre dimensions 2 (0,0, 1) >> surfaceTransformPoints -translate '(1445 32 0)' -rotate '((0 0 1) (0 -1 0))! <+-scale ‘(0.001 0,001 0.001)! estate.obj estateMesh/constant/triSurface/CAD.obj SurgaceTwonsgurmRends - hranelehe *C (Ws 726)' ~ roll Pda Yau 1(G0 oe)! ~Kale CFD Direct Copyright © 2015-2016 CFD Direct Ltd snappyHexMesh: mesh refinement | External patches 59/102 = Set the external patches (inlet, outlet, etc.) in background mesh @ Use alternative blockMeshDict .extPatches file in template case >> ep system/blockMeshDict.extPatches systen/blockMeshDict ground: type wall back, front, top: type symmetry a InblockMeshDict, set backgroundMesh according to diagram (si. 35) m Change patch names, e.g. left —> inlet, etc. Set patch types, see diagram = Run blockMesh CFD Direct Copyright © 2015-2016 CFD Direct Ltd snappyHexMesh: mesh refinement | Initial mesh refinement 60/102 = In snappyHexMeshDict, delete region sub-dictionaries (in CAD. obj geometry and refinementSurfaces) Initial cell length = 2/3 m; level 5 refinement — (2/3)/2° = 21 mm oy) = Run snappyHexMesh ‘ Jed tro Zerbiea (aoe and mort) frommelannhe pe dtbe puroy (5 5) teal -£ log \ gree “Time. Copyright © 2015-2016 CFD Direct Ltd snappyHexMesh: mesh refinement | Review of the initial mesh 61/102 Refinement box A ——— Refinement interfaces separated by 3 cells Y Vehicle surface quite well resolved = Insufficient refinement in the wake; refinement along ground? underbody? = Final Step: add 1 layer of cells to vehicle = ...for more uniform near wall cell size/shape Copyright © 2015-2016 CFD Direct Ltd CFD Direct snappyHexMesh: mesh refinement | Additional refinement 62/102 = In your own time: add refinement boxes (copy/paste boxA) Box min max level _ Region boxA (3-10) (511.6) 4 Wake boxB (3-10) (811.6) 3 Wake boxC (3-10) (1511.6) 2 Wake boxD (-8 -10) (5 1 0.16) 4 Upstream/underbody m Increase nCel1sBetweenLevels from 3 (default) to 4, 5, ...to extend refinement Upstream/underbody Cell tayer: refinement (cut, purple) ond Copyright © 2015-2026 CFD Direct Ltd CFD Direct Objective data | Probes 63/102 = Aim: to set up estate case to output objective data . Monitored during a simulation = Create an estate case by cloning estateMesh and ; fle dds setting Uinlet to (40 0 0) in0/U Alee grrs ™ Add pressure probes at select locations m Copy packaged probes function object into system directory >> cp $FOAM_ETC/caseDicts/postProcessing/probee/probes systen = Set the fields and probeLocations in probes —\ ™ Include probes from the controlDict file | Foam CloneCure See Sone ln gent wu oo Caer \w Como chs \uor wo FAY Wu softens Hema gee WN gee HY a perdi (92 4 “cael © S a 0): 25 yaw aubrd yer Unies (40 00); 22 ype ves \ 4 (us Suthetweo- due Um f Viale’ 4 copyright © 2015-2016.cRD Direct cd ! CFD Direct Objective data | Force coefficients 64/102 ™ Packaged function objects for force calculation are listed by >> 1s SFOAM_ETC/caseDicts/postProcessing/forces Files ending . cfg contain configuration settings 1 Other files are function objects for copying to system directory 1 Copy the forceCoef fsIncompressible file to system 1m #include this file in functions in controlDict Name of patch over which forces are integrated |U.0| for coefficient calculation Tres for moment coefficient Crm Aves for lift/drag coefficients C\, C: Estimate of frontal area } lift and drag directions } moment pitch axis and centre of rotation — midpoint between wheel axles [ogk /oorgsoeo] ere /cedrchs /seh Conan! Fen edt a (2 Andie pavrtune ica eee eae her FAME Ym catcos de am poeko ayers ~ pre el pot Prercmmads k Pam ve te Célelen ey wuvehl ne coai tie ane polar callow cous chr oee foo nope. CFD Direct Copyright © 2015-2016 CFD Direct Ltd Objective data | Monitoring data 65/102 = Run simpleFoam m= foamMonitor: displays data graphically; for usage type >> foamMonitor -h m= Execute it on a time-data file, e.g. probe data >> foamMonitor postProcessing/probes/0/p & m Data refreshes every 10s; stops refreshing if data unchanged for 60s = Monitor drag coefficient, setting y—range from 0.3 to 0.4 >> foamMonitor -y "[0.3:0.4]" postProcessing/forceCoeffs/0/forceCoefts.dat & copay vendedo lea Visyelrahen, rr a a a Tie As bok foparceom30/ere Jcare Dict Joat Receosng/ ¥ de age & puede enhbev a prubes ey corpiguacer de, r poremeéhey Inclow ef archive eo el cembel cuhd Diet pile . FUL 29 ; frobtg yy ge auade Gr el curhel Dich che ve Ge x Callen Al yerlear- e poe Copyright © 2015-2016 CFD Direct Ltd CFD Direct Objective data | Residuals. 66/102 Residuals are printed to terminal / log file . but residuals function object writes to file for monitoring Set up residuals to write residuals for U, p and k . . ™ Copy packaged residuals function object into system directory . = #include residuals in functions in the controlDict = Monitor residuals, setting logarithmic y—scale (-1 or -logscale option) >> foamMonitor -1 postProcessing/residuals/0/residuals.dat & os oor oie 10 200 aso a0 35000 Coplar Yenduls en conbdlOict ge yrolle prow stop At wellenow 5 CFD Direct Copyright © 2015-2016 CFD Direct Ltd Objective data | Other objective function objects 67/102 f m In $FOAM_ETC/caseDicts/postProcessing = flowRatePatch: flow rate between 2 patches owRateSurface: volume flow rate between 2 tri-surfaces vo. minMax directory: several function objects to write min/max values m .. especially fieldMinMax; useful to check boundedness, e.g. a, T', k, 6, w staticPressure: converts kinematic pressure to pressure (force/area) totalPressure: calculates total pressure pr = Pret + p + p|U|?/2 u pressureDifferencePatch: difference in mean pressure on 2 patches oh tan wenite Corba hone ste} yunbbne } ( Copyright © 2015-2016 CFD Direct Ltd CFD Direct Graphs | Quick graphs 68/102 1m Task: plot pressure downstream of tallest building in windAroundBuildings 1m ParaView has graphs plotting = Load case into ParaView, t = 400 = Extract building patches = Filter + Data Analysis mu... Plot Over Line = Limited format control 204 Pressure 10} Pp im*/s*] 0 20 40 60 80 100 120 140 Height z [m] CFD Direct Copyright © 2015-2016 CFD Direct Ltd Graphs | Graphs with the sample utility 69/102 m sample utility: samples data from a sampleDict configuration file = Copy the template sampleDict file to system >> op SFOAM_ETC/caseDicts/postProcessing/graphe/sampleDict system = Edit the file; set same sample line as before = Run sample >> sample m Files in postProcessing/sets/

You might also like