https://linen.dev logo
how can one save a `Foam::tmp<Foam::Field<double> ...
# programming
o
how can one save a
Foam::tmp<Foam::Field<double> >
? I am trying to save the
UrCoNum
which is included in the twoPhaseEulerFoam as:
Copy code
#include "CourantNo.H"

{
    scalar UrCoNum = 0.5*gMax
    (
        fvc::surfaceSum(mag(phi1 - phi2))().primitiveField()/mesh.V().field()
    )*runTime.deltaTValue();

    Info<< "Max Ur Courant Number = " << UrCoNum << endl;

    CoNum = max(CoNum, UrCoNum);
}
but I would like to output the field UrCoNum instead. I created a field in
createFields.H
Copy code
Info<< "Creating field CoRCalc\n" << endl;
volScalarField CoRCalc
(
    IOobject
    (
        "CoRCalc",
     runTime.timeName(),
     mesh,
     IOobject::NO_READ,
     IOobject::AUTO_WRITE
    ),
 mesh,
 dimensionSet(0,0,0,0,0,0,0)
);
and then in the main .C i did:
CoRCalc= 0.5*fvc::surfaceSum(mag(phi1 - phi2))().primitiveField()/mesh.V().field()*runTime.deltaTValue();
but I am getting an error while compiling:
error: no match for ‘operator=’ (operand types are ‘Foam::volScalarField’ {aka ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’} and ‘Foam::tmp<Foam::Field<double> >’)