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 can I write out a volscalarfield in openFOAM (https://www.cfd-online.com/Forums/openfoam-programming-development/122762-how-can-i-write-out-volscalarfield-openfoam.html)

Marshak August 27, 2013 12:38

How can I write out a volscalarfield in openFOAM
 
I am trying to write out a volscalarfield 'a'. I define it in the library as follows

tmp<volScalarField> ta
(
new volScalarField
(
IOobject
(
"a",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh(),
dimensionedScalar("a", dimless/dimLength, 0.0)
)
);

In the solve, in createFileds.H, i define it as

volScalarField a
(
IOobject
(
"a",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("a", dimensionSet(0,-1,0,0,0,0,0), 0.0)
);

But when I save field data for a given time step the it does create a file 'a' but there are no values and instead for each bounday patch it is written :

internalField uniform 0;

boundaryField
{
boundary1
{
type calculated;
value uniform 0;
}
}

can someone tell me how to write out any volscalarfield.

hrushi.397 August 28, 2013 02:32

Why define two a's separately? Can you not define a separate variable for dimensionless a?

It looks like your a is not changing during simulation. Check that too

Marshak August 29, 2013 05:53

'a' is a dimensioned variable. I also have defined it as

AUTO-WRITE

in the code and removed it from createfields.H but it is still not writting for each time step.

mkraposhin August 29, 2013 14:10

1) If you don't want to read field from the file, then you must specify it's boundary types in constructor

2) volScalarField is a typedef for the GeomtricField<scalar, fvPatchScalarField, fvMesh>, full list of constructors you can find here

3) If you want to write your field at the each time step, you must call a.write()


All times are GMT -4. The time now is 23:36.