ENH: the adjoint grid displacement field (ma)

is now appended by the name of the adjoint solver, if more than one
exist. This was necessary for an accurate continuation since, before
these changes, only the ma field of the last solver was written. As a
result, when restarting the first adjoint solver was reading the ma
field of the last one. No changes are needed in fvSolution and fvSchemes
w.r.t. the previous code version.
This commit is contained in:
Vaggelis Papoutsis
2021-10-19 18:06:20 +03:00
committed by Andrew Heather
parent 148815265c
commit 0b0b308db2
3 changed files with 75 additions and 35 deletions

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2021 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2021 FOSS GP
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,6 +28,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "adjointMeshMovementSolverIncompressible.H" #include "adjointMeshMovementSolverIncompressible.H"
#include "incompressibleAdjointSolver.H"
#include "fixedValueFvPatchFields.H"
#include "subCycleTime.H" #include "subCycleTime.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -70,12 +72,22 @@ adjointMeshMovementSolver::adjointMeshMovementSolver
tolerance_(-1), tolerance_(-1),
ma_ ma_
( (
variablesSet::autoCreateMeshMovementField IOobject
( (
word
(
adjointSensitivity.adjointVars().useSolverNameForFields() ?
"ma" + adjointSensitivity.adjointSolver().solverName() :
"ma"
),
mesh.time().timeName(),
mesh, mesh,
"ma", IOobject::READ_IF_PRESENT,
dimensionSet(pow3(dimLength/dimTime)) IOobject::AUTO_WRITE
) ),
mesh,
dimensionedVector(pow3(dimLength/dimTime), Zero),
fixedValueFvPatchVectorField::typeName
), ),
source_ source_
( (
@ -142,7 +154,8 @@ void adjointMeshMovementSolver::solve()
maEqn.boundaryManipulate(ma_.boundaryFieldRef()); maEqn.boundaryManipulate(ma_.boundaryFieldRef());
//scalar residual = max(maEqn.solve().initialResidual()); //scalar residual = max(maEqn.solve().initialResidual());
scalar residual = mag(maEqn.solve().initialResidual()); scalar residual =
mag(Foam::solve(maEqn, mesh_.solverDict("ma")).initialResidual());
Info<< "Max ma " << gMax(mag(ma_)()) << endl; Info<< "Max ma " << gMax(mag(ma_)()) << endl;

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2007-2021 PCOpt/NTUA
Copyright (C) 2013-2020 FOSS GP Copyright (C) 2013-2021 FOSS GP
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -100,6 +100,24 @@ autoPtr<adjointSensitivity> adjointSensitivity::New
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * //
const incompressibleVars& adjointSensitivity::primalVars() const
{
return primalVars_;
}
const incompressibleAdjointVars& adjointSensitivity::adjointVars() const
{
return adjointVars_;
}
const incompressibleAdjointSolver& adjointSensitivity::adjointSolver() const
{
return adjointSolver_;
}
const scalarField& adjointSensitivity::calculateSensitivities() const scalarField& adjointSensitivity::calculateSensitivities()
{ {
assembleSensitivities(); assembleSensitivities();

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2020 PCOpt/NTUA Copyright (C) 2007-2021 PCOpt/NTUA
Copyright (C) 2013-2020 FOSS GP Copyright (C) 2013-2021 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -155,6 +155,15 @@ public:
// Member Functions // Member Functions
//- Get primal variables
const incompressibleVars& primalVars() const;
//- Get adjoint variables
const incompressibleAdjointVars& adjointVars() const;
//- Get adjoint solver
const incompressibleAdjointSolver& adjointSolver() const;
//- Accumulate sensitivity integrands //- Accumulate sensitivity integrands
// Corresponds to the flow and adjoint part of the sensitivities // Corresponds to the flow and adjoint part of the sensitivities
virtual void accumulateIntegrand(const scalar dt) = 0; virtual void accumulateIntegrand(const scalar dt) = 0;