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-2021 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 (
35  const tmp<volVectorField>& tHbyA,
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 
60  {
61  if
62  (
63  !U.boundaryField()[patchi].assignable()
64  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
65  (
67  )
68  )
69  {
70  HbyAbf[patchi] = U.boundaryField()[patchi];
71  }
72  }
73 
74  return tHbyANew;
75 }
76 
77 
79 (
80  const tmp<surfaceScalarField>& tphiHbyA,
81  const volVectorField& U,
82  const volScalarField& p
83 )
84 {
85  tmp<surfaceScalarField> tphiHbyANew;
86 
87  if (tphiHbyA.isTmp())
88  {
89  tphiHbyANew = tphiHbyA;
90  tphiHbyANew.ref().rename(IOobject::groupName("phiHbyA", U.group()));
91  }
92  else
93  {
94  tphiHbyANew = surfaceScalarField::New
95  (
96  IOobject::groupName("phiHbyA", U.group()),
97  tphiHbyA
98  );
99  }
100 
101  surfaceScalarField& phiHbyA = tphiHbyANew.ref();
102  surfaceScalarField::Boundary& phiHbyAbf = phiHbyA.boundaryFieldRef();
103 
105  {
106  if
107  (
108  !U.boundaryField()[patchi].assignable()
109  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
110  (
111  p.boundaryField()[patchi]
112  )
113  )
114  {
115  phiHbyAbf[patchi] =
116  U.mesh().Sf().boundaryField()[patchi]
117  & U.boundaryField()[patchi];
118  }
119  }
120 
121  return tphiHbyANew;
122 }
123 
124 
125 // ************************************************************************* //
Foam::surfaceFields.
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:134
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
const Boundary & boundaryField() const
Return const-reference to the boundary field.
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
bool isTmp() const
Return true if this is really a temporary object.
Definition: tmpI.H:153
tmp< surfaceScalarField > constrainPhiHbyA(const tmp< surfaceScalarField > &tphiHbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:79
tmp< volVectorField > tHbyA
Definition: pEqn.H:1
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
tmp< volVectorField > constrainHbyA(const tmp< volVectorField > &tHbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:34
const Mesh & mesh() const
Return mesh.
phiHbyA
Definition: pEqn.H:32
label patchi
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
volVectorField & HbyA
Definition: pEqn.H:13
A class for managing temporary objects.
Definition: PtrList.H:53