Vous êtes sur la page 1sur 40

OpenFOAM Tips & Tricks

- 1 OpenFOAM Korea Users Community Conference


st

2012. 10. 18 ( )

utilities,boundaryconditions,functions,etc...

Preprocessing Solversetup&solving postprocessing

Pre-processing

Mesh generation

BlockMesh SnappyHexMesh

BlockMeshSnappyHexMesh BlockMeshDict,snappyHexMeshDict Stlfile Featureline(OF2.x)

SnappyHexMesh featureline

featurelineextract

surfaceFeatureExtract[options]<surface><outputset> surfaceFeatureExtractincludedAngle150writeObj ./constant/triSurface/stator.stl./stator surfaceFeatureConvert[options]<inputfile><outputfile> surfaceFeatureConvertstator.eMeshstator.obj

featurelineconvert

***.obj paraview ***.eMesh snappyHexMesh featureline

Mesh file convert

fluentMeshToFoam[options]<meshfile> Options

scale,writeZones,writeSets 2dor3dmsh,casfileasciitypeonly fluentMeshToFoamscale0.001writeZones../test.msh

Meshfile

Example

fluent3DMeshToFoam

Mesh file convert

StarCCM+

ccm26ToFoam<ccmfile> plot3dToFoam[options]<plot3dgeomfile> Options

Plot3d

2D<thickness>,noBlank,scale Plot3dToFoamnoBlankscale0.001test.grd

Example

Scale, translate, rotate

transformPoints[options] Options

parallel,region<name>,rollPitchYaw<vector>, rotate<(vectorAvectorB)>,rotateFields,scale <vector>,translate<vector> transformPointsscale(0.0010.0010.001) transformPointstranslate(100) transformPointsrotate((100)(001))

Example

Point,face,cell handling

checkMesh

constant/polyMesh

checkMesh> checkMeshResults& tailfcheckMeshResults setsofpoints,faces,cells zonesofpoints,faces,cells regionsofmeshes

boundary points faces neighbour owner pointZones faceZones cellZones sets(directory)

sets

zones

regions

Point,face,cell handling

setSet

Interactiveorbatchjob Batchjob:setSetbatch<batchfilename> cellSet|faceSet|pointSet<setName><action> <source> list,clear,invert,remove,new<source>,add <source>,delete<source>,subset<source>

setcommand

action

Point,face,cell handling

setSetexample

Wrongorientedface highskewface cell set SetSetbatchbatchFileExample batchFileExample


cellSettestnew cellSettestaddfaceToCellwrongOrientedFacesany cellSettestaddfaceToCellskewFacesany quit

Makezonesfromsets

setsToZonesnoFlipMap pointsZones,faceZones,cellZones

Point,face,cell handling

topoSet[options] set options

topoSetDictexample
actions ( { name type action source cell1;//anyname cellSet;//pointSet,faceSet new;//add,delete... cylinderToCell;//boxToCell...

latestTime,noZero,time, parallel,region<name>,

system/topoSetdict

sourceInfo {p1(0.50.50.5); p2(0.60.50.5); radius0.1;} } );

Mesh handling

mergeMeshes

mergeMeshes<mastercase><casetoadd>[options] Example

mergeMeshesstatorrotor(OF21) mergeMeshes.stator.rotor(OF16ext)

system/controlDict functionObjects subsetMesh[options]<cellSet> Options:cellZones,cellZonesFileOnly,cellZonesOnly,overwrite

subsetMesh

splitMeshRegions[options]

regionCellsets:of16extonly,cellZones constant/polyMesh/sets cellregion .

Bad cell remove

checkMesh

wrongOrientedFaces,skewFaces,zeroVolumeCells,nonOrthoFaces, zeroAreaFaces constant/polyMesh/sets/ setSetbatchbatchFile batchFile cellSetzeroVolumeCellsinvert cellSetzeroVolumeCellssubset quit

setSet cell

subsetMeshzeroVolumeCellsoverwrite oldInternalFaces patch type symmetryPlane

GGI interface

int1,int2 ggi setSet faceSet .

