OpenFOAMslides-02 (1185932), страница 4
Текст из файла (страница 4)
Creating the ner meshMapping the coarse mesh results onto the ne meshmapFieldsutility maps one or more elds relating to a given geometryonto the corresponding elds for another geometry.The eld data that mapFields maps is read from the time directoryspecied by startFrom/startTime in the controlDict of the target case, i.e.those into which the results are being mapped.deltaT -> 0.0025, writeControl: timeSteprunTime, writeInterval -> 0.1Control adjustments:Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.->69 / 89Plotting graphsfoamCalc <calcType> <fieldName1 ... fieldNameN>cd $FOAM_RUN/tutorials/incompressible/icoFoam/cavityfoamCalc components UIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.70 / 89Stress analysis of a plate with a holeIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.71 / 89Stress analysis of a plate with a holeIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.72 / 89Stress analysis of a plate with a holeIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.73 / 89Stress analysis of a plate with a holeIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.74 / 89Stress analysis of a plate with a holeblockMeshDict IconvertToMeters 1;vertices((0.5 0 0)(1 0 0)(2 0 0)(2 0.707107 0)(0.707107 0.707107 0)(0.353553 0.353553 0)(2 2 0)(0.707107 2 0)(0 2 0)(0 1 0)(0 0.5 0)(0.5 0 0.5)(1 0 0.5)(2 0 0.5)(2 0.707107 0.5)(0.707107 0.707107 0.5)(0.353553 0.353553 0.5)(2 2 0.5)(0.707107 2 0.5)(0 2 0.5)(0 1 0.5)(0 0.5 0.5));blocks(hex (5 4 9 10 16 15 20 21) (10 10 1) simpleGrading (1 1 1)hex (0 1 4 5 11 12 15 16) (10 10 1) simpleGrading (1 1 1)hex (1 2 3 4 12 13 14 15) (20 10 1) simpleGrading (1 1 1)hex (4 3 6 7 15 14 17 18) (20 20 1) simpleGrading (1 1 1)hex (9 4 7 8 20 15 18 19) (10 20 1) simpleGrading (1 1 1)Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.75 / 89Stress analysis of a plate with a holeblockMeshDict IIedges(arc 0 5 (0.469846 0.17101 0)arc 5 10 (0.17101 0.469846 0)arc 1 4 (0.939693 0.34202 0)arc 4 9 (0.34202 0.939693 0)arc 11 16 (0.469846 0.17101 0.5)arc 16 21 (0.17101 0.469846 0.5)arc 12 15 (0.939693 0.34202 0.5)arc 15 20 (0.34202 0.939693 0.5));boundary(left{type symmetryPlane;faces((8 9 20 19)(9 10 21 20));}right{type patch;faces((2 3 14 13)(3 6 17 14));}down{Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.76 / 89Applications and librariessolvers are each designed to solve a specic problemin computational continuum mechanics;utilities perform simple pre-and post-processingtasks, mainly involving data manipulationand algebraic calculations.Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.77 / 89The programming language of OpenFOAMOpenFOAM is written in object-oriented C++Equations representations:∂ρU+ ∇ · (φU ) − ∇ · (µ∇U ) = −∇p∂tsolve(fvm::ddt(rho, U)+ fvm::div(phi, U)- fvm::laplacian(mu, U)==- fvc::grad(p));Solver codes are documented with Doxygen at$WM_PROJECT_DIR/doc/Doxygen/html/index.htmlIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.78 / 89OpenFOAM classes can be compiled to shared object library with .soextensions.Later they can be user in other programms or classed with dynamic linkingIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.79 / 89Class declarationEach class requires a class declaration, contained in a header le with a .Hle extension, e.g.nc.H, that includes the names of the class and itsfunctions.This le is included at the beginning of any piece of code using the class,including the class declaration code itself..C code can resource any number of classes and must begin with all the .Hles required to declare these classes.The classes in turn can resource other classes and begin with the relevant.H les.
By searching recursively down the class hierarchy we can produce acomplete list of header les for all the classes on which the top level .Ccode ultimately depends; these .H les are known as the dependencies.With a dependency list, a compiler can check whether the source les havebeen updated since their last compilation and selectively compile only thosethat need to be.Header les are included in the code using # include statements, e.g.#include "otherHeader.H";Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.80 / 89Building with wmakeAutomatic generation and maintenance of le dependency lists, i.e. lists ofles which are included in the source les and hence on which they depend.Multi-platform compilation and linkage, handled through appropriatedirectory structure.Multi-language compilation and linkage, e.g.
C, C++, Java.Multi-option compilation and linkage, e.g. debug, optimised, parallel andproling.Support for source code generation programs, e.g. lex, yacc, IDL, MOC.Simple syntax for source le lists.Automatic creation of source le lists for new codes.Simple handling of multiple shared or static libraries.Extensible to new machine types.Extremely portable, works on any machine with: make; sh, ksh or csh; lex, cc.Has been tested on Apollo, SUN, SGI, HP (HPUX), Compaq (DEC), IBM(AIX), Cray, Ardent, Stardent, PC Linux, PPC Linux, NEC, SX4, FujitsuVP1000.Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.81 / 89Compiling with wmakeIncluding headers: troughMake/optionsEXE_INC = \-I<directoryPath1> \-I<directoryPath2> \...\-I<directoryPathN>Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.82 / 89Linking to librariesMake/options leEXE_LIBS = \-L<libraryPath1>-L<libraryPath2>...-L<libraryPathN>-l<library1>-l<library2>...-l<libraryN>Ilias Sibgatullin (Moscow University)\\\\\\\OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.83 / 89Source les to be compiledThe full list of .C source les must be included in the Make/les leMost simple case:newApp.CEXE = $(FOAM_USER_APPBIN)/newAppTo run wmake:wmake <optionalArguments> <optionalDirectory>Options:all wmake all subdirectories, running Allwmake les if presentexe Compile statically linked executablelib Compile statically linked archive lib (.a)libo Compile statically linked lib (.o)libso Compile dynamically linked lib (.so)dep Compile lnInclude and dependencies onlyIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.84 / 89Removing dependency lists: wclean and rmdepallwclean <optionalArguments> <optionalDirectory>Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.85 / 89Adding temperature transport to icoFoamLet's check where$FOAM_SOLVERSenviroment variable points to:echo $FOAM_SOLVERSls $FOAM_SOLVERSYes, it does point to the residence of all the OpenFOAM default solvers.Now we will rst go to the directory where we want to keep the sourcecodes of our own solvers, f.e.$HOME/calc/source/OpenFOAMand we willcopy icoFoam solver to that direcorycp -rf $FOAM_SOLVERS/incompressible/icoFoam icoFoamHeatNow change the lename of the.Csource le of the new solver:mv icoFoam.C icoFoamHeat.CNext, you have to changeMake/files(3! changes):icoFoam.C -> icoFoamHeat.CEXE = $(FOAM_USER_APPBIN)/icoFoam-> EXE = $(FOAM_USER_APPBIN)/icoFoamHeatIlias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.86 / 89After you have compiled your new solver, you have,the name of the solver inIlias Sibgatullin (Moscow University)system/controlDictOpenFOAM course 1: theory of FVMof course,to change19 ìàÿ 2016 ã.87 / 89SIMPLE algorithm, SIMPLE is an acronym for Semi-Implicit Method for PressureLinked Equations.1Set the boundary conditions.2Compute the gradients of velocity and pressure.3Solve the discretized momentum equation to compute theintermediate velocity eld.4Compute the uncorrected mass uxes at faces.5Solve the pressure correction equation to produce cell values of thepressure correction.6Update the pressure eld:pk+1 = pk + urf · punder-relaxation factor for pressure.where urf is the0pb .0∗= ṁf + ṁf7Update the boundary pressure corrections8k+1Correct the face mass uxes: ṁf9Correct the cell velocities:gradient of the pressure000~v k+1 = ~v ∗ − Vol~av∇p ; where∇p is thePcorrections, ~avP is the vector of centralcoecients for the discretized linear system representing the velocityequation and Vol is the cell volume.10 Update density dueIlias Sibgatullin(Moscow University)topressurechangesOpenFOAMcourse1: theory ofFVM19 ìàÿ 2016 ã.88 / 89PISO algorithm (Pressure Implicit with Splitting ofOperator)1Set the boundary conditions.2Solve the discretized momentum equation to compute an intermediatevelocity eld.3Compute the mass uxes at the cells faces.4Solve the pressure equation.5Correct the mass uxes at the cell faces.6Correct the velocities on the basis of the new pressure eld.7Update the boundary conditions.8Repeat from 3 for the prescribed number of times.9Increase the time step and repeat from 1.Ilias Sibgatullin (Moscow University)OpenFOAM course 1: theory of FVM19 ìàÿ 2016 ã.89 / 89.