patchExprDriver.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) 2019-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "patchExprDriver.H"
29#include "patchExprScanner.H"
30#include "error.H"
31#include "fvMesh.H"
32#include "fvPatch.H"
34
35// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36
37namespace Foam
38{
39namespace expressions
40{
41namespace patchExpr
42{
43
45
47(
51 patch
52);
53
55(
58 idName,
59 patch
60);
61
62} // End namespace patchExpr
63} // End namespace expressions
64} // End namespace Foam
65
66
67// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
68
69namespace Foam
70{
71
72static inline const fvPatch& lookupFvPatch
73(
74 const fvMesh& mesh,
75 const word& patchName
76)
77{
78 return mesh.boundary()[patchName];
79}
80
81} // End namespace Foam
82
83
84// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
85
86const Foam::fvPatch& Foam::expressions::patchExpr::parseDriver::getFvPatch
87(
88 const fvMesh& fvm,
89 const dictionary& dict
90)
91{
92 return lookupFvPatch
93 (
94 regionMesh(dict, fvm, true),
95 dict.get<word>("patch")
96 );
97}
98
99
100// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
101
103(
104 const fvPatch& p,
105 const dictionary& dict
106)
107:
108 parsing::genericRagelLemonDriver(),
109 expressions::fvExprDriver(dict),
110 patch_(p)
111{
112 resetTimeReference(nullptr);
114}
115
116
118(
119 const fvPatch& p,
120 const parseDriver& rhs,
121 const dictionary& dict
122)
123:
124 parsing::genericRagelLemonDriver(),
125 expressions::fvExprDriver(rhs, dict),
126 patch_(p)
127{
128 resetTimeReference(nullptr);
130}
131
132
134(
135 const word& patchName,
136 const fvMesh& mesh
137)
138:
139 parseDriver(lookupFvPatch(mesh, patchName))
140{}
141
142
144(
145 const dictionary& dict,
146 const fvMesh& mesh
147)
148:
149 parseDriver(getFvPatch(mesh, dict), dict)
150{}
151
152
153// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
154
156(
157 const std::string& expr,
158 size_t pos,
159 size_t len
160)
161{
162 scanner scan(this->debugScanner());
163
164 scan.process(expr, pos, len, *this);
165
166 return 0;
167}
168
169
170// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
void resetDb(const objectRegistry *obrPtr=nullptr)
Reset the objectRegistry (for functions)
Definition: exprDriver.C:142
void resetTimeReference(const TimeState *ts)
Reset the time-state reference.
Definition: exprDriver.C:130
const dictionary & dict() const noexcept
The dictionary with all input data/specification.
Definition: exprDriver.H:385
Base driver for parsing value expressions associated with an fvMesh.
Definition: fvExprDriver.H:139
static const fvMesh & regionMesh(const dictionary &dict, const fvMesh &mesh, bool readIfNecessary)
Definition: fvExprDriver.C:509
virtual unsigned parse(const std::string &expr, size_t pos=0, size_t len=std::string::npos)
Execute the parser.
const fvPatch & patch_
The referenced patch.
Ragel lexer/scanner interface for patch expressions.
bool process(const std::string &str, size_t pos, size_t len, parseDriver &driver_)
Evaluate sub-string.
const fvMesh & mesh() const noexcept
Return the mesh reference.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
Definition: fvMesh.H:302
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:712
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
const fvBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: fvPatch.H:209
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
dynamicFvMesh & mesh
Namespace for OpenFOAM.
dimensionedScalar pos(const dimensionedScalar &ds)
static const fvPatch & lookupFvPatch(const fvMesh &mesh, const word &patchName)
dictionary dict