modeling of bed roughness using a geometry function and

28
Introduction Solver set-up Case set-up Post-Processing Modeling of bed roughness using a geometry function and forcing terms in the momentum equations Jonatan Margalit A project work in the course CFD with OpenSource software, taught by H˚ akan Nilsson at Chalmers University of Technology, Gothenburg, Sweden 01-12-2014 Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 1 / 28

Upload: others

Post on 02-Feb-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Modeling of bed roughness using a geometry functionand forcing terms in the momentum equations

Jonatan Margalit

A project work in the course CFD with OpenSource software,taught by Hakan Nilsson at Chalmers University of Technology,

Gothenburg, Sweden

01-12-2014

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 1 / 28

Page 2: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Background

A tutorial of how to set up an OpenFOAM case with a rough bed usingporosity to define the bed elements.

Wall functions have quite limited success with LES.

Good for simulating near bed dynamics.

Use of structured mesh with porous bed elements

Bed elements - normal distribution.

Method based on Stoesser, T. (2010). ”Physically Realistic RoughnessClosure Scheme to Simulate Turbulent Channel Flow over Rough Bedswithin the Framework of LES.” J. Hydraul. Eng., 136(10), 812-819.

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 2 / 28

Page 3: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Shear stress in open-channel flow

Force balance in time averaged pressure driven channel flow:

∂y

(µ∂u

∂y− ρu′v′

)=∂p

∂x,

Denoting the shear with τ :∂τ

∂y=∂p

∂x,

Solution for the mean shear stress:

τ = −∂p∂xh(1− y

h

).

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 3 / 28

Page 4: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Velocity profiles

Log law over a smooth bed:

u

Uf=

1

κln(y+)+ 5.5,

Log law over a rough wall:

u

Uf=

1

κln

(30y

ks

),

with friction velocity Uf =√τb/ρ.

From wikipedia

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 4 / 28

Page 5: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Getting started

Start by sourcing your OpenFOAM-2.2.x:

source $HOME/OpenFOAM/OpenFOAM-2.2.x/etc/bashrc

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 5 / 28

Page 6: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Configuring the solver

Make a copy of the pimpleFoam solver in the user directory:

cd $FOAM_APP

cp -r --parents solvers/incompressible/pimpleFoam $WM_PROJECT_USER_DIR

cd $WM_PROJECT_USER_DIR/solvers/incompressible

Rename the copied pimpleFoam solver:

mv pimpleFoam pimpleFoam_mod

cd pimpleFoam_mod

mv pimpleFoam.C pimpleFoam_mod.C

Cleanup the directory and delete the unnecessary folders and files:

wclean

rm -rf SRFPimpleFoam/ pimpleDyMFoam/ Allwmake Make/linux*

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 6 / 28

Page 7: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Write out sgs and viscous stresses

Add the following before the runtime.write() in pimpleFoam_mod.C.

nuGradU = laminarTransport.nu()*-2*dev(symm(fvc::grad(U)));

B = turbulence->R();

Add to createFields.H

volSymmTensorField nuGradU

(

IOobject

(

"nuGradU",

runTime.timeName(),

mesh,

IOobject::NO_READ,

IOobject::AUTO_WRITE

),

laminarTransport.nu()*-2*dev(symm(fvc::grad(U)))

);

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 7 / 28

Page 8: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Write out sgs and viscous stresses

Add to createFields.H

volSymmTensorField B

(

IOobject

(

"B",

runTime.timeName(),

mesh,

IOobject::NO_READ,

IOobject::AUTO_WRITE

),

laminarTransport.nu()*-2*dev(symm(fvc::grad(U)))

);

Modify Make/files and compile with wmake

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 8 / 28

Page 9: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Copying a case from the tutorials

Copy the tutorial case channel395:

cp -r $FOAM_TUTORIALS/incompressible/pimpleFoam/channel395 $FOAM_RUN

run

