CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to know where a specified "const scalar" defined and calculated in openfoam ?? (https://www.cfd-online.com/Forums/openfoam-programming-development/171573-how-know-where-specified-const-scalar-defined-calculated-openfoam.html)

bijan darbari May 11, 2016 07:06

How to know where a specified "const scalar" defined and calculated in openfoam ??
 
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??

hk318i May 15, 2016 05:54

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

bijan darbari May 15, 2016 16:10

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.

fvallejog July 17, 2016 21:08

const scalar
 
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 (Post 599616)
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 July 19, 2016 03:21

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

hk318i July 19, 2016 06:34

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

anishtain4 July 20, 2016 12:56

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


All times are GMT -4. The time now is 21:31.