You are on page 1of 40

OpenFOAM Tips & Tricks

- 1 OpenFOAM Korea Users’ Community Conference
st

2012. 10. 18 ( 주 ) 넥스트폼

목차 .

utilities, boundary conditions, functions, etc...

Pre­processing Solver setup & solving post­processing

Pre-processing

Mesh generation

BlockMesh SnappyHexMesh

BlockMesh → SnappyHexMesh BlockMeshDict, snappyHexMeshDict Stl file Feature line (OF­2.x)

eMesh stator./constant/triSurface/stator.eMesh  파일은 snappyHexMesh 에서 feature line 으 로 사용  .obj  파일은 paraview 에서 확인 가능 ***./stator surfaceFeatureConvert [options] <input file> <output file> surfaceFeatureConvert stator.stl .SnappyHexMesh featureline  feature line extract  surfaceFeatureExtract [options] <surface> <output set> surfaceFeatureExtract ­includedAngle 150 ­writeObj  .obj   feature line convert    ***.

msh  Mesh file   Example   fluent3DMeshToFoam . ­writeZones.Mesh file convert  fluentMeshToFoam [options] <mesh file> Options   ­scale./test. ­writeSets 2d or 3d msh. cas file ­ ascii type only fluentMeshToFoam ­scale 0..001 ­writeZones .

