constrainHbyA.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 | Copyright (C) 2016 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"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
33 (
34  const tmp<volVectorField>& tHbyA,
35  const volVectorField& U,
36  const volScalarField& p
37 )
38 {
39  tmp<volVectorField> tHbyANew;
40 
41  if (tHbyA.isTmp())
42  {
43  tHbyANew = tHbyA;
44  tHbyANew.ref().rename("HbyA");
45  }
46  else
47  {
48  tHbyANew = new volVectorField("HbyA", tHbyA);
49  }
50 
51  volVectorField& HbyA = tHbyANew.ref();
52  volVectorField::Boundary& HbyAbf = HbyA.boundaryFieldRef();
53 
55  {
56  if
57  (
58  !U.boundaryField()[patchi].assignable()
59  && !isA<fixedFluxExtrapolatedPressureFvPatchScalarField>
60  (
62  )
63  )
64  {
65  HbyAbf[patchi] = U.boundaryField()[patchi];
66  }
67  }
68 
69  return tHbyANew;
70 }
71 
72 
73 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
HbyA
Definition: pcEqn.H:74
tmp< volVectorField > tHbyA
Definition: pEqn.H:1
const Boundary & boundaryField() const
Return const-reference to the boundary field.
tmp< volVectorField > constrainHbyA(const tmp< volVectorField > &tHbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:33
label patchi
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
bool isTmp() const
Return true if this is really a temporary object.
Definition: tmpI.H:146
A class for managing temporary objects.
Definition: PtrList.H:54
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174