histogramModel.H
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) 2022 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 Namespace
27  Foam::histogramModels
28 
29 Description
30  A namespace for various histogram model implementations.
31 
32 Class
33  Foam::histogramModel
34 
35 Description
36  A base class for histogram models.
37 
38 SourceFiles
39  histogramModel.C
40  histogramModelNew.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Foam_histogramModel_H
45 #define Foam_histogramModel_H
46 
47 #include "writeFile.H"
48 #include "volFields.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 class fvMesh;
57 
58 /*---------------------------------------------------------------------------*\
59  Class histogramModel Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class histogramModel
63 :
65 {
66  // Private Data
67 
68  //- Const reference to the mesh
69  const fvMesh& mesh_;
70 
71  //- Name of operand field
72  word fieldName_;
73 
74 
75 protected:
76 
77  // Protected Member Functions
78 
79  //- Output file header information
80  virtual void writeFileHeader(Ostream& os);
81 
82  //- Return requested field from the object registry
83  //- or read+register the field to the object registry
85 
86  //- Write histogram data
87  void write
88  (
89  scalarField& dataNormalised,
90  const labelField& dataCount,
91  const scalarField& magMidBin
92  );
93 
94 
95 public:
96 
97  //- Runtime type information
98  TypeName("histogramModel");
99 
100 
101  // Declare runtime constructor selection table
102 
104  (
105  autoPtr,
107  dictionary,
108  (
109  const word& name,
110  const fvMesh& mesh,
111  const dictionary& dict
112  ),
113  (name, mesh, dict)
114  );
115 
116 
117  // Selectors
118 
119  //- Return a reference to the selected histogram model
121  (
122  const word& name,
123  const fvMesh& mesh,
124  const dictionary& dict
125  );
126 
127 
128  // Constructors
129 
130  //- Construct from components
132  (
133  const word& name,
134  const fvMesh& mesh,
135  const dictionary& dict
136  );
137 
138  //- No copy construct
139  histogramModel(const histogramModel&) = delete;
140 
141  //- No copy assignment
142  void operator=(const histogramModel&) = delete;
143 
144 
145  //- Destructor
146  virtual ~histogramModel() = default;
147 
148 
149  // Member Functions
150 
151  // Access
152 
153  //- Return const reference to the mesh
154  const fvMesh& mesh() const noexcept
155  {
156  return mesh_;
157  }
158 
159  //- Return const reference to the operand field name
160  const word& fieldName() const noexcept
161  {
162  return fieldName_;
163  }
164 
165 
166  // I-O
167 
168  //- Read top-level dictionary
169  virtual bool read(const dictionary& dict);
170 
171  //- Write data to stream and files
172  virtual bool write(const bool log) = 0;
173 };
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace Foam
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 #endif
183 
184 // ************************************************************************* //
void write(scalarField &dataNormalised, const labelField &dataCount, const scalarField &magMidBin)
Write histogram data.
virtual ~histogramModel()=default
Destructor.
dictionary dict
virtual void writeFileHeader(Ostream &os)
Output file header information.
dimensionedScalar log(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual bool read(const dictionary &dict)
Read top-level dictionary.
histogramModel(const word &name, const fvMesh &mesh, const dictionary &dict)
Construct from components.
const word & fieldName() const noexcept
Return const reference to the operand field name.
static autoPtr< histogramModel > New(const word &name, const fvMesh &mesh, const dictionary &dict)
Return a reference to the selected histogram model.
const fvMesh & mesh() const noexcept
Return const reference to the mesh.
void operator=(const histogramModel &)=delete
No copy assignment.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
declareRunTimeSelectionTable(autoPtr, histogramModel, dictionary,(const word &name, const fvMesh &mesh, const dictionary &dict),(name, mesh, dict))
A base class for histogram models.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
volScalarField & getOrReadField(const word &fieldName) const
Return requested field from the object registry or read+register the field to the object registry...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Base class for writing single files from the function objects.
Definition: writeFile.H:112
TypeName("histogramModel")
Runtime type information.
Namespace for OpenFOAM.