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

How to know where a specified "const scalar" defined and calculated in openfoam ??

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By hk318i

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 11, 2016, 07:06
Default How to know where a specified "const scalar" defined and calculated in openfoam ??
  #1
Member
 
Bijan Darbari
Join Date: Nov 2015
Posts: 48
Rep Power: 10
bijan darbari is on a distinguished road
Dear Foamers

In many OpenFoam codes we can see some imported constant scalars.
For example look at lines 163-170 of:
Code:
Foam::forceSuSp Foam::BrownianMotionForce<CloudType>::calcCoupled
(
    const typename CloudType::parcelType& p,
    const scalar dt,
    const scalar mass,
    const scalar Re,
    const scalar muc
) const
Due to above lines, we can see that "dt" , "mass" , "Re" and "muc" have been imported to this code and all these scalars have predefined values.

Now, I want to know where the scalar "dt" defined and calculated before it have been imported to these code??
bijan darbari is offline   Reply With Quote

Old   May 15, 2016, 05:54
Default
  #2
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 17
hk318i is on a distinguished road
This code snippet is basically the definition of a member function called calcCoupled and dt, mass , ... are the input parameters (arguments) of this function. Their values depend on the passed values when this function is called. Therefore, you have to search OF source code related to this function and see how these values are calculated and passed to this particular function.

Best wishes,
Hassan Kassem
Luttappy and bijan darbari like this.
hk318i is offline   Reply With Quote

Old   May 15, 2016, 16:10
Default
  #3
Member
 
Bijan Darbari
Join Date: Nov 2015
Posts: 48
Rep Power: 10
bijan darbari is on a distinguished road
Thanks very much "hk318i"


Unfortunately, I'm beginner in openfoam programming. So need more help.
Can you tell me how I can search and find that special source code?? (where this function have been defined or "dt" have been calculated)
Because I want to define my own constant "dt". but openfoam use variable "dt" that calculated and changed in each lagrangian solution iteration.

best regards.
bijan darbari is offline   Reply With Quote

Old   July 17, 2016, 21:08
Default const scalar
  #4
New Member
 
Fidel Vallejo
Join Date: Dec 2015
Location: Santiago
Posts: 7
Rep Power: 10
fvallejog is on a distinguished road
Hi,

I'm in the same topic. I want to use a set of equations only in a one region.

In your problem, I think you must write

const scalar 'name_of_variable' 'expression'
Example: const scalar a=0.5*U;

Please, comment if it's correct

Quote:
Originally Posted by bijan darbari View Post
Dear Foamers

In many OpenFoam codes we can see some imported constant scalars.
For example look at lines 163-170 of:
Code:
Foam::forceSuSp Foam::BrownianMotionForce<CloudType>::calcCoupled
(
    const typename CloudType::parcelType& p,
    const scalar dt,
    const scalar mass,
    const scalar Re,
    const scalar muc
) const
Due to above lines, we can see that "dt" , "mass" , "Re" and "muc" have been imported to this code and all these scalars have predefined values.

Now, I want to know where the scalar "dt" defined and calculated before it have been imported to these code??
fvallejog is offline   Reply With Quote

Old   July 19, 2016, 03:21
Default
  #5
Member
 
Bijan Darbari
Join Date: Nov 2015
Posts: 48
Rep Power: 10
bijan darbari is on a distinguished road
Dear fvallejog

Thanks for your attention.
unfortunately, your commit didn't work.

my question is still remaining with no answer. and I don't find the place that "dt" have been defined and calculated.

ping
bijan darbari is offline   Reply With Quote

Old   July 19, 2016, 06:34
Default
  #6
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 17
hk318i is on a distinguished road
I will try to give you a quick hint because I don't know alot about your problem and the solver you are using.

  • BrownianMotionForce is inherited form ParticleForce<CloudType> class which is a base abstract class for particle forces.
  • BrownianMotionForce will be calculated only if BrownianMotion is selected in particleForces properties.
Example: SprayParcel and KinematicParcel

From SprayParcel line 248
Code:
    const forceSuSp Fcp = forces.calcCoupled(p, dt, mass, Re, muAv);
If you checked the code above this line, you will find how each variable is calculated exactly. Please note this line is within a function which is called somewhere in OpenFOAM. It is not the full picture, you may need to dig more in the source code.

Best wishes,
Hassan
__________________
@HIKassem | HassanKassem.me
hk318i is offline   Reply With Quote

Old   July 20, 2016, 12:56
Default
  #7
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18
anishtain4 is on a distinguished road
Name of parameters can change on every call so don't rely on them. Name of the function on the other hand should always be the same, so just try this:

Quote:
cd $FOAM_SRC
grep -nr calcCoupled
It shows you which files and which lines the function has been called and you can figure out how the arguments are calculated. If you're using a specific solver you can simply change the $FOAM_SRC to $FOAM_APP/solvers/yourSolverName
anishtain4 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
dsmcFoam setup hherbol OpenFOAM Pre-Processing 1 November 19, 2021 01:52
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 05:36
pipe flow OpenFOAM stix OpenFOAM Running, Solving & CFD 1 March 4, 2013 16:44
Difference between exact value and calculated value OFU OpenFOAM Post-Processing 2 August 19, 2011 06:10
User Defined Scalars - Returning Values Carlos V. FLUENT 0 April 19, 2006 18:18


All times are GMT -4. The time now is 13:39.