function1Base.C
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) 2020-2021 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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\*---------------------------------------------------------------------------*/
27
28#include "function1Base.H"
29#include "objectRegistry.H"
30#include "Time.H"
31
32// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33
35(
36 const bool useTime
37) const noexcept
38{
39 if (obrPtr_ && useTime)
40 {
41 return &(obrPtr_->time());
42 }
43
44 return obrPtr_;
45}
46
47
48// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
49
51(
52 const word& entryName,
53 const objectRegistry* obrPtr
54)
55:
56 refCount(),
57 name_(entryName),
58 obrPtr_(obrPtr)
59{}
60
61
63(
64 const word& entryName,
65 const dictionary& dict,
66 const objectRegistry* obrPtr
67)
68:
69 refCount(),
70 name_(entryName),
71 obrPtr_(obrPtr)
72{}
73
74
76:
77 refCount(),
78 name_(rhs.name_),
79 obrPtr_(rhs.obrPtr_)
80{}
81
82
83// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
84
85// NOTE : do not delete obrPtr_ (no ownership)
87{}
88
89
90// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91
93{
94 if (!obrPtr_)
95 {
97 << "Object registry not set"
98 << abort(FatalError);
99 }
100 return *obrPtr_;
101}
102
103
105{
106 if (!obrPtr_)
107 {
109 << "Object registry not set"
110 << abort(FatalError);
111 }
112
113 return obrPtr_->time();
114}
115
116
118{
119 return (obrPtr_ && obrPtr_->isTimeDb());
120}
121
122
124{
125 obrPtr_ = obrPtr;
126}
127
128
130{
131 obrPtr_ = &db;
132}
133
134
136{}
137
138
139// ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Base class for template-invariant parts of Function1.
Definition: function1Base.H:57
const Time & time() const
Return the time database.
void resetDb(const objectRegistry *obrPtr=nullptr) noexcept
Reset the associated objectRegistry.
const objectRegistry & obr() const
Return the object registry.
Definition: function1Base.C:92
bool isTime() const noexcept
Return true if this function was created with the time database.
const objectRegistry * whichDb() const noexcept
Return the associated registry or nullptr.
virtual ~function1Base()
Destructor.
Definition: function1Base.C:86
virtual void userTimeToTime(const Time &t)
Convert time.
Registry of regIOobjects.
Reference counter for various OpenFOAM components.
Definition: refCount.H:51
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
errorManip< error > abort(error &err)
Definition: errorManip.H:144
const direction noexcept
Definition: Scalar.H:223
error FatalError
dictionary dict