CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to compare volume scalar field with constant values (https://www.cfd-online.com/Forums/openfoam-solving/70438-how-compare-volume-scalar-field-constant-values.html)

sachin November 24, 2009 12:59

How to compare volume scalar field with constant values
 
Hi,
I wanted to compare one volscalarfield w.r.t a constant value
To be more precise if I want to compare enthalpy h with specific value say enthalpy of sat liq
i need to find in all h values i.e forAll(arg1,arg2)
what should these arguments be

Please do let me know

thanks
sachin

l_r_mcglashan November 24, 2009 13:05

Something like:

Code:

forAll(enthalpy,celli)
{
    if(enthalpy[celli] == satEnthalpy){}
    else{}
}

Sounds like you know how to do it already if you've found the forAll macro.

sachin November 24, 2009 13:07

thanks for your quick reply,
I was having a basic idea...was just missing the arguments
sachin

l_r_mcglashan November 24, 2009 13:09

That's probably a bit sloppy for a volScalarField.

Code:

forAll(enthalpy.internalField(),celli)
{
        if(enthalpy[celli] == satEnthalpy){}
        else{}
}


iconde April 11, 2019 03:34

Hi there!

I'm trying to compare one volScalarField with one scalar, but It doesn't work properly.

I've used the code posted in previous post but it doesn´t get correct values. My code is:

Quote:

forAll(myVolScalarField.internalField(), i)
{

if (myVolScalarField[i] < scalar(1.0))
{

te.ref() = myVolScalarField * (dimensionedScalar("s", dimensionSet(0,0,1,0,0,0,0), scalar(1.0)));

}
else
{
te.ref() = 100 * (dimensionedScalar("s", dimensionSet(0,0,1,0,0,0,0), scalar(1.0)));
}

}
I'm not getting error, but when I analize the results, I'm not gettig what i spect. It seems like it doesn't compare cell by cell, it gets for all the vector the first equation or the second, but not both in the same timestep. Anyone knows how to fix it? Or how to do a comparation between scalar and volScalarField.

Thanks!


All times are GMT -4. The time now is 00:25.