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-2021 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
29 #include "fvPatch.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<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 :
43  PatchFunction1<Type>(pp, entryName, dict, faceValues),
44  dict_(dict), // Deep copy
45  valueExpr_(),
46  driver_(fvPatch::lookupPatch(this->patch()), dict_)
47 {
48  if (dict.getOrDefault("debug", false))
49  {
50  debug |= 1;
51  }
52 
53  valueExpr_.readEntry("expression", dict_);
54 
55  // Basic sanity
56  if (valueExpr_.empty())
57  {
59  << "The expression was not defined!" << nl
60  << exit(FatalIOError);
61  }
62 
63  driver_.readDict(dict_);
64 }
65 
66 
67 template<class Type>
69 (
70  const PatchExprField<Type>& rhs
71 )
72 :
73  PatchExprField<Type>(rhs, rhs.patch())
74 {}
75 
76 
77 template<class Type>
79 (
80  const PatchExprField<Type>& rhs,
81  const polyPatch& pp
82 )
83 :
84  PatchFunction1<Type>(rhs, pp),
85  dict_(rhs.dict_), // Deep copy
86  valueExpr_(rhs.valueExpr_),
87  driver_(fvPatch::lookupPatch(this->patch()), rhs.driver_, dict_)
88 {}
89 
90 
91 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
92 
93 template<class Type>
96 (
97  const scalar x
98 ) const
99 {
100  // Expression evaluation
101  driver_.clearVariables();
102 
103  driver_.setArgument(x);
104 
105  tmp<Field<Type>> tresult(driver_.evaluate<Type>(this->valueExpr_));
106 
107  DebugInfo
108  << "Evaluated: " << tresult() << nl;
109 
110  return tresult;
111 }
112 
113 
114 template<class Type>
117 (
118  const scalar x1,
119  const scalar x2
120 ) const
121 {
123  return nullptr;
124 }
125 
126 
127 template<class Type>
129 (
130  const FieldMapper& mapper
131 )
132 {
134 }
135 
136 
137 template<class Type>
139 (
140  const PatchFunction1<Type>& pf1,
141  const labelList& addr
142 )
143 {
144  PatchFunction1<Type>::rmap(pf1, addr);
145 }
146 
147 
148 template<class Type>
150 (
151  Ostream& os
152 ) const
153 {
154  // PatchFunction1-from-subdict so output dictionary contains
155  // only the relevant entries.
156  dict_.writeEntry(this->name(), os);
157 }
158 
159 
160 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::PatchFunction1Types::PatchExprField::integrate
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: PatchFunction1Expression.C:117
Foam::PatchFunction1Types::PatchExprField::value
virtual tmp< Field< Type > > value(const scalar x) const
Return value.
Definition: PatchFunction1Expression.C:96
Foam::FieldMapper
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:49
Foam::FatalIOError
IOerror FatalIOError
PatchFunction1Expression.H
Foam::PatchFunction1Types::PatchExprField::rmap
virtual void rmap(const PatchFunction1< Type > &pf1, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
Definition: PatchFunction1Expression.C:139
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::PatchFunction1Types::PatchExprField::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: PatchFunction1Expression.C:150
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::PatchFunction1Types::PatchExprField::PatchExprField
PatchExprField(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from patch, entry name and dictionary.
Definition: PatchFunction1Expression.C:35
os
OBJstream os(runTime.globalPath()/outputName)
Foam::PatchFunction1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: PatchFunction1.H:60
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::PatchFunction1Types::PatchExprField::autoMap
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: PatchFunction1Expression.C:129
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::PatchFunction1Types::PatchExprField
PatchFunction1 with values supplied by a parsed expression.
Definition: PatchFunction1Expression.H:83
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
fvPatch.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56