CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Surface roughness (https://www.cfd-online.com/Forums/openfoam-solving/58050-surface-roughness.html)

daefi September 24, 2008 09:06

Hi. I have recently started
 
Hi.

I have recently started modelling in OpenFOAM and I need to run a kEpsilon model on a duct with surface roughness on the bottom wall.

Is there any way to do this in OpenFOAM? I fear that I have to write the C++ code on my own which would probably take more time than I have.

Sincerely David Fich

andrea_barbera September 29, 2008 05:32

Hi, I have a similar proble
 
Hi,

I have a similar problem and I have discovered that a way to consider roughness is perhaps already implemented. Unfortunately I'm not able to apply it.

In the folder ~/OpenFOAM/OpenFOAM-1.5/src/turbulenceModels/RAS/compressible/wallFunctions/mutW allFunctions/mutStandardRoughWallFunction
a BC which allows to consider roughness is implemented, but, sincerely, I do not understand how to apply it (to K or Epsilon, perhaps?)
and what is the meaning of the two constants
"roughnessConstant" and "roughnessFudgeFactor".

Can someone please illustrate how to apply this BC?

Regards

Andrea

ngj September 29, 2008 08:35

Hi Andrea and David A lot o
 
Hi Andrea and David

A lot of discussions about roughnesses and turbulencemodels can be found here:

http://www.cfd-online.com/OpenFOAM_D...es/1/5791.html

Please note that it contains some of my own work, and that it has not been validated. Just implemented directly out of the textbook.

Best regards

niklas November 24, 2008 02:07

I have added surface roughness
 
I have added surface roughness according to the fluent manual.
found for instance here http://web.njit.edu/topics/Prog_Lang_Docs/html/FLUENT/fluent/fluent5/ug/html/nod e195.htm

What I did was to add

Ks_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Ks",
subDict("wallFunctionCoeffs"),
0.0
)
),

Cs_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cs",
subDict("wallFunctionCoeffs"),
0.0
)
),

to RASModel.H and the corresponding stuff in RASModel.C

and in wallViscosityI.H i modified the for-loop to

forAll(curPatch, facei)
{
label faceCelli = curPatch.faceCells()[facei];

scalar uStar = Cmu25*sqrt(k_[faceCelli]);
scalar yPlus = y_[patchi][facei]*uStar/nuw[facei];
scalar KsPlus = Ks_.value()*uStar/nuw[facei];

// hydrodynamically smooth
scalar logDB = 1.0;

if (KsPlus > 2.25)
{
// fully rough
if (KsPlus > 90.0)
{
logDB = 1.0 + Cs_.value()*KsPlus;
}
else
// transitional
{
scalar n = ::sin(0.4258*(log(KsPlus) - 0.811))
scalar a = (KsPlus - 2.25)/87.75 + Cs_.value()*KsPlus;
logDB = ::pow(a, n);
}
}

if (yPlus > yPlusLam_)
{
nutw[facei] =
nuw[facei]
*(yPlus*kappa_.value()/log(E_.value()*yPlus/logDB) - 1);
}
else
{
nutw[facei] = 0.0;
}
}

using the facts that
log(A)-log(B) = log(A/B)
log(A)*n = log(A^n)

you essentially just need to divide the wall constant E with the variable logDB.

Normally setting the constants to zero would revert to the normal smooth approach, but not here and that is easily fixed also.
But is there anything else I need to modify that I have missed or is this all I have to do?

N

maddalena January 26, 2009 09:54

Dear Niklas, thanks for your
 
Dear Niklas,
thanks for your contribution, the piece of code you pasted above is exactly what I need! I have a couple of questions for you:
1) What do you mean when you said: "you essentially just need to divide the wall constant E with the variable logDB"? Do you mean I need to do some extra calculation in order to define properly E in the RASProperty file? Or can I set E arbitrairly, i.e. to zero?
2) Is this piece of code tested for OF 1.5? I think so, but I just want to be sure...
Thanks!
Mad

niklas January 27, 2009 02:47

Maybe this makes it abit clear
 
Maybe this makes it abit clearer
http://openfoamwiki.net/index.php/Ho...eWallRoughness

maddalena January 27, 2009 04:59

Hi Niklas, one more basic q
 
Hi Niklas,

one more basic question... Since I do not want to change OF original files, I want to copy the turbFoam solver, rename it and change references to the new IncompressibleWallRoughness RANS, that I will copy as well. Thus, I followed the user guide:

1) take $WM_PROJECT_DIR/applications/solvers/incompressible/turbFoam and copy it to $WM_PROJECT_USER_DIR/applications/solvers/myFoam
2) change filename turbFoam.C to myFoam.C
3) change /Make/files to match my application name
4) change EXE = $(FOAM_APPBIN)/turbFoam to EXE = $(FOAM_USER_APPBIN)/myFoam
5) wclean and wmake libso

