fvPatch.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 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 \*---------------------------------------------------------------------------*/
28 
29 #include "fvPatch.H"
31 #include "fvBoundaryMesh.H"
32 #include "fvMesh.H"
33 #include "primitiveMesh.H"
34 #include "volFields.H"
35 #include "surfaceFields.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41  defineTypeNameAndDebug(fvPatch, 0);
42  defineRunTimeSelectionTable(fvPatch, polyPatch);
43  addToRunTimeSelectionTable(fvPatch, fvPatch, polyPatch);
44 }
45 
46 
47 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
48 
50 {
51  const fvMesh* meshptr = isA<fvMesh>(p.boundaryMesh().mesh());
52 
53  if (!meshptr)
54  {
56  << "The polyPatch is not attached to a base fvMesh" << nl
57  << exit(FatalError);
58  }
59 
60  return meshptr->boundary()[p.index()];
61 }
62 
63 
64 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
65 
66 Foam::fvPatch::fvPatch(const polyPatch& p, const fvBoundaryMesh& bm)
67 :
68  polyPatch_(p),
69  boundaryMesh_(bm)
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
74 
76 {} // fvBoundaryMesh was forward declared
77 
78 
79 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
80 
82 {
84 }
85 
86 
88 {
89  wordList cTypes(polyPatchConstructorTablePtr_->size());
90 
91  label i = 0;
92 
93  forAllConstIters(*polyPatchConstructorTablePtr_, cstrIter)
94  {
95  if (constraintType(cstrIter.key()))
96  {
97  cTypes[i++] = cstrIter.key();
98  }
99  }
100 
101  cTypes.setSize(i);
102 
103  return cTypes;
104 }
105 
106 
108 {
109  return polyPatch_.faceCells();
110 }
111 
112 
114 {
115  return boundaryMesh().mesh().Cf().boundaryField()[index()];
116 }
117 
118 
120 {
121  auto tcc = tmp<vectorField>::New(size());
122  auto& cc = tcc.ref();
123 
124  const labelUList& faceCells = this->faceCells();
125 
126  // get reference to global cell centres
127  const vectorField& gcc = boundaryMesh().mesh().cellCentres();
128 
129  forAll(faceCells, facei)
130  {
131  cc[facei] = gcc[faceCells[facei]];
132  }
133 
134  return tcc;
135 }
136 
137 
139 {
140  return Sf()/magSf();
141 }
142 
143 
145 {
146  return boundaryMesh().mesh().Sf().boundaryField()[index()];
147 }
148 
149 
151 {
152  return boundaryMesh().mesh().magSf().boundaryField()[index()];
153 }
154 
155 
157 {
158  // Use patch-normal delta for all non-coupled BCs
159  const vectorField nHat(nf());
160  return nHat*(nHat & (Cf() - Cn()));
161 }
162 
163 
165 {
166  w = 1.0;
167 }
168 
169 
171 {}
172 
173 
175 {}
176 
177 
179 {}
180 
181 
183 {}
184 
185 
187 {}
188 
189 
191 {
192  return boundaryMesh().mesh().deltaCoeffs().boundaryField()[index()];
193 }
194 
195 
197 {
198  return boundaryMesh().mesh().weights().boundaryField()[index()];
199 }
200 
201 
202 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
volFields.H
Foam::boundaryMesh::mesh
const bMesh & mesh() const
Definition: boundaryMesh.H:206
Foam::fvPatch::Sf
const vectorField & Sf() const
Return face area vectors.
Definition: fvPatch.C:144
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fvPatch::~fvPatch
virtual ~fvPatch()
Destructor.
Definition: fvPatch.C:75
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::fvPatch::delta
virtual tmp< vectorField > delta() const
Definition: fvPatch.C:156
Foam::fvPatch::makeNonOrthoCorrVectors
virtual void makeNonOrthoCorrVectors(vectorField &) const
Correct patch non-ortho correction vectors.
Definition: fvPatch.C:178
Foam::fvPatch::makeDeltaCoeffs
virtual void makeDeltaCoeffs(scalarField &) const
Correct patch deltaCoeffs.
Definition: fvPatch.C:170
primitiveMesh.H
surfaceFields.H
Foam::surfaceFields.
Foam::fvPatch::movePoints
virtual void movePoints()
Correct patches after moving points.
Definition: fvPatch.C:186
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fvBoundaryMesh
Foam::fvBoundaryMesh.
Definition: fvBoundaryMesh.H:56
Foam::fvPatch::lookupPatch
static const fvPatch & lookupPatch(const polyPatch &p)
Lookup the polyPatch index on corresponding fvMesh.
Definition: fvPatch.C:49
Foam::fvPatch::nf
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:138
Foam::Field< vector >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::fvPatch::initMovePoints
virtual void initMovePoints()
Initialise the patches for moving points.
Definition: fvPatch.C:182
Foam::fvPatch::constraintType
static bool constraintType(const word &pt)
Return true if the given type is a constraint type.
Definition: fvPatch.C:81
Foam::fvPatch::Cf
const vectorField & Cf() const
Return face centres.
Definition: fvPatch.C:113
fvBoundaryMesh.H
Foam::fvPatch::makeNonOrthoDeltaCoeffs
virtual void makeNonOrthoDeltaCoeffs(scalarField &) const
Correct patch non-ortho deltaCoeffs.
Definition: fvPatch.C:174
Foam::FatalError
error FatalError
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:679
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::fvPatch::weights
const scalarField & weights() const
Return patch weighting factors.
Definition: fvPatch.C:196
Foam::List< word >
Foam::fvPatch::deltaCoeffs
const scalarField & deltaCoeffs() const
Definition: fvPatch.C:190
Foam::UList< label >
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::fvPatch::faceCells
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:107
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:62
fvPatch.H
Foam::fvPatch::magSf
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:150
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::fvPatch::makeWeights
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:164
Foam::fvPatch::constraintTypes
static wordList constraintTypes()
Return a list of all the constraint patch types.
Definition: fvPatch.C:87
Foam::fvPatch::Cn
tmp< vectorField > Cn() const
Return neighbour cell centres.
Definition: fvPatch.C:119