LagrangianDistribution.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) 2025 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::LagrangianDistribution
26 
27 Description
28  Function to generate a plot of the distribution of the values in a
29  Lagrangian field
30 
31 Usage
32  \table
33  Property | Description | Required? | Default
34  Lagrangian | Name of the Lagrangian mesh | yes |
35  field | Field to operate on | if fields not specified |
36  fields | List of fields to operate on | if field not specified |
37  weightField | Field with which to weight the distribution | no | none
38  weightFields | List of fields with which to \
39  weight the distribution | no | none
40  nBins | The number of bins used in the plot | yes |
41  setFormat | Format of the plot file | yes |
42  \endtable
43 
44  Example specification to generate the diameter distribution:
45  \verbatim
46  LagrangianDistribution1
47  {
48  type LagrangianDistribution;
49  libs ("libLagrangianFunctionObjects.so");
50  Lagrangian cloud;
51  field d;
52  weightField number;
53  nBins 20;
54  setFormat raw;
55  }
56  \endverbatim
57 
58 SourceFiles
59  LagrangianDistribution.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef LagrangianDistribution_H
64 #define LagrangianDistribution_H
65 
67 #include "setWriter.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 namespace functionObjects
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class LagrangianDistribution Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 class LagrangianDistribution
81 :
82  public LagrangianMeshFunctionObject
83 {
84 private:
85 
86  // Private Data
87 
88  //- List of fields
89  wordList fields_;
90 
91  //- List of weight fields
92  wordList weightFields_;
93 
94  //- Number of bins
95  label nBins_;
96 
97  //- File writer
98  autoPtr<setWriter> formatter_;
99 
100 
101  // Private Member Functions
102 
103  //- Non-virtual read
104  void readCoeffs(const dictionary& dict);
105 
106  //- Multiply the argument by the given weight field. Return whether or
107  // not the weight field was found.
108  template<template<class> class GeoField>
109  bool multiplyWeight
110  (
111  const word& weightFieldName,
112  scalarField& weight
113  ) const;
114 
115  //- Write the distribution of the given scalar field
116  void writeDistribution
117  (
118  const word& fieldName,
119  const word& componentName,
120  const scalarField& x,
121  const scalarField& PDF,
122  const scalarField& CDF
123  ) const;
124 
125  //- Compute and write the distribution of the given scalar field
126  void writeDistribution
127  (
128  const scalarField& weight,
129  const word& fieldName,
130  const word& componentName,
131  const scalarField& field
132  );
133 
134  //- Compute and write the distribution of a field given its name.
135  // Return whether or not the field was found. In the case of higher
136  // rank types, multiple distributions will be calculated and written
137  // independently.
138  template<template<class> class GeoField, class Type>
139  bool writeDistribution
140  (
141  const scalarField& weight,
142  const word& fieldName
143  );
144 
145 
146 public:
147 
148  //- Runtime type information
149  TypeName("LagrangianDistribution");
150 
151 
152  // Constructors
153 
154  //- Construct from Time and dictionary
156  (
157  const word& name,
158  const Time& runTime,
159  const dictionary& dict
160  );
161 
162  //- Disallow default bitwise copy construction
164 
165 
166  //- Destructor
167  virtual ~LagrangianDistribution();
168 
169 
170  // Member Functions
171 
172  //- Read parameters
173  virtual bool read(const dictionary&);
174 
175  //- Return the list of fields required
176  virtual wordList fields() const;
177 
178  //- Execute. Does nothing.
179  virtual bool execute();
180 
181  //- Write the sum
182  virtual bool write();
183 
184 
185  // Member Operators
186 
187  //- Disallow default bitwise assignment
188  void operator=(const LagrangianDistribution&) = delete;
189 };
190 
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 } // End namespace functionObjects
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return the name of this functionObject.
Function to generate a plot of the distribution of the values in a Lagrangian field.
void operator=(const LagrangianDistribution &)=delete
Disallow default bitwise assignment.
virtual wordList fields() const
Return the list of fields required.
TypeName("LagrangianDistribution")
Runtime type information.
LagrangianDistribution(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual bool execute()
Execute. Does nothing.
virtual bool read(const dictionary &)
Read parameters.
A class for handling words, derived from string.
Definition: word.H:62
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
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dictionary dict