Mesh file convert  StarCCM+  ccm26ToFoam <ccm file> plot3dToFoam [options] <plot3d geom file> Options   Plot3d   ­2D <thickness>. ­noBlank. ­scale Plot3dToFoam ­noBlank ­scale 0.001 test.grd  Example  .

 ­region <name>. rotate  transformPoints [options] Options   ­parallel.001 0.001)’ transformPoints ­translate ’(1 0 0)’ transformPoints ­rotate ’( (1 0 0) (0 0 1) )’  Example    . ­translate <vector> transformPoints ­scale ’(0. ­rotateFields. ­scale  <vector>.001 0. ­rollPitchYaw <vector>.Scale. translate.  ­rotate <(vectorA vectorB)>.

 faces.face.cell handling  checkMesh   constant/polyMesh 의 구성  checkMesh >  checkMeshResults & tail ­f checkMeshResults sets of points. cells zones of points. cells regions of meshes boundary points  faces neighbour owner pointZones faceZones cellZones sets(directory)    sets     zones     regions     . faces.Point.

 remove.face.cell handling  setSet  Interactive or batch job Batch job : setSet ­batch <batch file name> cellSet | faceSet | pointSet <setName> <action>  <source> list.Point. invert. clear. delete <source>. add  <source>. new <source>. subset <source>   set command   action  .

 faceZones. cellZones  등의 파일이 수정됨  .Point.face.cell handling  setSet example  Wrong oriented face 와 high skew face 들과 인접한 cell 들의 set 의 설정 SetSet ­batch batchFileExample batchFileExample  파일의 내용 cellSet test new cellSet test add faceToCell wrongOrientedFaces any cellSet test add faceToCell skewFaces any quit    Make zones from sets  setsToZones ­noFlipMap pointsZones.

 //pointSet.5). // any name cellSet. } } ). cylinderToCell.  ­parallel. ­noZero. ­region <name>... .5 0.cell handling  topoSet [options] set  을 만드는 다른 방법 options   topoSetDict example actions ( {    name     type    action    source cell1. // add. faceSet new. …  system/topoSetdict  파일에서 방 법 지정    sourceInfo    { p1 (0. ­time. delete.   ­latestTime.. //boxToCell.1.Point.6 0.       radius 0..       p2 (0.5 0.5 0.face.5).

 cellZones 를 만들기 위해 constant/polyMesh/sets 에 cell region 을 써 준다 . ­overwrite  subsetMesh   splitMeshRegions [options]   regionCellsets : of16ext only.Mesh handling  mergeMeshes  mergeMeshes <master case> <case to add> [options] Example   mergeMeshes stator rotor (OF21) mergeMeshes . ­cellZonesOnly. rotor (OF16ext)   system/controlDict  파일에 functionObjects 가 없어야 한다 subsetMesh [options] <cellSet> Options : ­cellZones. ­cellZonesFileOnly. . stator .

 nonOrthoFaces.Bad cell remove  checkMesh  실행  wrongOrientedFaces. zeroVolumeCells.  zeroAreaFaces  등의 파일이 constant/polyMesh/sets/  폴더에 생성 setSet ­batch batchFile batchFile  파일의 내용 cellSet zeroVolumeCells invert cellSet zeroVolumeCells subset quit  setSet  유틸리티를 사용하여 삭제할 cell  지정    subsetMesh zeroVolumeCells ­overwrite oldInternalFaces 라는 patch 가 생성 ­  type 을 symmetryPlane 으로 수 정  . skewFaces.

 }    bridgeOverlap  false. rightZone. leftZone. 988976. int­1. } setsToZones ­noFlipMap  constant/polyMesh/boundary  파일 편집 0/<boundary file>  편집 int­1 { type   ggi. } .GGI interface  int­1.     ggi.  setSet ­batch <batch file name> batch file 의 내용 예 faceSet leftZone new patchToFace int­1 faceSet rightZone new patchToFace int­2   faceSet 을 zone 으로 만든다 .    bridgeOverlap  false. int­2  두 개의 면을 ggi 로 설정하는 방법 setSet  유틸리티를 이용하여 각 면에 해 당하는 faceSet 을 만든다 . 333. int­2.   constant/polyMesh/boundary  파일 편집 int­1 {type    nfaces     startFace    shadowPatch   zone  int­2 { type   nfaces   startFace   shadowPatch   zone    ggi. 299. 989000.

rotationAxis   (0 0 1). nface       2344.       rotor_in_zone. } .Cyclic ggi / overlap ggi  rotor1 과 rotor2 가 쌍을 이루고 있다면 rotor1 { type nface   startFace   zone         cyclicGgi. bridgeOverlap   off. ncopies     6.      234666. separationOffset off.   234666. shadowPatch stator_out. rotationAxis     ( 0 0 1).      2344. rotationAngle   60.  rotor_in 과 stator_out 이 쌍을 이루고 있다면 rotor_in { type      startFace   zone overlapGgi. } shadowPatch   rotor2.        rotor1Zone.

. neighbourPatch transform   }   noOrdering. AMI2 nfaces     startFace   matchTolerance 0.   22416.AMI interface  constant/polyMesh/boundary AMI1 { type      cyclicAMI.0001.   177343.

Patch handling  autoPatch [options] <feature angle[0­180]>  feature angle 을 이용하여 여러개의 면으로 나누기 Example   autoPatch ­overwrite 90  createPatch [options]   createPatchDict 를 이용하여 patch  생성 Example   createPatch ­overwrite .

Patch handling  createPatch example topoSet  유틸리티를 이용하여 faceSet 을 만든 다음 createPatch 를 사용 topoSet → createPatch topoSetDict  파일 actions ( {     name    type    action    source waterin. new. faceSet.  createPatchDict matchTolerance patches ( {    name     patchInfo { type patch. boxToFace.0 0. pointSync      true.       sourceInfo { box (­15 ­11 ­10) (­ 14.    set } ). waterInlet. }    constructFrom set. 1e­3.6 1. waterin.34). } } ). .

Solver setup & solving .

inletOutlet.  surfaceNormalFixedValue.Boundary conditions  fixedValue type   value fixedValue. uniform (0 0 0). uniform 1.  pressureInletOutletVelocity type   value pressureInletOutletVelocity. uniform (0 0 0). 1. uniform (0 0 0).  surfaceNormalFixedValue type value  inletOutlet type   value inletValue uniform (0 0 0).  fixedMeanValue type    fixedMeanValue. refValue . meanValue   zeroGradient type   zeroGradient. uniform (0 0 0).

out. uniform 323. uniform (1 0 0).Boundary conditions  flowRateInletVelocity   AtmboundaryLayerInletVelocity type atmBoundaryLayerInletVelocity.2 Href   n z z0       300. (0 0 1). uniform 0. outletMappedUniformInlet. CH4 uniform 0.1.4. gamma p0   1. Uref 1.    totalPressure  type totalPressure.03. uniform 101325. value uniform (0 0 0). flowRate 0. type flowRateInletVelocity. (1 0 0).                outletMappedUniformInlet  value type   field   value zGround  outletPatchName     .1.

uniform 300. // power q K uniform 10. heatSource flux. uniform 5.      value KName  .    heatflux type compressible::turbulentHeatFluxTe mperature.Boundary conditions  Heat transfer coeff. none. basicThermo.  mixed fixedEnthalpy fixedInternalEnergy gradientEnthalpy gradientInternalEnergy mixedEnthalpy mixedInternalEnergy totalTemperature externalWallHeatFluxTemperature compressible::turbulentTemperatureCou pledBaffle compressible::turbulentTemperatureRad CoupledMixed   alphaWall uniform 1e­5. type    Tinf    value wallHeatTransfer. uniform 300.

1) (100 ).1.4. Example1 type   uniformFixedValue..0 UniformFixedValue FlowRateInletVelocity UniformTotalPressure oscillating.  flowRate table    ).0)  Example2 type (  (0 1. uniformValue table ( (0  0. p0 U phi gamma value 40.0)   flowRateInletVelocity. U phi 1.0) (1 3. Example3 type uniformTotalPressure.   From 2.. uniform 40. 10.Time dependent B. pressure table ( (0 10) (1 40) ).C.  .

uniform 0. "ccc".  Example1  Example2 type   variables     valueExpression  value              . groovyBC.1. "ccc=time()*0.1.  변수 구분은 .". uniform 0.Boundary conditions  groovyBC  swak4Foam keyword     type : groobyBC variable :  변수 선언 .  변수선언은 ”” valueExpression : C++  수식 입력 방식 type   variables valueExpression  value                groovyBC. "con". "con{out}=sum(CH4*mag(Sf()))/sum(mag(Sf()))..".

1. source.      scalar  bb=10.  controlDict  등에서 사용 가능 Value 가 들어갈 자리에 #codeStream 이라고 입력 후 그 아래 코드 작성 코드 작성은 #{     #}  사이에  Example scalarExplicitSourceCoeffs { volumeMode specific. injectionRate { S #codeStream { code   #{ scalar  aa=100.      os<<(aa+bb). Boundary condition.codeStream  OF­2. } }   .  #} }.

 kOmega. omega nuTilda (SA) nut. uniform 0. SpalartAllmaras. mut.3..   0  폴더에 필요한 파일들  k. epsilon.turbulence  Constant   wall function  사용하지 않을 때 k : fixedValue 0 omega :  compressible::omegaWallFunction mut  turbulenceProperties   laminar RASModel.. 9. LES   RASProperties  kepsilon. 0. alphat  mutLowReWallFunction zeroGradient (OF16ext) alphatJayatillekeWallFunction zeroGradient (OF16ext)     roughWallFunction  사용  alphat   nut  파일 type   Ks   Cs   value nutRoughWallFunction. .

k 1e­5.Convergence criteria  FvSolution  파일의 SIMPLE dictionary 에서 정의 Example SIMPLE { nNonOrthogonalCorrectors 1. } }  . residualControl { p 1e­5. U 1e­5. epsilon 1e­5.

numberOfSubDomains 6. patchConstraints ( (rotorInlet 1)  (statorOutlet 1) ). simple. patchConstrainedCoeffs   reconstructPar ­latestTime ReconstructPar ­time ***  ... ggi decompose : decomposeParDict 에 ggi  면들을 globalFaceZones 에 등록 globalFaceZones ( leftZone rightZone ). metis.  patchConstrained. } patchConstrained.  hostfile node1 cpu=12 node2 cpu=12 node3 cpu=12    mpirun ­np 6 simpleFoam ­parallel Mpirun ­ ­hostfile hosts ­np 36  simpleFoam ­parallel reconstructPar   patchContrained example type { method metis.parallel  decomposePar Type : scotch.

py <solver>  pyFoamPlotRunner.py mpirun ­­hostfile hosts ­np 36  simpleFoam ­parallel .계산과정 monitoring  pyFoam  pyFoamPlotRunner.py mpirun ­­hostfile <host file  name> hosts ­np <# of core> <solver>  ­parallel  pyFoamPlotRunner.py simpleFoam   pyFoamPlotRunner.

  swakExpression. forceCoeffs..Function  controlDict 에 추가 function 이 필요로하는 library  지정   libs ( ”< library name>. probes.   type 의 value  . type 의 value 에 의해 결정 patchMassFlow. expression. patchExpression. expressionField. patches. fieldName. fields. keyword   type. patchMassFlowAverage.  accumulation..  function 은 dictionary 로 지정한다 ... patchAverage. faceSource.so” ). volumeIntegrate. verbose. valueType.  forces. autoWrite.

(faceA faceB).Function  면에서의 평균값 구하기  area­weighed average areaAverage { type patchAverage functionObjectLibs (”libsimpleFunctionObjects. (p T U rho).so”) verbose fields  patches factor } true. . 1. (faceA faceB). }  mass­weighed average massAverage { type   patchMassflowAverage functionObjectLibs (”libsimpleFunctionObjects. (p T U rho). 1.so”) verbose fields  patches factor true.

verbose true. functionObjectLibs (”libsimpleFunctionObjects . totalLiquid { type    volumeIntegrate. factor   ­1. patches  (faceA).  . fileds } (alpha1). }  Volume integral  구하기 libs (”libsimpleFunctionObjects.so”).so”). verbose true.Function  유량 구하기 inletMassFlow { type    patchMassFlow.

patch.so”). false. functionObjectLibs (”libsampling. outputControl outputTime.Function  Area integral  구하기 faceA { type      faceSource.         true. fluidA. ( p U T ). minX. operation   fields } areaAverage. . false. enable region log source          true. solidA. areaIntegrate. true. true. point.so”). outputControl timeStep.  Point value  구하기 pointValues { type  enable region log   source       probes. valueOutput probeLocations valueOutput sourceName operation   fields }   ( ( 1 1 1)  (2 2 2)  (3 3 3) ).     ( U ). functionObjectLibs (”libfieldFunctionObjects.

patches rhoInf nuInf CofR }         (faceA faceB). 1.         p. rhoInf. (0 0 0).so”). timeStep. (0 0 0). outputInterval 1. 1e­6. 1. outputControl outputInterval patches rhoName pName UName  rhoInf CofR liftDir  dragDir pitchAxis lRef  Aref    }   . (0 0 1).2.2. (faceA faceB). outputControl timeStep.  Force coefficient 구하기 forceCoeffs { type     forceCoeffs. functionObjectLibs (”libforces. (1 0 0).Function  force 구하기 force { type    forces.so”). U. (0 1 0). functionObjectLibs (”libforces.   1. 1. 1.

CdHistory. master DragCoeff. . (”drag coefficient”).customRegexp  계산중 물리량 변화 모니터링 작업 폴더 아래 customRegexp  파일 에서 지정 DragCoeff { expr  name titles type  } ”Cd = (%f%)”.  LiftCoeff { expr  ”Cl = (%f%)”. type  slave. titles (”lift coefficient”). } theTitle ”forec coefficient”. regular.

ETC  setFields  setFieldsDict mapFieldsDict  mapFields  .

Post-processing .

utilities  yPlusRAS vorticity wallShearStress Mach    .