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 
106 
107 template<class Type>
109 (
110  const scalar x
111 ) const
112 {
114 
115  return Field<Type>();
116 }
117 
118 template<class Type>
120 {
121  return !coordSys_.active();
122 }
123 
124 
125 template<class Type>
127 (
128  const scalar x1,
129  const scalar x2
130 ) const
131 {
133 
134  return Field<Type>();
135 }
136 
137 
138 template<class Type>
141 {
142  if (!coordSys_.active())
143  {
144  return globalPos;
145  }
146 
147  return coordSys_.coordSys()().localPosition(globalPos);
148 }
149 
150 
151 template<class Type>
153 (
154  const tmp<Field<Type>>& tfld
155 ) const
156 {
157  if (!coordSys_.active())
158  {
159  return tfld;
160  }
161 
162  tmp<Field<Type>> tresult =
163  (
164  faceValues_
165  ? this->coordSys_.transform(this->patch_.faceCentres(), tfld())
166  : this->coordSys_.transform(this->patch_.localPoints(), tfld())
167  );
168 
169  tfld.clear();
170  return tresult;
171 }
172 
173 
174 template<class Type>
176 (
177  const Field<Type>& fld
178 ) const
179 {
180  if (!coordSys_.active())
181  {
182  return fld;
183  }
184 
185  if (faceValues_)
186  {
187  return this->coordSys_.transform(this->patch_.faceCentres(), fld);
188  }
189  else
190  {
191  return this->coordSys_.transform(this->patch_.localPoints(), fld);
192  }
193 }
194 
195 
196 template<class Type>
198 {}
199 
200 
201 template<class Type>
203 (
204  const PatchFunction1<Type>& pf1,
205  const labelList& addr
206 )
207 {}
208 
209 
210 template<class Type>
212 {
213  coordSys_.writeEntry(os);
214 
215  // Leave type() output up to derived type. This is so 'Constant'&Uniform
216  // can do backwards compatibility.
217  //os.writeKeyword(name_) << type();
218 }
219 
220 
221 // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
222 
223 template<class Type>
224 Foam::Ostream& Foam::operator<<
225 (
226  Ostream& os,
227  const PatchFunction1<Type>& pf1
228 )
229 {
230  os.check(FUNCTION_NAME);
231 
232  os << pf1.name_;
233  pf1.writeData(os);
234 
235  return os;
236 }
237 
238 
239 // ************************************************************************* //
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:140
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:211
PatchFunction1.H
Foam::FieldMapper
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:49
polyMesh.H
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:419
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:127
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:176
Foam::PatchFunction1::uniform
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
Definition: PatchFunction1.C:119
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:103
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:261
Foam::PatchFunction1::value
virtual tmp< Field< Type > > value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: PatchFunction1.C:109
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:203
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:197