OpenFOAM: API Guide
v2112
The open source CFD toolbox
maxDurationCondition.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) 2018-2022 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
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 "
maxDurationCondition.H
"
29
#include "
addToRunTimeSelectionTable.H
"
30
#include "
Time.H
"
31
32
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34
namespace
Foam
35
{
36
namespace
functionObjects
37
{
38
namespace
runTimeControls
39
{
40
defineTypeNameAndDebug
(
maxDurationCondition
, 0);
41
addToRunTimeSelectionTable
42
(
43
runTimeCondition
,
44
maxDurationCondition
,
45
dictionary
46
);
47
}
48
}
49
}
50
51
52
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53
54
Foam::functionObjects::runTimeControls::maxDurationCondition::
55
maxDurationCondition
56
(
57
const
word
& name,
58
const
objectRegistry
& obr,
59
const
dictionary
&
dict
,
60
stateFunctionObject
& state
61
)
62
:
63
runTimeCondition
(
name
, obr,
dict
, state),
64
duration_(
dict
.get<scalar>(
"duration"
)),
65
startTime_(-1),
66
initialised_(false),
67
resetOnRestart_(
dict
.getOrDefault(
"resetOnRestart"
, false))
68
{
69
if
70
(
71
!
resetOnRestart_
72
&&
conditionDict
().
readIfPresent
(
"startTime"
,
startTime_
))
73
{
74
initialised_
=
true
;
75
}
76
}
77
78
79
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
80
81
bool
Foam::functionObjects::runTimeControls::maxDurationCondition::apply
()
82
{
83
if
(!active_)
84
{
85
return
true
;
86
}
87
88
if
(!initialised_)
89
{
90
startTime_ = obr_.time().value();
91
initialised_ =
true
;
92
}
93
94
scalar
delta
= obr_.time().value() - startTime_;
95
delta
= obr_.time().timeToUserTime(
delta
);
96
97
Log
<<
" "
<<
type
() <<
": "
<< name_ <<
nl
98
<<
" Completed "
<<
delta
<<
" out of "
<< duration_ <<
nl
;
99
100
return
delta
>= duration_;
101
}
102
103
104
void
Foam::functionObjects::runTimeControls::maxDurationCondition::write
()
105
{
106
if
(initialised_)
107
{
108
conditionDict().set(
"startTime"
, startTime_);
109
}
110
}
111
112
113
void
Foam::functionObjects::runTimeControls::maxDurationCondition::reset
()
114
{
115
initialised_ =
false
;
116
}
117
118
119
// ************************************************************************* //
delta
scalar delta
Definition:
LISASMDCalcMethod2.H:8
Log
#define Log
Definition:
PDRblock.C:35
Time.H
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
addToRunTimeSelectionTable
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Definition:
addToRunTimeSelectionTable.H:42
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition:
dictionary.H:126
Foam::functionObjects::runTimeControls::maxDurationCondition
Activated after a user-specified duration.
Definition:
maxDurationCondition.H:58
Foam::functionObjects::runTimeControls::maxDurationCondition::apply
virtual bool apply()
Apply the condition.
Definition:
maxDurationCondition.C:81
Foam::functionObjects::runTimeControls::maxDurationCondition::initialised_
bool initialised_
Initialisation flag.
Definition:
maxDurationCondition.H:70
Foam::functionObjects::runTimeControls::maxDurationCondition::resetOnRestart_
Switch resetOnRestart_
Reset on restart (ignores any state information)
Definition:
maxDurationCondition.H:73
Foam::functionObjects::runTimeControls::maxDurationCondition::write
virtual void write()
Write.
Definition:
maxDurationCondition.C:104
Foam::functionObjects::runTimeControls::maxDurationCondition::reset
virtual void reset()
Reset.
Definition:
maxDurationCondition.C:113
Foam::functionObjects::runTimeControls::maxDurationCondition::startTime_
scalar startTime_
Time when the condition is activated.
Definition:
maxDurationCondition.H:67
Foam::functionObjects::runTimeControls::runTimeCondition
Base class for run time conditions.
Definition:
runTimeCondition.H:62
Foam::functionObjects::runTimeControls::runTimeCondition::conditionDict
const dictionary & conditionDict() const
Return const access to the conditions dictionary.
Definition:
runTimeCondition.C:62
Foam::functionObjects::stateFunctionObject
Base class for function objects, adding functionality to read/write state information (data required ...
Definition:
stateFunctionObject.H:72
Foam::objectRegistry
Registry of regIOobjects.
Definition:
objectRegistry.H:65
Foam::word
A class for handling words, derived from Foam::string.
Definition:
word.H:68
defineTypeNameAndDebug
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition:
className.H:121
maxDurationCondition.H
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:34
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition:
MSwindows.C:598
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition:
exprTraits.C:59
Foam::nl
constexpr char nl
The newline '\n' character (0x0a)
Definition:
Ostream.H:53
dict
dictionary dict
Definition:
searchingEngine.H:14
readIfPresent
propsDict readIfPresent("fields", acceptFields)
src
functionObjects
utilities
runTimeControl
runTimeCondition
maxDurationCondition
maxDurationCondition.C
Generated by
1.9.5
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.