In the run folder make another copy of channel395 and call itroughChannel:

cp -r channel395 roughChannel

Now run the channel395 case while you configure the roughChannel:

blockMesh -case channel395

pimpleFoam -case channel395 > channel395/log.run &

We will use the results for comparison.

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 9 / 28

Page 10: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Edit the mesh

Open constant/polyMesh/blockMeshDict and edit the verticessection to the following:

vertices

(

(0 0 0)

(4 0 0)

(0 0.2 0)

(4 0.2 0)

(0 1 0)

(4 1 0)

(0 0 2)

(4 0 2)

(0 0.2 2)

(4 0.2 2)

(0 1 2)

(4 1 2)

);

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 10 / 28

Page 11: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Edit the mesh

Then edit the blocks section in the following way:

blocks

(

hex (0 1 3 2 6 7 9 8) (60 25 40) simpleGrading (1 1 1)

hex (2 3 5 4 8 9 11 10) (60 35 40) simpleGrading (1 6 1)

);

Finally, change the boundary type of the topWall into a patch:

topWall

{

type patch;

faces ((4 10 11 5));

}

Run blockMesh

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 11 / 28

Page 12: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Boundary and internal conditions of the fields

Set all internalFields to 0 in the 0 folder files.

For the velocity set the boundary condition at the topWall to be of thetype slip, in order to have a rigid lid surface:

topWall

{

type slip;

}

In the turbulence energy file k set a Neumann boundary condition at thetop wall by modifying it into:

topWall

{

type zeroGradient;

}

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 12 / 28

Page 13: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Mapping fieldsMap the fields of the lower half of the channel in channel395 into yourrough channel. This is done by first copying the mapFieldsDict into thesystem folder:

cp -r $FOAM_APP/utilities/preProcessing/mapFields/mapFieldsDict system/

Modify mapFieldsDict:

patchMap

(

bottomWall bottomWall

sides1_half0 sides1_half0

sides2_half0 sides2_half0

inout1_half0 inout1_half0

inout2_half0 inout2_half0

);

cuttingPatches

(

topWall

);

Map the fields: mapFields ../channel395/Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 13 / 28

Page 14: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Generating the rough bed zone

Download the file boxes.C from pingpong and place it in the system

folder.

Compile the file with

g++ -std=c++11 boxes.C -o boxes

Run the file boxes:

./boxes > log.boxes

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 14 / 28

Page 15: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Generating the rough bed zoneCopy the topoSetDict file into the system folder:

cp -r $FOAM_APP/utilities/mesh/manipulation/topoSet/topoSetDict .

Edit topoSetDict to the following:

actions

(

{

name bed;

type cellSet;

action new;

source boxToCell;

sourceInfo

{

boxes

(

#include "boxes.txt"

);

}

}

);Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 15 / 28

Page 16: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Adding sources with fvOptions

Run topoSet followed by setsToZones

Now open up system/fvOptions

momentumSource

{

type pressureGradientExplicitSource;

active off; //on/off switch

selectionMode all; //cellSet // points //cellZone

pressureGradientExplicitSourceCoeffs

{

fieldNames (U);

Ubar ( 0.1335 0 0 );

}

}

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 16 / 28

Page 17: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Adding sources with fvOptions

porosity

{

type explicitPorositySource;

active true;

selectionMode cellZone;

cellZone bed;

explicitPorositySourceCoeffs

{

type DarcyForchheimer;

DarcyForchheimerCoeffs

{

d d [0 -2 0 0 0 0 0] (1e12 1e12 1e12);

f f [0 -1 0 0 0 0 0] (1e12 1e12 1e12);

coordinateSystem

{

e1 (1 0 0);

e2 (0 1 0);

}

}

}

}

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 17 / 28

Page 18: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Configuring controlDict

Run with adjusting the time step to a Courant number:

writeControl adjustableRunTime;

adjustTimeStep yes;

maxCo 0.5;

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 18 / 28

