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  volVectorField::Boundary& HbyAbf = HbyA.boundaryFieldRef();
41 
42  forAll(HbyAbf, patchi)
43  {
44  if
45  (
46  !U.boundaryField()[patchi].assignable()
47  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
48  (
49  p.boundaryField()[patchi]
50  )
51  )
52  {
53  HbyAbf[patchi] = U.boundaryField()[patchi];
54  }
55  }
56 }
57 
58 
60 (
62  const volVectorField& U,
63  const volScalarField& p
64 )
65 {
66  surfaceScalarField::Boundary& phiHbyAbf = phiHbyA.boundaryFieldRef();
67 
68  forAll(phiHbyAbf, patchi)
69  {
70  if
71  (
72  !U.boundaryField()[patchi].assignable()
73  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
74  (
75  p.boundaryField()[patchi]
76  )
77  )
78  {
79  phiHbyAbf[patchi] =
80  U.mesh().Sf().boundaryField()[patchi]
81  & U.boundaryField()[patchi];
82  }
83  }
84 }
85 
86 
88 (
90  const volVectorField& U,
91  const volScalarField& p
92 )
93 {
94  tmp<volVectorField> tHbyANew;
95 
96  if (tHbyA.isTmp())
97  {
98  tHbyANew = tHbyA;
99  tHbyANew.ref().rename(IOobject::groupName("HbyA", U.group()));
100  }
101  else
102  {
103  tHbyANew = volVectorField::New
104  (
105  IOobject::groupName("HbyA", U.group()),
106  tHbyA
107  );
108  }
109 
110  constrainHbyA(tHbyANew.ref(), U, p);
111 
112  return tHbyANew;
113 }
114 
115 
117 (
118  const tmp<surfaceScalarField>& tphiHbyA,
119  const volVectorField& U,
120  const volScalarField& p
121 )
122 {
123  tmp<surfaceScalarField> tphiHbyANew;
124 
125  if (tphiHbyA.isTmp())
126  {
127  tphiHbyANew = tphiHbyA;
128  tphiHbyANew.ref().rename(IOobject::groupName("phiHbyA", U.group()));
129  }
130  else
131  {
132  tphiHbyANew = surfaceScalarField::New
133  (
134  IOobject::groupName("phiHbyA", U.group()),
135  tphiHbyA
136  );
137  }
138 
139  constrainPhiHbyA(tphiHbyANew.ref(), U, p);
140 
141  return tphiHbyANew;
142 }
143 
144 
146 (
147  const tmp<surfaceScalarField>& tphid,
148  const volScalarField& p
149 )
150 {
151  surfaceScalarField& phid = tphid.ref();
153 
154  const volScalarField::Boundary& pBf = p.boundaryField();
155 
156  forAll(phidBf, patchi)
157  {
158  if (isA<fixedFluxPressureFvPatchScalarField>(pBf[patchi]))
159  {
160  phidBf[patchi] = 0;
161  }
162  }
163 
164  return tphid;
165 }
166 
167 
168 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Generic GeometricBoundaryField class.
Generic GeometricField class.
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)
void constrainHbyA(volVectorField &HbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:34
tmp< surfaceScalarField > constrainPhid(const tmp< surfaceScalarField > &tphiHbyA, const volScalarField &p)
void constrainPhiHbyA(surfaceScalarField &phiHbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:60
volScalarField & p
Foam::surfaceFields.