CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Problem creating a new Wallfunction on OF 2.2 ! (https://www.cfd-online.com/Forums/openfoam-programming-development/118282-problem-creating-new-wallfunction-2-2-a.html)

fredo490 May 24, 2013 04:17

Problem creating a new Wallfunction on OF 2.2 !
 
2 Attachment(s)
Dear all,
I'm trying to implement a new wall Function into OF 2.2 but I keep having bugs at compiling.

Here is what I did:
1) I copied the wall compressible turbulence model to my desktop:
opt/openfoam220/src/turbulenceModels/compressible/RAS

2) I made a copy of mutkRoughWallFunction and called it MYmutkRoughWallFunction
I've opened the MYmutkRoughWallFunction.C and MYmutkRoughWallFunction.H and I have replaced all "mutkRoughWallFunction" by "MYmutkRoughWallFunction" with a case matching.

3) I made a copy of alphaWallFunctions and called it MYalphaWallFunctions
I've opened the MYalphaWallFunctions.C and MYalphaWallFunctions.H and I have replaced all "alphaWallFunctions" by "MYalphaWallFunctions" with a case matching.

4) I went to the Make folder and I've changed the files to
Code:

/* Wall functions */
wallFunctions = derivedFvPatchFields/wallFunctions

alphatWallFunctions = $(wallFunctions)/alphatWallFunctions
$(alphatWallFunctions)/MYalphatWallFunction/MYalphatWallFunctionFvPatchScalarField.C

mutWallFunctions = $(wallFunctions)/mutWallFunctions

$(mutWallFunctions)/MYmutkRoughWallFunction/MYmutkRoughWallFunctionFvPatchScalarField.C

LIB = $(FOAM_USER_LIBBIN)/MyRoughlibcompressibleRASModels

5) Then I made a "wclaen" and after a "wmake" but a problem occurred during compiling:
See enclosed for the bug report

6) To solve my problem, I tried to include a maximum of library into the options file:
Code:

EXE_INC = \
    -I$(LIB_SRC)/turbulenceModels \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/genericPatchFields/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/RASModel \
    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
    -I$(LIB_SRC)/dynamicFvMesh/lnInclude \
    -I$(LIB_SRC)/dynamicMesh/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \
    -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
    -I$(LIB_SRC)/turbulenceModels/derivedFvPatchFields/lnInclude \
    -I$(LIB_SRC)/finiteVolume/cfdTools \
    -I$(LIB_SRC)/fvOptions/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
    -I$(LIB_SRC)/OpenFOAM/lnInclude \

LIB_LIBS = \
    -ldynamicFvMesh \
    -ltopoChangerFvMesh \
    -ldynamicMesh \
    -lfluidThermophysicalModels \
    -lspecie \
    -lcompressibleTurbulenceModel \
    -lcompressibleRASModels \
    -lcompressibleLESModels \
    -lfiniteVolume \
    -lmeshTools \
    -lsampling \
    -lfvOptions

But the problem remain the same...

Does anybody know how to compile a new wall function on OpenFoam 2.2 ? You can find enclosed my custom RAS model.

fredo490 May 26, 2013 11:31

Small up:)

fredo490 May 28, 2013 07:58

Second up :(

fredo490 May 29, 2013 13:53

Error while compiling a custom wall function (OF 2.2)
 
2 Attachment(s)
Dear all,
I'm trying to implement a new wall Function into OF 2.2 but I keep having bugs at compiling. I guess I'm doing something wrong but I don't know where.

PART 1 I tried to create a Custom library

Here is what I did:
1) I copied the wall compressible turbulence model to my desktop:
opt/openfoam220/src/turbulenceModels/compressible/RAS

2) I made a copy of mutkRoughWallFunction folder and called it MYmutkRoughWallFunction
I've opened the MYmutkRoughWallFunction.C and MYmutkRoughWallFunction.H and I have replaced all "mutkRoughWallFunction" by "MYmutkRoughWallFunction" with a case matching.

3) I made a copy of alphaWallFunctions and called it MYalphaWallFunctions
I've opened the MYalphaWallFunctions.C and MYalphaWallFunctions.H and I have replaced all "alphaWallFunctions" by "MYalphaWallFunctions" with a case matching.

4) I went to the Make folder and I've changed the files to
Code:

/* Wall functions */
wallFunctions = derivedFvPatchFields/wallFunctions

alphatWallFunctions = $(wallFunctions)/alphatWallFunctions
$(alphatWallFunctions)/MYalphatWallFunction/MYalphatWallFunctionFvPatchScalarField.C

mutWallFunctions = $(wallFunctions)/mutWallFunctions

$(mutWallFunctions)/MYmutkRoughWallFunction/MYmutkRoughWallFunctionFvPatchScalarField.C

LIB = $(FOAM_USER_LIBBIN)/MyRoughlibcompressibleRASModels

5) Then I made a "wclaen" and after a "wmake" but a problem occurred during compiling. You can see enclosed the bug report.

