UniformValueField.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) 2018-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 Class
27  Foam::PatchFunction1Types::UniformValueField
28 
29 Description
30  Templated function that returns a uniform field based on a run-time
31  selectable Function1 entry.
32 
33  Usage - for entry <entryName> returning the value <value>:
34  \verbatim
35  <entryName> uniformValue
36  \endverbatim
37 
38 SourceFiles
39  UniformValueField.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef PatchFunction1Types_UniformValueField_H
44 #define PatchFunction1Types_UniformValueField_H
45 
46 #include "PatchFunction1.H"
47 #include "Function1.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 namespace PatchFunction1Types
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class UniformValueField Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class Type>
62 :
63  public PatchFunction1<Type>
64 {
65  // Private Data
66 
67  //- Source of uniform values (in local coordinate system)
68  autoPtr<Foam::Function1<Type>> uniformValuePtr_;
69 
70 
71 public:
72 
73  // Runtime type information
74  TypeName("uniformValue");
75 
76 
77  // Generated Methods
78 
79  //- No copy assignment
80  void operator=(const UniformValueField<Type>&) = delete;
81 
82 
83  // Constructors
84 
85  //- Construct from entry name and dictionary
87  (
88  const polyPatch& pp,
89  const word& redirectType,
90  const word& entryName,
91  const dictionary& dict,
92  const bool faceValues = true
93  );
94 
95  //- Copy construct
96  explicit UniformValueField(const UniformValueField<Type>& rhs);
97 
98  //- Copy construct setting patch
99  explicit UniformValueField
100  (
101  const UniformValueField<Type>& rhs,
102  const polyPatch& pp
103  );
104 
105  //- Construct and return a clone
106  virtual tmp<PatchFunction1<Type>> clone() const
107  {
109  (
110  new UniformValueField<Type>(*this)
111  );
112  }
113 
114  //- Construct and return a clone setting patch
115  virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
116  {
118  (
119  new UniformValueField<Type>(*this, pp)
120  );
121  }
122 
123 
124  //- Destructor
125  virtual ~UniformValueField() = default;
126 
127 
128  // Member Functions
129 
130  //- Is value constant (i.e. independent of x)
131  virtual inline bool constant() const
132  {
133  return uniformValuePtr_ && uniformValuePtr_->constant();
134  }
135 
136  //- Is value uniform (i.e. independent of coordinate)
137  virtual inline bool uniform() const
138  {
140  }
141 
142 
143  // Evaluation
144 
145  //- Return UniformValueField value
146  virtual inline tmp<Field<Type>> value(const scalar x) const;
147 
148  //- Integrate between two values
149  virtual inline tmp<Field<Type>> integrate
150  (
151  const scalar x1,
152  const scalar x2
153  ) const;
154 
155 
156  // Mapping
157 
158  //- Map (and resize as needed) from self given a mapping object
159  virtual void autoMap(const FieldMapper& mapper);
160 
161  //- Reverse map the given PatchFunction1 onto this PatchFunction1
162  virtual void rmap
163  (
164  const PatchFunction1<Type>& pf1,
165  const labelList& addr
166  );
167 
168 
169  // I-O
170 
171  //- Write in dictionary format
172  virtual void writeData(Ostream& os) const;
173 };
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace PatchFunction1Types
179 } // End namespace Foam
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 // Macros
184 
185 #undef addUniformValueFieldFunction1s
186 #define addUniformValueFieldFunction1s(F1Name, Type) \
187  PatchFunction1<Type>::adddictionaryConstructorToTable \
188  <PatchFunction1Types::UniformValueField<Type>> \
189  add##F1Name##UniformValueField##Type##ConstructorToTable_(#F1Name);
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #include "UniformValueFieldI.H"
195 
196 #ifdef NoRepository
197  #include "UniformValueField.C"
198 #endif
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
UniformValueField.C
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::UniformValueField::value
virtual tmp< Field< Type > > value(const scalar x) const
Return UniformValueField value.
Definition: UniformValueFieldI.H:36
Function1.H
PatchFunction1.H
Foam::FieldMapper
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:49
Foam::PatchFunction1Types::UniformValueField::rmap
virtual void rmap(const PatchFunction1< Type > &pf1, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
Definition: UniformValueField.C:96
Foam::PatchFunction1::entryName
const polyPatch const word const word & entryName
Definition: PatchFunction1.H:118
Foam::PatchFunction1Types::UniformValueField::operator=
void operator=(const UniformValueField< Type > &)=delete
No copy assignment.
Foam::PatchFunction1Types::UniformValueField::TypeName
TypeName("uniformValue")
Foam::PatchFunction1Types::UniformValueField::clone
virtual tmp< PatchFunction1< Type > > clone() const
Construct and return a clone.
Definition: UniformValueField.H:105
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::PatchFunction1Types::UniformValueField::~UniformValueField
virtual ~UniformValueField()=default
Destructor.
Foam::PatchFunction1Types::UniformValueField::constant
virtual bool constant() const
Is value constant (i.e. independent of x)
Definition: UniformValueField.H:130
Foam::PatchFunction1::uniform
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
Definition: PatchFunction1.C:83
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::PatchFunction1Types::UniformValueField::UniformValueField
UniformValueField(const polyPatch &pp, const word &redirectType, const word &entryName, const dictionary &dict, const bool faceValues=true)
Construct from entry name and dictionary.
Definition: UniformValueField.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::PatchFunction1Types::UniformValueField::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: UniformValueField.C:105
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::PatchFunction1Types::UniformValueField::integrate
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two values.
Definition: UniformValueFieldI.H:54
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::PatchFunction1::pp
const polyPatch & pp
Definition: PatchFunction1.H:116
Foam::PatchFunction1Types::UniformValueField::autoMap
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: UniformValueField.C:88
Foam::PatchFunction1Types::UniformValueField::clone
virtual tmp< PatchFunction1< Type > > clone(const polyPatch &pp) const
Construct and return a clone setting patch.
Definition: UniformValueField.H:114
Foam::PatchFunction1Types::UniformValueField
Templated function that returns a uniform field based on a run-time selectable Function1 entry.
Definition: UniformValueField.H:60
UniformValueFieldI.H
Foam::PatchFunction1::dict
const polyPatch const word const word const dictionary & dict
Definition: PatchFunction1.H:119
Foam::List< label >
Foam::PatchFunction1::faceValues
const polyPatch const word const word const dictionary const bool faceValues
Definition: PatchFunction1.H:121
Foam::PatchFunction1Types::UniformValueField::uniform
virtual bool uniform() const
Is value uniform (i.e. independent of coordinate)
Definition: UniformValueField.H:136
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56