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-------------------------------------------------------------------------------
10License
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
34template<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
47template<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
61template<class Type>
62Foam::PatchFunction1<Type>::PatchFunction1(const PatchFunction1<Type>& rhs)
63:
64 PatchFunction1<Type>(rhs, rhs.patch())
65{}
66
67
68template<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
82template<class Type>
84{
85 return !coordSys_.active();
86}
87
88
89template<class Type>
91(
92 const scalar x
93) const
94{
96 return nullptr;
97}
98
99
100template<class Type>
102(
103 const scalar x1,
104 const scalar x2
105) const
106{
108 return nullptr;
109}
110
111
112template<class Type>
115{
116 if (!coordSys_.active())
117 {
118 return globalPos;
119 }
120
121 return coordSys_.coordSys()().localPosition(globalPos);
122}
123
124
125template<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
148template<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
170template<class Type>
172{}
173
174
175template<class Type>
177(
178 const PatchFunction1<Type>& rhs,
179 const labelList& addr
180)
181{}
182
183
184template<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
197template<class Type>
198Foam::Ostream& Foam::operator<<
199(
200 Ostream& os,
201 const PatchFunction1<Type>& rhs
202)
203{
205
206 os << rhs.name();
207 rhs.writeData(os);
208
209 return os;
210}
211
212
213// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Abstract base class to hold the Field mapping addressing and weights.
Definition: FieldMapper.H:50
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
virtual const fileName & name() const
Read/write access to the name of the stream.
Definition: OSstream.H:107
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
virtual tmp< Field< Type > > integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
virtual bool uniform() const =0
Is value uniform (i.e. independent of coordinate)
virtual void rmap(const PatchFunction1< Type > &rhs, const labelList &addr)
Reverse map the given PatchFunction1 onto this PatchFunction1.
virtual void autoMap(const FieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
virtual tmp< pointField > localPosition(const pointField &globalPos) const
Helper: optionally convert coordinates to local coordinates.
Default transformation behaviour.
A class for managing temporary objects.
Definition: tmp.H:65
void clear() const noexcept
Definition: tmpI.H:287
dynamicFvMesh & mesh
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
const std::string patch
OpenFOAM patch number as a std::string.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict