CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   accessing 0 time directory in coded functionObject (https://www.cfd-online.com/Forums/openfoam-post-processing/211902-accessing-0-time-directory-coded-functionobject.html)

JM27 November 21, 2018 08:41

accessing 0 time directory in coded functionObject
 
Hi there,


I am hoping to get some help with coded function objects in openFoam.

I have written a function object to compute the radius of a bubble based on volume fraction alpha and cell volume as follows (compressibleInterFoam):

Code:


// section of coded to be executed, in controlDict

forAll(centers, I) 
            {
                        if (alpha[I] < th)       
                {

                    // TO COMPUTE RADIUS

                    // compute numerator, time-varying
                            sumNumerator  += (1-alpha[I])*(V[I]); // per time-step
                                                             
               
                    // compute denominator, constant at t = 0
                          sumDenominator += (1-alpha[I])*(V[I]);    // CHANGE TO ACCESS VALUES AT TIME = 0 -- how?
       

                  // At each time-step
                    bracket        = pow(sumNumerator/sumDenominator, 1/3);   

                 

                    // compute Radius               
                    Radius        = Rstart*bracket;
              }
      }

However, I cannot seem to figure out how to access the properties at time directory 0.

The code compiles and runs but with the above setting the radius clearly stays constant for all time-directories.
Please help. Any advice will be greatly appreciated.

p.s. I know I can do something similar in swak4Foam but so far I have not managed to make this work for my current version (v5.0) and I want to try out some coding in OpenFOAM and c++ as an exercise (still a newbie).


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