CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   add filed to OpenFOAM (http://www.cfd-online.com/Forums/openfoam-solving/64023-add-filed-openfoam.html)

sven82 April 27, 2009 10:50

add filed to OpenFOAM
 
Hi ,

at the moment I work with OpenFOAM especially with a new DES case.
After I finish the implementation I like to visual the individual zones (RANS or LES) with a easy 0 or 1, just to see in which zones work a RANS simulation and in which a LES

the idea

create a field in the turbulenceModell.C like this

DES_
(
IOobject
(
"DES",
runTime_.timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("DES", dimless, 0.0)
),

in the next step I create the two fields that I like to compare, and the turn

volScalarField keps_ = pow(sqrt(k_),3) / epsilon_;

volScalarField CDESdelta_ = CDES_ * delta();


if( keps < CDESdelta_ )
{DES_ = 1.0;}
else
{DES_ = 0.0;}

DES_.write();

But I got a problem when I run the case with my new DES, the field look like this

dimensions [0 0 0 0 0 0 0]; //Time 1e5 and NOT t=0
internalField uniform 1;
boundaryField
{
inlet
{
type calculated;
value uniform 1;
}
outlet
{
type calculated;
value uniform 1;
}
upperWall
{
type calculated;
value uniform 1;
}
lowerWall
{
type calculated;
value uniform 1;
}
}

My question now is whats wrong with the code.
The output of the values of the two compares parameters, CDESdelta and keps_, are correct (values of both possibilities , CDESdelta<keps and CDESdelta>keps) !

I hope anybody got a idea

best regards
sven

henrik April 27, 2009 11:08

Dear Sven,

DES_ = 1.0 sets the whole field to 1.0, likewise DES_ = 0.0;

You need a loop or translate the if into some function that is defined for fields.

Nice error, wonder what CDESdelta_ evaluates to in scalar context. Print it and enlighten me.

Henrik

henrik April 28, 2009 06:14

Some more info on the gory details:

Code:

forAll(DES_, cellI)
{
    if( keps_[cellI] < CDESdelta_[cellI] )
    {DES_[cellI] = 1.0;}
    else
    {DES_[cellI] = 0.0;}
}

DES_.write();

Henrik


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