constrainHbyA.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "constrainHbyA.H"
27 #include "volFields.H"
28 #include "surfaceFields.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
34 (
36  const volVectorField& U,
37  const volScalarField& p
38 )
39 {
40  tmp<volVectorField> tHbyANew;
41 
42  if (tHbyA.isTmp())
43  {
44  tHbyANew = tHbyA;
45  tHbyANew.ref().rename(IOobject::groupName("HbyA", U.group()));
46  }
47  else
48  {
49  tHbyANew = volVectorField::New
50  (
51  IOobject::groupName("HbyA", U.group()),
52  tHbyA
53  );
54  }
55 
56  volVectorField& HbyA = tHbyANew.ref();
57  volVectorField::Boundary& HbyAbf = HbyA.boundaryFieldRef();
58 
59  forAll(U.boundaryField(), patchi)
60  {
61  if
62  (
63  !U.boundaryField()[patchi].assignable()
64  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
65  (
66  p.boundaryField()[patchi]
67  )
68  )
69  {
70  HbyAbf[patchi] = U.boundaryField()[patchi];
71  }
72  }
73 
74  return tHbyANew;
75 }
76 
77 
79 (
80  const tmp<volVectorField>& tH,
81  const volScalarField& rA,
82  const volVectorField& U,
83  const volScalarField& p
84 )
85 {
86  tmp<volVectorField> tHNew;
87 
88  if (tH.isTmp())
89  {
90  tHNew = tH;
91  tHNew.ref().rename(IOobject::groupName("H", U.group()));
92  }
93  else
94  {
95  tHNew = volVectorField::New
96  (
97  IOobject::groupName("H", U.group()),
98  tH
99  );
100  }
101 
102  volVectorField& H = tHNew.ref();
104 
105  forAll(U.boundaryField(), patchi)
106  {
107  if
108  (
109  !U.boundaryField()[patchi].assignable()
110  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
111  (
112  p.boundaryField()[patchi]
113  )
114  )
115  {
116  Hbf[patchi] = U.boundaryField()[patchi]/rA.boundaryField()[patchi];
117  }
118  }
119 
120  return tHNew;
121 }
122 
123 
125 (
126  const tmp<surfaceScalarField>& tphiHbyA,
127  const volVectorField& U,
128  const volScalarField& p
129 )
130 {
131  tmp<surfaceScalarField> tphiHbyANew;
132 
133  if (tphiHbyA.isTmp())
134  {
135  tphiHbyANew = tphiHbyA;
136  tphiHbyANew.ref().rename(IOobject::groupName("phiHbyA", U.group()));
137  }
138  else
139  {
140  tphiHbyANew = surfaceScalarField::New
141  (
142  IOobject::groupName("phiHbyA", U.group()),
143  tphiHbyA
144  );
145  }
146 
147  surfaceScalarField& phiHbyA = tphiHbyANew.ref();
148  surfaceScalarField::Boundary& phiHbyAbf = phiHbyA.boundaryFieldRef();
149 
150  forAll(U.boundaryField(), patchi)
151  {
152  if
153  (
154  !U.boundaryField()[patchi].assignable()
155  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
156  (
157  p.boundaryField()[patchi]
158  )
159  )
160  {
161  phiHbyAbf[patchi] =
162  U.mesh().Sf().boundaryField()[patchi]
163  & U.boundaryField()[patchi];
164  }
165  }
166 
167  return tphiHbyANew;
168 }
169 
170 
172 (
173  const tmp<surfaceScalarField>& tphid,
174  const volScalarField& p
175 )
176 {
177  surfaceScalarField& phid = tphid.ref();
179 
180  const volScalarField::Boundary& pBf = p.boundaryField();
181 
182  forAll(pBf, patchi)
183  {
184  if (isA<fixedFluxPressureFvPatchScalarField>(pBf[patchi]))
185  {
186  phidBf[patchi] = 0;
187  }
188  }
189 
190  return tphid;
191 }
192 
193 
194 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Generic GeometricBoundaryField class.
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
A class for managing temporary objects.
Definition: tmp.H:55
bool isTmp() const
Return true if this is really a temporary object.
Definition: tmpI.H:153
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
label patchi
U
Definition: pEqn.H:72
tmp< volVectorField > tHbyA
Definition: pEqn.H:1
volVectorField & HbyA
Definition: pEqn.H:13
surfaceScalarField phiHbyA("phiHbyA", fvc::interpolate(rho) *fvc::flux(HbyA))
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
tmp< surfaceScalarField > constrainPhiHbyA(const tmp< surfaceScalarField > &tphiHbyA, const volVectorField &U, const volScalarField &p)
tmp< surfaceScalarField > constrainPhid(const tmp< surfaceScalarField > &tphiHbyA, const volScalarField &p)
tmp< volVectorField > constrainHbyA(const tmp< volVectorField > &tHbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:34
tmp< volVectorField > constrainH(const tmp< volVectorField > &tH, const volScalarField &rA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:79
volScalarField & p
Foam::surfaceFields.