CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

adding a new wall function to RAS in OF2.1.1

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   February 9, 2013, 14:04
Default adding a new wall function to RAS in OF2.1.1
  #1
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 4
NJG is on a distinguished road
How exactly do I build a new wall function to it is recognized by a solver? I have the function (.C and .H files) in the correct place in my <user> folder structure (under src/turbulenceModels/... and so on) but when I run my solver it says my new wall function is unknown. How do I build it so it is recognized?

Best,
NG
NJG is offline   Reply With Quote

Old   February 9, 2013, 17:59
Default
  #2
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 8
Hisham is on a distinguished road
Hi NG

You need to read chapter 3 of the user manual:

http://www.openfoam.org/docs/user/co...p#x10-690003.2

some OpenFOAM programming tutorials from Chalmers university are also helpful (Google )

Best
H
Hisham is offline   Reply With Quote

Old   February 9, 2013, 18:20
Default
  #3
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 4
NJG is on a distinguished road
Thank you for the advice, Hisham!

I have read that chapter, but when I try wmake to build my new wall function, it returns a "no rule to make target <function_name> needed by <function_name>.dep", or something to that effect (I don't have it in front of my right at this instance). This is where I am stuck. How exactly do I set up the files in my make folder in my <user>-2.1.1/src/turbulenceModels/incompressible/RAS/ so that is builds my new function in a manner that is accessible by my solver?

I would be happy to look through those programming tutorials for insight. I will google them.

-NG
NJG is offline   Reply With Quote

Old   February 9, 2013, 18:38
Default
  #4
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 8
Hisham is on a distinguished road
First you should make a copy of the code you want to modify into your user folder, for example to:
Code:
~/OpenFOAM/NG-2.1.x/newWallFunction
Then modify the "/Make/files" file to change the name of the library or create a new one, for example (~/OpenFOAM/NG-2.1.x/newWallFunction/Make/files):
Code:
File1.C
File2.C 
etc, 

LIB = $(FOAM_USER_LIBBIN)/libmyNewWall
If you post the error message when you get back to office you can get more ideas!

No rule to compile means you're missing the Make folder!
Have a nice weekend!

Hisham
Hisham is offline   Reply With Quote

Old   February 10, 2013, 09:33
Default
  #5
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 4
NJG is on a distinguished road
Ok, here is a more detailed description of what I did and how it is not working:

What I did (note I am running OF-2.1.1):

I have two new files for my new wall function. Its name is really long so for brevity here I will just call this "newWF".

Making my new function:

First, I created a newWFFvPatchScalarField.C and a newWFFvPatchScalarField.H file. As my function is just a variation on an existing one, I used the existing wall function .C and .H files as templates, made changes where I needed them, and called it good.

Putting my new wall function in the proper place:

I was not 100% sure where these should do in my file structure, so I used the OpenFOAM instal as a guide. As such, both of these files were placed in the following location (note the "newWF at the end here is a new folder I created):

<user>-2.1.1/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/newWFs

Making my new wmake files:

Next I created a a new "files" and a new "options" file. The "files" file is as follows:

"
wallFunctions = derivedFvPatchFields/wallFunctions
newW = $(wallFunctions)/newW
$(newW)/newWF/newWFFvPatchScalarField.C

LIB=$(FOAM_USER_LIBBIN)/libuserincompressibleRASModels
"

The "options" file is as follows:

"
EXE_INC = \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/transport/Models \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \

LIB_LIBS = \
-lincompressibleTurbulenceModels \
-lfiniteVolume \
-lmeshTools \
"

I am a little shaky on whether or not I have everything in this "options" file that I need, so I could have an issue there.

Placing the Make folder:

lastly, I created a "Make" folder in the following location:

<user>-2.1.1/src/turbulenceModels/incompressible/RAS/Make

and I put these two files in it.

When I tried to build I did it as follows:

<user>-2.1.1/src/turbulenceModels/incompressible/RAS/ wmake

And here is what I get (note the actual name is "DxtJayatillekeWallFunction"):

"
nick@ubuntu:~/OpenFOAM/nick-2.1.1/src/turbulenceModels/incompressible/RAS$ wmake
Making dependency list for source file derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C
could not open file RASModel.H for source file derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C
SOURCE=derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/turbulenceModels -I/opt/openfoam211/src/transportModels -I/opt/openfoam211/src/finiteVolume/lnInclude -I/opt/openfoam211/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o
derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C:27: 22: fatal error: RASModel.H: No such file or directory
compilation terminated.
make: *** [Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o] Error 1
"

So as you can see, it can't locate "RASModel.H". This comes from a instance of:

"#include RASModel.H"

in line 27 of "newWFFvPatchScalarField.C".

In response, I made a copy of the "RASModel" folder containing RASModel.C and RASModel.H, placed it here:

<user>-2.1.1/src/turbulenceModels/incompressible/RAS/

and tried again. I got the following:

"
SOURCE=derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/turbulenceModels -I/opt/openfoam211/src/transportModels -I/opt/openfoam211/src/finiteVolume/lnInclude -I/opt/openfoam211/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o
derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C:27: 22: fatal error: RASModel.H: No such file or directory
compilation terminated.
make: *** [Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o] Error 1
"


So I lose the first instance of "can't find RASModel.H" but still have the second.


Any ideas? Thanks!

NG
NJG is offline   Reply With Quote

Old   February 10, 2013, 12:16
Default
  #6
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 8
Hisham is on a distinguished road
Quote:
Originally Posted by NJG View Post
Ok, here is a more detailed description of what I did and how it is not working:

What I did (note I am running OF-2.1.1):

I have two new files for my new wall function. Its name is really long so for brevity here I will just call this "newWF".

Making my new function:

First, I created a newWFFvPatchScalarField.C and a newWFFvPatchScalarField.H file. As my function is just a variation on an existing one, I used the existing wall function .C and .H files as templates, made changes where I needed them, and called it good.

Putting my new wall function in the proper place:

I was not 100% sure where these should do in my file structure, so I used the OpenFOAM instal as a guide. As such, both of these files were placed in the following location (note the "newWF at the end here is a new folder I created):

<user>-2.1.1/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/newWFs

Making my new wmake files:

Next I created a a new "files" and a new "options" file. The "files" file is as follows:

"
wallFunctions = derivedFvPatchFields/wallFunctions
newW = $(wallFunctions)/newW
$(newW)/newWF/newWFFvPatchScalarField.C

LIB=$(FOAM_USER_LIBBIN)/libuserincompressibleRASModels
"

The "options" file is as follows:

"
EXE_INC = \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/transport/Models \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \

LIB_LIBS = \
-lincompressibleTurbulenceModels \
-lfiniteVolume \
-lmeshTools \
"

I am a little shaky on whether or not I have everything in this "options" file that I need, so I could have an issue there.

Placing the Make folder:

lastly, I created a "Make" folder in the following location:

<user>-2.1.1/src/turbulenceModels/incompressible/RAS/Make

and I put these two files in it.

When I tried to build I did it as follows:

<user>-2.1.1/src/turbulenceModels/incompressible/RAS/ wmake

And here is what I get (note the actual name is "DxtJayatillekeWallFunction"):

"
nick@ubuntu:~/OpenFOAM/nick-2.1.1/src/turbulenceModels/incompressible/RAS$ wmake
Making dependency list for source file derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C
could not open file RASModel.H for source file derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C
SOURCE=derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/turbulenceModels -I/opt/openfoam211/src/transportModels -I/opt/openfoam211/src/finiteVolume/lnInclude -I/opt/openfoam211/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o
derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C:27: 22: fatal error: RASModel.H: No such file or directory
compilation terminated.
make: *** [Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o] Error 1
"

So as you can see, it can't locate "RASModel.H". This comes from a instance of:

"#include RASModel.H"

in line 27 of "newWFFvPatchScalarField.C".

In response, I made a copy of the "RASModel" folder containing RASModel.C and RASModel.H, placed it here:

<user>-2.1.1/src/turbulenceModels/incompressible/RAS/

and tried again. I got the following:

"
SOURCE=derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam211/src/turbulenceModels -I/opt/openfoam211/src/transportModels -I/opt/openfoam211/src/finiteVolume/lnInclude -I/opt/openfoam211/src/meshTools/lnInclude -IlnInclude -I. -I/opt/openfoam211/src/OpenFOAM/lnInclude -I/opt/openfoam211/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o
derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C:27: 22: fatal error: RASModel.H: No such file or directory
compilation terminated.
make: *** [Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o] Error 1
"


So I lose the first instance of "can't find RASModel.H" but still have the second.


Any ideas? Thanks!

NG

First, you don't need to put the new library files inside the source files of OpenFOAM. All you should do is simply:
Code:
mkdir /home/nick/OpenFOAM/nick-2.1.1/DxtJayatillekeWallFunction
cd /home/nick/OpenFOAM/nick-2.1.1/DxtJayatillekeWallFunction
You then need to move the header and .C file, also the Make folder (including files & options) into the new folder. It is important to include the path to all included headers (to the options file) rather than including the headers themselves as copies (EXE_INC). Further the linking of libraries is added in (LIB_LIBS). So I think you added turbulence models but didn't add RAS models ... a little digging in Make of the original function can give you a better idea. You can also take a look at Make folders of solvers that use the RAS model (e.g. pisoFoam). Also do not forget to add the name in the runtime table so you don't have to include the library and recompile all solvers.

Hisham
Hisham is offline   Reply With Quote

Old   February 10, 2013, 13:15
Default
  #7
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 4
NJG is on a distinguished road
Hisham,

Ok, to simplify things I followed your advice and the new folder structure for all of this is:

<user>-2.1.1/DxtJayatillekeWallFunction/...
...DxtJayatillekeWallFunctionFvPatchScalarField.H
...DxtJayatillekeWallFunctionFvPatchScalarField.H
...Make/...
...files
...options

Thanks for the tip, this makes navigation less tedious.

This change led to a simplified "files" file as follows:

"
DxtJayatillekeWallFunctionFvPatchScalarField.C

LIB = $(FOAM_USER_LIBBIN)/libuserIncompressibleRASModels
"

Also, as per your advice I tried adding a reference to the location of the RASModel.H file to my "options" file so it could find it. In response to your suggestion that I dig up the original Make file for the function I am basing my modified function off, that is in fact what I did originally. The "options" file as it appears in my last post was just that file. I thought maybe that this line:

"
-I$(LIB_SRC)/turbulenceModels \
"

covered the RAS model .H as it is located under:

"
openfoam211/src/turbulenceModels/incompressible/RAS/RASModel

&

openfoam211/src/turbulenceModels/incompressible/RAS/lnInclude

As such I read "-I$(LIB_SRC)/turbulenceModels \" to reference everything within the "turbulenceModels" folder in the "openfoam211/src" folders.

Anyway, so I tried two different versions of a new options file as follows:

"
EXE_INC = \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/transport/Models \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \

LIB_LIBS = \
-lincompressibleTurbulenceModels \
-lfiniteVolume \
-lmeshTools \
"

&


"
EXE_INC = \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/transport/Models \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \

LIB_LIBS = \
-lincompressibleTurbulenceModels \
-lfiniteVolume \
-lmeshTools \

The result was the same as the shown at the end of my previous post, which ended as follows:

"
derivedFvPatchFields/wallFunctions/DxtWallFunctions/DxtJayatillekeWallFunction/DxtJayatillekeWallFunctionFvPatchScalarField.C:27: 22: fatal error: RASModel.H: No such file or directory
compilation terminated.
make: *** [Make/linuxGccDPOpt/DxtJayatillekeWallFunctionFvPatchScalarField.o] Error 1
"

My new question then is other than making a direct reference to a containing folder under my "EXE_INC =" list in my options file as I have here done, how to I tell it where to look for RASModel.H?

Also, do I need to add something to my "LIB_LIBS =" to this end?

And finally, you said in your response:

"Also do not forget to add the name in the runtime table so you don't have to include the library and recompile all solvers."

I am not sure what you are referring to here/how to do this. Any further information would be much appreciated.

Best,
NG
NJG is offline   Reply With Quote

Old   February 10, 2013, 15:59
Default
  #8
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 8
Hisham is on a distinguished road
You have not linked the RAS models library. Looking at options file of pisoFoam, you need to add:
Code:
-lincompressibleRASModels
to LIB_LIBS.

To use your compiled library, you either have to include it statically and recompile the solver (not a nice way to do it) or add it to run time table: change the name of the original model in lines such as (something like):
Code:
defineTypeNameAndDebug(LienLeschzinerLowRe, 0);
addToRunTimeSelectionTable(RASModel, LienLeschzinerLowRe, dictionary);
Similar stuff should be there in original files just change the name for the name you will use in input files.

Then you would need to dynamically link the library in the "system/controlDict" file.

Hisham
Hisham is offline   Reply With Quote

Old   February 10, 2013, 16:18
Default
  #9
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 4
NJG is on a distinguished road
Hisham,

First you're a God-Sent with this input. Thank you so much.

1) When I get a chance to work on it again I will add the LIB_LIBS addition you mention.

2) I am still not fully following on the second point. Let me ask this:

When you say "change the name of the original model", what/where is the "original model"? What specific files am I looking for when I am changing these lines? And am I making copies in my <user>-2.1.1 based folders for this? Like if I alter the RASModel say, would I first make a copy of the RASModel .C and .H files into my user area and edit there?

I appreciate your patience!

Best,
Nick

Last edited by NJG; February 10, 2013 at 16:37.
NJG is offline   Reply With Quote

Old   February 10, 2013, 16:35
Default
  #10
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 4
NJG is on a distinguished road
Let me clarify question 2) just a bit:

