Loading...
Searching...
No Matches
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 }
44 return obrPtr_;
45}
46
47
48// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
49
51(
52 const word& entryName,
53 const objectRegistry* obrPtr
54)
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)
69 refCount(),
70 name_(entryName),
71 obrPtr_(obrPtr)
72{}
73
74
76:
77 refCount(),
78 name_(rhs.name_),
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"
111 }
112
113 return obrPtr_->time();
114}
115
118{
119 return (obrPtr_ && obrPtr_->isTimeDb());
120}
121
123void Foam::function1Base::resetDb(const objectRegistry* obrPtr) noexcept
124{
125 obrPtr_ = obrPtr;
126}
127
129void Foam::function1Base::resetDb(const objectRegistry& db) noexcept
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:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Base class for template-invariant parts of Function1.
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.
bool isTime() const noexcept
Return true if this function was created with the time database.
const objectRegistry * obrPtr_
Pointer to an object registry.
function1Base(const word &entryName, const objectRegistry *obrPtr=nullptr)
Construct from entry name and optional registry.
const objectRegistry * whichDb() const noexcept
Return the associated registry or nullptr.
virtual ~function1Base()
Destructor.
virtual void userTimeToTime(const Time &t)
Convert time.
const word name_
Name of entry.
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
Reference counter for various OpenFOAM components.
Definition refCount.H:45
constexpr refCount() noexcept
Default construct, initializing count to 0.
Definition refCount.H:63
A class for handling words, derived from Foam::string.
Definition word.H:66
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
errorManip< error > abort(error &err)
Definition errorManip.H:139
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
const direction noexcept
Definition scalarImpl.H:265
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dictionary dict