I thought the problem might come from a missing library but even adding all the possible OpenFoam library to the option file doesn't solve the problem.

PART 2 I tried to edit OpenFoam library

Then I tried to edit the actual OpenFoam compressible library by editing the source files in opt/openfoam220/src/turbulenceModels/compressible/RAS and recompiling all OpenFoam but I still cannot use the new wall function.

I did the same things as described above but this time for the libcompressibleRASModels. I didn't change any code, I have simply copied the wall function code and replaced the names by adding "MY".

I wonder, is there any special "link" that is hard coded ? Also, how does the list of the possible wall function is generated when a solver settings are wrong ? Is it dynamic or hard coded ?

Thx in advance, Fred

wyldckat May 29, 2013 16:29

Greetings Fred,

I've merged your latest thread into this one, since it's on the same topic. ;)

As for the problem you're having, it's as simple as running wmake like this:
Code:

wmake libso
This is very briefly explained in the User Guide, section "3.2.2.4 Running wmake", table 3.1: http://www.openfoam.org/docs/user/co...php#x10-750011

Ironically, 8 days ago this was fixed in OpenFOAM 2.2.x: https://github.com/OpenFOAM/OpenFOAM...4c48941c9f1981 - so, if you had the latest OpenFOAM 2.2.x, you wouldn't have had this problem ;)


By the way, I saw that you had forgotten the "libso" option, because of this line:
Code:

          -lOpenFOAM -ldl  -lm -o OpenFOAM.out
The last name "OpenFOAM.out" is the indication that it tried to build it as an executable.


One last thing is that OpenFOAM commands usually respond to "-help":
Code:

wmake -help
Best regards,
Bruno

fredo490 May 30, 2013 03:12

My mistake then :p

I have also found another mistake. I forgot to change the wall function name in the .H file. I had a bug of "double declaration"... Now the code works.
Code:

    TypeName("MYmutkRoughWallFunction");
Once I finish coding the wall function I will create a topic with the source code and the procedure to compile it.

Thx again ;)

kjmaki July 14, 2014 16:10

compile custom wall function in v 2.3.x
 
I am trying to compile a custom rough-wall function in version 2.3.x. I have tried starting with the nutkRoughWallFunction by renaming it and compiling it into its own library. when I try to include the library (in system/controlDict) it isn't loaded by the solver.

I tried a second way, by copying nutkRoughWallFunction to say nutk2RoughWallFunction, changing the file names and all occurences in the .H and .C files, and then re-compiling libturbulenceModels with the new .C file. The library compiles, but then when I try to access the new boundary condtion the solver cannot find it.

Does any one have a suggestion?

kjmaki July 15, 2014 08:31

I thought I might add more details to entice comments from the community. If I copy $FOAM_SRC/TurbulenceModels/turbulenceModels to my work space and change only the last line in Make/files from

LIB = $(FOAM_LIBBIN)/libturbulenceModels

to

LIB = $(FOAM_USER_LIBBIN)/libmyTurbulenceModels

I can compile the library with wmake libso. When I run a case and include the line
libs( "libmyTurbulenceModels.so" ); in my system/controlDict, and the solver produces a long stream of information complaining about things such as

Duplicate entry atmBoundaryLayerInletVelocity in runtime selection table fvPatchField

I understand that there are duplicate entries. So, I try to modify an existing wall function by just changing its name. Such as converting nutkRough to nutk2Rough. I update the Make/files file to reflect the new wallFunction, and the library compiles. When I run simpleFoam on a case that uses the new wall function, I get an error that says:
Create mesh for time = 0

Reading field p

Reading field U

Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting RAS turbulence model kOmegaSST


--> FOAM FATAL ERROR:

request for turbulenceModel turbulenceProperties from objectRegistry region0 failed
available objects of type turbulenceModel are
0()

From function objectRegistry::lookupObject<Type>(const word&) const
in file /l/kjmaki/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 198.

FOAM aborting

wwzhao July 22, 2014 05:16

Hi, Kevin.

You should copy source code from $FOAM_SRC/turbulenceModels (lower case "t"), as the simpleFoam solver is linking to the libincompressibleTurbulenceModel.so generated by $FOAM_SRC/turbulenceModels [1].
One more thing, you should only keep the wall-function code which you want to modify, other code should be removed from your working directory otherwise it will complain duplicated entries :D.

FYI: A new turbulence modelling framework is introduced in OpenFOAM 2.3.0 [2].

Quote:

The framework can be found in $FOAM_SRC/TurbulenceModel (upper case “T”) and includes the incompressible, compressible, phase-incompressible and phase-compressible options including support for laminar, RAS and LES simulations with wall-functions and other specialised boundary conditions.
Best regards,
Weiwen

[1] https://github.com/OpenFOAM/OpenFOAM...m/Make/options
[2] http://www.openfoam.org/version2.3.0/multiphase.php


All times are GMT -4. The time now is 20:57.