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  const scalar x
86 ) const
87 {
89  return nullptr;
90 }
91 
92 template<class Type>
94 {
95  return !coordSys_.active();
96 }
97 
98 
99 template<class Type>
101 (
102  const scalar x1,
103  const scalar x2
104 ) const
105 {
107  return nullptr;
108 }
109 
110 
111 template<class Type>
114 {
115  if (!coordSys_.active())
116  {
117  return globalPos;
118  }
119 
120  return coordSys_.coordSys()().localPosition(globalPos);
121 }
122 
123 
124 template<class Type>
126 (
127  const tmp<Field<Type>>& tfld
128 ) const
129 {
130  if (!coordSys_.active())
131  {
132  return tfld;
133  }
134 
135  tmp<Field<Type>> tresult =
136  (
137  this->faceValues()
138  ? this->coordSys_.transform(this->patch_.faceCentres(), tfld())
139  : this->coordSys_.transform(this->patch_.localPoints(), tfld())
140  );
141 
142  tfld.clear();
143  return tresult;
144 }
145 
146 
147 template<class Type>
149 (
150  const Field<Type>& fld
151 ) const
152 {
153  if (!coordSys_.active())
154  {
155  return fld;
156  }
157 
158  if (this->faceValues())
159  {
160  return this->coordSys_.transform(this->patch_.faceCentres(), fld);
161  }
162  else
163  {
164  return this->coordSys_.transform(this->patch_.localPoints(), fld);
165  }
166 }
167 
168 
169 template<class Type>
171 {}
172 
173 
174 template<class Type>
176 (
177  const PatchFunction1<Type>& rhs,
178  const labelList& addr
179 )
180 {}
181 
182 
183 template<class Type>
185 {
186  coordSys_.writeEntry(os);
187 
188  // Leave type() output up to derived type. This is so 'Constant'&Uniform
189  // can do backwards compatibility.
190  //os.writeKeyword(this->name()) << this->type();
191 }
192 
193 
194 // * * * * * * * * * * * * * * IOStream Operators * * * * * * * * * * * * * //
195 
196 template<class Type>
197 Foam::Ostream& Foam::operator<<
198 (
199  Ostream& os,
200  const PatchFunction1<Type>& rhs
201 )
202 {
203  os.check(FUNCTION_NAME);
204 
205  os << rhs.name();
206  rhs.writeData(os);
207 
208  return os;
209 }
210 
211 
212 // ************************************************************************* //
Foam::PatchFunction1::localPosition
virtual tmp< pointField > localPosition(const pointField &globalPos) const
Helper: optionally convert coordinates to local coordinates.
Definition: PatchFunction1.C:113
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:291
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:184
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:445
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:101
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
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:149
Foam::PatchFunction1::uniform
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
Definition: PatchFunction1.C:93
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:59
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:176
x
x
Definition: LISASMDCalcMethod2.H:52
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:270
Foam::PatchFunction1::value
virtual tmp< Field< Type > > value(const scalar x) const
Return value as a function of (scalar) independent variable.
Definition: PatchFunction1.C:84
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:112
Foam::PatchFunction1::autoMap
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: PatchFunction1.C:170