ENH: The (final) sensitivities involved in topology optimisation

runs can now be written to files using the 'writeAllFields' flag in the
designVariables dictionary (defaults to false)
This commit is contained in:
Vaggelis Papoutsis
2023-12-04 16:04:50 +02:00
committed by Andrew Heather
parent c3b212e06c
commit 3cd2b2c692

View File

@ -488,6 +488,26 @@ Foam::tmp<Foam::scalarField> Foam::topODesignVariables::assembleSensitivities
// Add part due to regularisation and projection
regularisation_.postProcessSens(objectiveSens);
// Write final sensitivities field
if (writeAllFields_ && mesh_.time().writeTime())
{
volScalarField sens
(
IOobject
(
"topOSens" + adjointSens.getAdjointSolver().solverName(),
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar(dimless, Zero)
);
sens.primitiveFieldRef() = objectiveSens;
sens.write();
}
return tobjectiveSens;
}