Page 19: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Average the stresses in controlDict

Add to fieldAverage:

nuGradU

{

mean on;

prime2Mean on;

base time;

window 125;

}

B

{

mean on;

prime2Mean on;

base time;

window 125;

}

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 19 / 28

Page 20: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Set PIMPLE parameters

Set the pressure reference in fvSolution:

PIMPLE

{

nOuterCorrectors 1;

nCorrectors 2;

nNonOrthogonalCorrectors 0;

pRefPoint (0 1 0);

pRefValue 0;

}

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 20 / 28

Page 21: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Define LES properties

In constant/LESProperties use delta cubeRootVol

Van Driest delta not suitable as it is intended for wall patches.

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 21 / 28

Page 22: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Adjusting the Reynolds number

The last thing to do before the simulation starts is to reduce the viscositydue to the reduction of the channel depth with the creation of the bedinside the domain. Open constant/transportProperties and reducethe viscosity of the fluid to say:

nu nu [ 0 2 -1 0 0 0 0 ] 1.9e-05;

The case is now fully set-up. Run it with your modified solver:

pimpleFoam_mod > log.run &

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 22 / 28

Page 23: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Post-processing with postChannel

Open constant/postChannelDict and uncheck symmetry:

symmetric false;

Copy the postChannel utility into the utility directory in the userdirectory:

cp -r $FOAM_UTILITIES/postProcessing/miscellaneous/postChannel \

$WM_PROJECT_USER_DIR/utilities

cd $WM_PROJECT_USER_DIR/utilities

Now rename the folder and files:

mv postChannel postChannelRough

cd postChannelRough

wclean

mv postChannel.C postChannelRough.C

mv channelIndex.C channelIndexRough.C

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 23 / 28

Page 24: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Adding fields to postChannel

Add the stress fields to be read in readFields.H:

volSymmTensorField BMean

(

IOobject

(

"BMean",

runTime.timeName(),

mesh,

IOobject::MUST_READ

),

mesh

);

volScalarField Bxy(BMean.component(symmTensor::XY));

volSymmTensorField nuGradUMean

(

IOobject

(

"nuGradUMean",

runTime.timeName(),

mesh,

IOobject::MUST_READ

),

mesh

);

volScalarField nuGradUxy(nuGradUMean.component(symmTensor::XY));

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 24 / 28

Page 25: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Collapsing fields into spatially averaged profiles

Generate depth profiles of the stresses in collapse.H:

scalarField BxyValues(channelIndexing.collapse(Bxy));

scalarField nuGradUxyValues(channelIndexing.collapse(nuGradUxy));

makeGraph(y, BxyValues, "tauSgs", path, gFormat);

makeGraph(y, nuGradUxyValues, "tauVisc", path, gFormat);

Edit Make/files and compile the utility:

postChannelRough.C

channelIndexRough.C

EXE = $(FOAM_APPBIN)/postChannelRough

Compile with wmake

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 25 / 28

Page 26: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Post-processing the cases

Check the progress of the simulations. If time steps have been written, run:

postChannel -case channel395

postChannelRough -case roughChannel

Each case should now have a folder named graphs with the profiles invarious time steps.

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 26 / 28

Page 27: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Plotting with gnuplot

Obtain the mean pressure gradient in the rough channel from the log file:

cd roughChannel

cat log.run | grep ’pressure gradient’ | cut -d’ ’ -f11 | tr -d ’,’ > gradP.txt

awk ’{total += $1} END { print total/NR }’ gradP.txt

Download the file plotProfiles.gplt from pingpong, place it in thecase folder and execute it with gnuplot to visualize the profiles:

gnuplot plotProfiles.gplt

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 27 / 28

Page 28: Modeling of bed roughness using a geometry function and

Introduction Solver set-up Case set-up Post-Processing

Profiles

Jonatan Margalit Modeling of bed roughness in OpenFOAM 01-12-2014 28 / 28