regionFunctionObject.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) 2016-2023 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::regionFunctionObject
26 
27 Description
28  Specialisation of Foam::functionObject for a region and providing a
29  reference to the region Foam::objectRegistry.
30 
31 See also
32  Foam::functionObject
33 
34 SourceFiles
35  regionFunctionObject.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef functionObjects_regionFunctionObject_H
40 #define functionObjects_regionFunctionObject_H
41 
42 #include "functionObject.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward declaration of classes
50 class objectRegistry;
51 
52 namespace functionObjects
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class regionFunctionObject Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 :
61  public functionObject
62 {
63 
64 protected:
65 
66  // Protected member data
67 
68  //- Reference to the region objectRegistry
69  const objectRegistry& obr_;
70 
71 
72  // Protected member functions
73 
74  //- Find field in the objectRegistry
75  template<class ObjectType>
76  bool foundObject(const word& fieldName) const;
77 
78  //- Prints a warning message that fieldName cannot be found
79  template<class ObjectType>
80  void cannotFindObject(const word& fieldName);
81 
82  //- Prints a warning message that fieldName cannot be found
83  void cannotFindObject(const word& fieldName);
84 
85  //- Lookup object from the objectRegistry
86  template<class ObjectType>
87  const ObjectType& lookupObject(const word& fieldName) const;
88 
89  //- Lookup non-const object reference from the objectRegistry
90  template<class ObjectType>
91  ObjectType& lookupObjectRef(const word& fieldName);
92 
93  //- Store the given field in the objectRegistry
94  template<class ObjectType>
95  bool store(const tmp<ObjectType>& tfield);
96 
97  //- Store the given field in the objectRegistry under the given name
98  template<class ObjectType>
99  bool store
100  (
101  const word& fieldName,
102  const tmp<ObjectType>& tfield,
103  bool cacheable = false
104  );
105 
106  //- Write field if present in objectRegistry
107  bool writeObject(const word& fieldName);
108 
109  //- Clear field from the objectRegistry if present
110  bool clearObject(const word& fieldName);
111 
112 
113 public:
114 
115  //- Runtime type information
116  TypeName("regionFunctionObject");
117 
118 
119  // Constructors
120 
121  //- Construct from Time and dictionary.
122  // The region objectRegistry is looked-up runTime with the name
123  // looked-up from the dictionary (defaults to polyMesh::defaultRegion)
125  (
126  const word& name,
127  const Time& runTime,
128  const dictionary& dict
129  );
130 
131  //- Construct from the region objectRegistry and dictionary
133  (
134  const word& name,
135  const objectRegistry& obr,
136  const dictionary& dict
137  );
138 
139  //- Disallow default bitwise copy construction
141 
142 
143  //- Destructor
144  virtual ~regionFunctionObject();
145 
146 
147  // Member Functions
148 
149  //- Read optional controls
150  virtual bool read(const dictionary&);
151 
152 
153  // Member Operators
154 
155  //- Disallow default bitwise assignment
156  void operator=(const regionFunctionObject&) = delete;
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace functionObjects
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #ifdef NoRepository
169 #endif
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Abstract base-class for Time/database functionObjects.
const word & name() const
Return the name of this functionObject.
Specialisation of Foam::functionObject for a region and providing a reference to the region Foam::obj...
const ObjectType & lookupObject(const word &fieldName) const
Lookup object from the objectRegistry.
bool foundObject(const word &fieldName) const
Find field in the objectRegistry.
const objectRegistry & obr_
Reference to the region objectRegistry.
ObjectType & lookupObjectRef(const word &fieldName)
Lookup non-const object reference from the objectRegistry.
void operator=(const regionFunctionObject &)=delete
Disallow default bitwise assignment.
bool writeObject(const word &fieldName)
Write field if present in objectRegistry.
bool clearObject(const word &fieldName)
Clear field from the objectRegistry if present.
regionFunctionObject(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
TypeName("regionFunctionObject")
Runtime type information.
bool store(const tmp< ObjectType > &tfield)
Store the given field in the objectRegistry.
void cannotFindObject(const word &fieldName)
Prints a warning message that fieldName cannot be found.
virtual bool read(const dictionary &)
Read optional controls.
Registry of regIOobjects.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
dictionary dict