Loading...
Searching...
No Matches
ATCUaGradU.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2007-2023 PCOpt/NTUA
9 Copyright (C) 2013-2023 FOSS GP
10 Copyright (C) 2019 OpenCFD Ltd.
11-------------------------------------------------------------------------------
12License
13 This file is part of OpenFOAM.
14
15 OpenFOAM is free software: you can redistribute it and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27
28\*---------------------------------------------------------------------------*/
29
30#include "ATCUaGradU.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35namespace Foam
36{
37
38// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39
42(
44 ATCUaGradU,
46);
47
48
49// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50
51ATCUaGradU::ATCUaGradU
52(
53 const fvMesh& mesh,
54 const incompressibleVars& primalVars,
55 const incompressibleAdjointVars& adjointVars,
56 const dictionary& dict
57)
59 ATCModel(mesh, primalVars, adjointVars, dict)
60{}
61
62
63// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64
66{
67 const volVectorField& U = primalVars_.U();
71
72 // Build Ua to go into the ATC term, based on whether to smooth field or not
73 autoPtr<volVectorField> UaForATC(nullptr);
75 {
76 UaForATC.reset(new volVectorField(fvc::reconstruct(phia)));
77 }
78 else
79 {
80 UaForATC.reset(new volVectorField(Ua));
81 }
82
83 // Main ATC term
84 ATC_ = -fvc::grad(UaForATC(), "gradUaATC") & U;
85
86 if (extraConvection_ > 0)
87 {
88 // Implicit part added to increase diagonal dominance
90
91 // Correct rhs due to implicitly augmenting the adjoint convection
92 ATC_ += extraConvection_*(fvc::grad(UaForATC(), "gradUaATC")().T() & U);
93 }
94
95 // Zero ATC on cells next to given patch types
97
98 // Actual ATC term
99 UaEqn += ATC_.internalField();
100}
101
102
104{
105 auto tvolSDTerm = volTensorField::New
106 (
107 "ATCFISensitivityTerm" + type(),
109 mesh_,
111 );
112 auto& volSDTerm = tvolSDTerm.ref();
113
114 const volVectorField& U = primalVars_.U();
115 const volVectorField& Ua = adjointVars_.Ua();
116
117 //const volScalarField& mask = getLimiter();
118
119 volSDTerm -=
120 Ua.component(0) * fvc::grad(U.component(0) * U)
121 + Ua.component(1) * fvc::grad(U.component(1) * U)
122 + Ua.component(2) * fvc::grad(U.component(2) * U);
123
124 return tvolSDTerm;
125}
126
127
128// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129
130} // End namespace Foam
131
132// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Base class for selecting the adjoint transpose convection model. Inherits from regIOobject to add loo...
Definition ATCModel.H:59
const incompressibleAdjointVars & adjointVars_
Definition ATCModel.H:81
const fvMesh & mesh_
Definition ATCModel.H:79
const scalar extraConvection_
Definition ATCModel.H:85
volVectorField ATC_
Definition ATCModel.H:92
const bool reconstructGradients_
Definition ATCModel.H:88
void smoothATC()
Limit ATC field using ATClimiter_.
Definition ATCModel.C:44
const incompressibleVars & primalVars_
Definition ATCModel.H:80
volScalarField ATClimiter_
Definition ATCModel.H:91
The ATC formualtion resulting by differentiating the Conservative form of the Momentum equations.
Definition ATCUaGradU.H:53
virtual tmp< volTensorField > getFISensitivityTerm() const
Get the FI sensitivity derivatives term coming from the ATC.
Definition ATCUaGradU.C:96
virtual void addATC(fvVectorMatrix &UaEqn)
Add ATC.
Definition ATCUaGradU.C:58
static tmp< GeometricField< tensor, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< tensor >::calculatedType())
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
@ NO_REGISTER
Do not request registration (bool: false).
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition autoPtrI.H:37
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
const volVectorField & Ua() const
Return const reference to velocity.
const volVectorField & UaInst() const
Return const reference to velocity.
const surfaceScalarField & phiaInst() const
Return const reference to volume flux.
Class including all adjoint fields for incompressible flows.
Base class for solution control classes.
const volVectorField & U() const
Return const reference to velocity.
const surfaceScalarField & phi() const
Return const reference to volume flux.
A class for managing temporary objects.
Definition tmp.H:75
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
U
Definition pEqn.H:72
const volScalarField & T
dynamicFvMesh & mesh
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition fvcGrad.C:47
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > reconstruct(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition fvmDiv.C:41
Namespace for OpenFOAM.
GeometricField< vector, fvPatchField, volMesh > volVectorField
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
fvMatrix< vector > fvVectorMatrix
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
dictionary dict