Yann
06/06/2025, 3:23 PMcodeWrite
#{
auto* snGradcPtr =
mesh().getObjectPtr<surfaceScalarField>("snGradc");
if (!snGradcPtr)
{
Info<< "Create surface normal gradient field" << nl;
snGradcPtr = new surfaceScalarField
(
IOobject
(
"snGradc",
mesh().time().timeName(),
mesh(),
IOobject::NO_READ,
IOobject::AUTO_WRITE,
IOobject::REGISTER
),
mesh(),
dimensionedScalar("zero", dimensionSet(0, -1, 0, 0, 0, 0, 0), 0.0)
);
regIOobject::store(snGradcPtr);
}
auto& snGradc = *snGradcPtr;
Info<< "Computing surface normal gradient field\n" << endl;
const volScalarField& c = mesh().lookupObject<volScalarField>("c");
snGradc = 1e-8*fvc::snGrad(c);
#};
}
To be able to use the new snGradc variable in other FO it should be registered in the database.
I don't think the whole pointer is mandatory but it didn't sound like a bad idea to check if the object already exists before creating it.