LookupField.H
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) 2024 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 Class
27  Foam::PatchFunction1Types::LookupField
28 
29 Description
30  PatchFunction1 to lookup volField/surfaceField or pointField from an
31  objectregistry and return its value on the patch.
32 
33  The dictionary specification would typically resemble this:
34  \verbatim
35  entry
36  {
37  type lookup;
38  name myField;
39  }
40  \endverbatim
41 
42  where the entries mean:
43  \table
44  Property | Description | Type | Reqd | Default
45  type | Function type: lookup | word | yes |
46  name | name of volField/pointField | word | yes |
47  \endtable
48 
49 SourceFiles
50  LookupField.C
51 
52 \*---------------------------------------------------------------------------*/
53 
54 #ifndef PatchFunction1Types_LookupField_H
55 #define PatchFunction1Types_LookupField_H
56 
57 #include "PatchFunction1.H"
58 #include "lookupBase.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 namespace PatchFunction1Types
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class LookupField Declaration
69 \*---------------------------------------------------------------------------*/
70 
71 template<class Type>
72 class LookupField
73 :
74  public PatchFunction1<Type>,
75  protected lookupBase
76 {
77 
78 
79 public:
80 
81  // Runtime type information
82  TypeName("lookup");
83 
84 
85  // Generated Methods
86 
87  //- No copy assignment
88  void operator=(const LookupField<Type>&) = delete;
89 
90 
91  // Constructors
92 
93  //- Construct from entry name, dictionary and optional registry
95  (
96  const polyPatch& pp,
97  const word& redirectType,
98  const word& entryName,
99  const dictionary& dict,
100  const bool faceValues = true
101  );
102 
103  //- Copy construct, setting patch
104  explicit LookupField
105  (
106  const LookupField<Type>& rhs,
107  const polyPatch& pp
108  );
109 
110  //- Copy construct
111  explicit LookupField(const LookupField<Type>& rhs);
112 
113  //- Construct and return a clone
114  virtual tmp<PatchFunction1<Type>> clone() const
115  {
116  return tmp<PatchFunction1<Type>>(new LookupField<Type>(*this));
117  }
118 
119  //- Return a clone, setting the patch
120  virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
121  {
122  return PatchFunction1<Type>::Clone(*this, pp);
123  }
124 
125 
126  //- Destructor
127  virtual ~LookupField() = default;
128 
129 
130  // Member Functions
131 
132  //- Is value uniform (i.e. independent of coordinate)
133  virtual inline bool uniform() const { return false; }
134 
135 
136  // Evaluation
138  //- Return Lookup value
139  virtual tmp<Field<Type>> value(const scalar x) const;
140 
141  //- Integrate between two values
142  virtual tmp<Field<Type>> integrate
143  (
144  const scalar x1,
145  const scalar x2
146  ) const;
147 
148 
149  // I-O
150 
151  //- Write in dictionary format
152  virtual void writeData(Ostream& os) const;
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace PatchFunction1Types
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
163 #ifdef NoRepository
164  #include "LookupField.C"
165 #endif
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
LookupField(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from entry name, dictionary and optional registry.
Definition: LookupField.C:33
virtual tmp< Field< Type > > value(const scalar x) const
Return Lookup value.
Definition: LookupField.C:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual ~LookupField()=default
Destructor.
virtual bool uniform() const
Is value uniform (i.e. independent of coordinate)
Definition: LookupField.H:162
const polyPatch const word const word const dictionary & dict
PatchFunction1 to lookup volField/surfaceField or pointField from an objectregistry and return its va...
Definition: LookupField.H:85
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: LookupField.C:179
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual tmp< PatchFunction1< Type > > clone() const
Construct and return a clone.
Definition: LookupField.H:137
const polyPatch const word const word & entryName
bool faceValues() const noexcept
Generate face or point values on patch?
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: LookupField.C:168
OBJstream os(runTime.globalPath()/outputName)
A class for managing temporary objects.
Definition: HashPtrTable.H:50
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:69
static tmp< PatchFunction1< Type > > Clone(const Derived &fun)
Clone a PatchFunction1.
Namespace for OpenFOAM.
const polyPatch & pp
void operator=(const LookupField< Type > &)=delete
No copy assignment.