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/)
-   -   Why is field not being written? (https://www.cfd-online.com/Forums/openfoam-programming-development/106922-why-field-not-being-written.html)

Horus September 12, 2012 08:54

Why is field not being written?
 
Hello,

I have a function object (coded function object embeddd in controlDict) that calculates c_p for the entire field.

The function object execution is controlled by:
Code:

      outputControl  outputTime;
      outputInterval  1;

The field is declared like this:
Code:

volScalarField c_p
        (
          IOobject
          (
          "c_p",
          mesh().time().timeName(),
          mesh(),
          IOobject::NO_READ,
          IOobject::AUTO_WRITE
          ),
          (p - p_inf) / (0.5 * sqr(U_inf))
        );

In this case it is never written to the timestep directories. If I add a c_p.write() it is written like it should.

But why is not written without an explicit write even though AUTO_WRITE is set? The U and p fields are declared just like this.

Thanks,

Florian

Hisham September 12, 2012 10:16

Hello,

If your field is not needed inside the calculations (not explicitly updated, i.e. using code). You can try adding the following at the end of your time loop:

Code:

if (runTime.outputTime())
  {
    volScalarField c_p
        (
          IOobject
          (
          "c_p",
          runTime().timeName(),
          mesh(),
          IOobject::NO_READ,
          IOobject::AUTO_WRITE
          ),
          (p - p_inf) / (0.5 * sqr(U_inf))
        );

    runTime.write();

  }

Regards
Hisham

alabardati1918 February 13, 2023 05:59

Hi guys


I had the same issue. I managed to solve it by realizing that I had used the value of the field in another file. I removed its use there and it now works.


Hope it helps


All times are GMT -4. The time now is 17:53.