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/)
-   -   Adding New phaseCompressible Turbulence Model (https://www.cfd-online.com/Forums/openfoam-programming-development/170283-adding-new-phasecompressible-turbulence-model.html)

scram April 28, 2016 05:07

Adding New phaseCompressible Turbulence Model
 
Hello Foamers,

i try to add Rzehak's extension for bubble induced turbulence to the kOmegaSST model. See for example here:

http://www.qucosa.de/fileadmin/data/...nhein-ICMF.pdf

following the common procedure for adding new turbulence models:

- copy similar model (e.g kOmegaSSTSato)
- renaming files and functions
- adding Make/files + Make/options
- compiling using "wmake libso"

i got the following error multiple times for all functions/objects:
(example: )

kOmegaSSTRzehak.C:162:6: error: ‘virtual void Foam::RASModels::kOmegaSSTRzehak<BasicTurbulenceMo del>::correct()’ previously declared here
void kOmegaSSTRzehak<BasicTurbulenceModel>::correct()

AND

kOmegaSSTSASRzehak.C:40:1: error: redefinition of ‘Foam::RASModels::kOmegaSSTRzehak<BasicTurbulenceM odel>::kOmegaSSTRzehak(const alphaField&, const rhoField&, const volVectorField&, const surfaceScalarField&, const surfaceScalarField&, const transportModel&, const Foam::word&, const Foam::word&)’
kOmegaSSTRzehak<BasicTurbulenceModel>::kOmegaSSTRz ehak


same procedure still works for "normal" compressible/incompressible turbulence models but not for phaseIncompressible/phaseCompressible models.

I tried it with version 2.3.0/3.0.x and actual Openfoam-dev: same error in all versions.

Guess it has something to do with template formulation of the models.

Has anyone a suggestion how to add new phaseCompressible turbulence models to actual versions of OF?

Thanks to the community and best regards
Stefan

scram May 2, 2016 06:13

just to make sure i didn't made a basic linking mistake here are my Make/files Make/options:

files:
Code:


kOmegaSSTRzehak.C

LIB = $(FOAM_USER_LIBBIN)/myPhaseIncompressibleRASModels

options:
Code:

EXE_INC = \
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/RAS/RASModel \
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/RAS/kEpsilon \
    -I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/PhaseIncompressibleTurbulenceModel \
    -I$(LIB_SRC)/transportModels/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/transportModels/incompressible/lnInclude \
    -I$(WM_PROJECT_USER_DIR)/applications/solvers/orgTwoPhaseEulerFoam/twoPhaseSystem/lnInclude \
    -I$(WM_PROJECT_USER_DIR)/applications/solvers/orgTwoPhaseEulerFoam/interfacialModels/lnInclude \
    -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/transportModels/incompressible/lnInclude \
    -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude 

LIB_LIBS = \
    -lfiniteVolume \
    -lmeshTools \
    -lincompressibleTurbulenceModels \
    -lincompressibleTransportModels \
    -lfluidThermophysicalModels \
    -lturbulenceModels \
    -lspecie \
    -L$(FOAM_USER_LIBBIN) \
    -lcompressibleOrgTwoPhaseSystem


hk318i May 2, 2016 08:38

Hello,

I did a quick search and as we suspected the problems comes from compiling the template class directly instead of initiating it. Additionally, compiling such library isn't that straight forward even in OF original code.

Here what I found when I tried to compile a new phase compressible turbulence model;

you need to add new file which calling a macro to initialize the template class like;
Code:

$FOAM_SOLVERS/multiphase/twoPhaseEulerFoam/phaseCompressibleTurbulenceModels/phaseCompressibleTurbulenceModels.C
So, you can copy it and modify (rename it myphaseCompressibleTurbulenceModels.C) it to initialize your turbulence model as;

Code:

//copy all the header files

makeBaseTurbulenceModel
(
    volScalarField,
    volScalarField,
    compressibleTurbulenceModel,
    PhaseCompressibleTurbulenceModel,
    ThermalDiffusivity,
    phaseModel
);

#define makeRASModel(Type)                                                    \
    makeTemplatedTurbulenceModel                                              \
    (phaseModelPhaseCompressibleTurbulenceModel, RAS, Type)

#define makeLESModel(Type)                                                    \
    makeTemplatedTurbulenceModel                                              \
    (phaseModelPhaseCompressibleTurbulenceModel, LES, Type)




#include "kOmegaSSTRzehak.H"
makeRASModel(kOmegaSSTRzehak.H);

Then add this new file myphaseCompressibleTurbulenceModels.C to Make/files instead of kOmegaSSTRzehak.C

and here is a copy of the options file which I used,

Code:

EXE_INC = \
    -I$(FOAM_SOLVERS)/multiphase/twoPhaseEulerFoam/twoPhaseSystem/lnInclude \
    -I$(LIB_SRC)/transportModels/compressible/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \
    -I$(LIB_SRC)/thermophysicalModels/solidSpecie/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(FOAM_SOLVERS)/multiphase/twoPhaseEulerFoam/interfacialModels/lnInclude \
    -I$(LIB_SRC)/transportModels/incompressible/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
    -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \

    -I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude

LIB_LIBS = \
    -lcompressibleTransportModels \
    -lfluidThermophysicalModels \
    -lsolidThermo \
    -lsolidSpecie \
    -lturbulenceModels \
    -lspecie \
    -lfiniteVolume \
    -lcompressibleTurbulenceModels \
    -lmeshTools \
    -lcompressibleEulerianInterfacialModels \
    -lcompressibleTwoPhaseSystem

Probably many unneeded files are included, but I did quickly and tried to eliminate any possible source of error. Obviously, you can link your solver instead of twoPhaseEulerFoam libraries. The main trick (in red) about this options file is that TurbulenceModels/compressible must come first before TurbulenceModels/turbulenceModels. That is because there are two makeTurbulenceModel.H and you need the compressible one instead of the general one.

I tested by linking it to a tutorial case for twoPhaseEulerFoam and the solver recognized it and started to complain about the wallDist fvSchemes.
But having said that, there is another problem. The solver runs but complains first by showing a very long error. The main points of this error are;
Code:

 
 Duplicate entry laminar in runtime selection table TurbulenceModel
 Duplicate entry LES in runtime selection table TurbulenceModel

I hadn’t enough time to investigate further in this problem but I think if you linked it directly to your solver as in twoPhaseEulerFoam this problem may disappear. Please try and keep us updated.


I hope that will help you to fix this problem.

Best wishes,
Hassan Kassem

scram May 2, 2016 10:23

Hello Hassan,

thank you so much! Your method solved the problem. The solver recognises the new turbulence model. I'm still faced to the same errors as you but i will post a solution here as soon as i found one.

Thank you again, this was really a great help! :D

Best regards,
Stefan

hk318i June 25, 2016 06:31

Hello,

This problem comes from ``makeBaseTurbulenceModel`` macro which has two functions, initialize the base template class then add it to run time table. Using ``makeBaseTurbulenceModel`` as it is means re-adding the base models to the run time table again which cause this error. The following modified macro should solve the problem. Just replace everything (keep the header files) in ``myphaseCompressibleTurbulenceModels.C``

Note: This macro could be used for LES as well.

Best wishes,
Hassan Kassem

Code:

#define createBaseTurbulenceModel(                                            \
    Alpha, Rho, baseModel, BaseModel, TDModel, Transport)                      \
                                                                              \
    namespace Foam                                                            \
    {                                                                          \                                      \
        typedef TDModel<BaseModel<Transport>>                                  \
            Transport##BaseModel;                                              \
        typedef RASModel<EddyDiffusivity<Transport##BaseModel>>                \
            RAS##Transport##BaseModel;                                        \
        typedef LESModel<EddyDiffusivity<Transport##BaseModel>>                \
            LES##Transport##BaseModel;                                        \
}

