PatchFunction1.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) 2018 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 
28 #include "PatchFunction1.H"
29 #include "Time.H"
30 #include "polyMesh.H"
31 
32 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const polyPatch& pp,
38  const word& entryName,
39  const bool faceValues
40 )
41 :
42  refCount(),
43  name_(entryName),
44  patch_(pp),
45  faceValues_(faceValues),
46  coordSys_()
47 {}
48 
49 
50 template<class Type>
52 (
53  const polyPatch& pp,
54  const word& entryName,
55  const dictionary& dict,
56  const bool faceValues
57 )
58 :
59  refCount(),
60  name_(entryName),
61  patch_(pp),
62  faceValues_(faceValues),
63  coordSys_(pp.boundaryMesh().mesh().thisDb(), dict)
64 {}
65 
66 
67 template<class Type>
68 Foam::PatchFunction1<Type>::PatchFunction1(const PatchFunction1<Type>& pf1)
69 :
70  refCount(),
71  name_(pf1.name_),
72  patch_(pf1.patch_),
73  faceValues_(pf1.faceValues_),
74  coordSys_(pf1.coordSys_)
75 {}
76 
77 
78 template<class Type>
80 (
81  const PatchFunction1<Type>& pf1,
82  const polyPatch& pp
83 )
84 :
85  refCount(),
86  name_(pf1.name_),
87  patch_(pp),
88  faceValues_(pf1.faceValues_),
89  coordSys_(pf1.coordSys_)
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
95 template<class Type>
97 {
98  return name_;
99 }
100 
101 
102 template<class Type>
104 {
105  return patch_;
106 }
107 
108 
109 template<class Type>
111 {
112  return faceValues_;
113 }
114 
115 
116 template<class Type>
118 {}
119 
120 
121 template<class Type>
123 (
124  const scalar x
125 ) const
126 {
128 
129  return Field<Type>();
130 }
131 
132 template<class Type>
134 {
135  return !coordSys_.active();
136 }
137 
138 
139 template<class Type>
141 (
142  const scalar x1,
143  const scalar x2
144 ) const
145 {
147 
148  return Field<Type>();
149 }
150 
151 
152 template<class Type>
155 {
156  if (!coordSys_.active())
157  {
158  return globalPos;
159  }
160 
161  return coordSys_.coordSys()().localPosition(globalPos);
162 }
163 
164 
165 template<class Type>
167 (
168  const tmp<Field<Type>>& tfld
169 ) const
170 {
171  if (!coordSys_.active())
172  {
173  return tfld;
174  }
175 
176  tmp<Field<Type>> tresult =
177  (
178  faceValues_
179  ? this->coordSys_.transform(this->patch_.faceCentres(), tfld())
180  : this->coordSys_.transform(this->patch_.localPoints(), tfld())
181  );
182 
183  tfld.clear();
184  return tresult;
185 }
186 
187 
188 template<class Type>
190 (
191  const Field<Type>& fld
192 ) const
193 {
194  if (!coordSys_.active())
195  {
196  return fld;
197  }
198 
199  if (faceValues_)
200  {
201  return this->coordSys_.transform(this->patch_.faceCentres(), fld);
202  }
203  else
204  {
205  return this->coordSys_.transform(this->patch_.localPoints(), fld);
206  }
207 }
208 
209 
210 template<class Type>
212 {}
213 
214 
215 template<class Type>
217 (
218  const PatchFunction1<Type>& pf1,
219  const labelList& addr
220 )
221 {}
222 
223 
224 template<class Type>
226 {
227  coordSys_.writeEntry(os);
228 
229  // Leave type() output up to derived type. This is so 'Constant'&Uniform
230  // can do backwards compatibility.
231  //os.writeKeyword(name_) << type();
232 }
233 
234 
235 // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
236 
237 template<class Type>
238 Foam::Ostream& Foam::operator<<
239 (
240  Ostream& os,
241  const PatchFunction1<Type>& pf1
242 )
243 {
244  os.check(FUNCTION_NAME);
245 
246  os << pf1.name_;
247  pf1.writeData(os);
248 
249  return os;
250 }
251 
252 
253 // ************************************************************************* //
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::PatchFunction1::localPosition
virtual tmp< pointField > localPosition(const pointField &globalPos) const
Helper: optionally convert coordinates to local coordinates.
Definition: PatchFunction1.C:154
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:325
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::PatchFunction1::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: PatchFunction1.C:225
Foam::PatchFunction1::faceValues
bool faceValues() const
Whether to generate face or point values on patch.
PatchFunction1.H
Foam::FieldMapper
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:49
Foam::PatchFunction1::patch
const polyPatch & patch() const
Reference to the patch.
Definition: PatchFunction1.C:103
polyMesh.H
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::PatchFunction1::integrate
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: PatchFunction1.C:141
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:67
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::PatchFunction1::transform
virtual tmp< Field< Type > > transform(const Field< Type > &fld) const
Apply optional transformation.
Definition: PatchFunction1.C:190
Foam::PatchFunction1::uniform
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
Definition: PatchFunction1.C:133
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::PatchFunction1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: PatchFunction1.H:63
Time.H
Foam::PatchFunction1::convertTimeBase
virtual void convertTimeBase(const Time &t)
Convert time.
Definition: PatchFunction1.C:117
Foam::PatchFunction1::name
const word & name() const
Return the name of the entry.
Definition: PatchFunction1.C:96
Foam::PatchFunction1::name_
const word name_
Name of entry.
Definition: PatchFunction1.H:92
Foam::List< label >
x
x
Definition: LISASMDCalcMethod2.H:52
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:265
Foam::PatchFunction1::value
virtual tmp< Field< Type > > value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: PatchFunction1.C:123
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::PatchFunction1::rmap
virtual void rmap(const PatchFunction1< Type > &pf1, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
Definition: PatchFunction1.C:217
Foam::PatchFunction1::PatchFunction1
PatchFunction1
Definition: PatchFunction1.H:115
Foam::PatchFunction1::autoMap
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: PatchFunction1.C:211