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

Effect of "Yi.max(0.0)" in YEqn.H

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By knuckles

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 23, 2016, 02:14
Default Effect of "Yi.max(0.0)" in YEqn.H
  #1
Member
 
Join Date: Aug 2015
Posts: 37
Rep Power: 10
knuckles is on a distinguished road
reactingFoam's YEqn.H (applications/solvers/reactingFoam/YEqn.H) sets up an equation called YiEqn and then solves it as follows:

Code:
       
    YiEqn.relax();                        

    fvOptions.constrain(YiEqn);                        

    YiEqn.solve(mesh.solver("Yi"));                        

    fvOptions.correct(Yi);                        

    Yi.max(0.0);
I don't understand what Yi.max(0.0) does. Based on what makes sense at this location, I would assume that it takes values below 0.0 and clipping them to 0, but if that were the case, I'd expect the function to be called "min" or "enforceMin." "Max" suggests the opposite functionality, to me at least...

What does "Yi.max(0.0)" do?
knuckles is offline   Reply With Quote

Old   September 23, 2016, 06:51
Default
  #2
Member
 
Ben Jankauskas
Join Date: Jun 2013
Location: Exeter
Posts: 34
Rep Power: 12
rhythm is on a distinguished road
Hi,

I think you are correct, as to my understanding it is a hard coded lower bound for each of the scalar fields. It forces Y field to be non-negative. If after solving species field equation Yi is negative somewhere on your mesh, then the code just takes that value and substitutes it with 0.0. If it was as you suggested -> min(0.0) then it would do an opposite job of cutting of all of the positive values and forcing them to be zero.

This is done in addition to using a Gauss limitedLinear 1 fvScheme on div(Yi_h) that should try and get the top bounding condition for the mass fraction fields sorted.

Here's a snippet of how does the max() member function of GeometricField look like:
Code:
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::max
(
    const dimensioned<Type>& dt
)
{ 
    Foam::max(internalField(), internalField(), dt.value());
    Foam::max(boundaryField(), boundaryField(), dt.value()); 
}
At the moment I can't seem to find the reason Foam::max() takes three arguments, so maybe someone else might be able to answer that.

Hope this helps.
Ben

Last edited by rhythm; September 23, 2016 at 10:20.
rhythm is offline   Reply With Quote

Old   September 23, 2016, 11:01
Default
  #3
Member
 
Join Date: Aug 2015
Posts: 37
Rep Power: 10
knuckles is on a distinguished road
Thanks for your reply, Ben.

Good to hear that you agree with my interpretation. I suppose that the idea behind calling it "max" is that A.max(b) is equivalent to A = max(A,b) ? This is the part that I've gotten hung up on; I've been mentally parsing A.max(b) as "clip A so that its maximum is b," which is equivalent to A = min(A,b).

Also, for consistency, wouldn't it also make sense to add a second line:

Code:
Yi.min(1.0);
...to ensure that no mass fraction exceeds 1?
TommyM likes this.
knuckles is offline   Reply With Quote

Old   September 24, 2016, 07:28
Default
  #4
Member
 
Ben Jankauskas
Join Date: Jun 2013
Location: Exeter
Posts: 34
Rep Power: 12
rhythm is on a distinguished road
Hi,

Quote:
I suppose that the idea behind calling it "max" is that A.max(b) is equivalent to A = max(A,b) ?
Yep, I would think that the operation is equivalent, but my guess we need this separate member function in order to apply this operation to GeometricFields and in this case a volScalarField.

Quote:
Also, for consistency, wouldn't it also make sense to add a second line:

Code:
Yi.min(1.0);
...to ensure that no mass fraction exceeds 1?
One could do that, but my guess is that this would be a bit too harsh. Your code might be doing the wrong thing, but because there is a hard cut off point you would still get the results and could interpret them as valid.
My knowledge of the numerical schemes lacks, but I would think that this is the reason a Gauss limitedLinear 1 is used in fvSchemes. In addition to a lowerBound value of 0.0 it numerically tries to keep the solution between [0:1] hence hopefully making it as physical as possible and making the bounding slightly smoother.
This is a bit of a speculation on my part, so I'll read through the limiting schemes code later today, and if I have additional ideas I'll share it.

Ben
rhythm 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
modelling the effect of smear effect in Casing with Drilling babak1 Main CFD Forum 0 July 17, 2013 10:48
Can Flow-3D solve the Joule-Thomson effect? seasoul FLOW-3D 8 December 21, 2011 00:01
Can 'shock waves' occur in viscous fluid flows? diaw Main CFD Forum 104 February 16, 2006 05:44
VOF and strong surface tension effect phsieh2005 Main CFD Forum 1 August 30, 2005 06:56
Iclude particle diameter effect in wall? yueroo FLUENT 0 April 14, 2001 03:56


All times are GMT -4. The time now is 18:09.