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

Adding a new member function in src/../turbulenceModel

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

Reply
 
LinkBack Thread Tools Display Modes
Old   February 25, 2011, 18:55
Default Adding a new member function in src/../turbulenceModel
  #1
Member
 
Join Date: Oct 2010
Location: Stuttgart
Posts: 35
Rep Power: 6
grandgo is on a distinguished road
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:rintStack(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
grandgo is offline   Reply With Quote

Old   April 11, 2011, 09:34
Default
  #2
Senior Member
 
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 7
Fransje is on a distinguished road
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.
Fransje is offline   Reply With Quote

Old   May 9, 2011, 07:17
Default
  #3
Member
 
Join Date: Oct 2010
Location: Stuttgart
Posts: 35
Rep Power: 6
grandgo is on a distinguished road
Quote:
Originally Posted by Fransje View Post
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 is offline   Reply With Quote

Old   May 10, 2011, 10:25
Default
  #4
Member
 
Join Date: Oct 2010
Location: Stuttgart
Posts: 35
Rep Power: 6
grandgo is on a distinguished road
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:rintStack(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.
grandgo 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
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
latest OpenFOAM-1.6.x from git failed to compile phsieh2005 OpenFOAM Bugs 25 February 9, 2010 05:37
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 00:35
Compilation errors in ThirdPartymallochoard feng_w OpenFOAM Installation 1 January 25, 2009 07:59
Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Native Meshers: blockMesh 10 April 2, 2007 14:00


All times are GMT -4. The time now is 02:24.