All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2019 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  Specialization 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 Time
69  const Time& time_;
70 
71  //- Reference to the region objectRegistry
72  const objectRegistry& obr_;
73 
74 
75  // Protected member functions
76 
77  //- Find field in the objectRegistry
78  template<class ObjectType>
79  bool foundObject(const word& fieldName) const;
80 
81  //- Lookup object from the objectRegistry
82  template<class ObjectType>
83  const ObjectType& lookupObject(const word& fieldName) const;
84 
85  //- Lookup non-const object reference from the objectRegistry
86  template<class ObjectType>
87  ObjectType& lookupObjectRef(const word& fieldName);
88 
89  //- Store the given field in the objectRegistry
90  template<class ObjectType>
91  bool store(const tmp<ObjectType>& tfield);
92 
93  //- Store the given field in the objectRegistry under the given name
94  template<class ObjectType>
95  bool store
96  (
97  const word& fieldName,
98  const tmp<ObjectType>& tfield,
99  bool cacheable = false
100  );
101 
102  //- Write field if present in objectRegistry
103  bool writeObject(const word& fieldName);
104 
105  //- Clear field from the objectRegistry if present
106  bool clearObject(const word& fieldName);
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName("regionFunctionObject");
113 
114 
115  // Constructors
116 
117  //- Construct from Time and dictionary.
118  // The region objectRegistry is looked-up runTime with the name
119  // looked-up from the dictionary (defaults to polyMesh::defaultRegion)
121  (
122  const word& name,
123  const Time& runTime,
124  const dictionary& dict
125  );
126 
127  //- Construct from the region objectRegistry and dictionary
129  (
130  const word& name,
131  const objectRegistry& obr,
132  const dictionary& dict
133  );
134 
135  //- Disallow default bitwise copy construction
137 
138 
139  //- Destructor
140  virtual ~regionFunctionObject();
141 
142 
143  // Member Functions
144 
145  //- Read optional controls
146  virtual bool read(const dictionary&);
147 
148 
149  // Member Operators
150 
151  //- Disallow default bitwise assignment
152  void operator=(const regionFunctionObject&) = delete;
153 };
154 
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace functionObjects
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #ifdef NoRepository
165 #endif
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
Specialization of Foam::functionObject for a region and providing a reference to the region Foam::obj...
dictionary dict
bool writeObject(const word &fieldName)
Write field if present in objectRegistry.
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
engineTime & runTime
Abstract base-class for Time/database functionObjects.
const ObjectType & lookupObject(const word &fieldName) const
Lookup object from the objectRegistry.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual bool read(const dictionary &)
Read optional controls.
A class for handling words, derived from string.
Definition: word.H:59
TypeName("regionFunctionObject")
Runtime type information.
bool foundObject(const word &fieldName) const
Find field in the 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.
bool store(const tmp< ObjectType > &tfield)
Store the given field in the objectRegistry.
const Time & time_
Reference to the Time.
ObjectType & lookupObjectRef(const word &fieldName)
Lookup non-const object reference from the objectRegistry.
void operator=(const regionFunctionObject &)=delete
Disallow default bitwise assignment.
const objectRegistry & obr_
Reference to the region objectRegistry.
A class for managing temporary objects.
Definition: PtrList.H:53
Registry of regIOobjects.
Namespace for OpenFOAM.