constant/polyMesh/boundary
int1 {type nfaces startFace shadowPatch zone int2 {type nfaces startFace shadowPatch zone ggi; 333; 989000; int1; rightZone; ggi; 299; 988976; int2; leftZone;

setSetbatch<batchfilename> batchfile faceSetleftZonenewpatchToFaceint1 faceSetrightZonenewpatchToFaceint2

faceSet zone .

bridgeOverlap false;}

setsToZonesnoFlipMap

constant/polyMesh/boundary 0/<boundaryfile>
int1 {type ggi;}

bridgeOverlap false;}

Cyclic ggi / overlap ggi

rotor1 rotor2 rotor1 { type nface startFace zone cyclicGgi; 2344; 234666;

rotor_in stator_out rotor_in { type startFace zone overlapGgi; 234666; nface 2344; shadowPatch stator_out; rotor_in_zone; rotationAxis (001); ncopies 6; }

shadowPatch rotor2; rotor1Zone; bridgeOverlap off; rotationAxis (001); rotationAngle 60; separationOffset off; }

AMI interface

constant/polyMesh/boundary AMI1 { type cyclicAMI; 22416; 177343; AMI2 nfaces startFace

matchTolerance 0.0001; neighbourPatch transform } noOrdering;

Patch handling

autoPatch[options]<featureangle[0180]>

featureangle Example

autoPatchoverwrite90

createPatch[options]

createPatchDict patch Example

createPatchoverwrite

Patch handling

createPatchexample topoSet faceSet createPatch topoSetcreatePatch topoSetDict


actions ( { name type action source waterin; faceSet; new; boxToFace;

createPatchDict matchTolerance patches ( { name patchInfo { type patch;} constructFrom set; set } ); waterin; waterInlet; 1e3; pointSync true;

sourceInfo {box(151110)( 14.61.00.34);} } );

Solver setup & solving

Boundary conditions

fixedValue
type value fixedValue; uniform(000);

fixedMeanValue
type fixedMeanValue; 1; meanValue

zeroGradient
type zeroGradient; surfaceNormalFixedValue; uniform1; uniform(000);

pressureInletOutletVelocity
type value pressureInletOutletVelocity; uniform(000); inletOutlet; uniform(000);

surfaceNormalFixedValue
type value

inletOutlet
type value inletValue uniform(000);

refValue

Boundary conditions

flowRateInletVelocity

AtmboundaryLayerInletVelocity
type atmBoundaryLayerInletVelocity; Uref 1.2 Href n z z0 300; (100); (001); uniform0.03; uniform(100); uniform323;

type flowRateInletVelocity; flowRate 0.1; value uniform(000);

totalPressure

type totalPressure; gamma p0 1.4; uniform101325; outletMappedUniformInlet; out; CH4 uniform0.1;

outletMappedUniformInlet

value

type field value

zGround

outletPatchName

Boundary conditions

Heattransfercoeff.
type Tinf value wallHeatTransfer; uniform300; uniform5;

mixed fixedEnthalpy fixedInternalEnergy gradientEnthalpy gradientInternalEnergy mixedEnthalpy mixedInternalEnergy totalTemperature externalWallHeatFluxTemperature compressible::turbulentTemperatureCou pledBaffle compressible::turbulentTemperatureRad CoupledMixed

alphaWall uniform1e5;

heatflux
type compressible::turbulentHeatFluxTe mperature; heatSource flux;//power q K uniform10; basicThermo; uniform300; none;

value KName

Time dependent B.C.

From2.1.0 UniformFixedValue FlowRateInletVelocity UniformTotalPressure oscillating... Example1 type uniformFixedValue; uniformValue table ( (0 0.1) (100 ); 10.0)

Example2 type (
(01.0) (13.0)

flowRateInletVelocity;

flowRate table

); Example3 type uniformTotalPressure; pressure table ((010)(140)); p0 U phi gamma value 40; U phi 1.4; uniform40;

Boundary conditions

groovyBC

swak4Foam keyword

type:groobyBC variable: , ;, valueExpression:C++ type variables valueExpression value groovyBC; "con{out}=sum(CH4*mag(Sf()))/sum(mag(Sf()));"; "con"; uniform0.1; groovyBC; "ccc=time()*0.1;"; "ccc"; uniform0;

Example1

Example2
type variables

valueExpression value

codeStream

OF2.1,Boundarycondition,source, controlDict Value #codeStream #{#}

