CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   How to get omega fields ? (http://www.cfd-online.com/Forums/openfoam/69306-how-get-omega-fields.html)

johndeas October 19, 2009 08:54

How to get omega fields ?
 
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.

gschaider October 19, 2009 11:34

Quote:

Originally Posted by johndeas (Post 233221)
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

johndeas October 19, 2009 14:20

Get it. Didn't know it could be that simple.

Thanks !

Arnoldinho March 20, 2012 06:59

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 :confused:.

Any hints?

gschaider March 20, 2012 08:40

Quote:

Originally Posted by Arnoldinho (Post 350390)
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 :confused:.

Any hints?

You want a reference but you're creating a copy

Arnoldinho March 20, 2012 09:09

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

gschaider March 20, 2012 09:58

Quote:

Originally Posted by Arnoldinho (Post 350414)
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

Arnoldinho March 20, 2012 11:07

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.


All times are GMT -4. The time now is 20:34.