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-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 \*---------------------------------------------------------------------------*/
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  patchFunction1Base(pp, entryName, faceValues),
43  coordSys_()
44 {}
45 
46 
47 template<class Type>
49 (
50  const polyPatch& pp,
51  const word& entryName,
52  const dictionary& dict,
53  const bool faceValues
54 )
55 :
56  patchFunction1Base(pp, entryName, dict, faceValues),
57  coordSys_(pp.boundaryMesh().mesh().thisDb(), dict)
58 {}
59 
60 
61 template<class Type>
62 Foam::PatchFunction1<Type>::PatchFunction1(const PatchFunction1<Type>& rhs)
63 :
64  PatchFunction1<Type>(rhs, rhs.patch())
65 {}
66 
67 
68 template<class Type>
70 (
71  const PatchFunction1<Type>& rhs,
72  const polyPatch& pp
73 )
74 :
75  patchFunction1Base(pp, rhs.name(), rhs.faceValues()),
76  coordSys_(rhs.coordSys_)
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class Type>
84 {
85  return !coordSys_.active();
86 }
87 
88 
89 template<class Type>
91 (
92  const scalar x
93 ) const
94 {
96  return nullptr;
97 }
98 
99 
100 template<class Type>
102 (
103  const scalar x1,
104  const scalar x2
105 ) const
106 {
108  return nullptr;
109 }
110 
111 
112 template<class Type>
115 {
116  if (!coordSys_.active())
117  {
118  return globalPos;
119  }
120 
121  return coordSys_.coordSys()().localPosition(globalPos);
122 }
123 
124 
125 template<class Type>
127 (
128  const tmp<Field<Type>>& tfld
129 ) const
130 {
131  if (!coordSys_.active())
132  {
133  return tfld;
134  }
135 
136  tmp<Field<Type>> tresult =
137  (
138  this->faceValues()
139  ? this->coordSys_.transform(this->patch_.faceCentres(), tfld())
140  : this->coordSys_.transform(this->patch_.localPoints(), tfld())
141  );
142 
143  tfld.clear();
144  return tresult;
145 }
146 
147 
148 template<class Type>
150 (
151  const Field<Type>& fld
152 ) const
153 {
154  if (!coordSys_.active())
155  {
156  return fld;
157  }
158 
159  if (this->faceValues())
160  {
161  return this->coordSys_.transform(this->patch_.faceCentres(), fld);
162  }
163  else
164  {
165  return this->coordSys_.transform(this->patch_.localPoints(), fld);
166  }
167 }
168 
169 
170 template<class Type>
172 {}
173 
174 
175 template<class Type>
177 (
178  const PatchFunction1<Type>& rhs,
179  const labelList& addr
180 )
181 {}
182 
183 
184 template<class Type>
186 {
187  coordSys_.writeEntry(os);
188 
189  // Leave type() output up to derived type. This is so 'Constant'&Uniform
190  // can do backwards compatibility.
191  //os.writeKeyword(this->name()) << this->type();
192 }
193 
194 
195 // * * * * * * * * * * * * * * IOStream Operators * * * * * * * * * * * * * //
196 
197 template<class Type>
198 Foam::Ostream& Foam::operator<<
199 (
200  Ostream& os,
201  const PatchFunction1<Type>& rhs
202 )
203 {
204  os.check(FUNCTION_NAME);
205 
206  os << rhs.name();
207  rhs.writeData(os);
208 
209  return os;
210 }
211 
212 
213 // ************************************************************************* //
Foam::PatchFunction1::localPosition
virtual tmp< pointField > localPosition(const pointField &globalPos) const
Helper: optionally convert coordinates to local coordinates.
Definition: PatchFunction1.C:114
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:287
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::PatchFunction1::writeData
virtual void writeData(Ostream &os) const
Write in dictionary format.
Definition: PatchFunction1.C:185
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:517
Foam::Field< vector >
Foam::PatchFunction1::integrate
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Definition: PatchFunction1.C:102
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:150
Foam::PatchFunction1::uniform
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
Definition: PatchFunction1.C:83
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:58
os
OBJstream os(runTime.globalPath()/outputName)
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:60
Time.H
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
Foam::PatchFunction1::rmap
virtual void rmap(const PatchFunction1< Type > &rhs, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
Definition: PatchFunction1.C:177
x
x
Definition: LISASMDCalcMethod2.H:52
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::PatchFunction1::value
virtual tmp< Field< Type > > value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: PatchFunction1.C:91
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::PatchFunction1::PatchFunction1
PatchFunction1
Definition: PatchFunction1.H:113
Foam::PatchFunction1::autoMap
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: PatchFunction1.C:171