Loading...
Searching...
No Matches
PatchFunction1Expression.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) 2020-2022 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\*---------------------------------------------------------------------------*/
29#include "fvPatch.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const polyPatch& pp,
37 const word& redirectType,
38 const word& entryName,
39 const dictionary& dict,
40 const bool faceValues
41)
42:
44 dict_(dict), // Deep copy
45 valueExpr_("expression", dict_),
46 driver_(fvPatch::lookupPatch(this->patch()), dict_)
47{
48 if (dict.getOrDefault("debug", false))
49 {
50 debug |= 1;
51 }
52
53 // Basic sanity
54 if (valueExpr_.empty())
55 {
56 FatalIOErrorInFunction(dict_)
57 << "The expression was not defined!" << nl
58 << exit(FatalIOError);
59 }
60
61 driver_.readDict(dict_);
62}
63
64
65template<class Type>
67(
69 const polyPatch& pp
70)
71:
72 PatchFunction1<Type>(rhs, pp),
73 dict_(rhs.dict_), // Deep copy
74 valueExpr_(rhs.valueExpr_),
75 driver_(fvPatch::lookupPatch(this->patch()), rhs.driver_, dict_)
76{}
77
78
79template<class Type>
81(
83)
84:
85 PatchExprField<Type>(rhs, rhs.patch())
86{}
87
88
89// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
90
91template<class Type>
94(
95 const scalar x
96) const
97{
98 // Expression evaluation
99 driver_.clearVariables();
100
101 driver_.setArgument(x);
102
103 tmp<Field<Type>> tresult(driver_.evaluate<Type>(this->valueExpr_));
104
106 << "Evaluated: " << tresult() << nl;
108 return tresult;
109}
110
111
112template<class Type>
115(
116 const scalar x1,
117 const scalar x2
118) const
121 return nullptr;
122}
123
124
125template<class Type>
127(
128 const FieldMapper& mapper
130{
132}
133
134
135template<class Type>
137(
138 const PatchFunction1<Type>& pf1,
139 const labelList& addr
141{
143}
144
145
146template<class Type>
148(
149 Ostream& os
150) const
151{
152 // PatchFunction1-from-subdict so output dictionary contains
153 // only the relevant entries.
154 dict_.writeEntry(this->name(), os);
155}
156
157
158// ************************************************************************* //
if(patchID !=-1)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Abstract base class to hold the Field mapping addressing and weights.
Definition FieldMapper.H:44
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
PatchFunction1 with values supplied by a parsed expression.
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
PatchExprField(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from patch, entry name and dictionary.
virtual void rmap(const PatchFunction1< Type > &pf1, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
virtual void writeData(Ostream &os) const
Write in dictionary format.
virtual tmp< Field< Type > > value(const scalar x) const
Return value.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
const polyPatch const word const word & entryName
virtual void rmap(const PatchFunction1< Type > &rhs, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
const polyPatch const word const word const dictionary & dict
const polyPatch & pp
const polyPatch const word const word const dictionary const bool faceValues
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
const polyPatch & patch() const noexcept
Reference to the patch.
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
OBJstream os(runTime.globalPath()/outputName)
auto & name
#define DebugInfo
Report an information message using Foam::Info.
List< label > labelList
A List of labels.
Definition List.H:62
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50