diff --git a/src/optimisation/adjointOptimisation/adjoint/Make/files b/src/optimisation/adjointOptimisation/adjoint/Make/files index 17297eaf98739d2b0392f8d6a18b990068a2190e..d79ad9af80ae8c317d0c467303f52d8f8f2073f9 100644 --- a/src/optimisation/adjointOptimisation/adjoint/Make/files +++ b/src/optimisation/adjointOptimisation/adjoint/Make/files @@ -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 diff --git a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.C b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.C new file mode 100644 index 0000000000000000000000000000000000000000..f5b8362cd054eb18b4cad6ba01c21ae3b9f3304a --- /dev/null +++ b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.C @@ -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 + ); +} + +// ************************************************************************* // diff --git a/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.H b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.H new file mode 100644 index 0000000000000000000000000000000000000000..382ffa5baaaf9791b1521668825a0f70a096222f --- /dev/null +++ b/src/optimisation/adjointOptimisation/adjoint/adjointBoundaryConditions/adjointRotatingWallVelocity/adjointRotatingWallVelocityFvPatchVectorField.H @@ -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 + +// ************************************************************************* //