AUTO_WRITE and field updating
I have been puzzled by the a simple question about a field defined say in createFields.H as:
If in the solver, rho as defined here is not updated or touched in anyway by calling thermo->correct somewhere or by explicitly modifying it,
but is still used in solved equations i.e. momentum, pressure equations etc.... Will the field "rho" used in these solved equations be modified everytime time step due to its definition in createFields?
As far as I figure, when it is written in the time folder it will be evaluated and updated as thermo->rho(), which in this case might be "rho = P/RT",
In other words is there a difference between the values of the field "rho" used in the solver and the "rho" written down?
Any help would be appreciated.
I'm not sure I completley understand but from my experience (somewhat limited). This code is a one-time creation of a volScalarField object. Thermo is used to point to a structure that has a member called rho (I assume this is used to calc rho of of the ideal gas law?). These values are used to populate the volScalarField rho. So... Without putting my foot in my mouth, I would say unless its modified in the time loop it shouldn't change.
Chris is totally right. With such a deffinition you create a copy of the data and that does not change unless you explicitly update it with something like "rho = ...". If you would like to connect variable rho with current thermo model data use a reference:
volScalarField & rho = thermo->rho();
or something like that.
I did little tests last night to check the matter and indeed the field does not change and keeps the value set initially.
The question initially arose because some way or another, the density in the code I was working on was changing in mysterious ways... when, as I thought at the time, it wasn't supposed to. Eventually, I found the real culprit.... Me. I just can't see what's right in front of me.
|All times are GMT -4. The time now is 17:20.|