Example
scalarExplicitSourceCoeffs { volumeMode specific; injectionRate {S #codeStream { code #{scalar aa=100; scalar bb=10; os<<(aa+bb);#} }; } }

turbulence

Constant

wallfunction k:fixedValue0 omega: compressible::omegaWallFunction mut

turbulenceProperties

laminarRASModel,LES

RASProperties

kepsilon,kOmega,SpalartAllmaras...

k,epsilon,omega nuTilda(SA) nut,mut,alphat

mutLowReWallFunction zeroGradient(OF16ext) alphatJayatillekeWallFunction zeroGradient(OF16ext)

roughWallFunction

alphat

nut type Ks Cs value nutRoughWallFunction; 9; 0.3; uniform0;

Convergence criteria

FvSolution SIMPLEdictionary Example


SIMPLE { nNonOrthogonalCorrectors 1; residualControl { p 1e5; U 1e5; k 1e5; epsilon 1e5; } }

parallel

decomposePar Type:scotch,metis,simple, patchConstrained... ggidecompose:decomposeParDict ggi globalFaceZones


globalFaceZones(leftZonerightZone);

hostfile
node1 cpu=12 node2 cpu=12 node3 cpu=12

mpirunnp6simpleFoamparallel Mpirunhostfilehostsnp36 simpleFoamparallel reconstructPar

patchContrainedexample
type { method metis; numberOfSubDomains 6; patchConstraints ((rotorInlet1) (statorOutlet1)); } patchConstrained; patchConstrainedCoeffs

reconstructParlatestTime ReconstructPartime***

monitoring

pyFoam

pyFoamPlotRunner.py<solver>

pyFoamPlotRunner.pysimpleFoam

pyFoamPlotRunner.pympirunhostfile<hostfile name>hostsnp<#ofcore><solver>parallel

pyFoamPlotRunner.pympirunhostfilehostsnp36 simpleFoamparallel

Function

controlDict function library

libs (<libraryname>.so);

function dictionary . keyword

type,fields,verbose,patches,expression,fieldName,autoWrite,valueType, accumulation... type value patchMassFlow,patchAverage,patchMassFlowAverage,volumeIntegrate, forces,forceCoeffs,faceSource,probes,expressionField, swakExpression,patchExpression...

type value

Function

areaweighedaverage areaAverage { type patchAverage functionObjectLibs (libsimpleFunctionObjects.so) verbose fields patches factor } true; (pTUrho); (faceAfaceB); 1;
}

massweighedaverage massAverage { type patchMassflowAverage functionObjectLibs (libsimpleFunctionObjects.so) verbose fields patches factor true; (pTUrho); (faceAfaceB); 1;

Function

inletMassFlow { type patchMassFlow; functionObjectLibs (libsimpleFunctionObjects .so); verbose true; patches (faceA); factor 1; }

Volumeintegral libs (libsimpleFunctionObjects.so); totalLiquid { type volumeIntegrate; fileds } (alpha1); verbose true;

Function

Areaintegral faceA { type faceSource; functionObjectLibs (libfieldFunctionObjects.so); enable region log source true; solidA; true; false; patch; minX; areaIntegrate; (pUT); outputControl outputTime;

Pointvalue pointValues { type enable region log source probes; true; fluidA; true; false; point; functionObjectLibs (libsampling.so); outputControl timeStep;

valueOutput probeLocations

valueOutput sourceName operation fields }

((111)(222)(333)); operation fields } areaAverage; (U);

Function

force force { type forces; functionObjectLibs (libforces.so); outputControl timeStep; outputInterval 1; patches rhoInf nuInf CofR } (faceAfaceB); 1.2; 1e6; (000);

Forcecoefficient forceCoeffs { type forceCoeffs; timeStep; 1; (faceAfaceB); rhoInf; p; U; 1.2; (000); (010); (100); (001); 1; 1; functionObjectLibs (libforces.so); outputControl outputInterval patches rhoName pName UName rhoInf CofR liftDir dragDir pitchAxis lRef Aref }

customRegexp

customRegexp DragCoeff { expr name titles type } Cd=(%f%); CdHistory; (dragcoefficient); regular;

LiftCoeff { expr Cl=(%f%); titles (liftcoefficient); type slave; master DragCoeff; }

theTitle foreccoefficient;

ETC

setFields

setFieldsDict mapFieldsDict

mapFields

Post-processing

utilities

yPlusRAS vorticity wallShearStress Mach

Vous aimerez peut-être aussi