No error displayed during the compilation. However, when I want to use myFoam as a solver, I get bash: myFoam: command not found. It seems that my solver is not defined. I am sure I am missing something, but I do not know what!!! Could you help me? Thanks a lot!

Mad

maddalena January 27, 2009 05:19

I got it! I missed this: rm -r
 
I got it! I missed this: rm -rf linuxGccDP0pt after point 4)! ;O)

niklas January 27, 2009 06:56

by not specifying the Ks and C
 
by not specifying the Ks and Cs values, the original way of doing things will be used. (or by setting Ks to zero).

no need to copy turbFoam, nothing will change there.

Xabi March 18, 2009 09:47

Variable Roughness
 
Hi all!

I am interested in applying a variable roughness along a surface (wall). Does anyone know whether it is possible or not using OpenFoam? Every post I read and code i see, roughness was considered constant ...
Thanks in advance,

X

niklas March 18, 2009 09:50

Quote:

Originally Posted by Xabi (Post 209899)
Hi all!

I am interested in applying a variable roughness along a surface (wall). Does anyone know whether it is possible or not using OpenFoam? Every post I read and code i see, roughness was considered constant ...
Thanks in advance,

X

When you say variable, is it a function variable, or do you have different walls with different constants?

Xabi March 19, 2009 05:30

Quote:

Originally Posted by niklas (Post 209900)
When you say variable, is it a function variable, or do you have different walls with different constants?

Hi,

It is a function variable.I have wall and the roughness is different in each point.
Regards

niklas March 19, 2009 05:53

Quote:

Originally Posted by Xabi (Post 209988)
It is a function variable.I have wall and the roughness is different in each point.
Regards

OK..........
and the function is?

Xabi March 26, 2009 06:43

constant roughness
 
Hi Niklas,

Before starting with variable roughness I finally decided to implement first a simple constant roughness. I found your piece of code and I add it and had a little problem.
It is quite strange because although Cs_ and Ks_ are declared in Rasmodel.c and set up in Rasmodel .h I get an error saying :

.../wallFunction/wallViscosityI.H : error :'Cs_' was not declared in the scope.

.../wallFunction/wallViscosityI.H : error :'Ks_' was not declared in the scope.

And its strange because the definition of kappa as well as E is the same as Cs and Ks and everything it is ok with them.

so Do you know why it can be?
Thank you.

Quote:

Originally Posted by niklas (Post 209993)
OK..........
and the function is?


maurice March 28, 2009 22:44

Save Ks+ field
 
Hi All,

I am a new user of OF and I justed added Niklas's roughness wall code mentioned in this thread. I would like to write a postprocessing code that saves the KsPlus values just like the yPlusRAS utility.

I know KsPlus=uStar*Ks/nuw but how can I access uStar, Ks and nuw in the program. I am trying to modify the yPlusRAS code but don't know how to get these variables. Any help is appreciated.

Thanks,

Qi

ruedavallejo April 26, 2009 22:22

hi Niklas

maybe i'm forgetting something but I modified all the files mentioned in the wiki and recompiled again, but I do not get any change in my results when I change the values of Cs, Ks. could you tell me what I'm forgetting? I'm usign k-e, simplefoam. I would expect to see a pressure drop with the increase of Ks.

Regards
Nestor

Skrifvars April 26, 2010 04:43

Hi,
I did the changes (OF1.5) described in the Wiki page (or I thought I did) and I get the following
error:

LHS and RHS of + have different dimensions
dimensions : [0 2 -3 0 0 0 0] + [0 2 -2 0 0 0 0]

Chrisi1984 May 21, 2010 02:56

define Ks and Cs
 
I am working with OF 1.6. I would like to know, where I should define the variables Ks and Cs when i am using roughWallfunctions. Must this be done in the RasProperties file or some where else. What I have to write to force Ks and Cs?

Regards Chrisi

Burak_1984 November 21, 2012 06:09

Quote:

Originally Posted by niklas (Post 209993)
OK..........
and the function is?

Hello Maybe it's a long history but I couldn't find the answer

I have terrain map I want to add roughness lenght to z0.I am trying to convert the simpleFOAM case for wind turbine siting;There the z0 roughness height is defined in ABLconditions as a single value.I would like to include a matrix to define the roughness on the ground patch.

At least I would like to create a patch saying "the points inside the patch should have z0=0.1 instead of z0=0.05"so being able to manually include the variable roughness crudely.

Is this possible? Here Mr. Hanael compiled a code that implements Mr.Tapia's Master Thesis as basis.

https://github.com/hananel/roughnessToFoam

However I don't have wasp *.map file, only coordinates and roughness values and I don't quite get the idea to implement a OpenFOAM source code.

How does for example internalField nonuniform List<Vector> work out?How can I call the <Vector> part from another file.I guess my solution lies there.

