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

How to limit min and max values in scalarCodedSource

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 18, 2021, 12:32
Default How to limit min and max values in scalarCodedSource
  #1
Member
 
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5
jdw135 is on a distinguished road
Hello,

I am writing my own scalarCodedSource term, and I need to clamp the value of a calculated variable between a min and max value. I've seen in the tutorial here:

http://https://develop.openfoam.com/...anopyTSource.C

the use of the method scalarMinMax, but I cannot find that in the source code guide. Even if I could, I am unsure how to implement it into my code.

Basically, I am wanting to do something like:

Code:
const scalarField A = (B*C)/D;
clamp(A, min, max);
Is there a way to do this? I have tried

Code:
A = min(A, minValue)
to set a minimum, but I don't know if it's doing the correct thing.
jdw135 is offline   Reply With Quote

Old   March 18, 2021, 18:25
Default
  #2
Senior Member
 
Wouter van der Meer
Join Date: May 2009
Location: Elahuizen, Netherlands
Posts: 203
Rep Power: 17
wouter is on a distinguished road
try:
A=max(min(A,maxval),minval). max clips the minimum value and min clips the maximum value
wouter is offline   Reply With Quote

Old   March 19, 2021, 17:23
Default
  #3
Member
 
Jonathan Wells
Join Date: Oct 2020
Location: Indiana
Posts: 44
Rep Power: 5
jdw135 is on a distinguished road
Quote:
Originally Posted by wouter View Post
try:
A=max(min(A,maxval),minval). max clips the minimum value and min clips the maximum value
Using this I get:

Code:
fvOptions.energySource.scalarCodedSourceCoeffs(46): error: no instance of overloaded function "Foam::min" matches the argument list
            argument types are: (Foam::scalarField, int)
                mach = max(min(mach,1),0.1);
jdw135 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
y+ and u+ values with low-Re RANS turbulence models: utility + testcase florian_krause OpenFOAM 114 August 23, 2023 05:37
Converging Diverging Nozzle with dbnsTurbFoam Saleh Abuhanieh OpenFOAM Running, Solving & CFD 4 December 13, 2019 10:26
Near wall treatment in k-omega SST Arnoldinho OpenFOAM Running, Solving & CFD 38 March 8, 2017 13:48
Problem of simulating of small droplet with radius of 2mm liguifan OpenFOAM Running, Solving & CFD 5 June 3, 2014 02:53
On the damBreak4phaseFine cases paean OpenFOAM Running, Solving & CFD 0 November 14, 2008 21:14


All times are GMT -4. The time now is 14:22.