I just looked in the RASModel.C file and found instances of both things you have there. But I would leave this unchanged, right? I have made no edits to the RASModel.

Within my new wallFunction file DxtJAYAtillekeWallFunctionFvPatchScalarField.C however I already have:

"
#include "addtoRunTimeSelectionTable.H
"

This is in there as I used another very similar wall function as a template and it had the same thing.

Am I all set then?

Best,
NG
NJG is offline   Reply With Quote

Old   February 10, 2013, 22:48
Default
  #11
NJG
Member
 
Nick Gutschow
Join Date: Jan 2013
Posts: 36
Rep Power: 4
NJG is on a distinguished road
Hisham,

I added the new "-lincompressibleRASModels" to the LIB_LIBS list with no change in error. It still gives me the "No such file or directory" on the file "RASModel.H".

Best,
NG
NJG is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Radiation interface hinca CFX 15 January 26, 2014 18:11
Implementation of wall function mantec Main CFD Forum 0 July 19, 2012 09:18
About the nut wall function in RAS spwater OpenFOAM 1 October 28, 2011 10:37
Need some wall function approaches! yka8150 Main CFD Forum 0 September 21, 2009 23:08
Wall function in adverse pressure gradients stephane baralon Main CFD Forum 11 September 2, 1999 04:05


All times are GMT -4. The time now is 18:58.