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

bound() function of the bound.C file

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By mAlletto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 8, 2018, 10:46
Default bound() function of the bound.C file
  #1
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hi everybody,

yesterday I had a discussion with my colleague about the bound function. We were digging into the code and were finally surprised how interesting this function is working. Actually we needed just the max() function but for unknown reason we went the wrong direction at the beginning. Nevertheless it was good that we discussed about the bound() functionality. However, it is always nice to have the code implementation and be able to understand it but in that particular case, does anybody know if there is a mathematical background behind this interesting expression?

After small drafts we realized that the unbounded values will get some values which are somehow an average of the field values. We can imagine that this makes much more sense than setting it to a - lets say - minimum value e.g. 0.

The question as already mentioned is. Does anybody know if there is some mathematical background / formula behind that? At least there should be some mathematical or physical background for that implementation.

https://cpp.openfoam.org/v5/bound_8C_source.html

Code:
   32 Foam::volScalarField&   33 Foam::bound(volScalarField& vsf, const dimensionedScalar& lowerBound)
   34 {
   35     const scalar minVsf = min(vsf).value();
   36 
   37     if (minVsf < lowerBound.value())
   38     {
   39         Info<< "bounding " << vsf.name()
   40             << ", min: " << minVsf
   41             << " max: " << max(vsf).value()
   42             << " average: " << gAverage(vsf.primitiveField())
   43             << endl;
   44 
   45         vsf.primitiveFieldRef() = max
   46         (
   47             max
   48             (
   49                 vsf.primitiveField(),
   50                 fvc::average(max(vsf, lowerBound))().primitiveField()
   51               * pos(-vsf.primitiveField())
   52             ),
   53             lowerBound.value()
   54         );
   55 
   56         vsf.boundaryFieldRef() = max(vsf.boundaryField(), lowerBound.value());
   57     }
   58 
   59     return vsf;
   60 }
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   November 20, 2018, 07:55
Default
  #2
gu1
Senior Member
 
Guilherme
Join Date: Apr 2017
Posts: 245
Rep Power: 10
gu1 is on a distinguished road
Hi Tobi,

I'm studying about the bound function... so unfortunately I can not help you in your post. I have a question and maybe you can help me..., related to the kEpsilon model. Based on original file: kEpsilon

On lines 132 and 133 I could substitute for:

Quote:
bound(k_, kMin_);
bound(epsilon_, epsilonMin_);

for

bound(k_, SMALL);
bound(epsilon_, SMALL);
? and lines 259 and 275:

Quote:
bound(epsilon_, epsilonMin_);
bound(k_, kMin_);

for

bound(epsilon_, SMALL);
bound(k_, SMALL);
? I could not understand if kMin and epsilonMin are updated every iteration. Could you explain to me what their function is (these are in RASModel)? Would I disrupt the efficiency of the kEpsilon model if I removed them?

OBS: I understand that SMALL is the default value of this function.
gu1 is offline   Reply With Quote

Old   November 20, 2018, 08:55
Default
  #3
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16
mAlletto will become famous soon enough
Quote:
Originally Posted by Tobi View Post
Hi everybody,

yesterday I had a discussion with my colleague about the bound function. We were digging into the code and were finally surprised how interesting this function is working. Actually we needed just the max() function but for unknown reason we went the wrong direction at the beginning. Nevertheless it was good that we discussed about the bound() functionality. However, it is always nice to have the code implementation and be able to understand it but in that particular case, does anybody know if there is a mathematical background behind this interesting expression?

After small drafts we realized that the unbounded values will get some values which are somehow an average of the field values. We can imagine that this makes much more sense than setting it to a - lets say - minimum value e.g. 0.

The question as already mentioned is. Does anybody know if there is some mathematical background / formula behind that? At least there should be some mathematical or physical background for that implementation.

https://cpp.openfoam.org/v5/bound_8C_source.html

Code:
   32 Foam::volScalarField&   33 Foam::bound(volScalarField& vsf, const dimensionedScalar& lowerBound)
   34 {
   35     const scalar minVsf = min(vsf).value();
   36 
   37     if (minVsf < lowerBound.value())
   38     {
   39         Info<< "bounding " << vsf.name()
   40             << ", min: " << minVsf
   41             << " max: " << max(vsf).value()
   42             << " average: " << gAverage(vsf.primitiveField())
   43             << endl;
   44 
   45         vsf.primitiveFieldRef() = max
   46         (
   47             max
   48             (
   49                 vsf.primitiveField(),
   50                 fvc::average(max(vsf, lowerBound))().primitiveField()
   51               * pos(-vsf.primitiveField())
   52             ),
   53             lowerBound.value()
   54         );
   55 
   56         vsf.boundaryFieldRef() = max(vsf.boundaryField(), lowerBound.value());
   57     }
   58 
   59     return vsf;
   60 }
from the source code it seams all positive values smaller than lowerBound will be bounded by lowerBound (pos((-vsf.primitiveField()) is 0 for positive values of vsf). For negative values the field is averaged over neighboring cells and after that the maximum between the calculated value and lowerBound is taken.

I quess the averaging is made in order to suppress numerical oscillations.
As far as I know the bounding is performed to help the solver to find a solution or avoid that the solver diverges.
randolph likes this.
mAlletto 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
[swak4Foam] funkyDoCalc with OF2.3 massflow NiFl OpenFOAM Community Contributions 14 November 25, 2020 04:30
[swak4Foam] Problem installing swak_2.x for OpenFoam-2.4.0 towanda OpenFOAM Community Contributions 6 September 5, 2015 22:03
[OpenFOAM] Annoying issue of automatic "Rescale to Data Range " with paraFoam/paraview 3.12 keepfit ParaView 60 September 18, 2013 04:23
[blockMesh] BlockMesh FOAM warning gaottino OpenFOAM Meshing & Mesh Conversion 7 July 19, 2010 15:11
DecomposePar links against liblamso0 with OpenMPI jens_klostermann OpenFOAM Bugs 11 June 28, 2007 18:51


All times are GMT -4. The time now is 03:33.