ENH: added the adjointRotatingWallVelocity boundary condition

Same as adjointWallVelocity but also returns the contribution
of the differentiation of the rotatingWallVelocity BC wrt the
face centres, to be added to the sensitivity derivatives.
This commit is contained in:
Vaggelis Papoutsis
2020-01-17 11:11:14 +02:00
committed by Andrew Heather
parent d3938a79f4
commit 0d9421c6a8
3 changed files with 290 additions and 0 deletions

View File

@ -81,6 +81,7 @@ adjointBoundaryConditions/adjointInletVelocity/adjointInletVelocityFvPatchVector
adjointBoundaryConditions/adjointOutletVelocity/adjointOutletVelocityFvPatchVectorField.C
adjointBoundaryConditions/adjointWallVelocity/adjointWallVelocityFvPatchVectorField.C
adjointBoundaryConditions/adjointWallVelocityLowRe/adjointWallVelocityLowReFvPatchVectorField.C
adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.C
adjointBoundaryConditions/adjointOutletPressure/adjointOutletPressureFvPatchScalarField.C
adjointBoundaryConditions/adjointFarFieldPressure/adjointFarFieldPressureFvPatchScalarField.C
adjointBoundaryConditions/adjointFarFieldVelocity/adjointFarFieldVelocityFvPatchVectorField.C

View File

@ -0,0 +1,135 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 PCOpt/NTUA
Copyright (C) 2020 FOSS GP
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "adjointRotatingWallVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::adjointRotatingWallVelocityFvPatchVectorField::
adjointRotatingWallVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
adjointWallVelocityFvPatchVectorField(p, iF),
origin_(),
axis_(Zero),
omega_(nullptr)
{}
Foam::adjointRotatingWallVelocityFvPatchVectorField::
adjointRotatingWallVelocityFvPatchVectorField
(
const adjointRotatingWallVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
adjointWallVelocityFvPatchVectorField(ptf, p, iF, mapper),
origin_(ptf.origin_),
axis_(ptf.axis_),
omega_(ptf.omega_.clone())
{}
Foam::adjointRotatingWallVelocityFvPatchVectorField::
adjointRotatingWallVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
adjointWallVelocityFvPatchVectorField(p, iF, dict),
origin_(dict.lookup("origin")),
axis_(dict.lookup("axis")),
omega_(Function1<scalar>::New("omega", dict))
{}
Foam::adjointRotatingWallVelocityFvPatchVectorField::
adjointRotatingWallVelocityFvPatchVectorField
(
const adjointRotatingWallVelocityFvPatchVectorField& pivpvf,
const DimensionedField<vector, volMesh>& iF
)
:
adjointWallVelocityFvPatchVectorField(pivpvf, iF),
origin_(pivpvf.origin_),
axis_(pivpvf.axis_),
omega_(pivpvf.omega_.clone())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::tensorField>
Foam::adjointRotatingWallVelocityFvPatchVectorField::dxdbMult() const
{
const scalar t(this->db().time().timeOutputValue());
const scalar om(omega_->value(t));
const vector omega(om*axis_/mag(axis_));
tensor mult
(
scalar(0), -omega.z(), omega.y(),
omega.z(), scalar(0), -omega.x(),
-omega.y(), omega.x(), scalar(0)
);
return tmp<tensorField>::New(patch().size(), mult);
}
void Foam::adjointRotatingWallVelocityFvPatchVectorField::write
(
Ostream& os
) const
{
adjointWallVelocityFvPatchVectorField::write(os);
os.writeEntry("origin", origin_);
os.writeEntry("axis", axis_);
omega_->writeData(os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
adjointRotatingWallVelocityFvPatchVectorField
);
}
// ************************************************************************* //

View File

@ -0,0 +1,154 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 PCOpt/NTUA
Copyright (C) 2020 FOSS GP
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::adjointRotatingWallVelocityFvPatchVectorField
Description
The same as adjointWallVelocity but additionally computes the sensitivity
contribution emerging from the change in the positions of the face centres,
in case rotatingWallVelocity is used for the flow simulation.
SourceFiles
adjointRotatingWallVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef adjointRotatingWallVelocityFvPatchVectorField_H
#define adjointRotatingWallVelocityFvPatchVectorField_H
#include "adjointWallVelocityFvPatchVectorField.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class adjointRotatingWallVelocity Declaration
\*---------------------------------------------------------------------------*/
class adjointRotatingWallVelocityFvPatchVectorField
:
public adjointWallVelocityFvPatchVectorField
{
private:
// Private Data
//- Origin of the rotation
vector origin_;
//- Axis of the rotation
vector axis_;
//- Rotational speed
autoPtr<Function1<scalar>> omega_;
public:
//- Runtime type information
TypeName("adjointRotatingWallVelocity");
// Constructors
//- Construct from patch and internal field
adjointRotatingWallVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
adjointRotatingWallVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given
//- adjointRotatingWallVelocityFvPatchVectorField onto a new patch
adjointRotatingWallVelocityFvPatchVectorField
(
const adjointRotatingWallVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new adjointRotatingWallVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
adjointRotatingWallVelocityFvPatchVectorField
(
const adjointRotatingWallVelocityFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new adjointRotatingWallVelocityFvPatchVectorField(*this, iF)
);
}
// Member functions
//- Compute contribution to SDs
virtual tmp<tensorField> dxdbMult() const;
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //