|
[Sponsors] |
build your own turbulence model with buoyancy |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 6, 2009, 11:51 |
build your own turbulence model with buoyancy
|
#1 |
Senior Member
Join Date: Apr 2009
Location: Karlsruhe, Germany
Posts: 103
Rep Power: 17 |
Hallo all,
I try to make my own turbulence model with buoyancy effects. I began making my own kEpsilonModel with a dynamic library and included this one in the controlDict-data with the line libs ("libmyBCs.so");. I copied the kEpsilonModel, renamed it and compiled it. It works. Now I want to modify this model. For my case it's neccessary to make a new class of RASModel with the Temperaturefield: RASModel::RASModel ( const word& type, const volVectorField& U, const surfaceScalarField& phi, const volScalarField& T, transportModel& lamTransportModel ) So I modified the RASModel.C & RasModel.H, the transportModel.C&H and the turbulenceModel.C&H datas. I used for all of them namespace incompressible. Compiling all of them works without problems. But using this turbulenceModel with I case I get following error message: / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 Reading g Reading thermophysical properties Reading field T Reading field p Reading field U Reading/calculating face flux field phi Selecting incompressible transport model Newtonian Creating turbulence model Selecting RAS turbulence model kEpsilonTom lookup of RASProperties from objectRegistry region0 successful but it is not a RASModel, it is a kEpsilonTom#0 Foam::error:rintStack(Foam::Ostream&) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so" #1 Foam::error::abort() in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so" #2 Foam::Ostream& Foam:perator<< <Foam::error>(Foam::Ostream&, Foam::errorManip<Foam::error>) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantSimpleOne" #3 Foam::incompressible::RASModel const& Foam:bjectRegistry::lookupObject<Foam::incompres sible::RASModel>(Foam::word const&) const in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so" #4 Foam::incompressible::RASModels::nutWallFunctionFv PatchScalarField::calcNut() const in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so" #5 Foam::incompressible::RASModels::nutWallFunctionFv PatchScalarField::updateCoeffs() in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so" #6 Foam::fvPatchField<double>::evaluate(Foam::Pstream ::commsTypes) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantSimpleOne" #7 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::evaluate() in "/user/hi204/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantSimpleOne" #8 Foam::incompressible::RASModels::kEpsilonTom::kEps ilonTom(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::transportModel&) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libmyincompressibleRASModels.so" #9 Foam::incompressible::RASModel::adddictionaryConst ructorToTable<Foam::incompressible::RASModels::kEp silonTom>::New(Foam::GeometricField<Foam::Vector<d ouble>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::transportModel&) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libmyincompressibleRASModels.so" #10 Foam::incompressible::RASModel::New(Foam::Geometri cField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::transportModel&) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so" #11 main in "/user/hi204/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantSimpleOne" #12 __libc_start_main in "/lib/libc.so.6" #13 _start at /build/buildd/glibc-2.9/csu/../sysdeps/x86_64/elf/start.S:116 From function objectRegistry::lookupObject<Type>(const word&) const in file /home/dm2/henry/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 121. FOAM aborting So my problem is, it is a RASModel, made with the new constructor with more arguments (temperature-field T is included). So is it neccessary to create my own namespace? Has anybody an idea? Regards Thomas |
|
November 6, 2009, 11:59 |
|
#2 |
Senior Member
Join Date: Apr 2009
Location: Karlsruhe, Germany
Posts: 103
Rep Power: 17 |
[QUOTE=Thomas Baumann;235374]Hallo all,
I try to make my own turbulence model with buoyancy effects. I began making my own kEpsilonModel with a dynamic library and included this one in the controlDict-data with the line libs ("libmyBCs.so");. I copied the kEpsilonModel, renamed it and compiled it. It works. Now I want to modify this model. For my case it's neccessary to make a new class of RASModel with the Temperaturefield: RASModel::RASModel ( const word& type, const volVectorField& U, const surfaceScalarField& phi, const volScalarField& T, transportModel& lamTransportModel ) So I modified the RASModel.C & RasModel.H, the transportModel.C&H and the turbulenceModel.C&H datas. I used for all of them namespace incompressible. Compiling all of them works without problems. But using this turbulenceModel with I case I get following error message: / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 Reading g Reading thermophysical properties Reading field T Reading field p Reading field U Reading/calculating face flux field phi Selecting incompressible transport model Newtonian Creating turbulence model Selecting RAS turbulence model kEpsilonTom lookup of RASProperties from objectRegistry region0 successful but it is not a RASModel, it is a kEpsilonTom#0 Foam::error:rintStack(Foam::Ostream&) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so" #1 Foam::error::abort() in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libOpenFOAM.so" #2 Foam::Ostream& Foam:perator<< <Foam::error>(Foam::Ostream&, Foam::errorManip<Foam::error>) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantSimpleOne" #3 Foam::incompressible::RASModel const& Foam:bjectRegistry::lookupObject<Foam::incompres sible::RASModel>(Foam::word const&) const in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so" #4 Foam::incompressible::RASModels::nutWallFunctionFv PatchScalarField::calcNut() const in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so" #5 Foam::incompressible::RASModels::nutWallFunctionFv PatchScalarField::updateCoeffs() in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so" #6 Foam::fvPatchField<double>::evaluate(Foam::Pstream ::commsTypes) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantSimpleOne" #7 Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::evaluate() in "/user/hi204/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantSimpleOne" #8 Foam::incompressible::RASModels::kEpsilonTom::kEps ilonTom(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::transportModel&) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libmyincompressibleRASModels.so" #9 Foam::incompressible::RASModel::adddictionaryConst ructorToTable<Foam::incompressible::RASModels::kEp silonTom>::New(Foam::GeometricField<Foam::Vector<d ouble>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::transportModel&) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libmyincompressibleRASModels.so" #10 Foam::incompressible::RASModel::New(Foam::Geometri cField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh> const&, Foam::transportModel&) in "/user/hi204/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/libincompressibleRASModels.so" #11 main in "/user/hi204/OpenFOAM/OpenFOAM-1.6/applications/bin/linux64GccDPOpt/buoyantSimpleOne" #12 __libc_start_main in "/lib/libc.so.6" #13 _start at /build/buildd/glibc-2.9/csu/../sysdeps/x86_64/elf/start.S:116 From function objectRegistry::lookupObject<Type>(const word&) const in file /home/dm2/henry/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 121. FOAM aborting So my problem is, it is a RASModel, made with the new constructor with more arguments (temperature-field T is included). So is it neccessary to create my own namespace? Has anybody an idea? Regards Thomas |
|
November 8, 2009, 06:24 |
|
#3 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
For example, in kEpsilon.C you'll see it is registered via a dictionary constructor: Code:
addToRunTimeSelectionTable(RASModel, kEpsilon, dictionary); You are thus currently stuck with an identical number of parameters if you wish to hook into the current RASModel selection mechanism. A workaround would be to retain the normal parameter list (like the other RASModels) and assign the temperature reference within the constructor using the objectRegistry lookup mechanism. You can use "T" as the default name for the temperature field, but also provision for an alternative name by using a 'readIfPresent' on the corresponding model coefficients sub-dictionary. |
||
November 10, 2009, 02:49 |
|
#4 |
Senior Member
Join Date: Apr 2009
Location: Karlsruhe, Germany
Posts: 103
Rep Power: 17 |
Hallo Mark,
I had a closer look at the different solvers (for example buoyantBoussinesqPisoFoam). There is the RASModel.H included. So I think making a dynamic bibliothek with new MyRASModel.H&C with a new constructor isn't the best solution. So I'm trying your proposal with the old RASModel.H&C and include the reference for the temperaturefield in the new myTurbulenceModel.C&H like you discribed. Regards Thomas Last edited by Thomas Baumann; November 12, 2009 at 10:55. |
|
November 11, 2009, 03:52 |
|
#5 |
Senior Member
Join Date: Apr 2009
Location: Karlsruhe, Germany
Posts: 103
Rep Power: 17 |
Finally I modified the kEpsilon model without modifying the class RASModel.
My modifications being able to include the temperature field in the turbulence modelling transport equations are: kEpsilonBuoyancy.H (former kEpsilon.H) volScalarField Tnew_; virtual tmp<volScalarField> T() const { return Tnew_; } kEpsilonBuoyancy.C (former kEpsilon.C) Tnew_ ( IOobject ( "T", runTime_.timeName(), mesh_, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh_ ), I modified the transport equations, implemented the turbulent Prandtl number, thermal expansion coefficient, some constants, too. The first simulations show nice results. Regards Thomas Last edited by Thomas Baumann; November 11, 2009 at 07:21. |
|
November 11, 2009, 04:07 |
|
#6 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
My first impression is that it may somehow work (ie, not crash), but it isn't quite right either. |
||
November 12, 2009, 11:38 |
|
#7 |
Senior Member
Join Date: Apr 2009
Location: Karlsruhe, Germany
Posts: 103
Rep Power: 17 |
Hallo Mark,
thank you for the information. I'm trying to implement the temperature field using the lookup-method. But my experience with C++ and programming in OpenFOAM is not very high. I have looked in some codes and tried to implement it in my model, but nothing has matched until now. I think the code must look like: const volScalarField& T = ???.lookupObject<volScalarField>("T"); So I'm further searching for "how to include T" without writing a new constructor of the RASModel-class. Regards Thomas |
|
November 13, 2009, 04:23 |
|
#8 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
For example, const volScalarField& T = U.db().lookupObject<volScalarField>("T"); /mark |
||
November 13, 2009, 07:25 |
|
#9 |
Senior Member
Join Date: Apr 2009
Location: Karlsruhe, Germany
Posts: 103
Rep Power: 17 |
Implementing
const volScalarField& T = U.db().lookupObject<volScalarField>("T"); and compiling the new turbulence-model I get following error message: clude -I. -I/user/hi204/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/user/hi204/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/kEpsilonBuoyancy.o kEpsilonBuoyancy/kEpsilonBuoyancy.C:157: error: ‘U’ was not declared in this scope kEpsilonBuoyancy/kEpsilonBuoyancy.C:157: error: expected primary-expression before ‘>’ token make: *** [Make/linux64GccDPOpt/kEpsilonBuoyancy.o] Fehler 1 Regards Thomas |
|
November 13, 2009, 07:59 |
|
#10 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
|
||
November 23, 2009, 08:32 |
|
#11 |
Senior Member
Join Date: Apr 2009
Location: Karlsruhe, Germany
Posts: 103
Rep Power: 17 |
Hallo Mark,
I think it works now. Your tips helped me very much. By the way, you were right: the velocity field was U_, not U. It took me some time to understand your tips and I had to understand more about C++. For the sake of completeness: I want to use the new turbulence model in simulations using the BuoyantSimpleFoam solver. I implemented a pointer to get the temperature field without modifying the constructor of RASModel. myTurbulenceModel.H const volScalarField* Tnew_; myTurbulenceModel.C within the constructor: Tnew_ = &(U_.db().lookupObject<volScalarField>("T")); Because of the overloaded Operator * in the turbulent kinetic energy and dissipation equation I created a function Tnew() to use the temperature field T for modelling the turbulent viscoity. So I implemented following member function, too: myTurbulenceModel.H virtual const volScalarField Tnew(); myTurbulenceModel.C const volScalarField myTurbulenceModel::Tnew() { return *Tnew_; } It's not easy to test, if the right temperature field is used. So I did the same method to get the velocity field U, modified the kEpsilon turbulence model by solving the k and epsilon equation using this new method to get the velocity field (the same as the T field). I simulated a basic problem with the basic kEpsilon and with the modified kEpsilon model. Comparing the residuals showed no differences. So I think the temperature-field should be included in a right way. So thank you very much for your help. Regards Thomas |
|
November 23, 2009, 08:53 |
|
#12 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Servus Thomas,
It looks mostly okay, except that in OpenFOAM they mostly use references instead of pointers and it look more consistent if you used references too, but that is, I suppose, a matter of taste for your case. Quote:
Code:
const volScalarField& myTurbulenceModel::Tnew() const { return *Tnew_; } You should also have a trailing 'const' on the Tnew() method, since calling it does not change anything inside of your model - ie, you can call the Tnew() method on a read-only object without any problem. /mark |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding a Turbulence Model | doug | OpenFOAM Running, Solving & CFD | 11 | May 21, 2018 13:54 |
Eul-Eul flow, k-e-kp-ep-Theta Turbulence model | us | FLUENT | 5 | April 5, 2011 02:29 |
KOmega Turbulence model from wwwopenFOAMWikinet | philippose | OpenFOAM Running, Solving & CFD | 30 | August 4, 2010 10:26 |
Turbulence Model | GG | Siemens | 3 | March 3, 2008 19:06 |
v2-f turbulence model in CFX? | flga | CFX | 14 | November 23, 2006 06:12 |