40
OpenFOAM Tips & Tricks - 1 st OpenFOAM Korea Users’ Community Conference 2012. 10. 18 ( ) 넥스트폼

OpenFOAM Tips & Tricks

  • Upload
    binho58

  • View
    946

  • Download
    25

Embed Size (px)

Citation preview

OpenFOAM Tips & Tricks - 1st OpenFOAM Korea Users’

Community Conference

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)

SnappyHexMesh featureline

feature line extract surfaceFeatureExtract [options] <surface> <output set> surfaceFeatureExtract ­includedAngle 150 ­writeObj 

./constant/triSurface/stator.stl ./stator

feature line convert surfaceFeatureConvert [options] <input file> <output file> surfaceFeatureConvert stator.eMesh stator.obj

***.obj  파일은 paraview 에서 확인 가능

***.eMesh  파일은 snappyHexMesh 에서 feature line으 로 사용

Mesh file convert

fluentMeshToFoam [options] <mesh file> Options

­scale, ­writeZones, ­writeSets

Mesh file 2d or 3d msh, cas file ­ ascii type only

Example fluentMeshToFoam ­scale 0.001 ­writeZones ../test.msh

fluent3DMeshToFoam

Mesh file convert

StarCCM+ ccm26ToFoam <ccm file>

Plot3d plot3dToFoam [options] <plot3d geom file> Options

­2D <thickness>, ­noBlank, ­scale Example

Plot3dToFoam ­noBlank ­scale 0.001 test.grd

Scale, translate, rotate

transformPoints [options] Options

­parallel, ­region <name>, ­rollPitchYaw <vector>, ­rotate <(vectorA vectorB)>, ­rotateFields, ­scale <vector>, ­translate <vector>

Example transformPoints ­scale ’(0.001 0.001 0.001)’ transformPoints ­translate ’(1 0 0)’ transformPoints ­rotate ’( (1 0 0) (0 0 1) )’

Point,face,cell handling

checkMesh checkMesh > 

checkMeshResults &

tail ­f checkMeshResults

sets sets of points, faces, cells

zones zones of points, faces, cells

regions regions of meshes

constant/polyMesh 의 구성 boundary points  faces neighbour owner pointZones faceZones cellZones sets(directory)

Point,face,cell handling

setSet Interactive or batch job Batch job : setSet ­batch <batch file name>

set command cellSet | faceSet | pointSet <setName> <action> 

<source>

action list, clear, invert, remove, new <source>, add 

<source>, delete <source>, subset <source>

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, faceZones, cellZones  등의 파일이 수정됨

Point,face,cell handling

topoSet [options]

set  을 만드는 다른 방법

options ­latestTime, ­noZero, ­time, 

­parallel, ­region <name>, …

system/topoSetdict  파일에서 방 법 지정

topoSetDict example

actions

(

{

   name  cell1; // any name

   type cellSet; //pointSet, faceSet

   action new; // add, delete...

   source cylinderToCell; //boxToCell...

   sourceInfo

   { p1 (0.5 0.5 0.5);

      p2 (0.6 0.5 0.5);

      radius 0.1; }

}

);

Mesh handling

mergeMeshes mergeMeshes <master case> <case to add> [options]

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

system/controlDict  파일에 functionObjects 가 없어야 한다

subsetMesh subsetMesh [options] <cellSet>

splitMeshRegions [options] Options : ­cellZones, ­cellZonesFileOnly, ­cellZonesOnly, ­overwrite

regionCellsets : of16ext only, cellZones 를 만들기 위해constant/polyMesh/sets 에 cell region 을 써 준다 .

Bad cell remove

checkMesh 실행 wrongOrientedFaces, skewFaces, zeroVolumeCells, nonOrthoFaces, 

zeroAreaFaces  등의 파일이 constant/polyMesh/sets/  폴더에 생성

setSet  유틸리티를 사용하여 삭제할 cell 지정 setSet ­batch batchFile

batchFile  파일의 내용

cellSet zeroVolumeCells invert

cellSet zeroVolumeCells subset

quit

subsetMesh zeroVolumeCells ­overwrite

oldInternalFaces 라는 patch 가 생성 ­  type 을 symmetryPlane 으로 수정

GGI interface int­1, int­2  두 개의 면을 ggi 로 설정하는방법

setSet  유틸리티를 이용하여 각 면에 해 당하는 faceSet 을 만든다 .

setSet ­batch <batch file name>

batch file 의 내용 예

faceSet leftZone new patchToFace int­1

faceSet rightZone new patchToFace int­2

faceSet 을 zone 으로 만든다 .

setsToZones ­noFlipMap

constant/polyMesh/boundary  파일 편집

0/<boundary file> 편집

int­1

{ type   ggi; }

constant/polyMesh/boundary  파일 편집

int­1

{type    ggi;

  nfaces   299;

  startFace    988976;

  shadowPatch int­2;

  zone  leftZone;

  bridgeOverlap  false; }

int­2

