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

How to compare volume scalar field with constant values

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By l_r_mcglashan
  • 1 Post By l_r_mcglashan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 24, 2009, 12:59
Default How to compare volume scalar field with constant values
  #1
Member
 
Sachin Kanetkar
Join Date: Mar 2009
Posts: 57
Rep Power: 17
sachin is on a distinguished road
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
sachin is offline   Reply With Quote

Old   November 24, 2009, 13:05
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
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.
tonnykz likes this.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   November 24, 2009, 13:07
Default
  #3
Member
 
Sachin Kanetkar
Join Date: Mar 2009
Posts: 57
Rep Power: 17
sachin is on a distinguished road
thanks for your quick reply,
I was having a basic idea...was just missing the arguments
sachin
sachin is offline   Reply With Quote

Old   November 24, 2009, 13:09
Default
  #4
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
That's probably a bit sloppy for a volScalarField.

Code:
forAll(enthalpy.internalField(),celli)
{
         if(enthalpy[celli] == satEnthalpy){}
         else{}
}
tonnykz likes this.
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   April 11, 2019, 03:34
Default
  #5
New Member
 
Anna
Join Date: Feb 2019
Posts: 17
Rep Power: 7
iconde is on a distinguished road
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!
iconde is offline   Reply With Quote

Reply


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
[Commercial meshers] CuBit t42 OpenFOAM Meshing & Mesh Conversion 6 July 10, 2008 07:51
Constant field inside the volume Ben Makhal CFX 10 February 6, 2008 16:32
from a vecor field to get a gradient of scalar dusky.he Main CFD Forum 4 March 30, 2007 09:08
transient temperature field with constant velocity Törnquist CFX 0 September 16, 2003 04:22
Scalar summation over whole volume Jakub CFX 2 April 18, 2002 12:21


All times are GMT -4. The time now is 17:51.