mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: replace OSspecific clockValue with std::chrono version (#1278)
- aids with portability and maintenance (#1238)
This commit is contained in:
committed by
Andrew Heather
parent
51aae5f34d
commit
b56fbc4377
3
applications/test/OSspecific/Make/files
Normal file
3
applications/test/OSspecific/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-OSspecific.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-OSspecific
|
||||
59
applications/test/OSspecific/Test-OSspecific.C
Normal file
59
applications/test/OSspecific/Test-OSspecific.C
Normal file
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Report some basic os-specific values
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OSspecific.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<< "Report some basic OS-specific values" << nl;
|
||||
|
||||
Info<< nl
|
||||
<< "host : " << hostName() << nl
|
||||
<< "user : " << userName() << nl
|
||||
<< "home : " << home() << nl;
|
||||
|
||||
Info<< nl
|
||||
<< "cwd : " << cwd() << nl
|
||||
<< "cwd -P : " << cwd(false) << nl
|
||||
<< "cwd -L : " << cwd(true) << nl;
|
||||
|
||||
Info<< nl
|
||||
<< "libs : " << dlLoaded() << nl;
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,2 +0,0 @@
|
||||
Test-POSIX.C
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-POSIX
|
||||
3
applications/test/clock/Make/files
Normal file
3
applications/test/clock/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-clock.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-clock
|
||||
2
applications/test/clock/Make/options
Normal file
2
applications/test/clock/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
|
||||
/* EXE_LIBS = -lfiniteVolume */
|
||||
@ -2,10 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011 OpenFOAM Foundation
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,6 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Test some clock-related routines
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -31,21 +30,59 @@ Description
|
||||
#include "clock.H"
|
||||
#include "clockTime.H"
|
||||
#include "cpuTime.H"
|
||||
#include "clockValue.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
|
||||
template<class ClockValue>
|
||||
void testEpoch()
|
||||
{
|
||||
Info<< nl << "Test epoch" << nl;
|
||||
|
||||
ClockValue now(true);
|
||||
|
||||
Info<< "epoch = " << now.str() << " # day-hh:mm::ss" << nl
|
||||
<< "epoch = " << now << nl;
|
||||
}
|
||||
|
||||
|
||||
template<class ClockValue>
|
||||
void testElapsed()
|
||||
{
|
||||
Info<< nl << "Test elapsed" << nl;
|
||||
|
||||
ClockValue a;
|
||||
|
||||
Info<< "clockValue() " << a << nl;
|
||||
a.update();
|
||||
Info<< "updated " << a << nl;
|
||||
|
||||
Info<< "sleep 4..." << endl;
|
||||
sleep(4);
|
||||
|
||||
a.update();
|
||||
Info<< " = " << a.seconds() << nl;
|
||||
|
||||
Info<< "sleep 2..." << endl;
|
||||
sleep(2);
|
||||
|
||||
Info<< "elapsed = " << a.elapsed() << nl
|
||||
<< "elapsed = " << a.elapsed().seconds() << nl
|
||||
<< "elapsed = " << a.elapsed().str() << nl;
|
||||
|
||||
ClockValue b(true);
|
||||
|
||||
Info<< "(" << b << " - " << a << ") = " << (b - a) << nl;
|
||||
Info<< "(" << b << " + " << a << ") = " << (b + a) << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Info<<"cwd() " << cwd() << nl;
|
||||
Info<<"cwd(-P) " << cwd(false) << nl;
|
||||
Info<<"cwd(-L) " << cwd(true) << nl;
|
||||
|
||||
Info<<"rmDir" << nl;
|
||||
rmDir("hmm");
|
||||
|
||||
{
|
||||
Foam::clock sysClock();
|
||||
|
||||
@ -54,33 +91,10 @@ int main(int argc, char *argv[])
|
||||
<< "clock: iso " << clock::dateTime() << nl;
|
||||
}
|
||||
|
||||
Info<< "since epoch = " << clockValue::now().str() << nl;
|
||||
testEpoch<clockValue>();
|
||||
|
||||
{
|
||||
clockValue a;
|
||||
testElapsed<clockValue>();
|
||||
|
||||
Info<< "clockValue() " << a << nl;
|
||||
a.update();
|
||||
Info<< "updated " << a << nl;
|
||||
|
||||
Info<< "sleep 4..." << endl;
|
||||
sleep(4);
|
||||
|
||||
a.update();
|
||||
Info<< " = " << a.seconds() << nl;
|
||||
|
||||
Info<< "sleep 2..." << endl;
|
||||
sleep(2);
|
||||
|
||||
Info<< "elapsed = " << a.elapsed() << nl;
|
||||
Info<< "elapsed = " << a.elapsed().seconds() << nl;
|
||||
Info<< "elapsed = " << a.elapsed().str() << nl;
|
||||
|
||||
clockValue b = clockValue::now();
|
||||
|
||||
Info<< "(" << b << " - " << a << ") = " << (b - a) << nl;
|
||||
Info<< "(" << b << " + " << a << ") = " << (b + a) << nl;
|
||||
}
|
||||
|
||||
{
|
||||
clockTime clk;
|
||||
Reference in New Issue
Block a user