CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] storeOldTime() and groovyBC oldTime() (https://www.cfd-online.com/Forums/openfoam-community-contributions/158257-storeoldtime-groovybc-oldtime.html)

Tobi August 19, 2015 11:31

storeOldTime() and groovyBC oldTime()
 
Hey all,

for a more complex boundary I need to know the previous mag of a vector field, to be able to compute the gradient (sign is important). For that I checked goovyBC and want to use oldTime(field). This is only working if the old field exist. In my case I get the same values for the old and actual value:

Code:

            "HF=sum(mag(heatFlux));"
            "oldHF=sum(mag(oldTime(heatFlux)));"

They are identical for each time steps which can not be possible (source of heat is powered off for example).

Therefore I implemented the following line in my code:
Code:

heatFlux.storeOldTime();
Compiled successfully but I still do not get different values!
Can somebody suggest something?

Thanks for any help.

Tobi August 20, 2015 02:23

It would be also possible if we can define a boolean in groovy that is not changing till some criterion is reached again.

Hence I am not getting a result with groovyBC, I will code this into my solver and create a variable that can be called by groovyBC.

Saideep August 20, 2015 09:25

Hi Tobi;

To have the previous time step variable value i guess the oldTime() function could be used.

Saideep

Tobi August 20, 2015 09:51

Hi,

thanks for the replay.
As I showed in the first post, the values were the same:

Code:

"new=max(magHeatFlux);"
"old=max(oldTime(magHeatFlux);"

With the debug flag on, it gave me identical values.
Anyway. I solved this problem now using C++ in the solver. Here I generated a new register field on which groovy has access. Its like a switch and in groovy I have no access like:

Code:

"TonOff=max(Ton);"
Where Ton is set in the *.C file of my solver.
Unfortunatelly Ton is a volScalarField at the moment that stores 0 or 1 (for all cells). Its working fine but the better way would be to generate a registry object as bool or scalar and use that to access in groovy. But at the moment I have no time to figure out how to create a registry booleans / scalar.

Saideep August 20, 2015 10:59

Hi,

Just wanted to know why you are using max function for all the variables?

Saideep


All times are GMT -4. The time now is 01:42.