instant.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) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2018-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "instant.H"
30#include "Time.H"
31#include <cstdlib> // std::atof
32#include <utility> // std::move
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36const char* const Foam::instant::typeName = "instant";
37
38
39// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
41Foam::instant::instant(scalar timeValue)
42:
43 Instant<word>(timeValue, Time::timeName(timeValue))
44{}
45
46
48:
50{
51 value() = std::atof(name().c_str());
52}
53
54
56:
57 Instant<word>(0, std::move(timeName))
58{
59 value() = std::atof(name().c_str());
60}
61
62
63// ************************************************************************* //
A tuple of scalar value and key. The value often corresponds to a time value, thus the naming of the ...
Definition: Instant.H:52
scalar value() const noexcept
The value (const access)
Definition: Instant.H:118
const word & name() const noexcept
The name/key (const access)
Definition: Instant.H:130
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
instant()=default
Default construct, with value = 0 and empty name.
static const char *const typeName
The type name (eg, for pTraits)
Definition: instant.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:68
word timeName
Definition: getTimeIndex.H:3