CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

How to get omega fields ?

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

Like Tree2Likes
  • 2 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 19, 2009, 09:54
Default How to get omega fields ?
  #1
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
Hi,

I am using OpenFOAM-1.5. I am doing RANS k-omega SST computations with a custom solver derived from simpleFoam and would like to manipulate fields of omega.

In createFields.H, there is

Code:
autoPtr<incompressible::RASModel> turbulence
(
    incompressible::RASModel::New(U, phi, laminarTransport)
);
and looking at the doc, I found that RASModel has no omega() method, while the kOmegaSST class which derives from RASModel has one.

I also found the declaration of New() which did not help me much:

Code:
//- Return a reference to the selected turbulence model
static autoPtr<RASModel> New
(
    const volVectorField& U,
    const surfaceScalarField& phi,
    transportModel& transport
);
I would like to know how can I access the method omega() corresponding to the turbulence model I am currently using.
johndeas is offline   Reply With Quote

Old   October 19, 2009, 12:34
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by johndeas View Post
Hi,

I am using OpenFOAM-1.5. I am doing RANS k-omega SST computations with a custom solver derived from simpleFoam and would like to manipulate fields of omega.

In createFields.H, there is

Code:
autoPtr<incompressible::RASModel> turbulence
(
    incompressible::RASModel::New(U, phi, laminarTransport)
);
and looking at the doc, I found that RASModel has no omega() method, while the kOmegaSST class which derives from RASModel has one.

I also found the declaration of New() which did not help me much:

Code:
//- Return a reference to the selected turbulence model
static autoPtr<RASModel> New
(
    const volVectorField& U,
    const surfaceScalarField& phi,
    transportModel& transport
);
I would like to know how can I access the method omega() corresponding to the turbulence model I am currently using.
What might help you is

mesh.lookupObject<volScalarField>("omega")

Have a look at Doxygen to find out what that actually does
gschaider is offline   Reply With Quote

Old   October 19, 2009, 15:20
Default
  #3
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 17
johndeas is on a distinguished road
Get it. Didn't know it could be that simple.

Thanks !
johndeas is offline   Reply With Quote

Old   March 20, 2012, 06:59
Default
  #4
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 17
Arnoldinho is on a distinguished road
Hi,

I have a question/problem accessing and modifying k and omega.
Using the above mentioned as simply taking
Quote:
volScalarField omega = mesh.lookupObject<volScalarField>("omega"); and e.g.
omega.boundaryField()[patchi] == 0.0;
does not change anything in my runs. I can access the omega field, but I cannot change it .

Any hints?
Arnoldinho is offline   Reply With Quote

Old   March 20, 2012, 08:40
Default
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Arnoldinho View Post
Hi,

I have a question/problem accessing and modifying k and omega.
Using the above mentioned as simply taking
does not change anything in my runs. I can access the omega field, but I cannot change it .

Any hints?
You want a reference but you're creating a copy
gschaider is offline   Reply With Quote

Old   March 20, 2012, 09:09
Default
  #6
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 17
Arnoldinho is on a distinguished road
Hello Bernhard,

I'm sorry to say that I'm not that familiar with c++ and references/pointers. I tried to reference the object in the following ways:
Quote:
volScalarField &omega = mesh.lookupObject<volScalarField>("omega");
volScalarField const &omega = mesh.lookupObject<volScalarField>("omega");
In the first case, the compiler complains
Quote:
invalid initialization of reference of type ‘Foam::volScalarField&’ from expression of type ‘const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>
whereas in the second case, I can't change the omega values (because of const).

I know that I definitely have to improve my c++ skills, but could you nevertheless give me the correct referencing syntax here?

Thanks,
Arne
Arnoldinho is offline   Reply With Quote

Old   March 20, 2012, 09:58
Default
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by Arnoldinho View Post
Hello Bernhard,

I'm sorry to say that I'm not that familiar with c++ and references/pointers. I tried to reference the object in the following ways:
In the first case, the compiler complains
whereas in the second case, I can't change the omega values (because of const).

I know that I definitely have to improve my c++ skills, but could you nevertheless give me the correct referencing syntax here?

Thanks,
Arne
Usually if you only get a const-reference it is because the designer of the class doesn't think it is a good idea. If you disagree google for const_cast

My last answer (about const_cast) was meant to be in answer of this message. I relocated it

Last edited by gschaider; March 20, 2012 at 10:56. Reason: Answered wrong message
gschaider is offline   Reply With Quote

Old   March 20, 2012, 11:07
Default
  #8
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 17
Arnoldinho is on a distinguished road
Thanks, I already got the casting working and am currently trying to understand a bit more about it - esp. the "unwanted behavior" of a const_cast.
Arnoldinho is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incompatible fields for operation divphi Ub vvqf OpenFOAM Running, Solving & CFD 4 April 4, 2018 04:28
Use of k omega turbulence model john_w OpenFOAM Running, Solving & CFD 2 September 22, 2009 06:15
Wall function implementation K Omega SSt cbarry OpenFOAM 3 August 18, 2009 11:09
PostChannel maka OpenFOAM Post-Processing 5 July 22, 2009 10:15
Airfoil with k Omega hoochie OpenFOAM Running, Solving & CFD 0 July 3, 2007 09:10


All times are GMT -4. The time now is 05:38.