-2
$\begingroup$

For learning purposes, how do I create an scalar variable like temperature divided by 2 and outputs it on files generated?

$\endgroup$
1
  • $\begingroup$ This is a question specific to OpenFOAM -- which you should ask on the OpenFOAM-specific mailing lists and forums because that's where the people who know this software hang out. $\endgroup$ Aug 31 '18 at 21:10
0
$\begingroup$

Supposing that your variable is totally dependent of T, so you don't need to read it on "0" file.

On createFields.h add:

Info<< "Creating T2\n" << endl;
volScalarField T2
(
    IOobject
    (
        "T2",
        runTime.timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::AUTO_WRITE
    ),
    mesh,dimensionedScalar("T2", dimensionSet(0,0,0,1,0,0,0),0.0 )
);

0.0 inside dimensioned scalar just initializes the variable.

Then you should add the equation to your runTimeLoop:

T2=T/2;
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.