#define makeRASModel(Type)                                                    \
    makeTemplatedTurbulenceModel                                              \
    (phaseModelPhaseCompressibleTurbulenceModel, RAS, Type)

#define makeLESModel(Type)                                                    \
    makeTemplatedTurbulenceModel                                              \
    (phaseModelPhaseCompressibleTurbulenceModel, LES, Type)

createBaseTurbulenceModel
(
    volScalarField,
    volScalarField,
    compressibleTurbulenceModel,
    PhaseCompressibleTurbulenceModel,
    ThermalDiffusivity,
    phaseModel
);

#include "mykOmegaSSTSato.H"
makeRASModel(mykOmegaSSTSato);


nic92 June 30, 2016 12:29

Does your solution is still valid for OpenFOAM 3.0.x?
I notice that adding a new turbulence model in OpenFOAM 3.0.x is not so straightforward than in previous version

hk318i June 30, 2016 12:37

Quote:

Originally Posted by nic92 (Post 607466)
Does your solution is still valid for OpenFOAM 3.0.x?
I notice that adding a new turbulence model in OpenFOAM 3.0.x is not so straightforward than in previous version

Yes, you are right. It is not straight forward. I explained in details why here
This solution for OpenFOAM-3.0.0 and upward unless they changed again.

nic92 June 30, 2016 17:55

