stateModel.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::stateModel
26 
27 Description
28  Base class for models with state
29 
30 SourceFiles
31  stateModel.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef stateModel_H
36 #define stateModel_H
37 
38 #include "objectRegistry.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class stateModel Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class stateModel
50 {
51  // Private Static Member Functions
52 
53  //- Return the state IO object
54  static IOobject io
55  (
56  const word& name,
57  const objectRegistry& db,
58  const bool processor,
59  const bool write
60  );
61 
62 
63  // Private Classes
64 
65  //- State writer class
66  class stateModelWriter
67  :
68  public regIOobject
69  {
70  // Private Member Data
71 
72  //- Reference to the model
73  const stateModel& model_;
74 
75  //- Is this processor-local state?
76  const bool processor_;
77 
78 
79  public:
80 
81  //- Runtime type information
82  TypeName("dictionary");
83 
84 
85  // Constructors
86 
87  //- Construct from a reference to the model
88  stateModelWriter
89  (
90  const stateModel& model,
91  const bool processor
92  );
93 
94 
95  // Member Functions
96 
97  //- Write data
98  virtual bool writeData(Ostream&) const;
99  };
100 
101 
102 public:
103 
104  // Constructors
105 
106  //- Construct null
107  stateModel();
108 
109  //- Disallow default bitwise copy construction
110  stateModel(const stateModel&) = delete;
111 
112 
113  //- Destructor
114  virtual ~stateModel();
115 
116 
117  // Member Functions
118 
119  //- Return the model name
120  virtual const word& name() const = 0;
121 
122  //- Return the model's database
123  virtual const objectRegistry& db() const = 0;
124 
125  //- Write state
126  bool writeState(const bool write) const;
127 
128  //- Write state
129  virtual void writeState(Ostream& os) const;
130 
131  //- Write processor state
132  virtual void writeProcessorState(Ostream& os) const;
133 
134  //- Construct and return the state dictionary for reading
135  static dictionary stateDict
136  (
137  const word& name,
138  const objectRegistry& db
139  );
140 
141 
142  // Member Operators
143 
144  //- Disallow default bitwise assignment
145  void operator=(const stateModel&) = delete;
146 };
147 
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #endif
156 
157 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Registry of regIOobjects.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
Base class for models with state.
Definition: stateModel.H:49
virtual const word & name() const =0
Return the model name.
bool writeState(const bool write) const
Write state.
Definition: stateModel.C:104
static dictionary stateDict(const word &name, const objectRegistry &db)
Construct and return the state dictionary for reading.
Definition: stateModel.C:137
void operator=(const stateModel &)=delete
Disallow default bitwise assignment.
virtual ~stateModel()
Destructor.
Definition: stateModel.C:82
stateModel()
Construct null.
Definition: stateModel.C:76
virtual const objectRegistry & db() const =0
Return the model's database.
virtual void writeProcessorState(Ostream &os) const
Write processor state.
Definition: stateModel.C:132
A class for handling words, derived from string.
Definition: word.H:62
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:74
const bool writeData(readBool(pdfDictionary.lookup("writeData")))