fvPatch.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) 2011-2026 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 "fvPatch.H"
28 #include "fvBoundaryMesh.H"
29 #include "fvMesh.H"
30 #include "primitiveMesh.H"
31 #include "volFields.H"
32 #include "surfaceFields.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 :
48  poly_(p),
49  boundaryMesh_(bm)
50 {}
51 
52 
53 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54 
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 
62 {
63  return boundaryMesh_.mesh();
64 }
65 
66 
68 {
69  return boundaryMesh_.mesh();
70 }
71 
72 
74 {
75  return boundaryMesh_.mesh().time();
76 }
77 
78 
80 {
81  return poly_.faceCells();
82 }
83 
84 
86 {
87  return mesh().Cf().boundaryField()[index()];
88 }
89 
90 
93 {
94  if (!CPtr_.valid())
95  {
97  (
98  IOobject
99  (
100  "C",
101  mesh().time().name(),
102  mesh(),
105  false
106  ),
107  *this,
108  dimLength,
109  Cf()
110  );
111  }
112  else
113  {
114  CPtr_->reset(Cf());
115  }
116 
117  return *CPtr_;
118 }
119 
120 
121 
123 {
124  tmp<vectorField> tcc(new vectorField(size()));
125  vectorField& cc = tcc.ref();
126 
127  const labelUList& faceCells = this->faceCells();
128 
129  // get reference to global cell centres
130  const vectorField& gcc = mesh().cellCentres();
131 
132  forAll(faceCells, facei)
133  {
134  cc[facei] = gcc[faceCells[facei]];
135  }
136 
137  return tcc;
138 }
139 
140 
142 {
143  return Sf()/magSf();
144 }
145 
146 
148 {
149  return mesh().Sf().boundaryField()[index()];
150 }
151 
152 
154 {
155  return mesh().magSf().boundaryField()[index()];
156 }
157 
158 
160 {
161  // Use patch-normal delta for all non-coupled BCs
162  const vectorField nHat(nf());
163  return nHat*(nHat & (Cf() - Cn()));
164 }
165 
166 
168 {
169  return
170  mesh().conformal()
171  ? tmp<scalarField>(new scalarField(size(), scalar(1)))
172  : magSf()
173  /scalarField
174  (
175  mesh().magFaceAreas(),
176  mesh().polyFacesBf()[index()]
177  );
178 }
179 
180 
182 {
183  w = 1.0;
184 }
185 
186 
188 {
189  return mesh().deltaCoeffs().boundaryField()[index()];
190 }
191 
192 
194 {
195  return mesh().weights().boundaryField()[index()];
196 }
197 
198 
200 {
201  return mesh();
202 }
203 
204 
205 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const Boundary & boundaryField() const
Return const-reference to the boundary field.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Specialisation of DimensionedField which holds a slice of a given complete field in such a form that ...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
Foam::fvBoundaryMesh.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const surfaceVectorField & Cf() const
Return face centres.
const surfaceVectorField & Sf() const
Return cell face area vectors.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
bool conformal() const
Return whether the fvMesh is conformal with the polyMesh.
Definition: fvMesh.C:949
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
const fvMesh & operator()() const
Return reference to fvMesh.
Definition: fvPatch.C:199
virtual ~fvPatch()
Destructor.
Definition: fvPatch.C:55
const Time & time() const
Return time.
Definition: fvPatch.C:73
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:181
const objectRegistry & db() const
Return the local object registry.
Definition: fvPatch.C:61
tmp< vectorField > Cn() const
Return neighbour cell centres.
Definition: fvPatch.C:122
tmp< scalarField > polyFaceFraction() const
Return the fraction of the poly-face that each fv-face in this.
Definition: fvPatch.C:167
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector.
Definition: fvPatch.C:159
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:153
const scalarField & weights() const
Return patch weighting factors.
Definition: fvPatch.C:193
const DimensionedField< vector, fvPatch > & C() const
Return dimensioned face centres.
Definition: fvPatch.C:92
fvPatch(const polyPatch &, const fvBoundaryMesh &)
Construct from polyPatch and fvBoundaryMesh.
Definition: fvPatch.C:46
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:141
const fvMesh & mesh() const
Return mesh reference.
Definition: fvPatch.C:67
const vectorField & Cf() const
Return face centres.
Definition: fvPatch.C:85
virtual const scalarField & deltaCoeffs() const
Return the face - cell distance coefficient.
Definition: fvPatch.C:187
const vectorField & Sf() const
Return face area vectors.
Definition: fvPatch.C:147
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:79
Registry of regIOobjects.
const Time & time() const
Return time.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
const vectorField & cellCentres() const
const surfaceScalarField & weights() const
Return reference to linear difference weighting factors.
const surfaceScalarField & deltaCoeffs() const
Return reference to cell-centre difference coefficients.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const dimensionSet time
Namespace for OpenFOAM.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
const dimensionSet & dimLength
Definition: dimensions.C:141
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
defineRunTimeSelectionTable(fvConstraint, dictionary)
Field< vector > vectorField
Specialisation of Field<T> for vector.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
volScalarField & p
Foam::surfaceFields.