Many thanks
Regards
Burak

Mojtaba.a May 9, 2013 06:14

Quote:

Originally Posted by Burak_1984 (Post 393400)
Hello Maybe it's a long history but I couldn't find the answer

I have terrain map I want to add roughness lenght to z0.I am trying to convert the simpleFOAM case for wind turbine siting;There the z0 roughness height is defined in ABLconditions as a single value.I would like to include a matrix to define the roughness on the ground patch.

At least I would like to create a patch saying "the points inside the patch should have z0=0.1 instead of z0=0.05"so being able to manually include the variable roughness crudely.

Is this possible? Here Mr. Hanael compiled a code that implements Mr.Tapia's Master Thesis as basis.

https://github.com/hananel/roughnessToFoam

However I don't have wasp *.map file, only coordinates and roughness values and I don't quite get the idea to implement a OpenFOAM source code.

How does for example internalField nonuniform List<Vector> work out?How can I call the <Vector> part from another file.I guess my solution lies there.

Many thanks
Regards
Burak

Hello Burak,
Have you found any solutions to this?
Before reading your post, I was dividing my ground surface into multiple surfaces using my CAD program, and then in the next step, I defined each of those surfaces as separate wall boundary conditions, and at last in openFOAM while assigning boundary conditions, I set different z0 values for each of those surfaces. I mean something like this:

ground_rough
{
type nutkAtmRoughWallFunction;
value uniform 0;
z0 $z0_rough;
}

ground_smooth
{
type nutkAtmRoughWallFunction;
value uniform 0;
z0 $z0_smooth;
}

But, I think this is wrong. because I see some discontinuities between borders of these surfaces.
Now that I have read your post, I think it is a great idea to use nonuniform List<Vector> to define various z0 values to a surface and not by dividing it into multiple surfaces. but right now I have no idea how to define z0 value for each surface cells. Do you have anything in mind to share with me?

Thank you,
Warmest wishes,
Mojtaba

leonardo.oliveira October 1, 2014 10:09

Hello Burak,

I've downloaded the roughnessToFoam application but I can't use it. It asks for a z0 file in the "0" folder and I don't know how to write it.

Can you upload some z0 file so I can use it as an example, or show me how to write it.

Thanks in advance.
Sorry for the bad English.

Burak_1984 October 13, 2014 15:45

Hi Leonardo

It has been a while since I ran this program.But as far as I remember the program didn't work for me either.So I cannot help you with the file.

What I did was to group my mesh to create patches like Mojtaba mentioned.Meshlab was a usefull tool for that.So the solution was more of a "manual" one than of an automatic one.

Wish you the best luck!

Regards
Burak

leonardo.oliveira October 15, 2014 07:08

Thanks for the reply man, I'will try what Mojtaba did.

Thank you.

Shuveksha July 12, 2021 10:29

Quote:

Originally Posted by niklas (Post 196228)
I have added surface roughness according to the fluent manual.
found for instance here http://web.njit.edu/topics/Prog_Lang_Docs/html/FLUENT/fluent/fluent5/ug/html/nod e195.htm

What I did was to add

Ks_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Ks",
subDict("wallFunctionCoeffs"),
0.0
)
),

Cs_
(
dimensioned<scalar>::lookupOrAddToDict
(
"Cs",
subDict("wallFunctionCoeffs"),
0.0
)
),

to RASModel.H and the corresponding stuff in RASModel.C

and in wallViscosityI.H i modified the for-loop to

forAll(curPatch, facei)
{
label faceCelli = curPatch.faceCells()[facei];

scalar uStar = Cmu25*sqrt(k_[faceCelli]);
scalar yPlus = y_[patchi][facei]*uStar/nuw[facei];
scalar KsPlus = Ks_.value()*uStar/nuw[facei];

// hydrodynamically smooth
scalar logDB = 1.0;

if (KsPlus > 2.25)
{
// fully rough
if (KsPlus > 90.0)
{
logDB = 1.0 + Cs_.value()*KsPlus;
}
else
// transitional
{
scalar n = ::sin(0.4258*(log(KsPlus) - 0.811))
scalar a = (KsPlus - 2.25)/87.75 + Cs_.value()*KsPlus;
logDB = ::pow(a, n);
}
}

if (yPlus > yPlusLam_)
{
nutw[facei] =
nuw[facei]
*(yPlus*kappa_.value()/log(E_.value()*yPlus/logDB) - 1);
}
else
{
nutw[facei] = 0.0;
}
}

using the facts that
log(A)-log(B) = log(A/B)
log(A)*n = log(A^n)

you essentially just need to divide the wall constant E with the variable logDB.

Normally setting the constants to zero would revert to the normal smooth approach, but not here and that is easily fixed also.
But is there anything else I need to modify that I have missed or is this all I have to do?

N

Where do you write this program?


All times are GMT -4. The time now is 17:49.