Thanks for your answer. I follow your steps, but I failed when I compiled the solver with the command wmake libso. In fact, I get:

make: *** No rule to make target 'Make/linux64GccDPInt32Opt/myphaseCompressibleTurbulenceModels.C.dep', needed by 'Make/linux64GccDPInt32Opt/myphaseCompressibleTurbulenceModels.o'. Stop.

I am pretty sure that it is a very basic error, but since I am at the beginning with OpenFOAM and with creating a new turbulent solver, I have not been able to solve it up to now. Thanks for your answer.

hk318i June 30, 2016 18:18

2 Attachment(s)
You maybe need to run wclean first. In case, it did not wok, I'm attaching here two examples which you can use for comparison.

Bw,
Hassan

nic92 July 3, 2016 18:53

Hi Thanks for your help. Now I am able to compile it. Just last questions, when I run my solver, the case is not able to recognize the new turbulence model. I add at the end of my controldict the command libs ("libmyphaseCompressibleTurbulenceModels.so"), as you suggested in your guide; in fact, the new model is not put in the directory /OpenFOAM-3.0.x/src/TurbulenceModels/phaseCompressible/RAS to mantain pure the installed version of OpenFOAM.

By doing so, I obtained an error concerning the fact that my model has not been recognized among those available.

hk318i July 4, 2016 05:57

The library name is incorrect, it should be exactly the same as in Make/file. For example for the attached mymixtureKEpsilon model

Code:

libs ("mymixtureKEpsilon.so");

nic92 July 27, 2016 18:34

Hi,

Up to now I succeded in compiling my new turbulence model. It works without errors. Nevertheless, I notice this warning:

--> FOAM Warning :
From function dlOpen(const fileName&, const bool)
in file POSIX.C at line 1179
dlopen error : /cineca/prod/opt/applications/openfoam/3.0/openmpi--1.6.4--gnu--4.7.2/OpenFOAM-3.0.x/platforms/linux64GccDPInt32Opt/lib/libcompressibleTwoPhaseSystem.so: undefined symbol: _ZN4Foam2fv10optionList5debugE
--> FOAM Warning :
From function dlLibraryTable::open(const fileName&, const bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99
could not load "mymixtureKEpsilon.so"

If I use this model in my case, the solver correctly selects my turbulence model. However, this warning appears whenever I run checkMesh, decomposePar or other command that has to do with calling the controlDict. Even though, I obtained results I would like to solve this problem and avoid warnings.

Thanks in advance for your help

hk318i July 28, 2016 08:14

Quote:

Originally Posted by nic92 (Post 611679)
Hi,

Up to now I succeded in compiling my new turbulence model. It works without errors. Nevertheless, I notice this warning:

--> FOAM Warning :
From function dlOpen(const fileName&, const bool)
in file POSIX.C at line 1179
dlopen error : /cineca/prod/opt/applications/openfoam/3.0/openmpi--1.6.4--gnu--4.7.2/OpenFOAM-3.0.x/platforms/linux64GccDPInt32Opt/lib/libcompressibleTwoPhaseSystem.so: undefined symbol: _ZN4Foam2fv10optionList5debugE
--> FOAM Warning :
From function dlLibraryTable::open(const fileName&, const bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 99
could not load "mymixtureKEpsilon.so"

If I use this model in my case, the solver correctly selects my turbulence model. However, this warning appears whenever I run checkMesh, decomposePar or other command that has to do with calling the controlDict. Even though, I obtained results I would like to solve this problem and avoid warnings.

Thanks in advance for your help

I'm not sure about this warning, it is probably because ``checkMesh`` cannot load the library. It think it will disappear once you comment out ``libs`` in ``controlDict``. The important point here, do you receive any warning with the solver or not?

Adlak November 11, 2016 07:10

I am trying to compile my dynamicsmagorinsky model in openfoam 3.0.x but getting following error :

symbol lookup error: /home/adlak/OpenFOAM/adlak-3.0.x-cfdsupport/platforms/linux64Gcc49DPInt32Opt/lib/libdynamicSmagorinsky.so: undefined symbol: _ZNK4Foam9LESModels18dynamicSmagorinskyINS_15EddyD iffusivityINS_18ThermalDiffusivityINS_27Compressib leTurbulenceModelINS_11fluidThermoEEEEEEEE2CkEv

If any one can help then it will be a great help for me. I followed steps given here http://hassankassem.me/posts/newturbulencemodel/

hk318i November 11, 2016 09:11

Quote:

Originally Posted by Adlak (Post 625091)
I am trying to compile my dynamicsmagorinsky model in openfoam 3.0.x but getting following error :

symbol lookup error: /home/adlak/OpenFOAM/adlak-3.0.x-cfdsupport/platforms/linux64Gcc49DPInt32Opt/lib/libdynamicSmagorinsky.so: undefined symbol: _ZNK4Foam9LESModels18dynamicSmagorinskyINS_15EddyD iffusivityINS_18ThermalDiffusivityINS_27Compressib leTurbulenceModelINS_11fluidThermoEEEEEEEE2CkEv

If any one can help then it will be a great help for me. I followed steps given here http://hassankassem.me/posts/newturbulencemodel/


It is hard to debug such error without the code. BTW, are you using CFD-support windows version?

Adlak November 14, 2016 06:29

[/QUOTE][/QUOTE][/QUOTE][/QUOTE]
Quote:

Originally Posted by hk318i (Post 625101)
It is hard to debug such error without the code. BTW, are you using CFD-support windows version?


It is OpenFoam-in-box based on openfoam 3.0.x for ubuntu. Give me ur email id. i will mail u my code. I have modified dynamickeqn model to make dynamicSmagorinsky model.

schuyler November 16, 2016 09:41

Quote:

Originally Posted by Adlak (Post 625245)


It is OpenFoam-in-box based on openfoam 3.0.x for ubuntu. Give me ur email id. i will mail u my code. I have modified dynamickeqn model to make dynamicSmagorinsky model.


Did you guys figure this out? I am having the same issue at run-time. I had just assumed it was something silly in my code. Curious to see if you guys found anything useful? What was the issue?

Schuyler

hk318i November 16, 2016 09:51

If it a common case, could anyone upload the code here with a test case or at least the steps to reproduce the error? It will be helpful for the community to keep a record of this case here.

Schuyler, could you please confirm which OF version have you tested? is it CFD-Support version?

Best wishes,
Hassan

schuyler November 16, 2016 10:25

2 Attachment(s)
Quote:

Originally Posted by hk318i (Post 625586)
If it a common case, could anyone upload the code here with a test case or at least the steps to reproduce the error? It will be helpful for the community to keep a record of this case here.

Schuyler, could you please confirm which OF version have you tested? is it CFD-Support version?

Best wishes,
Hassan

Thanks for the quick response Hassan. I am using 4.1 on ubuntu. I have uploaded a case file that I have been trying it on. I also uploaded a zipped directory of the code.

This is just a simple case to see if the model would run. I have run this model before using OpenFOAM 2.3 but wanted to update it to the newer version using the new format for the turbulence src.

Schuyler

hk318i November 16, 2016 11:11

Hello Schuyle,

Thank you for uploading the code it helped a lot.

The problem of your model is a missing defination of one function, namely
Code:

tmp<volScalarField> fmu(const volScalarField& chi) const;
The definition must be added (as f2() function) in the source file (.C)

Please keep us updated!

Best wishes,
Hassan


All times are GMT -4. The time now is 10:23.