{ type ggi;

  nfaces 333;

  startFace 989000;

  shadowPatch int­1;

  zone    rightZone;

  bridgeOverlap  false; }

Cyclic ggi / overlap ggi rotor1 과 rotor2 가 쌍을 이루고 있다면

rotor1

{

type        cyclicGgi;

nface        2344;

startFace        234666;

shadowPatch   rotor2;

zone         rotor1Zone;

bridgeOverlap   off;

rotationAxis     ( 0 0 1);

rotationAngle   60;

separationOffset off;

}

rotor_in 과 stator_out 이 쌍을 이루고있다면

rotor_in

{

type      overlapGgi;

nface       2344;

startFace     234666;

shadowPatch stator_out;

zone       rotor_in_zone;

rotationAxis   (0 0 1);

ncopies     6;

}

AMI interface

constant/polyMesh/boundary

AMI1

{

type      cyclicAMI;

nfaces       22416;

startFace     177343;

matchTolerance 0.0001;

neighbourPatch AMI2

transform     noOrdering;

}

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 waterin;

   type faceSet;

   action new;

   source boxToFace;

   sourceInfo { box (­15 ­11 ­10) (­14.6 1.0 0.34); }

}

);

createPatchDict

matchTolerance 1e­3;

pointSync      true;

patches

(

{

   name  waterInlet;

   patchInfo

{ type patch; }

   constructFrom set;

   set waterin;

}

);

Solver setup & solving

Boundary conditions

fixedValue

type   fixedValue;

value uniform (0 0 0);

zeroGradient

type   zeroGradient;

surfaceNormalFixedValue

type  surfaceNormalFixedValue;

refValue uniform 1;

value uniform (0 0 0);

fixedMeanValue

type    fixedMeanValue;

meanValue  1;

pressureInletOutletVelocity

type   pressureInletOutletVelocity;

value uniform (0 0 0);

inletOutlet

type   inletOutlet;

inletValue uniform (0 0 0);

value uniform (0 0 0);

Boundary conditions flowRateInletVelocity

type flowRateInletVelocity;

flowRate 0.1;

value uniform (0 0 0);

totalPressure

type totalPressure;

gamma 1.4;

p0   uniform 101325;

outletMappedUniformInlet

type   outletMappedUniformInlet;

outletPatchName   out;

field       CH4

value         uniform 0.1;

AtmboundaryLayerInletVelocity

type atmBoundaryLayerInletVelocity;

Uref 1.2

Href   300;

n   (1 0 0);

z   (0 0 1);

z0   uniform 0.03;

value uniform (1 0 0);

zGround uniform 323;

Boundary conditions Heat transfer coeff.

type    wallHeatTransfer;

Tinf    uniform 300;

alphaWall uniform 1e­5;

value uniform 5;

heatflux

typecompressible::turbulentHeatFluxTemperature;

heatSource flux; // power

q uniform 10;

K basicThermo;

value uniform 300;

KName none;

mixed

fixedEnthalpy

fixedInternalEnergy

gradientEnthalpy

gradientInternalEnergy

mixedEnthalpy

mixedInternalEnergy

totalTemperature

externalWallHeatFluxTemperature

compressible::turbulentTemperatureCoupledBaffle

compressible::turbulentTemperatureRadCoupledMixed

Time dependent B.C. From 2.1.0

UniformFixedValue

FlowRateInletVelocity

UniformTotalPressure

oscillating...

Example1

type   uniformFixedValue;

uniformValue table

(

(0  0.1)

(100 10.0)

);

Example2

type   flowRateInletVelocity;

flowRate table

(0 1.0)

(1 3.0)

);

Example3

type uniformTotalPressure;

pressure table

( (0 10) (1 40) );

p0 40;

U U

phi phi

gamma 1.4;

value uniform 40;

Boundary conditions groovyBC

swak4Foam

keyword type : groobyBC

variable :  변수 선언 ,  변수 구분은 ;,  ””변수선언은

valueExpression : C++  수식 입력 방식

Example1type     groovyBC;

variables "con{out}=sum(CH4*mag(Sf()))/sum(mag(Sf()));";

valueExpression  "con";

value              uniform 0.1;

Example2type     groovyBC;

variables   "ccc=time()*0.1;";

valueExpression  "ccc";

value              uniform 0;

codeStream OF­2.1, Boundary condition, source, 

controlDict  등에서 사용 가능

Value 가 들어갈 자리에 #codeStream 이라고 입력 후 그 아래 코드 작성

코드 작성은 #{     #} 사이에

Example

scalarExplicitSourceCoeffs

