diff --git a/etc/caseDicts/postProcessing/numerical/timeStep b/etc/caseDicts/postProcessing/numerical/timeStep new file mode 100644 index 0000000000..b475b07dee --- /dev/null +++ b/etc/caseDicts/postProcessing/numerical/timeStep @@ -0,0 +1,15 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ + +type timeStep; +libs ("libutilityFunctionObjects.so"); + +writeControl timeStep; +writeInterval 1; + +// ************************************************************************* // diff --git a/src/functionObjects/utilities/Make/files b/src/functionObjects/utilities/Make/files index 19c8063eb1..7a9b4fc183 100644 --- a/src/functionObjects/utilities/Make/files +++ b/src/functionObjects/utilities/Make/files @@ -1,6 +1,7 @@ codedFunctionObject/codedFunctionObject.C residuals/residuals.C timeActivatedFileUpdate/timeActivatedFileUpdate.C +timeStep/timeStepFunctionObject.C setTimeStep/setTimeStepFunctionObject.C systemCall/systemCall.C stopAt/stopAt.C diff --git a/src/functionObjects/utilities/timeStep/timeStepFunctionObject.C b/src/functionObjects/utilities/timeStep/timeStepFunctionObject.C new file mode 100644 index 0000000000..5bb1311a5f --- /dev/null +++ b/src/functionObjects/utilities/timeStep/timeStepFunctionObject.C @@ -0,0 +1,118 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ 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 . + +\*---------------------------------------------------------------------------*/ + +#include "timeStepFunctionObject.H" +#include "Time.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(timeStep, 0); + + addToRunTimeSelectionTable + ( + functionObject, + timeStep, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::timeStep::timeStep +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + regionFunctionObject(name, runTime, dict), + logFiles(obr_, name) +{ + read(dict); + resetName(typeName); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::timeStep::~timeStep() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::timeStep::read(const dictionary& dict) +{ + functionObject::read(dict); + + return true; +} + + +void Foam::functionObjects::timeStep::writeFileHeader(const label i) +{ + if (Pstream::master()) + { + writeHeader(file(), "Time step"); + writeCommented(file(), "Time"); + + file() << tab << "deltaT"; + + file() << endl; + } +} + + +bool Foam::functionObjects::timeStep::execute() +{ + return true; +} + + +bool Foam::functionObjects::timeStep::write() +{ + logFiles::write(); + + if (Pstream::master()) + { + writeTime(file()); + + file() << tab << obr_.time().deltaTValue(); + + file() << endl; + } + + return true; +} + + +// ************************************************************************* // diff --git a/src/functionObjects/utilities/timeStep/timeStepFunctionObject.H b/src/functionObjects/utilities/timeStep/timeStepFunctionObject.H new file mode 100644 index 0000000000..067ee575a0 --- /dev/null +++ b/src/functionObjects/utilities/timeStep/timeStepFunctionObject.H @@ -0,0 +1,135 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation + \\/ 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 . + +Class + Foam::functionObjects::timeStep + +Description + Writes the time step + + Example of function object specification: + \verbatim + timeStep + { + type timeStep; + writeControl timeStep; + writeInterval 1; + } + \endverbatim + + Output data is written to the dir postProcessing/timeStep/\/ + +See also + Foam::functionObject + Foam::functionObjects::regionFunctionObject + Foam::functionObjects::logFiles + +SourceFiles + timeStep.C + +\*---------------------------------------------------------------------------*/ + +#ifndef timeStepFunctionObject_H +#define timeStepFunctionObject_H + +#include "regionFunctionObject.H" +#include "logFiles.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class timeStep Declaration +\*---------------------------------------------------------------------------*/ + +class timeStep +: + public regionFunctionObject, + public logFiles +{ + +protected: + + // Protected Member Functions + + //- Output file header information + virtual void writeFileHeader(const label i); + + +public: + + //- Runtime type information + TypeName("timeStep"); + + + // Constructors + + //- Construct from Time and dictionary + timeStep + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + //- Disallow default bitwise copy construction + timeStep(const timeStep&) = delete; + + + //- Destructor + virtual ~timeStep(); + + + // Member Functions + + //- Read the controls + virtual bool read(const dictionary&); + + //- Execute, currently does nothing + virtual bool execute(); + + //- Write the time step value + virtual bool write(); + + + // Member Operators + + //- Disallow default bitwise assignment + void operator=(const timeStep&) = delete; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //