patchCutLayerAverage.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::patchCutLayerAverage
26 
27 Description
28  This function object writes graphs of patch face values, area-averaged in
29  planes perpendicular to a given direction or in contours of a given
30  distance field. It adaptively grades the distribution of graph points to
31  match the resolution of the mesh.
32 
33  Example of function object specification:
34  \verbatim
35  patchCutLayerAverage1
36  {
37  type patchCutLayerAverage;
38  libs ("libfieldFunctionObjects.so");
39 
40  writeControl writeTime;
41  writeInterval 1;
42 
43  patch lowerWall;
44  direction (1 0 0);
45  nPoints 100;
46  interpolate no;
47 
48  fields (p U);
49 
50  axis x;
51  setFormat raw;
52  }
53  \endverbatim
54 
55 Usage
56  \table
57  Property | Description | Required | Default value
58  type | type name: patchCutLayerAverage | yes |
59  patch | Name of the patch | yes |
60  direction | Axis along which to plot | if distance not specified |
61  distance | Distance field along which to plot \\
62  | if direction not specified |
63  nPoints | Number of points in the plot | yes |
64  interpolate | Do linear interpolation | no | false
65  fields | Fields to plot values of | yes |
66  axis | Component of the position to plot against | yes |
67  setFormat | Format of the output file | yes |
68  \endtable
69 
70 SourceFiles
71  patchCutLayerAverage.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef patchCutLayerAverage_H
76 #define patchCutLayerAverage_H
77 
78 #include "fvMeshFunctionObject.H"
79 #include "cutPlot.H"
80 #include "setWriter.H"
81 
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83 
84 namespace Foam
85 {
86 
87 class polyPatch;
88 
89 namespace functionObjects
90 {
91 
92 /*---------------------------------------------------------------------------*\
93  Class patchCutLayerAverage Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 class patchCutLayerAverage
97 :
98  public fvMeshFunctionObject
99 {
100  // Private Data
101 
102  //- Name of the patch
103  word patchName_;
104 
105  //- Direction along which to plot
106  vector direction_;
107 
108  //- Name of the distance field along which to plot
109  word distanceName_;
110 
111  //- Number of layers
112  label nLayers_;
113 
114  //- Whether or not to interpolate
115  bool interpolate_;
116 
117  //- Fields to plot
118  wordList fields_;
119 
120  //- The direction over which to plot the results
121  coordSet::axisType axis_;
122 
123  //- File writer
124  autoPtr<setWriter> formatter_;
125 
126  //- Number of optimisation iterations. Default is 2.
127  label nOptimiseIter_;
128 
129  //- Weights
130  autoPtr<List<cutPlot::weight>> weights_;
131 
132  //- Layer distances. The distance of the layers' cut-planes to the
133  // origin, in the direction of the given vector. If interpolate is
134  // false, then the distance is taken to the middle of the layer.
135  autoPtr<scalarField> layerDistances_;
136 
137  //- Layer thicknesses. If interpolate is false, then this is the
138  // thickness of the layer that the plot point represents.
139  autoPtr<scalarField> layerThicknesses_;
140 
141  //- Layer positions. The average position of the layer.
142  autoPtr<pointField> layerPositions_;
143 
144 
145  // Private Member functions
146 
147  //- Return the output path
148  fileName outputPath() const;
149 
150  //- Calculate and set the weights member data
151  void calcWeights();
152 
153  //- Clear the cached weights
154  void clear();
155 
156 
157 public:
158 
159  //- Runtime type information
160  TypeName("patchCutLayerAverage");
161 
162 
163  // Constructors
164 
165  //- Construct from Time and dictionary
167  (
168  const word& name,
169  const Time& runTime,
170  const dictionary& dict
171  );
172 
173 
174  //- Destructor
175  virtual ~patchCutLayerAverage();
176 
177 
178  // Member Functions
179 
180  //- Read the patchCutLayerAverage data
181  virtual bool read(const dictionary&);
182 
183  //- Return the list of fields required
184  virtual wordList fields() const;
185 
186  //- Execute, currently does nothing
187  virtual bool execute();
188 
189  //- Write the patchCutLayerAverage
190  virtual bool write();
191 
192  //- Update for mesh point-motion
193  virtual void movePoints(const polyMesh&);
194 
195  //- Update topology using the given map
196  virtual void topoChange(const polyTopoChangeMap&);
197 
198  //- Update from another mesh using the given map
199  virtual void mapMesh(const polyMeshMap&);
200 
201  //- Redistribute or update using the given distribution map
202  virtual void distribute(const polyDistributionMap&);
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace functionObjects
209 } // End namespace Foam
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 #endif
214 
215 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
axisType
Enumeration defining the output format for coordinates.
Definition: coordSet.H:58
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
const word & name() const
Return the name of this functionObject.
patchCutLayerAverage(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual wordList fields() const
Return the list of fields required.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
TypeName("patchCutLayerAverage")
Runtime type information.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
virtual bool execute()
Execute, currently does nothing.
virtual bool write()
Write the patchCutLayerAverage.
virtual bool read(const dictionary &)
Read the patchCutLayerAverage data.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
dictionary dict