CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   mykEpsilon - How to set a min/max constraint for a term with units (http://www.cfd-online.com/Forums/openfoam/80942-mykepsilon-how-set-min-max-constraint-term-units.html)

elektra79 October 11, 2010 19:18

mykEpsilon - How to set a min/max constraint for a term with units
 
Hello all,

I have implemented a k-epsilon turbulence model and named my directory "mykEpsilon".

In mykEpsilon.C, I have a term called "sstar_" that has units of (1/sec^2) that is defined as a volScalarField in mykEpsilon.H. Now, in mykEpsilon.C, I would like to fix a "min" constraint on this term. The code compiles but I get an error when running (regarding unmatched dimensions). These are the lines that I use in mykEpsilon.C to initialize:

gradU_(fvc::grad(U)),
ss_(0.5*(gradU_ + gradU_.T())),
sstar_(sqrt(max(ss_ && ss_.T(),1.0e-10))),

The problem is with the term "sstar_".
"ss_" is defined as a volTensorField.
"ss_ && ss_.T()" should give a volScalarField with units of (1/sec^2).
"sstar_" is defined as a volScalarField.

So the error is coming up because the code is attempting to compare a term that has units of (1/sec^2) to a number (1e-10) that is unitless. Does anyone know how to fix this? Thank you!

FYI, my code was running well before I attempted to add the "min" constraint.

sabin.ceuca October 12, 2010 02:31

Hi elektra79,
my simplest solution would be to initialize a field in createFields.H which has the desired dimension and a constant value. It would look something like this
volScalarField yourConstantValueScalarField
(
IOobject
(
"yourConstantValueScalarField",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("zero",dimensionSet
(0, 0, -2, 0, 0, 0, 0), 1e-10)
);
It might not be the most elegant way to solve your problem but it does the trick.
Ciao,
Sabin

elektra79 October 12, 2010 13:52

Hi Sabin. Thank you for your reply.

Here is what I added to "createFields.H" which is located in the "applications/solvers/incompressible/pisoFoam" directory:

volScalarField s_lim
(
IOobject
(
"s_lim",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("one-e-neg-ten",
dimensionSet(0, 0, -2, 0, 0, 0, 0),1.0e-10)
);

My questions now are:

(1) How would this feed back to the directory that holds my turbulence model? How would I denote a "pointer" to this variable?

(2) How would I use this in "mykEpsilon.C"? I tried the following in "mykEpsilon.C" and got errors when trying to compile:

gradU_(fvc::grad(U)),
ss_(0.5*(gradU_ + gradU_.T())),
sstar_(sqrt(max(ss_ && ss_.T(),"one-e-neg-ten"))),

Thank you!

elektra79 October 12, 2010 18:12

It is now working. I am able to fix a min/max constraint for the term "sstar_".

In "mykEpsilon.C", I did the following for initializing:

gradU_(fvc::grad(U)),
ss_(0.5*(gradU_ + gradU_.T())),

s_lim
(
IOobject
(
"s_lim",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("s_lim",dimensionSet(0, 0, -2, 0, 0, 0, 0),1.0e-10)
)
,

sstar_(pow(max(ss_ && ss_.T(),s_lim),0.5)),

In "mykEpsilon.H", I added:

volTensorField gradU_;
volTensorField ss_;

volScalarField s_lim;
volScalarField sstar_;

Thank you for the tips!


All times are GMT -4. The time now is 12:15.