Loading...
Searching...
No Matches
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>
63(
65 const polyPatch& pp
66)
67:
68 patchFunction1Base(pp, rhs.name(), rhs.faceValues()),
69 coordSys_(rhs.coordSys_)
70{}
71
72
73template<class Type>
75:
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
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 return coordSys_.localPosition(globalPos);
117}
118
119
120template<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 );
138 tfld.clear();
139 return tresult;
140}
141
142
143template<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
160 return this->coordSys_.transform(this->patch_.localPoints(), fld);
161 }
162}
163
165template<class Type>
167{}
168
169
170template<class Type>
172(
174 const labelList& addr
175)
176{}
177
178
179template<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
192template<class Type>
193Foam::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// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Abstract base class to hold the Field mapping addressing and weights.
Definition FieldMapper.H:44
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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 void writeData(Ostream &os) const
Write in dictionary format.
coordinateScaling< Type > coordSys_
Optional local coordinate system and scaling.
virtual tmp< Field< Type > > value(const scalar x) const
Return value as a function of (scalar) independent variable.
virtual tmp< pointField > localPosition(const pointField &globalPos) const
Helper: optionally convert coordinates to local coordinates.
virtual tmp< Field< Type > > transform(const Field< Type > &fld) const
Apply optional transformation.
const polyPatch const word const word const dictionary const bool faceValues
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
const polyPatch & patch_
Reference to the patch.
const polyPatch & patch() const noexcept
Reference to the patch.
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
A class for managing temporary objects.
Definition tmp.H:75
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Definition tmpI.H:289
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
OBJstream os(runTime.globalPath()/outputName)
auto & name
#define FUNCTION_NAME
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const std::string patch
OpenFOAM patch number as a std::string.
List< label > labelList
A List of labels.
Definition List.H:62
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
vectorField pointField
pointField is a vectorField.
dictionary dict