fixedFluxPressureFvPatchScalarField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fixedFluxPressureFvPatchScalarField
29 
30 Group
31  grpInletBoundaryConditions grpWallBoundaryConditions
32 
33 Description
34  This boundary condition sets the pressure gradient to the provided value
35  such that the flux on the boundary is that specified by the velocity
36  boundary condition.
37 
38  Example of the boundary condition specification:
39  \verbatim
40  <patchName>
41  {
42  type fixedFluxPressure;
43  }
44  \endverbatim
45 
46 See also
47  Foam::fixedGradientFvPatchField
48 
49 SourceFiles
50  fixedFluxPressureFvPatchScalarField.C
51 
52 \*---------------------------------------------------------------------------*/
53 
54 #ifndef fixedFluxPressureFvPatchScalarField_H
55 #define fixedFluxPressureFvPatchScalarField_H
56 
57 #include "fvPatchFields.H"
59 #include "updateableSnGrad.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 
66 /*---------------------------------------------------------------------------*\
67  Class fixedFluxPressureFvPatchScalarField Declaration
68 \*---------------------------------------------------------------------------*/
69 
71 :
72  public fixedGradientFvPatchScalarField,
74 {
75  // Private data
76 
77  //- Current time index (used for updating)
78  label curTimeIndex_;
79 
80 
81 public:
82 
83  //- Runtime type information
84  TypeName("fixedFluxPressure");
85 
86 
87  // Constructors
88 
89  //- Construct from patch and internal field
91  (
92  const fvPatch&,
94  );
95 
96  //- Construct from patch, internal field and dictionary
98  (
99  const fvPatch&,
101  const dictionary&
102  );
103 
104  //- Construct by mapping given fixedFluxPressureFvPatchScalarField onto
105  // a new patch
107  (
109  const fvPatch&,
111  const fvPatchFieldMapper&
112  );
113 
114  //- Construct as copy
116  (
118  );
119 
120  //- Construct as copy setting internal field reference
122  (
125  );
126 
127  //- Return a clone
128  virtual tmp<fvPatchField<scalar>> clone() const
129  {
130  return fvPatchField<scalar>::Clone(*this);
131  }
132 
133  //- Clone with an internal field reference
135  (
137  ) const
138  {
139  return fvPatchField<scalar>::Clone(*this, iF);
140  }
141 
142 
143  // Member functions
144 
145  //- Update the patch pressure gradient field from the given snGradp
146  virtual void updateSnGrad(const scalarField& snGradp);
147 
148  //- Update the patch pressure gradient field
149  virtual void updateCoeffs();
150 
151  //- Write
152  virtual void write(Ostream&) const;
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Foam
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 #include "volFields.H"
163 
164 namespace Foam
165 {
166  template<class GradBC>
167  inline void setSnGrad
168  (
170  const FieldField<fvsPatchField, scalar>& snGrad
171  )
172  {
173  forAll(bf, patchi)
174  {
175  if (isA<GradBC>(bf[patchi]))
176  {
177  refCast<GradBC>(bf[patchi]).updateSnGrad(snGrad[patchi]);
178  }
179  }
180  }
181 
182  template<class GradBC>
183  inline void setSnGrad
184  (
186  const tmp<FieldField<fvsPatchField, scalar>>& tsnGrad
187  )
188  {
189  setSnGrad<GradBC>(bf, tsnGrad());
190  }
191 }
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 #endif
196 
197 // ************************************************************************* //
virtual void updateSnGrad(const scalarField &snGradp)
Update the patch pressure gradient field from the given snGradp.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void setSnGrad(volScalarField::Boundary &bf, const FieldField< fvsPatchField, scalar > &snGrad)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
Type of boundary fields.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
virtual void updateCoeffs()
Update the patch pressure gradient field.
A FieldMapper for finite-volume patch fields.
TypeName("fixedFluxPressure")
Runtime type information.
This boundary condition sets the pressure gradient to the provided value such that the flux on the bo...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
fixedFluxPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A class for managing temporary objects.
Definition: HashPtrTable.H:50
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:40
Namespace for OpenFOAM.
virtual tmp< fvPatchField< scalar > > clone() const
Return a clone.