resolutionIndexModel.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::resolutionIndexModels
28 
29 Description
30  A namespace for various \c resolutionIndex model implementations.
31 
32 Class
33  Foam::resolutionIndexModel
34 
35 Description
36  A base class for \c resolutionIndex models.
37 
38 SourceFiles
39  resolutionIndexModel.C
40  resolutionIndexModelNew.C
41 
42 \*---------------------------------------------------------------------------*/
43 
44 #ifndef Foam_resolutionIndexModel_H
45 #define Foam_resolutionIndexModel_H
46 
47 #include "volFields.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward Declarations
55 class fvMesh;
56 
57 /*---------------------------------------------------------------------------*\
58  Class resolutionIndexModel Declaration
59 \*---------------------------------------------------------------------------*/
60 
62 {
63  // Private Data
64 
65  //- Const reference to the mesh
66  const fvMesh& mesh_;
67 
68  //- Name of result field
69  word resultName_;
70 
71 
72 protected:
73 
74  // Protected Member Functions
75 
76  //- Return requested field from the object registry
77  //- or read+register the field to the object registry
78  template<class GeoFieldType>
79  GeoFieldType& getOrReadField(const word& fieldName) const;
80 
81  //- Return cell volume field
82  tmp<volScalarField> V() const;
83 
84 
85 public:
86 
87  //- Runtime type information
88  TypeName("resolutionIndexModel");
89 
90 
91  // Declare runtime constructor selection table
92 
94  (
95  autoPtr,
97  dictionary,
98  (
99  const word& name,
100  const fvMesh& mesh,
101  const dictionary& dict
102  ),
103  (name, mesh, dict)
104  );
105 
106 
107  // Selectors
108 
109  //- Return a reference to the selected resolutionIndex model
111  (
112  const word& name,
113  const fvMesh& mesh,
114  const dictionary& dict
115  );
116 
117 
118  // Constructors
119 
120  //- Construct from components
122  (
123  const word& name,
124  const fvMesh& mesh,
125  const dictionary& dict
126  );
127 
128  //- No copy construct
130 
131  //- No copy assignment
132  void operator=(const resolutionIndexModel&) = delete;
133 
134 
135  //- Destructor
136  virtual ~resolutionIndexModel() = default;
137 
138 
139  // Member Functions
140 
141  // Access
142 
143  //- Return const reference to the mesh
144  const fvMesh& mesh() const noexcept
145  {
146  return mesh_;
147  }
148 
149  //- Return const reference to the result name
150  const word& resultName() const noexcept
151  {
152  return resultName_;
153  }
154 
155 
156  // I-O
157 
158  //- Read top-level dictionary
159  virtual bool read(const dictionary& dict);
160 
161  //- Calculate the result field
162  virtual bool execute() = 0;
163 
164  //- Write the result field
165  virtual bool write() = 0;
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #ifdef NoRepository
177 #endif
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const word & resultName() const noexcept
Return const reference to the result name.
TypeName("resolutionIndexModel")
Runtime type information.
GeoFieldType & getOrReadField(const word &fieldName) const
Return requested field from the object registry or read+register the field to the object registry...
virtual bool write()=0
Write the result field.
declareRunTimeSelectionTable(autoPtr, resolutionIndexModel, dictionary,(const word &name, const fvMesh &mesh, const dictionary &dict),(name, mesh, dict))
resolutionIndexModel(const word &name, const fvMesh &mesh, const dictionary &dict)
Construct from components.
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
A base class for resolutionIndex models.
static autoPtr< resolutionIndexModel > New(const word &name, const fvMesh &mesh, const dictionary &dict)
Return a reference to the selected resolutionIndex model.
const direction noexcept
Definition: Scalar.H:258
virtual bool execute()=0
Calculate the result field.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
void operator=(const resolutionIndexModel &)=delete
No copy assignment.
tmp< volScalarField > V() const
Return cell volume field.
const fvMesh & mesh() const noexcept
Return const reference to the mesh.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual ~resolutionIndexModel()=default
Destructor.
Namespace for OpenFOAM.
virtual bool read(const dictionary &dict)
Read top-level dictionary.