mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: added the adjoint to the kOmega SST turbulence model
for incompressible flows. The typical convention of appending the primal
field name with 'a' to form the adjoint field is followed for the
adjoint turbulent kinetic energy (i.e. 'ka') but since this would produce
an ugly variable name for the adjoint to omega (i.e. omegaa), the latter
is abbreviated to 'wa'.
The work is based on
\verbatim
Kavvadias, I., Papoutsis-Kiachagias, E.,
Dimitrakopoulos, G., & Giannakoglou, K. (2014).
The continuous adjoint approach to the k–$omega$ SST turbulence model with
applications in shape optimization
Engineering Optimization, 47(11), 1523-1542.
https://doi.org/10.1080/0305215X.2014.979816
\endverbatim
with changes in the discretisation of
a number of differential operators and the formulation of the adjoint to
the wall functions employed by the primal model.
Regarding the latter, the code assumes (and differentiates) the default
behaviour of nutkWallFunction (i.e. nutWallFunction::blendingType::STEPWISE)
and omegaWallFunction (i.e. omegaWallFunction::blendingType::BINOMIAL2).
Due to the availability of a number of terms required for the
formulation of the wall function for ka, the latter is implemented
within adjointkOmegaSST itself, with contributions from objective functions
implemented within kaqRWallFunction. Wall functions for wa are
implemented within waWallFunction.
The initial implementation of the above-mentioned reference was
performed by Dr. Ioannis Kavvadias
This commit is contained in:
committed by
Andrew Heather
parent
b550a23acb
commit
8f7fc54c27
@ -64,11 +64,18 @@ turbulenceModels/incompressibleAdjoint/adjointTurbulenceModel/adjointTurbulenceM
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/adjointRASModel/adjointRASModel.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/adjointLaminar/adjointLaminar.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/adjointSpalartAllmaras/adjointSpalartAllmaras.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/adjointkOmegaSST/adjointkOmegaSST.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointInletNuaTilda/adjointInletNuaTildaFvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointOutletNuaTilda/adjointOutletNuaTildaFvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointFarFieldNuaTilda/adjointFarFieldNuaTildaFvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointFarFieldTMVar1/adjointFarFieldTMVar1FvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointFarFieldTMVar2/adjointFarFieldTMVar2FvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointOutletNuaTildaFlux/adjointOutletNuaTildaFluxFvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointOutletFlux/adjointOutletFluxFvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointOutletFlux/adjointOutletFluxFvPatchFields.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/kaqRWallFunction/kaqRWallFunctionFvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/waWallFunction/waWallFunctionFvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointOutletKa/adjointOutletKaFvPatchScalarField.C
|
||||
turbulenceModels/incompressibleAdjoint/adjointRAS/derivedFvPatchFields/adjointOutletWa/adjointOutletWaFvPatchScalarField.C
|
||||
|
||||
/* ADJOINT BOUNDARY CONDITIONS */
|
||||
adjointBoundaryConditions/adjointBoundaryCondition/adjointBoundaryConditions.C
|
||||
|
||||
@ -147,6 +147,7 @@ adjointRASModel::adjointRASModel
|
||||
|
||||
adjointTMVariable1Ptr_(nullptr),
|
||||
adjointTMVariable2Ptr_(nullptr),
|
||||
adjointTMVariablesBaseNames_(0),
|
||||
adjointTMVariable1MeanPtr_(nullptr),
|
||||
adjointTMVariable2MeanPtr_(nullptr),
|
||||
adjMomentumBCSourcePtr_( createZeroBoundaryPtr<vector>(mesh_) ),
|
||||
@ -351,6 +352,12 @@ autoPtr<volScalarField>& adjointRASModel::getAdjointTMVariable2InstPtr()
|
||||
}
|
||||
|
||||
|
||||
const wordList& adjointRASModel::getAdjointTMVariablesBaseNames()
|
||||
{
|
||||
return adjointTMVariablesBaseNames_;
|
||||
}
|
||||
|
||||
|
||||
tmp<volScalarField> adjointRASModel::nutJacobianTMVar1() const
|
||||
{
|
||||
return
|
||||
|
||||
@ -116,6 +116,9 @@ protected:
|
||||
//- Adjoint turbulence model variable 2
|
||||
autoPtr<volScalarField> adjointTMVariable2Ptr_;
|
||||
|
||||
//- Base names of the adjoint fields
|
||||
wordList adjointTMVariablesBaseNames_;
|
||||
|
||||
//- Adjoint turbulence model variable 1, mean value
|
||||
autoPtr<volScalarField> adjointTMVariable1MeanPtr_;
|
||||
|
||||
@ -258,6 +261,10 @@ public:
|
||||
//- Return non-constant autoPtr to adjoint turbulence model variable 2
|
||||
autoPtr<volScalarField>& getAdjointTMVariable2InstPtr();
|
||||
|
||||
//- Return reference to the adjoint turbulence model variables base
|
||||
//- names
|
||||
const wordList& getAdjointTMVariablesBaseNames();
|
||||
|
||||
//- Return the effective stress tensor including the laminar stress
|
||||
virtual tmp<volSymmTensorField> devReff() const = 0;
|
||||
|
||||
|
||||
@ -675,6 +675,8 @@ adjointSpalartAllmaras::adjointSpalartAllmaras
|
||||
gradNuTilda_(fvc::grad(nuTilda())),
|
||||
minStilda_("SMALL", Stilda_.dimensions(), SMALL)
|
||||
{
|
||||
adjointTMVariablesBaseNames_.setSize(1);
|
||||
adjointTMVariablesBaseNames_[0] = "nuaTilda";
|
||||
// Read nuaTilda field and reset pointer to the first
|
||||
// adjoint turbulence model variable
|
||||
variablesSet::setField
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,620 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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::incompressibleAdjoint::adjointRASModels::adjointkOmegaSST
|
||||
|
||||
Description
|
||||
Continuous adjoint to the kOmegaSST turbulence model for incompressible
|
||||
flows.
|
||||
|
||||
Reference:
|
||||
\verbatim
|
||||
The code is based on the following reference, with a number of
|
||||
changes in the numerical implementation
|
||||
|
||||
Kavvadias, I., Papoutsis-Kiachagias, E., Dimitrakopoulos, G., &
|
||||
Giannakoglou, K. (2014).
|
||||
The continuous adjoint approach to the k–ω SST turbulence model
|
||||
with applications in shape optimization
|
||||
Engineering Optimization, 47(11), 1523-1542.
|
||||
https://doi.org/10.1080/0305215X.2014.979816
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
adjointkOmegaSST.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef adjointkOmegaSST_H
|
||||
#define adjointkOmegaSST_H
|
||||
|
||||
#include "adjointRASModel.H"
|
||||
#include "wallDist.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace incompressibleAdjoint
|
||||
{
|
||||
namespace adjointRASModels
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class adjointkOmegaSST Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class adjointkOmegaSST
|
||||
:
|
||||
public adjointRASModel
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- No copy construct
|
||||
adjointkOmegaSST(const adjointkOmegaSST&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const adjointkOmegaSST&) = delete;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
// Primal Model coefficients
|
||||
|
||||
dimensionedScalar kappa_;
|
||||
dimensionedScalar alphaK1_;
|
||||
dimensionedScalar alphaK2_;
|
||||
|
||||
dimensionedScalar alphaOmega1_;
|
||||
dimensionedScalar alphaOmega2_;
|
||||
|
||||
dimensionedScalar gamma1_;
|
||||
dimensionedScalar gamma2_;
|
||||
|
||||
dimensionedScalar beta1_;
|
||||
dimensionedScalar beta2_;
|
||||
|
||||
dimensionedScalar betaStar_;
|
||||
|
||||
dimensionedScalar a1_;
|
||||
dimensionedScalar b1_;
|
||||
dimensionedScalar c1_;
|
||||
|
||||
//- Flag to include the F3 term
|
||||
Switch F3_;
|
||||
|
||||
|
||||
// Fields
|
||||
|
||||
// Primal Fields
|
||||
|
||||
//- Wall distance
|
||||
// Note: reference to the distance known by the primal model
|
||||
const volScalarField& y_;
|
||||
|
||||
//- Cached primal gradient fields
|
||||
volTensorField gradU_;
|
||||
volVectorField gradOmega_;
|
||||
volVectorField gradK_;
|
||||
|
||||
//- Primal cached fields involved in the solution of the
|
||||
// adjoint equations
|
||||
// Cached to reduce the computational cost
|
||||
volScalarField S2_;
|
||||
volScalarField S_;
|
||||
volScalarField GbyNu0_;
|
||||
volScalarField CDkOmega_;
|
||||
volScalarField CDkOmegaPlus_;
|
||||
volScalarField F1_;
|
||||
volScalarField F2_;
|
||||
|
||||
// Model Field coefficients
|
||||
volScalarField alphaK_;
|
||||
volScalarField alphaOmega_;
|
||||
volScalarField beta_;
|
||||
volScalarField gamma_;
|
||||
|
||||
|
||||
// Switch fields
|
||||
|
||||
// Switch fields for the differentiation of F1
|
||||
volScalarField case_1_F1_;
|
||||
volScalarField case_2_F1_;
|
||||
volScalarField case_3_F1_;
|
||||
volScalarField case_4_F1_;
|
||||
|
||||
//- Switch fields for the production in the k Eqn
|
||||
volScalarField case_1_Pk_;
|
||||
volScalarField case_2_Pk_;
|
||||
volScalarField case_3_Pk_;
|
||||
|
||||
// Switch fields for the differentiation of nut
|
||||
// Holds also for the differentiation of the second branch of
|
||||
// GbyNu
|
||||
volScalarField case_1_nut_;
|
||||
volScalarField case_2_nut_;
|
||||
volScalarField case_3_nut_;
|
||||
|
||||
// Switch fields for GPrime
|
||||
volScalarField case_1_GPrime_;
|
||||
volScalarField case_2_GPrime_;
|
||||
|
||||
// Zero first cell field and IDs
|
||||
// Since the omega equation is a two-zonal one, some
|
||||
// of the terms in the adjoint equations need to ba canceled
|
||||
// at the cells next to omegaWallFunction BCs
|
||||
labelList firstCellIDs_;
|
||||
volScalarField zeroFirstCell_;
|
||||
|
||||
|
||||
// Turbulence model multipliers
|
||||
|
||||
//- Nut Jacobian w.r.t. omega
|
||||
volScalarField dnut_domega_;
|
||||
|
||||
//- Nut Jacobian w.r.t. k
|
||||
volScalarField dnut_dk_;
|
||||
|
||||
//- Diffusivity of the omega equation
|
||||
volScalarField DOmegaEff_;
|
||||
|
||||
//- Diffusivity of the k equation
|
||||
volScalarField DkEff_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
// Primal functions
|
||||
|
||||
virtual tmp<volScalarField> F1() const;
|
||||
virtual tmp<volScalarField> F2() const;
|
||||
virtual tmp<volScalarField> GbyNu
|
||||
(
|
||||
const volScalarField& GbyNu0,
|
||||
const volScalarField& F2,
|
||||
const volScalarField& S2
|
||||
) const;
|
||||
|
||||
//- Return G/nu
|
||||
virtual tmp<volScalarField::Internal> GbyNu
|
||||
(
|
||||
const volScalarField::Internal& GbyNu0,
|
||||
const volScalarField::Internal& F2,
|
||||
const volScalarField::Internal& S2
|
||||
) const;
|
||||
|
||||
tmp<volScalarField> blend
|
||||
(
|
||||
const volScalarField& F1,
|
||||
const dimensionedScalar& psi1,
|
||||
const dimensionedScalar& psi2
|
||||
) const
|
||||
{
|
||||
return F1*(psi1 - psi2) + psi2;
|
||||
}
|
||||
|
||||
tmp<volScalarField::Internal> blend
|
||||
(
|
||||
const volScalarField::Internal& F1,
|
||||
const dimensionedScalar& psi1,
|
||||
const dimensionedScalar& psi2
|
||||
) const
|
||||
{
|
||||
return F1*(psi1 - psi2) + psi2;
|
||||
}
|
||||
|
||||
tmp<volScalarField> alphaK(const volScalarField& F1) const
|
||||
{
|
||||
return blend(F1, alphaK1_, alphaK2_);
|
||||
}
|
||||
|
||||
tmp<volScalarField> alphaOmega(const volScalarField& F1) const
|
||||
{
|
||||
return blend(F1, alphaOmega1_, alphaOmega2_);
|
||||
}
|
||||
|
||||
tmp<volScalarField::Internal> beta
|
||||
(
|
||||
const volScalarField::Internal& F1
|
||||
) const
|
||||
{
|
||||
return tmp<volScalarField::Internal>::New
|
||||
(
|
||||
this->type() + ":beta",
|
||||
blend(F1, beta1_, beta2_)
|
||||
);
|
||||
}
|
||||
|
||||
tmp<volScalarField> beta
|
||||
(
|
||||
const volScalarField& F1
|
||||
) const
|
||||
{
|
||||
return tmp<volScalarField>::New
|
||||
(
|
||||
this->type() + ":beta",
|
||||
blend(F1, beta1_, beta2_)
|
||||
);
|
||||
}
|
||||
|
||||
tmp<volScalarField::Internal> gamma
|
||||
(
|
||||
const volScalarField::Internal& F1
|
||||
) const
|
||||
{
|
||||
return tmp<volScalarField::Internal>::New
|
||||
(
|
||||
this->type() + ":gamma",
|
||||
blend(F1, gamma1_, gamma2_)
|
||||
);
|
||||
}
|
||||
|
||||
tmp<volScalarField> gamma
|
||||
(
|
||||
const volScalarField& F1
|
||||
) const
|
||||
{
|
||||
return tmp<volScalarField>::New
|
||||
(
|
||||
this->type() + ":gamma",
|
||||
blend(F1, gamma1_, gamma2_)
|
||||
);
|
||||
}
|
||||
|
||||
tmp<volScalarField> zeroFirstCell();
|
||||
|
||||
|
||||
// References to the primal turbulence model variables
|
||||
|
||||
inline const volScalarField& k() const
|
||||
{
|
||||
return primalVars_.RASModelVariables()().TMVar1();
|
||||
}
|
||||
|
||||
inline volScalarField& k()
|
||||
{
|
||||
return primalVars_.RASModelVariables()().TMVar1();
|
||||
}
|
||||
|
||||
inline const volScalarField& omega() const
|
||||
{
|
||||
return primalVars_.RASModelVariables()().TMVar2();
|
||||
}
|
||||
|
||||
inline volScalarField& omega()
|
||||
{
|
||||
return primalVars_.RASModelVariables()().TMVar2();
|
||||
}
|
||||
|
||||
inline const volScalarField& nutRef() const
|
||||
{
|
||||
return primalVars_.RASModelVariables()().nutRef();
|
||||
}
|
||||
|
||||
inline volScalarField& nutRef()
|
||||
{
|
||||
return primalVars_.RASModelVariables()().nutRef();
|
||||
}
|
||||
|
||||
|
||||
// Adjoint related protected member functions
|
||||
|
||||
//- Derivative of the primal equations wrt nut
|
||||
tmp<volScalarField> dR_dnut();
|
||||
|
||||
//- Nut Jacobian wrt omega
|
||||
tmp<volScalarField> dnut_domega() const;
|
||||
|
||||
//- Nut Jacobian wrt k
|
||||
tmp<volScalarField> dnut_dk() const;
|
||||
|
||||
//- F2 Jacobian wrt omega
|
||||
tmp<volScalarField> dF2_domega() const;
|
||||
|
||||
//- F2 Jacobian wrt k
|
||||
tmp<volScalarField> dF2_dk() const;
|
||||
|
||||
//- GbyNu Jacobian wrt omega
|
||||
tmp<volScalarField> dGPrime_domega() const;
|
||||
|
||||
//- GbyNu Jacobian wrt k
|
||||
tmp<volScalarField> dGPrime_dk() const;
|
||||
|
||||
//- Derivative of the primal equations wrt F1
|
||||
tmp<volScalarField> dR_dF1() const;
|
||||
|
||||
//- F1 Jacobian wrt omega (no contributions from grad(omega))
|
||||
tmp<volScalarField> dF1_domega(const volScalarField& arg1) const;
|
||||
|
||||
//- F1 Jacobian wrt grad(omega)
|
||||
tmp<volVectorField> dF1_dGradOmega
|
||||
(
|
||||
const volScalarField& arg1
|
||||
) const;
|
||||
|
||||
//- Source to waEqn from the differentiation of F1
|
||||
tmp<volScalarField> waEqnSourceFromF1() const;
|
||||
|
||||
//- Source to waEqn from the differentiation of CDkOmega
|
||||
tmp<fvScalarMatrix> waEqnSourceFromCDkOmega() const;
|
||||
|
||||
//- F1 Jacobian wrt k (no contributions from grad(k))
|
||||
tmp<volScalarField> dF1_dk(const volScalarField& arg1) const;
|
||||
|
||||
//- F1 Jacobian wrt grad(k)
|
||||
tmp<volVectorField> dF1_dGradK(const volScalarField& arg1) const;
|
||||
|
||||
//- Source to kaEqn from the differentiation of F1
|
||||
tmp<volScalarField> kaEqnSourceFromF1() const;
|
||||
|
||||
//- Source to kaEqn from the differentiation of CDkOmega
|
||||
tmp<volScalarField> kaEqnSourceFromCDkOmega() const;
|
||||
|
||||
//- Differentiation of the turbulence model diffusion coefficients
|
||||
tmp<volScalarField> coeffsDifferentiation
|
||||
(
|
||||
const volScalarField& primalField,
|
||||
const volScalarField& adjointField,
|
||||
const word& schemeName
|
||||
) const;
|
||||
|
||||
//- Term multiplying dnut/db, coming from the turbulence model
|
||||
tmp<volScalarField> dNutdbMult
|
||||
(
|
||||
const volScalarField& primalField,
|
||||
const volScalarField& adjointField,
|
||||
const volScalarField& coeffField,
|
||||
const volScalarField& bcField,
|
||||
const word& schemeName
|
||||
) const;
|
||||
|
||||
//- Term multiplying dnut/db, coming from the momentum equations
|
||||
tmp<volScalarField> dNutdbMult
|
||||
(
|
||||
const volVectorField& primalField,
|
||||
const volVectorField& adjointField,
|
||||
const volScalarField& bcField,
|
||||
const word& schemeName
|
||||
) const;
|
||||
|
||||
// Functions computing the adjoint mean flow source
|
||||
|
||||
//- Contributions from the turbulence model convection terms
|
||||
tmp<volVectorField> convectionMeanFlowSource
|
||||
(
|
||||
const volScalarField& primalField,
|
||||
const volScalarField& adjointField
|
||||
) const;
|
||||
|
||||
//- Contributions from the G
|
||||
tmp<volVectorField> GMeanFlowSource
|
||||
(
|
||||
tmp<volSymmTensorField>& GbyNuMult
|
||||
) const;
|
||||
|
||||
//- Contributions from the divU
|
||||
tmp<volVectorField> divUMeanFlowSource
|
||||
(
|
||||
tmp<volScalarField>& divUMult
|
||||
) const;
|
||||
|
||||
//- Contributions from nut(U), in the diffusion coefficients
|
||||
//- of the turbulence model
|
||||
tmp<volScalarField> diffusionNutMeanFlowMult
|
||||
(
|
||||
const volScalarField& primalField,
|
||||
const volScalarField& adjointField,
|
||||
const volScalarField& coeffField
|
||||
) const;
|
||||
|
||||
//- Contributions from nut(U)
|
||||
tmp<volVectorField> nutMeanFlowSource
|
||||
(
|
||||
tmp<volScalarField>& mult
|
||||
) const;
|
||||
|
||||
|
||||
//- Contributions from the differentiation of k existing in
|
||||
//- nutkWallFunction.
|
||||
// This could also be implemented in kaqRWallFunction but all
|
||||
// the fields required for the computation already exist here,
|
||||
// hence the code complexity is reduced
|
||||
void addWallFunctionTerms
|
||||
(
|
||||
fvScalarMatrix& kaEqn,
|
||||
const volScalarField& dR_dnut
|
||||
);
|
||||
|
||||
// References to the adjoint turbulence model fields
|
||||
|
||||
inline volScalarField& ka()
|
||||
{
|
||||
return adjointTMVariable1Ptr_();
|
||||
};
|
||||
|
||||
inline const volScalarField& ka() const
|
||||
{
|
||||
return adjointTMVariable1Ptr_();
|
||||
};
|
||||
|
||||
inline volScalarField& wa()
|
||||
{
|
||||
return adjointTMVariable2Ptr_();
|
||||
};
|
||||
|
||||
inline const volScalarField& wa() const
|
||||
{
|
||||
return adjointTMVariable2Ptr_();
|
||||
};
|
||||
|
||||
|
||||
//- Update of the primal cached fields
|
||||
void updatePrimalRelatedFields();
|
||||
|
||||
//- Return the requested interpolation scheme if it exists,
|
||||
//- otherwise return a reverseLinear scheme
|
||||
template<class Type>
|
||||
tmp<surfaceInterpolationScheme<Type>> interpolationScheme
|
||||
(
|
||||
const word& schemeName
|
||||
) const;
|
||||
|
||||
//- Return the interpolation scheme used by the primal convection
|
||||
//- term of the equation corresponding to the argument
|
||||
tmp<surfaceInterpolationScheme<scalar>> convectionScheme
|
||||
(
|
||||
const word& varName
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("adjointkOmegaSST");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
adjointkOmegaSST
|
||||
(
|
||||
incompressibleVars& primalVars,
|
||||
incompressibleAdjointMeanFlowVars& adjointVars,
|
||||
objectiveManager& objManager,
|
||||
const word& adjointTurbulenceModelName
|
||||
= adjointTurbulenceModel::typeName,
|
||||
const word& modelName = typeName
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~adjointkOmegaSST() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the effective diffusivity for k
|
||||
tmp<volScalarField> DkEff(const volScalarField& F1) const
|
||||
{
|
||||
return tmp<volScalarField>
|
||||
(
|
||||
new volScalarField("DkEff", alphaK(F1)*this->nut() + this->nu())
|
||||
);
|
||||
}
|
||||
|
||||
//- Return the effective diffusivity for omega
|
||||
tmp<volScalarField> DomegaEff(const volScalarField& F1) const
|
||||
{
|
||||
return tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
"DomegaEff",
|
||||
alphaOmega(F1)*this->nut() + this->nu()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
virtual tmp<volSymmTensorField> devReff() const;
|
||||
|
||||
virtual tmp<volSymmTensorField> devReff(const volVectorField& U) const;
|
||||
|
||||
//- Return the transpose part of the adjoint momentum stresses
|
||||
virtual tmp<fvVectorMatrix> divDevReff(volVectorField& U) const;
|
||||
|
||||
//- Non-conservative part of the terms added to the mean flow equations
|
||||
virtual tmp<volVectorField> nonConservativeMomentumSource() const;
|
||||
|
||||
//- Source term added to the adjoint mean flow due to the
|
||||
//- differentiation of the turbulence model
|
||||
virtual tmp<volVectorField> adjointMeanFlowSource();
|
||||
|
||||
//- Jacobian of nut wrt to k
|
||||
// Needs to be implemented for objectives related to nut, defined in
|
||||
// the internal field
|
||||
virtual tmp<volScalarField> nutJacobianTMVar1() const;
|
||||
|
||||
//- Jacobian of nut wrt to omega
|
||||
// Needs to be implemented for objectives related to nut, defined in
|
||||
// the internal field
|
||||
virtual tmp<volScalarField> nutJacobianTMVar2() const;
|
||||
|
||||
//- Diffusion coeff at the boundary for k
|
||||
virtual tmp<scalarField> diffusionCoeffVar1(label patchI) const;
|
||||
|
||||
//- Diffusion coeff at the boundary for omega
|
||||
virtual tmp<scalarField> diffusionCoeffVar2(label patchI) const;
|
||||
|
||||
virtual const boundaryVectorField& adjointMomentumBCSource() const;
|
||||
|
||||
//- Sensitivity derivative contributions when using the (E)SI approach
|
||||
virtual const boundaryVectorField& wallShapeSensitivities();
|
||||
|
||||
virtual const boundaryVectorField& wallFloCoSensitivities();
|
||||
|
||||
//- Contributions to the adjoint eikonal equation (zero for now)
|
||||
virtual tmp<volScalarField> distanceSensitivities();
|
||||
|
||||
//- Sensitivity derivative contributions when using the FI approach
|
||||
virtual tmp<volTensorField> FISensitivityTerm();
|
||||
|
||||
virtual tmp<scalarField> topologySensitivities
|
||||
(
|
||||
const word& designVarsName
|
||||
) const;
|
||||
|
||||
//- Nullify all adjoint turbulence model fields and their old times
|
||||
virtual void nullify();
|
||||
|
||||
//- Solve the adjoint turbulence equations
|
||||
virtual void correct();
|
||||
|
||||
//- Read adjointRASProperties dictionary
|
||||
virtual bool read();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace adjointRASModels
|
||||
} // End namespace incompressibleAdjoint
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "adjointkOmegaSSTTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,69 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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 "reverseLinear.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace incompressibleAdjoint
|
||||
{
|
||||
namespace adjointRASModels
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
tmp<surfaceInterpolationScheme<Type>> adjointkOmegaSST::interpolationScheme
|
||||
(
|
||||
const word& schemeName
|
||||
) const
|
||||
{
|
||||
return
|
||||
tmp<surfaceInterpolationScheme<Type>>
|
||||
(
|
||||
mesh_.interpolationSchemes().found(schemeName) ?
|
||||
surfaceInterpolationScheme<Type>::New
|
||||
(
|
||||
mesh_,
|
||||
mesh_.interpolationScheme(schemeName)
|
||||
) :
|
||||
tmp<surfaceInterpolationScheme<Type>>
|
||||
(new reverseLinear<Type>(mesh_))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace adjointRASModels
|
||||
} // End namespace incompressible
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,178 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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 "adjointFarFieldTMVar1FvPatchScalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
adjointFarFieldTMVar1FvPatchScalarField::
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, word::null)
|
||||
{}
|
||||
|
||||
|
||||
adjointFarFieldTMVar1FvPatchScalarField::
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
(
|
||||
const adjointFarFieldTMVar1FvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
||||
adjointScalarBoundaryCondition(p, iF, ptf.adjointSolverName_)
|
||||
{}
|
||||
|
||||
|
||||
adjointFarFieldTMVar1FvPatchScalarField::
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, dict.get<word>("solverName"))
|
||||
{
|
||||
fvPatchField<scalar>::operator=
|
||||
(
|
||||
scalarField("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
adjointFarFieldTMVar1FvPatchScalarField::
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
(
|
||||
const adjointFarFieldTMVar1FvPatchScalarField& tppsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(tppsf, iF),
|
||||
adjointScalarBoundaryCondition(tppsf)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void adjointFarFieldTMVar1FvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
vectorField nf(patch().nf());
|
||||
|
||||
tmp<scalarField> tnuEff(boundaryContrPtr_->TMVariable1Diffusion());
|
||||
const scalarField& nuEff = tnuEff();
|
||||
const fvsPatchField<scalar>& phip = boundaryContrPtr_->phib();
|
||||
const scalarField& magSf = patch().magSf();
|
||||
|
||||
// Patch-adjacent values
|
||||
tmp<scalarField> intf(patchInternalField());
|
||||
|
||||
// Patch deltas
|
||||
const scalarField& delta = patch().deltaCoeffs();
|
||||
|
||||
operator==
|
||||
(
|
||||
pos(phip)
|
||||
*(
|
||||
(nuEff*delta*intf)
|
||||
/(phip/magSf + nuEff*delta)
|
||||
)
|
||||
);
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<scalar>> adjointFarFieldTMVar1FvPatchScalarField::
|
||||
valueInternalCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
const fvsPatchField<scalar>& phip = boundaryContrPtr_->phib();
|
||||
|
||||
// For fixedValue patches
|
||||
return tmp<Field<scalar>>::New(neg(phip)*pTraits<scalar>::one);
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<scalar>> adjointFarFieldTMVar1FvPatchScalarField::
|
||||
valueBoundaryCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
const fvsPatchField<scalar>& phip = boundaryContrPtr_->phib();
|
||||
|
||||
// For zeroGradient patches
|
||||
return tmp<Field<scalar>>::New(pos(phip)*(*this));
|
||||
}
|
||||
|
||||
|
||||
void adjointFarFieldTMVar1FvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
writeEntry("value", os);
|
||||
os.writeEntry("solverName", adjointSolverName_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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::adjointFarFieldTMVar1FvPatchScalarField
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
adjointFarFieldTMVar1FvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef adjointFarFieldTMVar1FvPatchScalarField_H
|
||||
#define adjointFarFieldTMVar1FvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "adjointBoundaryConditions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class adjointFarFieldTMVar1FvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class adjointFarFieldTMVar1FvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchScalarField,
|
||||
public adjointScalarBoundaryCondition
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("adjointFarFieldTMVar1");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given adjointFarFieldTMVar1FvPatchScalarField
|
||||
//- onto a new patch
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
(
|
||||
const adjointFarFieldTMVar1FvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new adjointFarFieldTMVar1FvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
adjointFarFieldTMVar1FvPatchScalarField
|
||||
(
|
||||
const adjointFarFieldTMVar1FvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new adjointFarFieldTMVar1FvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Return the matrix diagonal coefficients corresponding to the
|
||||
//- evaluation of the value of this patchField with given weights
|
||||
virtual tmp<Field<scalar>> valueInternalCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const;
|
||||
|
||||
//- Return the matrix source coefficients corresponding to the
|
||||
//- evaluation of the value of this patchField with given weights
|
||||
virtual tmp<Field<scalar>> valueBoundaryCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const;
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,178 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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 "adjointFarFieldTMVar2FvPatchScalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
adjointFarFieldTMVar2FvPatchScalarField::
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, word::null)
|
||||
{}
|
||||
|
||||
|
||||
adjointFarFieldTMVar2FvPatchScalarField::
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
(
|
||||
const adjointFarFieldTMVar2FvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
||||
adjointScalarBoundaryCondition(p, iF, ptf.adjointSolverName_)
|
||||
{}
|
||||
|
||||
|
||||
adjointFarFieldTMVar2FvPatchScalarField::
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, dict.get<word>("solverName"))
|
||||
{
|
||||
fvPatchField<scalar>::operator=
|
||||
(
|
||||
scalarField("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
adjointFarFieldTMVar2FvPatchScalarField::
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
(
|
||||
const adjointFarFieldTMVar2FvPatchScalarField& tppsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(tppsf, iF),
|
||||
adjointScalarBoundaryCondition(tppsf)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void adjointFarFieldTMVar2FvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
vectorField nf(patch().nf());
|
||||
|
||||
tmp<scalarField> tnuEff(boundaryContrPtr_->TMVariable2Diffusion());
|
||||
const scalarField& nuEff = tnuEff();
|
||||
const fvsPatchField<scalar>& phip = boundaryContrPtr_->phib();
|
||||
const scalarField& magSf = patch().magSf();
|
||||
|
||||
// Patch-adjacent values
|
||||
tmp<scalarField> intf(patchInternalField());
|
||||
|
||||
// Patch deltas
|
||||
const scalarField& delta = patch().deltaCoeffs();
|
||||
|
||||
operator==
|
||||
(
|
||||
pos(phip)
|
||||
*(
|
||||
(nuEff*delta*intf)
|
||||
/(phip/magSf + nuEff*delta)
|
||||
)
|
||||
);
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<scalar>> adjointFarFieldTMVar2FvPatchScalarField::
|
||||
valueInternalCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
const fvsPatchField<scalar>& phip = boundaryContrPtr_->phib();
|
||||
|
||||
// For fixedValue patches
|
||||
return tmp<Field<scalar>>::New(neg(phip)*pTraits<scalar>::one);
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<scalar>> adjointFarFieldTMVar2FvPatchScalarField::
|
||||
valueBoundaryCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
const fvsPatchField<scalar>& phip = boundaryContrPtr_->phib();
|
||||
|
||||
// For zeroGradient patches
|
||||
return tmp<Field<scalar>>::New(pos(phip)*(*this));
|
||||
}
|
||||
|
||||
|
||||
void adjointFarFieldTMVar2FvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
writeEntry("value", os);
|
||||
os.writeEntry("solverName", adjointSolverName_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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::adjointFarFieldTMVar2FvPatchScalarField
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
adjointFarFieldTMVar2FvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef adjointFarFieldTMVar2FvPatchScalarField_H
|
||||
#define adjointFarFieldTMVar2FvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "adjointBoundaryConditions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class adjointFarFieldTMVar2FvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class adjointFarFieldTMVar2FvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchScalarField,
|
||||
public adjointScalarBoundaryCondition
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("adjointFarFieldTMVar2");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given adjointFarFieldTMVar2FvPatchScalarField
|
||||
//- onto a new patch
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
(
|
||||
const adjointFarFieldTMVar2FvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new adjointFarFieldTMVar2FvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
adjointFarFieldTMVar2FvPatchScalarField
|
||||
(
|
||||
const adjointFarFieldTMVar2FvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new adjointFarFieldTMVar2FvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Return the matrix diagonal coefficients corresponding to the
|
||||
//- evaluation of the value of this patchField with given weights
|
||||
virtual tmp<Field<scalar>> valueInternalCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const;
|
||||
|
||||
//- Return the matrix source coefficients corresponding to the
|
||||
//- evaluation of the value of this patchField with given weights
|
||||
virtual tmp<Field<scalar>> valueBoundaryCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const;
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,150 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2022 PCOpt/NTUA
|
||||
Copyright (C) 2013-2022 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 "adjointOutletFluxFvPatchField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "volFields.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::adjointOutletFluxFvPatchField<Type>::adjointOutletFluxFvPatchField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::adjointOutletFluxFvPatchField<Type>::adjointOutletFluxFvPatchField
|
||||
(
|
||||
const adjointOutletFluxFvPatchField<Type>& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<Type, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(ptf, p, iF, mapper)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::adjointOutletFluxFvPatchField<Type>::adjointOutletFluxFvPatchField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<Type, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF)
|
||||
{
|
||||
fvPatchField<Type>::operator=
|
||||
(
|
||||
Field<Type>("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::adjointOutletFluxFvPatchField<Type>::adjointOutletFluxFvPatchField
|
||||
(
|
||||
const adjointOutletFluxFvPatchField<Type>& tppsf,
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(tppsf, iF)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::adjointOutletFluxFvPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
if (this->updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->operator==(Field<Type>(this->patch().size(), Zero));
|
||||
|
||||
fixedValueFvPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::adjointOutletFluxFvPatchField<Type>::valueInternalCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type>>::New(this->size(), Zero);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::adjointOutletFluxFvPatchField<Type>::valueBoundaryCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
return tmp<Field<Type>>::New(this->size(), Zero);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::adjointOutletFluxFvPatchField<Type>::gradientBoundaryCoeffs() const
|
||||
{
|
||||
return tmp<Field<Type>>::New(this->size(), Zero);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::adjointOutletFluxFvPatchField<Type>::gradientInternalCoeffs() const
|
||||
{
|
||||
return tmp<Field<Type>>::New(this->size(), Zero);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::adjointOutletFluxFvPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<Type>::write(os);
|
||||
this->writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,169 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2022 PCOpt/NTUA
|
||||
Copyright (C) 2013-2022 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::adjointOutletFluxFvPatchField
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
adjointOutletFluxFvPatchField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef adjointOutletFluxFvPatchField_H
|
||||
#define adjointOutletFluxFvPatchField_H
|
||||
|
||||
#include "fvPatchFields.H"
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class adjointOutletFluxFvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type>
|
||||
class adjointOutletFluxFvPatchField
|
||||
:
|
||||
public fixedValueFvPatchField<Type>
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("adjointOutletFlux");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
adjointOutletFluxFvPatchField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<Type, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
adjointOutletFluxFvPatchField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<Type, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given adjointOutletFluxFvPatchField
|
||||
//- onto a new patch
|
||||
adjointOutletFluxFvPatchField
|
||||
(
|
||||
const adjointOutletFluxFvPatchField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<Type, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchField<Type>> clone() const
|
||||
{
|
||||
return tmp<fvPatchField<Type>>
|
||||
(
|
||||
new adjointOutletFluxFvPatchField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
adjointOutletFluxFvPatchField
|
||||
(
|
||||
const adjointOutletFluxFvPatchField&,
|
||||
const DimensionedField<Type, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchField<Type>> clone
|
||||
(
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchField<Type>>
|
||||
(
|
||||
new adjointOutletFluxFvPatchField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Return the matrix diagonal coefficients corresponding to the
|
||||
//- evaluation of the value of this patchField with given weights
|
||||
virtual tmp<Field<Type>> valueInternalCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const;
|
||||
|
||||
//- Return the matrix source coefficients corresponding to the
|
||||
//- evaluation of the value of this patchField with given weights
|
||||
virtual tmp<Field<Type>> valueBoundaryCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
|
||||
) const;
|
||||
|
||||
//- Return the matrix source coefficients corresponding to the
|
||||
//- evaluation of the gradient of this patchField
|
||||
virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
|
||||
|
||||
//- Return the matrix diagonal coefficients corresponding to the
|
||||
//- evaluation of the gradient of this patchField
|
||||
virtual tmp<Field<Type>> gradientInternalCoeffs() const;
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "adjointOutletFluxFvPatchField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2022 PCOpt/NTUA
|
||||
Copyright (C) 2013-2022 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 "adjointOutletFluxFvPatchFields.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
makePatchFields(adjointOutletFlux);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2022 PCOpt/NTUA
|
||||
Copyright (C) 2013-2022 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/>.
|
||||
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef adjointOutletFluxFvPatchFields_H
|
||||
#define adjointOutletFluxFvPatchFields_H
|
||||
|
||||
#include "adjointOutletFluxFvPatchField.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePatchTypeFieldTypedefs(adjointOutletFlux);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2022 PCOpt/NTUA
|
||||
Copyright (C) 2013-2022 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef adjointOutletFluxFvPatchFieldsFwd_H
|
||||
#define adjointOutletFluxFvPatchFieldsFwd_H
|
||||
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type> class adjointOutletFluxFvPatchField;
|
||||
|
||||
makePatchTypeFieldTypedefs(adjointOutletFlux);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2020 PCOpt/NTUA
|
||||
Copyright (C) 2013-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 "adjointOutletKaFvPatchScalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
adjointOutletKaFvPatchScalarField::adjointOutletKaFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, word::null)
|
||||
{}
|
||||
|
||||
|
||||
adjointOutletKaFvPatchScalarField::adjointOutletKaFvPatchScalarField
|
||||
(
|
||||
const adjointOutletKaFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
||||
adjointScalarBoundaryCondition(p, iF, ptf.adjointSolverName_)
|
||||
{}
|
||||
|
||||
|
||||
adjointOutletKaFvPatchScalarField::adjointOutletKaFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, dict.get<word>("solverName"))
|
||||
{
|
||||
fvPatchField<scalar>::operator=
|
||||
(
|
||||
scalarField("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
adjointOutletKaFvPatchScalarField::adjointOutletKaFvPatchScalarField
|
||||
(
|
||||
const adjointOutletKaFvPatchScalarField& tppsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(tppsf, iF),
|
||||
adjointScalarBoundaryCondition(tppsf)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void adjointOutletKaFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
vectorField nf(patch().nf());
|
||||
|
||||
const fvPatchField<vector>& Ub = boundaryContrPtr_->Ub();
|
||||
tmp<scalarField> tnuEff(boundaryContrPtr_->TMVariable1Diffusion());
|
||||
const scalarField& nuEff = tnuEff();
|
||||
|
||||
// Patch-adjacent ka
|
||||
tmp<scalarField> tkaNei(patchInternalField());
|
||||
const scalarField& kaNei = tkaNei();
|
||||
|
||||
const scalarField& delta = patch().deltaCoeffs();
|
||||
|
||||
// Source from the objective
|
||||
tmp<scalarField> source = boundaryContrPtr_->adjointTMVariable1Source();
|
||||
|
||||
operator==
|
||||
(
|
||||
(nuEff*delta*kaNei - source)
|
||||
/((Ub & nf) + nuEff*delta)
|
||||
);
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void adjointOutletKaFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
writeEntry("value", os);
|
||||
os.writeEntry("solverName", adjointSolverName_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePatchTypeField(fvPatchScalarField, adjointOutletKaFvPatchScalarField);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,138 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2020 PCOpt/NTUA
|
||||
Copyright (C) 2013-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::adjointOutletKaFvPatchScalarField
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
adjointOutletKaFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef adjointOutletKaFvPatchScalarField_H
|
||||
#define adjointOutletKaFvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "adjointBoundaryConditions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class adjointOutletKaFvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class adjointOutletKaFvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchScalarField,
|
||||
public adjointScalarBoundaryCondition
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("adjointOutletKa");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
adjointOutletKaFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
adjointOutletKaFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given adjointOutletKaFvPatchScalarField
|
||||
//- onto a new patch
|
||||
adjointOutletKaFvPatchScalarField
|
||||
(
|
||||
const adjointOutletKaFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new adjointOutletKaFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
adjointOutletKaFvPatchScalarField
|
||||
(
|
||||
const adjointOutletKaFvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new adjointOutletKaFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2020 PCOpt/NTUA
|
||||
Copyright (C) 2013-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 "adjointOutletWaFvPatchScalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
adjointOutletWaFvPatchScalarField::adjointOutletWaFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, word::null)
|
||||
{}
|
||||
|
||||
|
||||
adjointOutletWaFvPatchScalarField::adjointOutletWaFvPatchScalarField
|
||||
(
|
||||
const adjointOutletWaFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
|
||||
adjointScalarBoundaryCondition(p, iF, ptf.adjointSolverName_)
|
||||
{}
|
||||
|
||||
|
||||
adjointOutletWaFvPatchScalarField::adjointOutletWaFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, dict.get<word>("solverName"))
|
||||
{
|
||||
fvPatchField<scalar>::operator=
|
||||
(
|
||||
scalarField("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
adjointOutletWaFvPatchScalarField::adjointOutletWaFvPatchScalarField
|
||||
(
|
||||
const adjointOutletWaFvPatchScalarField& tppsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchScalarField(tppsf, iF),
|
||||
adjointScalarBoundaryCondition(tppsf)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void adjointOutletWaFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
vectorField nf(patch().nf());
|
||||
|
||||
const fvPatchField<vector>& Ub = boundaryContrPtr_->Ub();
|
||||
tmp<scalarField> tnuEff(boundaryContrPtr_->TMVariable2Diffusion());
|
||||
const scalarField& nuEff = tnuEff();
|
||||
|
||||
// Patch-adjacent wa
|
||||
tmp<scalarField> twaNei = patchInternalField();
|
||||
const scalarField& waNei = twaNei();
|
||||
|
||||
const scalarField& delta = patch().deltaCoeffs();
|
||||
|
||||
// Source from the objective
|
||||
tmp<scalarField> source = boundaryContrPtr_->adjointTMVariable2Source();
|
||||
|
||||
operator==
|
||||
(
|
||||
(nuEff*delta*waNei - source)
|
||||
/((Ub & nf) + nuEff*delta)
|
||||
);
|
||||
|
||||
fixedValueFvPatchScalarField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void adjointOutletWaFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
writeEntry("value", os);
|
||||
os.writeEntry("solverName", adjointSolverName_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePatchTypeField(fvPatchScalarField, adjointOutletWaFvPatchScalarField);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,138 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2007-2020 PCOpt/NTUA
|
||||
Copyright (C) 2013-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::adjointOutletWaFvPatchScalarField
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
adjointOutletWaFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef adjointOutletWaFvPatchScalarField_H
|
||||
#define adjointOutletWaFvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "adjointBoundaryConditions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class adjointOutletWaFvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class adjointOutletWaFvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchScalarField,
|
||||
public adjointScalarBoundaryCondition
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("adjointOutletWa");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
adjointOutletWaFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
adjointOutletWaFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given adjointOutletWaFvPatchScalarField
|
||||
//- onto a new patch
|
||||
adjointOutletWaFvPatchScalarField
|
||||
(
|
||||
const adjointOutletWaFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new adjointOutletWaFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
adjointOutletWaFvPatchScalarField
|
||||
(
|
||||
const adjointOutletWaFvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new adjointOutletWaFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,176 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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 "kaqRWallFunctionFvPatchScalarField.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "nutkWallFunctionFvPatchScalarField.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::kaqRWallFunctionFvPatchScalarField::kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
kqRWallFunctionFvPatchField<scalar>(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, word::null)
|
||||
{}
|
||||
|
||||
|
||||
Foam::kaqRWallFunctionFvPatchScalarField::kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
kqRWallFunctionFvPatchField<scalar>(p, iF, dict),
|
||||
adjointScalarBoundaryCondition(p, iF, dict.get<word>("solverName"))
|
||||
{}
|
||||
|
||||
|
||||
Foam::kaqRWallFunctionFvPatchScalarField::kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kaqRWallFunctionFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
kqRWallFunctionFvPatchField<scalar>(ptf, p, iF, mapper),
|
||||
adjointScalarBoundaryCondition(p, iF, ptf.adjointSolverName_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::kaqRWallFunctionFvPatchScalarField::kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kaqRWallFunctionFvPatchScalarField& tkqrwfpf
|
||||
)
|
||||
:
|
||||
kqRWallFunctionFvPatchField<scalar>(tkqrwfpf),
|
||||
adjointScalarBoundaryCondition(tkqrwfpf)
|
||||
{}
|
||||
|
||||
|
||||
Foam::kaqRWallFunctionFvPatchScalarField::kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kaqRWallFunctionFvPatchScalarField& tkqrwfpf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
kqRWallFunctionFvPatchField<scalar>(tkqrwfpf, iF),
|
||||
adjointScalarBoundaryCondition(tkqrwfpf)
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::kaqRWallFunctionFvPatchScalarField::manipulateMatrix
|
||||
(
|
||||
fvMatrix<scalar>& matrix
|
||||
)
|
||||
{
|
||||
scalarField& source = matrix.source();
|
||||
tmp<fvPatchScalarField> tnutWall(boundaryContrPtr_->turbulentDiffusivity());
|
||||
fvPatchScalarField& nutWall = tnutWall.constCast();
|
||||
if (isA<nutkWallFunctionFvPatchScalarField>(nutWall))
|
||||
{
|
||||
const label patchi(patch().index());
|
||||
const scalarField& magSf = patch().magSf();
|
||||
const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
|
||||
(
|
||||
IOobject::groupName
|
||||
(
|
||||
turbulenceModel::propertiesName,
|
||||
internalField().group()
|
||||
)
|
||||
);
|
||||
const scalarField& y = turbModel.y()[patchi];
|
||||
const tmp<scalarField> tnuw = turbModel.nu(patchi);
|
||||
const scalarField& nuw = tnuw();
|
||||
const nutWallFunctionFvPatchScalarField& nutWF =
|
||||
refCast<nutWallFunctionFvPatchScalarField>(nutWall);
|
||||
const wallFunctionCoefficients& wallCoeffs = nutWF.wallCoeffs();
|
||||
const scalar Cmu = wallCoeffs.Cmu();
|
||||
const scalar kappa = wallCoeffs.kappa();
|
||||
const scalar E = wallCoeffs.E();
|
||||
const scalar yPlusLam = wallCoeffs.yPlusLam();
|
||||
|
||||
const scalar Cmu25 = pow025(Cmu);
|
||||
|
||||
const labelList& faceCells = patch().faceCells();
|
||||
const fvPatchVectorField& Uw = boundaryContrPtr_->Ub();
|
||||
const scalarField magGradUw(mag(Uw.snGrad()));
|
||||
|
||||
tmp<scalarField> tdJdnut = boundaryContrPtr_->dJdnut();
|
||||
const scalarField& dJdnut = tdJdnut();
|
||||
|
||||
const tmp<volScalarField> tk = turbModel.k();
|
||||
const volScalarField& k = tk();
|
||||
forAll(dJdnut, facei)
|
||||
{
|
||||
const label celli = faceCells[facei];
|
||||
|
||||
const scalar sqrtkCell(sqrt(k[celli]));
|
||||
const scalar yPlus = Cmu25*y[facei]*sqrtkCell/nuw[facei];
|
||||
if (yPlusLam < yPlus)
|
||||
{
|
||||
const scalar logEyPlus = log(E*yPlus);
|
||||
const scalar dnut_dyPlus =
|
||||
nuw[facei]*kappa*(logEyPlus - 1)/sqr(logEyPlus);
|
||||
const scalar dyPlus_dk =
|
||||
Cmu25*y[facei]/(2*nuw[facei]*sqrtkCell);
|
||||
const scalar dnut_dk = dnut_dyPlus*dyPlus_dk;
|
||||
source[celli] -= dJdnut[facei]*dnut_dk*magSf[facei];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::kaqRWallFunctionFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
kqRWallFunctionFvPatchField<scalar>::write(os);
|
||||
os.writeEntry("solverName", adjointSolverName_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
kaqRWallFunctionFvPatchScalarField
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,144 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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::kaqRWallFunctionFvPatchScalarField
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
kaqRWallFunctionFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef kaqRWallFunctionFvPatchScalarField_H
|
||||
#define kaqRWallFunctionFvPatchScalarField_H
|
||||
|
||||
#include "kqRWallFunctionFvPatchField.H"
|
||||
#include "adjointBoundaryConditions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class kaqRWallFunctionFvPatchScalarField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class kaqRWallFunctionFvPatchScalarField
|
||||
:
|
||||
public kqRWallFunctionFvPatchField<scalar>,
|
||||
public adjointScalarBoundaryCondition
|
||||
{
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("kaqRWallFunction");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given kaqRWallFunctionFvPatchScalarField
|
||||
//- onto a new patch
|
||||
kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kaqRWallFunctionFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kaqRWallFunctionFvPatchScalarField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new kaqRWallFunctionFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
kaqRWallFunctionFvPatchScalarField
|
||||
(
|
||||
const kaqRWallFunctionFvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new kaqRWallFunctionFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Add source terms to the rhs of the first cell centre
|
||||
virtual void manipulateMatrix(fvMatrix<scalar>& matrix);
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,318 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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 "waWallFunctionFvPatchScalarField.H"
|
||||
#include "wallFvPatch.H"
|
||||
#include "omegaWallFunctionFvPatchScalarField.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void waWallFunctionFvPatchScalarField::checkType()
|
||||
{
|
||||
if (!isA<wallFvPatch>(patch()))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Invalid wall function specification" << nl
|
||||
<< " Patch type for patch " << patch().name()
|
||||
<< " must be wall" << nl
|
||||
<< " Current patch type is " << patch().type() << nl << endl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
waWallFunctionFvPatchScalarField::waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(p, iF),
|
||||
adjointScalarBoundaryCondition(p, iF, "wa")
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
waWallFunctionFvPatchScalarField::waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const waWallFunctionFvPatchScalarField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(ptf, p, iF, mapper),
|
||||
adjointScalarBoundaryCondition(p, iF, ptf.adjointSolverName_)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
waWallFunctionFvPatchScalarField::waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<scalar, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(p, iF, dict),
|
||||
adjointScalarBoundaryCondition(p, iF, dict.get<word>("solverName"))
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
waWallFunctionFvPatchScalarField::waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const waWallFunctionFvPatchScalarField& ewfpsf
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(ewfpsf),
|
||||
adjointScalarBoundaryCondition(ewfpsf)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
waWallFunctionFvPatchScalarField::waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const waWallFunctionFvPatchScalarField& ewfpsf,
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<scalar>(ewfpsf, iF),
|
||||
adjointScalarBoundaryCondition(ewfpsf)
|
||||
{
|
||||
checkType();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void waWallFunctionFvPatchScalarField::manipulateMatrix
|
||||
(
|
||||
fvMatrix<scalar>& matrix
|
||||
)
|
||||
{
|
||||
scalarField& Diag = matrix.diag();
|
||||
scalarField& lower = matrix.lower();
|
||||
scalarField& upper = matrix.upper();
|
||||
FieldField<Field, scalar>& internalCoeffs = matrix.internalCoeffs();
|
||||
FieldField<Field, scalar>& boundaryCoeffs = matrix.boundaryCoeffs();
|
||||
const fvMesh& mesh = patch().boundaryMesh().mesh();
|
||||
const labelList& faceCells = patch().faceCells();
|
||||
|
||||
// Add diag term from the omega expression next to the wall
|
||||
for (const label celli : faceCells)
|
||||
{
|
||||
Diag[celli] = 1;
|
||||
}
|
||||
|
||||
// We want something similar to setValues, but slightly modified.
|
||||
// The solution of the boundary cell should understand contributions from
|
||||
// the second cells off the wall but they should see the
|
||||
// solution of the boundary cell as zero.
|
||||
// Contributions from neighbouring cells with an omegaWallFunction boundary
|
||||
// condition should also be zero
|
||||
|
||||
const cellList& cells = mesh.cells();
|
||||
const labelUList& own = mesh.owner();
|
||||
|
||||
/*
|
||||
const labelUList& nei = mesh.neighbour();
|
||||
const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
|
||||
(
|
||||
IOobject::groupName
|
||||
(
|
||||
turbulenceModel::propertiesName,
|
||||
internalField().group()
|
||||
)
|
||||
);
|
||||
|
||||
const tmp<volScalarField> tomega = turbModel.omega();
|
||||
const volScalarField& omega = tomega();
|
||||
typedef omegaWallFunctionFvPatchScalarField omegaWF;
|
||||
*/
|
||||
|
||||
forAll(faceCells, i)
|
||||
{
|
||||
const label celli = faceCells[i];
|
||||
const cell& c = cells[celli];
|
||||
|
||||
forAll(c, j)
|
||||
{
|
||||
const label facei = c[j];
|
||||
|
||||
if (mesh.isInternalFace(facei))
|
||||
{
|
||||
// Neighbouring cells should get no contribution from
|
||||
// ourselves in all cases
|
||||
//label cellNei(-1);
|
||||
if (celli == own[facei])
|
||||
{
|
||||
//cellNei = nei[facei];
|
||||
lower[facei] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//cellNei = own[facei];
|
||||
upper[facei] = 0.0;
|
||||
}
|
||||
// Additionally, if the neighbouring cell is also a boundary
|
||||
// one with omegaWallFunction in one of its faces,
|
||||
// contributions between the two cells should be canceled out
|
||||
// as well.
|
||||
// Already covered by the above
|
||||
/*
|
||||
bool neiHasOmegaWFface(false);
|
||||
const cell& neiCell = cells[cellNei];
|
||||
forAll(neiCell, fNei)
|
||||
{
|
||||
const label faceNei = neiCell[fNei];
|
||||
|
||||
const label patchNei =
|
||||
mesh.boundaryMesh().whichPatch(faceNei);
|
||||
if (patchNei != -1)
|
||||
{
|
||||
const fvPatchField& omegaNei =
|
||||
omega.boundaryField()[patchNei];
|
||||
if (isA<omegaWF>(omegaNei))
|
||||
{
|
||||
neiHasOmegaWFface = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (neiHasOmegaWFface)
|
||||
{
|
||||
if (celli == own[facei])
|
||||
{
|
||||
upper[facei] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
lower[facei] = 0.0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
// Contributions from boundaries should have already been removed
|
||||
// using value*Coeffs and boundary*Coeffs
|
||||
// Just to be safe
|
||||
else
|
||||
{
|
||||
const label patchi = mesh.boundaryMesh().whichPatch(facei);
|
||||
if (internalCoeffs[patchi].size())
|
||||
{
|
||||
label patchFacei =
|
||||
mesh.boundaryMesh()[patchi].whichFace(facei);
|
||||
internalCoeffs[patchi][patchFacei] = Zero;
|
||||
boundaryCoeffs[patchi][patchFacei] = Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fvPatchField<scalar>::manipulateMatrix(matrix);
|
||||
}
|
||||
|
||||
|
||||
void waWallFunctionFvPatchScalarField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
operator == (scalarField(patch().size(), Zero));
|
||||
fixedValueFvPatchField<scalar>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<scalar>> waWallFunctionFvPatchScalarField::valueInternalCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
return tmp<Field<scalar>>::New(this->size(), Zero);
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<scalar>> waWallFunctionFvPatchScalarField::valueBoundaryCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const
|
||||
{
|
||||
return tmp<Field<scalar>>::New(this->size(), Zero);
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<scalar>>
|
||||
waWallFunctionFvPatchScalarField::gradientBoundaryCoeffs() const
|
||||
{
|
||||
return tmp<Field<scalar>>::New(this->size(), Zero);
|
||||
}
|
||||
|
||||
|
||||
tmp<Field<scalar>>
|
||||
waWallFunctionFvPatchScalarField::gradientInternalCoeffs() const
|
||||
{
|
||||
return tmp<Field<scalar>>::New(this->size(), Zero);
|
||||
}
|
||||
|
||||
|
||||
void waWallFunctionFvPatchScalarField::write(Ostream& os) const
|
||||
{
|
||||
fixedValueFvPatchField<scalar>::write(os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchScalarField,
|
||||
waWallFunctionFvPatchScalarField
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,184 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2014-2022 PCOpt/NTUA
|
||||
Copyright (C) 2014-2022 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::waWallFunctionFvPatchScalarField
|
||||
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
waWallFunctionFvPatchScalarField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef waWallFunctionFvPatchScalarField_H
|
||||
#define waWallFunctionFvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "adjointBoundaryConditions.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class waWallFunctionFvPatchScalarField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class waWallFunctionFvPatchScalarField
|
||||
:
|
||||
public fixedValueFvPatchField<scalar>,
|
||||
public adjointScalarBoundaryCondition
|
||||
{
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Check the type of the patch
|
||||
void checkType();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("waWallFunction");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// waWallFunctionFvPatchScalarField
|
||||
// onto a new patch
|
||||
waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const waWallFunctionFvPatchScalarField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<scalar, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const waWallFunctionFvPatchScalarField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<fvPatchScalarField> clone() const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new waWallFunctionFvPatchScalarField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
waWallFunctionFvPatchScalarField
|
||||
(
|
||||
const waWallFunctionFvPatchScalarField&,
|
||||
const DimensionedField<scalar, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct and return a clone setting internal field reference
|
||||
virtual tmp<fvPatchScalarField> clone
|
||||
(
|
||||
const DimensionedField<scalar, volMesh>& iF
|
||||
) const
|
||||
{
|
||||
return tmp<fvPatchScalarField>
|
||||
(
|
||||
new waWallFunctionFvPatchScalarField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Manipulate waEqn at the cells next to the wall
|
||||
virtual void manipulateMatrix(fvMatrix<scalar>& matrix);
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Return the matrix diagonal coefficients corresponding to the
|
||||
//- evaluation of the value of this patchField with given weights
|
||||
virtual tmp<Field<scalar>> valueInternalCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
) const;
|
||||
|
||||
//- Return the matrix source coefficients corresponding to the
|
||||
//- evaluation of the value of this patchField with given weights
|
||||
virtual tmp<Field<scalar>> valueBoundaryCoeffs
|
||||
(
|
||||
const tmp<scalarField>&
|
||||
|
||||
) const;
|
||||
|
||||
//- Return the matrix source coefficients corresponding to the
|
||||
//- evaluation of the gradient of this patchField
|
||||
virtual tmp<Field<scalar>> gradientBoundaryCoeffs() const;
|
||||
|
||||
//- Return the matrix diagonal coefficients corresponding to the
|
||||
//- evaluation of the gradient of this patchField
|
||||
virtual tmp<Field<scalar>> gradientInternalCoeffs() const;
|
||||
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write
|
||||
void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -90,8 +90,8 @@ protected:
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
void allocateInitValues();
|
||||
void allocateMeanFields();
|
||||
virtual void allocateInitValues();
|
||||
virtual void allocateMeanFields();
|
||||
|
||||
refPtr<volScalarField>
|
||||
cloneRefPtr(const refPtr<volScalarField>& obj) const;
|
||||
@ -213,6 +213,13 @@ public:
|
||||
const singlePhaseTransportModel& laminarTransport
|
||||
) const;
|
||||
|
||||
//- Return the turbulence production term
|
||||
virtual tmp<volScalarField::Internal> G()
|
||||
{
|
||||
NotImplemented;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Restore turbulent fields to their initial values
|
||||
void restoreInitValues();
|
||||
|
||||
@ -220,7 +227,7 @@ public:
|
||||
void resetMeanFields();
|
||||
|
||||
//- Compute mean fields on the fly
|
||||
void computeMeanFields();
|
||||
virtual void computeMeanFields();
|
||||
|
||||
//- Return stress tensor based on the mean flow variables
|
||||
tmp<volSymmTensorField> devReff
|
||||
|
||||
@ -28,6 +28,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "kOmegaSST.H"
|
||||
#include "wallDist.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -44,6 +45,34 @@ namespace RASVariables
|
||||
defineTypeNameAndDebug(kOmegaSST, 0);
|
||||
addToRunTimeSelectionTable(RASModelVariables, kOmegaSST, dictionary);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void kOmegaSST::allocateMeanFields()
|
||||
{
|
||||
RASModelVariables::allocateMeanFields();
|
||||
if (solverControl_.average())
|
||||
{
|
||||
GMean_.reset
|
||||
(
|
||||
new volScalarField::Internal
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"GMean",
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar(dimArea/pow3(dimTime), Zero)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
kOmegaSST::kOmegaSST
|
||||
@ -61,13 +90,76 @@ kOmegaSST::kOmegaSST
|
||||
TMVar2Ptr_.ref(mesh_.lookupObjectRef<volScalarField>(TMVar2BaseName_));
|
||||
nutPtr_.ref(mesh_.lookupObjectRef<volScalarField>(nutBaseName_));
|
||||
|
||||
distPtr_.ref(const_cast<volScalarField&>(wallDist::New(mesh_).y()));
|
||||
|
||||
allocateInitValues();
|
||||
allocateMeanFields();
|
||||
}
|
||||
|
||||
|
||||
tmp<volScalarField::Internal> kOmegaSST::computeG()
|
||||
{
|
||||
const turbulenceModel& turbModel = mesh_.lookupObject<turbulenceModel>
|
||||
(
|
||||
IOobject::groupName
|
||||
(
|
||||
turbulenceModel::propertiesName,
|
||||
TMVar2().internalField().group()
|
||||
)
|
||||
);
|
||||
// Recompute G and modify values next to the walls
|
||||
// Ideally, grad(U) should be cached to avoid the overhead
|
||||
const volVectorField& U = turbModel.U();
|
||||
tmp<volTensorField> tgradU = fvc::grad(U);
|
||||
volScalarField::Internal GbyNu0
|
||||
(
|
||||
this->type() + ":GbyNu",
|
||||
(tgradU() && dev(twoSymm(tgradU())))
|
||||
);
|
||||
auto tG =
|
||||
tmp<volScalarField::Internal>::New
|
||||
(
|
||||
turbModel.GName(),
|
||||
nutRefInst()*GbyNu0
|
||||
);
|
||||
// Use correctBoundaryConditions instead of updateCoeffs to avoid
|
||||
// messing with updateCoeffs in the next iteration of omegaEqn
|
||||
TMVar2Inst().correctBoundaryConditions();
|
||||
|
||||
return tG;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
tmp<volScalarField::Internal> kOmegaSST::G()
|
||||
{
|
||||
if (solverControl_.useAveragedFields())
|
||||
{
|
||||
DebugInfo
|
||||
<< "Using GMean" << endl;
|
||||
return tmp<volScalarField::Internal>(GMean_());
|
||||
}
|
||||
DebugInfo
|
||||
<< "Using instantaneous G" << endl;
|
||||
return computeG();
|
||||
}
|
||||
|
||||
|
||||
void kOmegaSST::computeMeanFields()
|
||||
{
|
||||
RASModelVariables::computeMeanFields();
|
||||
if (solverControl_.doAverageIter())
|
||||
{
|
||||
const label iAverageIter = solverControl_.averageIter();
|
||||
scalar avIter(iAverageIter);
|
||||
scalar oneOverItP1 = 1./(avIter + 1);
|
||||
scalar mult = avIter*oneOverItP1;
|
||||
GMean_() = GMean_()*mult + computeG()*oneOverItP1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void kOmegaSST::correctBoundaryConditions
|
||||
(
|
||||
const incompressible::turbulenceModel& turbulence
|
||||
|
||||
@ -59,6 +59,21 @@ class kOmegaSST
|
||||
public RASModelVariables
|
||||
{
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Average of the production term
|
||||
// Avaraged separetely due the bi-zonal treatment next to the wall
|
||||
autoPtr<volScalarField::Internal> GMean_;
|
||||
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
virtual void allocateMeanFields();
|
||||
tmp<volScalarField::Internal> computeG();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -81,6 +96,12 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the turbulence production term
|
||||
virtual tmp<volScalarField::Internal> G();
|
||||
|
||||
//- Compute mean fields on the fly
|
||||
virtual void computeMeanFields();
|
||||
|
||||
//- Correct boundary conditions of turbulent fields
|
||||
virtual void correctBoundaryConditions
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user