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  return coordSys_.localPosition(globalPos);
117 }
118 
119 
120 template<class Type>
122 (
123  const tmp<Field<Type>>& tfld
124 ) const
125 {
126  if (!coordSys_.active())
127  {
128  return tfld;
129  }
130 
131  tmp<Field<Type>> tresult =
132  (
133  this->faceValues()
134  ? this->coordSys_.transform(this->patch_.faceCentres(), tfld())
135  : this->coordSys_.transform(this->patch_.localPoints(), tfld())
136  );
137 
138  tfld.clear();
139  return tresult;
140 }
141 
142 
143 template<class Type>
145 (
146  const Field<Type>& fld
147 ) const
148 {
149  if (!coordSys_.active())
150  {
151  return fld;
152  }
153 
154  if (this->faceValues())
155  {
156  return this->coordSys_.transform(this->patch_.faceCentres(), fld);
157  }
158  else
159  {
160  return this->coordSys_.transform(this->patch_.localPoints(), fld);
161  }
162 }
163 
164 
165 template<class Type>
167 {}
168 
169 
170 template<class Type>
172 (
174  const labelList& addr
175 )
176 {}
177 
178 
179 template<class Type>
181 {
182  coordSys_.writeEntry(os);
183 
184  // Leave type() output up to derived type. This is so 'Constant'&Uniform
185  // can do backwards compatibility.
186  //os.writeKeyword(this->name()) << this->type();
187 }
188 
189 
190 // * * * * * * * * * * * * * * IOStream Operators * * * * * * * * * * * * * //
191 
192 template<class Type>
193 Foam::Ostream& Foam::operator<<
194 (
195  Ostream& os,
196  const PatchFunction1<Type>& rhs
197 )
198 {
199  os.check(FUNCTION_NAME);
200 
201  os << rhs.name();
202  rhs.writeData(os);
203 
204  return os;
205 }
206 
207 
208 // ************************************************************************* //
dictionary dict
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:43
virtual tmp< pointField > localPosition(const pointField &globalPos) const
Helper: optionally convert coordinates to local coordinates.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
virtual void writeData(Ostream &os) const
Write in dictionary format.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
virtual tmp< Field< Type > > value(const scalar x) const
Return value as a function of (scalar) independent variable.
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))
virtual tmp< Field< Type > > transform(const Field< Type > &fld) const
Apply optional transformation.
const std::string patch
OpenFOAM patch number as a std::string.
const word & name() const noexcept
The name of the entry.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
virtual void rmap(const PatchFunction1< Type > &rhs, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())