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 a new member function in src/../turbulenceModel (https://www.cfd-online.com/Forums/openfoam-programming-development/85457-adding-new-member-function-src-turbulencemodel.html)

grandgo February 25, 2011 17:55

Adding a new member function in src/../turbulenceModel
 
Hi FOAMers,

I'm using OF 1.7.1 and i wanted to add a new member function into src/turbulenceModels/incompressible/turbulenceModel called 'nuSgs'. It's similar to 'nut' so i just copied all the lines with 'nut' within turbulenceModel.H, laminar.H and laminar.C and changed to nuSgs.
The problem is, that when i start a modified pisoFoam solver with the energy equation in it, i get these error messages:

Courant Number mean: 0 max: 0.520522
#0 Foam::error::printStack(Foam::Ostream&) in "/home/gee/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigSegv::sigSegvHandler(int) in "/home/gee/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 in "/lib64/libc.so.6"
#3 Foam::incompressible::LESModel::correct() in "/home/gee/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libincompressibleLESModels.so"
#4
in "/home/gee/OpenFOAM/gee-1.7.1/applications/bin/linux64GccDPOpt/pisoFoamTNuLES"
#5 __libc_start_main in "/lib64/libc.so.6"
#6
at /usr/src/packages/BUILD/glibc-2.11.2/csu/../sysdeps/x86_64/elf/start.S:116
Speicherzugriffsfehler

Does anyone know, what's wrong?

Best regards
grandgo

Fransje April 11, 2011 09:34

Dear Grandgo,

Well, the problem is that the nut defined in ./src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H is a virtual function, so it doesn't do anything. The whole turbulenceModel.* in that folder are prototype functions, and should be implemented in specific models themselves.

Since you seem confused by this constructions, I recommend you first start by improving your C++ skills, with a special attention on inheritance, polymorphism and templates. This will greatly improve your understanding of how the OpenFOAM code is programmed.

As for the use of your new variable, you will probably have to program it inside the turbulence model you want to use. Choose a turbulence model making use of nut as reference, to understand how it can be done in OpenFOAM. Good luck!

Kind regards,

Francois.

grandgo May 9, 2011 07:17

Quote:

Originally Posted by Fransje (Post 303102)
Dear Grandgo,

Well, the problem is that the nut defined in ./src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H is a virtual function, so it doesn't do anything. The whole turbulenceModel.* in that folder are prototype functions, and should be implemented in specific models themselves.

Since you seem confused by this constructions, I recommend you first start by improving your C++ skills, with a special attention on inheritance, polymorphism and templates. This will greatly improve your understanding of how the OpenFOAM code is programmed.

As for the use of your new variable, you will probably have to program it inside the turbulence model you want to use. Choose a turbulence model making use of nut as reference, to understand how it can be done in OpenFOAM. Good luck!

Kind regards,

Francois.


hi francois,

first of all: thanks and sorry for the delay.

  • now: i modified the "dynSmagorinsky" turbulence model by adding the following in "member functions" (dynSmagorinsky.H)

//- Return the effective thermal diffusivity
tmp<volScalarField> alphaEff() const
{
return tmp<volScalarField>
(
new volScalarField("alphaEff", nuSgs_ + nu())
);
}

i compilied this turbulence model with a new name.


  • this is what i implemented into the pisoFoam solver:
turbulence->correct();

volScalarField alphaEff
(
"alphaEff",
laminarTransport.nu()/pr + turbulence->nuSgs_/prSgs
);

//solves scalar equation
{
//add energy equation
fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(alphaEff, T)
);

TEqn.solve();
}

(the equation is from this page: www.idurun.com/?p=556)



the problem is that compiling doesn't work. i get these messages:

Making dependency list for source file pisoFoamTNuLES.C
SOURCE=pisoFoamTNuLES.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/turbulenceModels/incompressible/turbulenceModel -I/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/transportModels -I/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/transportModels/incompressible/singlePhaseTransportModel -I/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude -I/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/pisoFoamTNuLES.o
In file included from pisoFoamTNuLES.C:38:0:
/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H:172:37: error: ‘nuSgs_’ declared as a ‘virtual’ field
/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H:172:44: error: expected ‘;’ before ‘const’
pisoFoamTNuLES.C: In function ‘int main(int, char**)’:
pisoFoamTNuLES.C:137:42: error: ‘class Foam::incompressible::turbulenceModel’ has no member named ‘nuSgs_’
pisoFoamTNuLES.C:137:49: error: ‘prSgs’ was not declared in this scope
/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/finiteVolume/lnInclude/readPISOControls.H:11:10: warning: unused variable ‘transonic’
/home/gee/OpenFOAM/OpenFOAM-1.7.1/src/finiteVolume/lnInclude/readPISOControls.H:14:9: warning: unused variable ‘nOuterCorr’
make: *** [Make/linux64GccDPOpt/pisoFoamTNuLES.o] Fehler 1


i dont know what the problem is. something about nuSgs_ and prSgs obviously but i just don't know what to do.



anyone with an idea?

grandgo May 10, 2011 10:25

hi,

the modified dynSmagorinsky is inaccurate, i think.

this

http://openfoamwiki.net/index.php/Si...ry_/_Tutorials

says in chapter 3.2.2 that i need to add the member function, which i want to use, in src/turbulenceModels/incompressible/turbulenceModel/turbulenceModel.H . so i added this line:

virtual tmp<volScalarField> nuSgs const=0; .



but the modified pisoFoam solver with TEqn:

turbulence->correct();

volScalarField alphaEff
(
"alphaEff",
laminarTransport.nu()/pr + turbulence->nuSgs()/prSgs
);

//solves scalar equation
{
//add energy equation
fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(alphaEff, T)
);

TEqn.solve();
}


doesn't work.

i get some erros about printStack:

#0 Foam::error::printStack(Foam::Ostream&) in "/home/gee/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#1 Foam::sigSegv::sigSegvHandler(int) in "/home/gee/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libOpenFOAM.so"
#2 in "/lib64/libc.so.6"
#3 Foam::incompressible::LESModel::correct() in "/home/gee/OpenFOAM/OpenFOAM-1.7.1/lib/linux64GccDPOpt/libincompressibleLESModels.so"
#4
in "/home/gee/OpenFOAM/gee-1.7.1/applications/bin/linux64GccDPOpt/pisoFoamTNuLES"
#5 __libc_start_main in "/lib64/libc.so.6"
#6
at /usr/src/packages/BUILD/glibc-2.11.2/csu/../sysdeps/x86_64/elf/start.S:116
Speicherzugriffsfehler


i don't understand why everything works fine when i'm using the original pisoFoam + dynSmagorinsky,
but doesn't work when i use a modified pisoFoam with energy equation in it.


All times are GMT -4. The time now is 22:00.