{

volumeMode specific;

injectionRate

{ S #codeStream

{code  #{ scalar  aa=100;     scalar  bb=10;     os<<(aa+bb);  #}};

}

}

turbulence Constant

turbulenceProperties laminar RASModel, LES

RASProperties kepsilon, kOmega, SpalartAllmaras...

0  폴더에 필요한 파일들

k, epsilon, omega

nuTilda (SA)

nut, mut, alphat

roughWallFunction 사용

nut 파일

type   nutRoughWallFunction;

Ks   9;

Cs   0.3;

value uniform 0;

wall function  사용하지 않을 때

k : fixedValue 0

omega : compressible::omegaWallFunction

mut mutLowReWallFunction

zeroGradient (OF16ext)

alphat alphatJayatillekeWallFunction

zeroGradient (OF16ext)

Convergence criteria

FvSolution  파일의 SIMPLE dictionary 에서 정의

Example

SIMPLE

{

nNonOrthogonalCorrectors 1;

residualControl

{

p 1e­5;U 1e­5;k 1e­5;epsilon 1e­5;

}

}

parallel decomposePar

Type : scotch, metis, simple, patchConstrained...

ggi decompose : decomposeParDict 에 ggi  면들을 globalFaceZones 에 등록

globalFaceZones ( leftZone rightZone );

patchContrained example

type patchConstrained;

patchConstrainedCoeffs

{

method metis;

numberOfSubDomains 6;

patchConstraints ( (rotorInlet 1) (statorOutlet 1) );

}

hostfile

node1 cpu=12

node2 cpu=12

node3 cpu=12

mpirun ­np 6 simpleFoam ­parallel

Mpirun ­ ­hostfile hosts ­np 36 simpleFoam ­parallel

reconstructPar reconstructPar ­latestTime

ReconstructPar ­time ***

계산과정 monitoring

pyFoam pyFoamPlotRunner.py <solver>

pyFoamPlotRunner.py simpleFoam 

pyFoamPlotRunner.py mpirun ­­hostfile <host file name> hosts ­np <# of core> <solver>  ­parallel

pyFoamPlotRunner.py mpirun ­­hostfile hosts ­np 36 simpleFoam ­parallel

Function

controlDict 에 추가

function 이 필요로하는 library  지정 libs ( ”< library name>.so” );

function 은 dictionary 로 지정한다 .

keyword type, fields, verbose, patches, expression, fieldName, autoWrite, valueType, 

accumulation...

type 의 value 에 의해 결정

type 의 value patchMassFlow, patchAverage, patchMassFlowAverage, volumeIntegrate, 

forces, forceCoeffs, faceSource, probes, expressionField, swakExpression, patchExpression...

Function 면에서의 평균값 구하기

area­weighed average

areaAverage

{

type patchAverage

functionObjectLibs(”libsimpleFunctionObjects.so”)

verbose true;

fields  (p T U rho);

patches (faceA faceB);

factor 1;

}

mass­weighed average

massAverage

{

type   patchMassflowAverage

functionObjectLibs(”libsimpleFunctionObjects.so”)

verbose true;

fields  (p T U rho);

patches (faceA faceB);

factor 1;

}

Function 유량 구하기

inletMassFlow

{

type    patchMassFlow;

functionObjectLibs(”libsimpleFunctionObjects.so”);

verbose true;

patches  (faceA);

factor   ­1;

}

Volume integral 구하기

libs (”libsimpleFunctionObjects.so”);

totalLiquid

{

type    volumeIntegrate;

fileds (alpha1);

verbose true;

}

Function Area integral 구하기

faceA

{

type      faceSource;

functionObjectLibs(”libfieldFunctionObjects.so”);

enable   true;

outputControl outputTime;

region   solidA;

log   true;

valueOutput false;

source    patch;

sourceName minX;

operation   areaIntegrate;

fields   ( p U T );

}

Point value 구하기

pointValues

{

type       probes;

functionObjectLibs (”libsampling.so”);

enable   true;

outputControl timeStep;

region   fluidA;

log     true;

valueOutput false;

source    point;

probeLocations

( ( 1 1 1)  (2 2 2)  (3 3 3) );

operation   areaAverage;

fields     ( U );

}

Function force구하기

force

{

type    forces;

functionObjectLibs (”libforces.so”);

outputControl timeStep;

outputInterval 1;

patches   (faceA faceB);

rhoInf   1.2;

nuInf   1e­6;

CofR   (0 0 0);

}

Force coefficient구하기

forceCoeffs

{

type     forceCoeffs;

functionObjectLibs (”libforces.so”);

outputControl timeStep;

outputInterval 1;

patches   (faceA faceB);

rhoName rhoInf;

pName   p;

UName  U;

rhoInf   1.2;

CofR   (0 0 0);

liftDir    (0 1 0);

dragDir (1 0 0);

pitchAxis (0 0 1);

lRef    1;

Aref    1;

}

customRegexp 계산중 물리량 변화 모니터링

작업 폴더 아래 customRegexp 파일 에서 지정

DragCoeff

{

expr  ”Cd = (%f%)”;

name CdHistory;

theTitle ”forec coefficient”;

titles (”drag coefficient”);

type  regular;

}

LiftCoeff

{

expr  ”Cl = (%f%)”;

titles (”lift coefficient”);

type  slave;

master DragCoeff;

}

ETC

setFields setFieldsDict

mapFields mapFieldsDict

Post-processing

utilities

yPlusRAS vorticity wallShearStress Mach