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-2019 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("HbyA");
46  }
47  else
48  {
49  tHbyANew = volVectorField::New("HbyA", tHbyA);
50  }
51 
52  volVectorField& HbyA = tHbyANew.ref();
53  volVectorField::Boundary& HbyAbf = HbyA.boundaryFieldRef();
54 
56  {
57  if
58  (
59  !U.boundaryField()[patchi].assignable()
60  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
61  (
63  )
64  )
65  {
66  HbyAbf[patchi] = U.boundaryField()[patchi];
67  }
68  }
69 
70  return tHbyANew;
71 }
72 
73 
75 (
76  const tmp<surfaceScalarField>& tphiHbyA,
77  const volVectorField& U,
78  const volScalarField& p
79 )
80 {
81  tmp<surfaceScalarField> tphiHbyANew;
82 
83  if (tphiHbyA.isTmp())
84  {
85  tphiHbyANew = tphiHbyA;
86  tphiHbyANew.ref().rename("phiHbyA");
87  }
88  else
89  {
90  tphiHbyANew = surfaceScalarField::New("phiHbyA", tphiHbyA);
91  }
92 
93  surfaceScalarField& phiHbyA = tphiHbyANew.ref();
94  surfaceScalarField::Boundary& phiHbyAbf = phiHbyA.boundaryFieldRef();
95 
97  {
98  if
99  (
100  !U.boundaryField()[patchi].assignable()
101  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
102  (
103  p.boundaryField()[patchi]
104  )
105  )
106  {
107  phiHbyAbf[patchi] =
108  U.mesh().Sf().boundaryField()[patchi]
109  & U.boundaryField()[patchi];
110  }
111  }
112 
113  return tphiHbyANew;
114 }
115 
116 
117 // ************************************************************************* //
Foam::surfaceFields.
#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:174
bool isTmp() const
Return true if this is really a temporary object.
Definition: tmpI.H:146
tmp< surfaceScalarField > constrainPhiHbyA(const tmp< surfaceScalarField > &tphiHbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:75
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