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-2020 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 public:
71 
72  // Runtime type information
73  TypeName("uniformValue");
74 
75 
76  // Generated Methods
77 
78  //- No copy assignment
79  void operator=(const UniformValueField<Type>&) = delete;
80 
81 
82  // Constructors
83 
84  //- Construct from entry name and dictionary
86  (
87  const polyPatch& pp,
88  const word& redirectType,
89  const word& entryName,
90  const dictionary& dict,
91  const bool faceValues = true
92  );
93 
94  //- Copy construct
95  explicit UniformValueField(const UniformValueField<Type>& rhs);
96 
97  //- Copy construct setting patch
98  explicit UniformValueField
99  (
100  const UniformValueField<Type>& rhs,
101  const polyPatch& pp
102  );
103 
104  //- Construct and return a clone
105  virtual tmp<PatchFunction1<Type>> clone() const
106  {
108  (
109  new UniformValueField<Type>(*this)
110  );
111  }
112 
113  //- Construct and return a clone setting patch
114  virtual tmp<PatchFunction1<Type>> clone(const polyPatch& pp) const
115  {
117  (
118  new UniformValueField<Type>(*this, pp)
119  );
120  }
121 
122 
123  //- Destructor
124  virtual ~UniformValueField() = default;
125 
126 
127  // Member Functions
128 
129  // Evaluation
130 
131  //- Return UniformValueField value
132  virtual inline tmp<Field<Type>> value(const scalar x) const;
133 
134  //- Is value constant (i.e. independent of x)
135  virtual inline bool constant() const;
136 
137  //- Is value uniform (i.e. independent of coordinate)
138  virtual inline bool uniform() const
139  {
141  }
142 
143  //- Integrate between two values
144  virtual inline tmp<Field<Type>> integrate
145  (
146  const scalar x1,
147  const scalar x2
148  ) const;
149 
150 
151  // Mapping
152 
153  //- Map (and resize as needed) from self given a mapping object
154  virtual void autoMap(const FieldMapper& mapper);
155 
156  //- Reverse map the given PatchFunction1 onto this PatchFunction1
157  virtual void rmap
158  (
159  const PatchFunction1<Type>& pf1,
160  const labelList& addr
161  );
162 
163 
164  // I-O
165 
166  //- Write in dictionary format
167  virtual void writeData(Ostream& os) const;
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace PatchFunction1Types
174 } // End namespace Foam
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #include "UniformValueFieldI.H"
179 
180 #ifdef NoRepository
181  #include "UniformValueField.C"
182 #endif
183 
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 
186 #endif
187 
188 // ************************************************************************* //
UniformValueField.C
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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:45
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:90
Foam::PatchFunction1Types::UniformValueField::constant
virtual bool constant() const
Is value constant (i.e. independent of x)
Definition: UniformValueFieldI.H:36
Foam::PatchFunction1::entryName
const polyPatch const word const word & entryName
Definition: PatchFunction1.H:117
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:104
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::PatchFunction1::uniform
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
Definition: PatchFunction1.C:93
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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
Foam::PatchFunction1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: PatchFunction1.H:59
Foam::PatchFunction1Types::UniformValueField::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: UniformValueField.C:99
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:63
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:115
Foam::PatchFunction1Types::UniformValueField::autoMap
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: UniformValueField.C:82
Foam::PatchFunction1Types::UniformValueField::clone
virtual tmp< PatchFunction1< Type > > clone(const polyPatch &pp) const
Construct and return a clone setting patch.
Definition: UniformValueField.H:113
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:118
Foam::List< label >
Foam::PatchFunction1::faceValues
const polyPatch const word const word const dictionary const bool faceValues
Definition: PatchFunction1.H:120
Foam::PatchFunction1Types::UniformValueField::uniform
virtual bool uniform() const
Is value uniform (i.e. independent of coordinate)
Definition: UniformValueField.H:137
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