diff --git a/src/functionObjects/utilities/Make/files b/src/functionObjects/utilities/Make/files
index 8b6b039a52..2a91fc2123 100644
--- a/src/functionObjects/utilities/Make/files
+++ b/src/functionObjects/utilities/Make/files
@@ -8,6 +8,7 @@ systemCall/systemCall.C
stopAt/stopAt.C
stopAt/stopAtFile/stopAtFile.C
stopAt/stopAtClockTime/stopAtClockTime.C
+stopAt/stopAtTimeStep/stopAtTimeStep.C
removeRegisteredObject/removeRegisteredObject.C
writeDictionary/writeDictionary.C
writeObjects/writeObjects.C
diff --git a/src/functionObjects/utilities/stopAt/stopAt.C b/src/functionObjects/utilities/stopAt/stopAt.C
index b9b279ae73..744c66d1d1 100644
--- a/src/functionObjects/utilities/stopAt/stopAt.C
+++ b/src/functionObjects/utilities/stopAt/stopAt.C
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
- \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation
+ \\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@@ -86,10 +86,6 @@ bool Foam::functionObjects::stopAt::read(const dictionary& dict)
{
action_ = actionTypeNames_.read(dict.lookup("action"));
}
- else
- {
- action_ = actionType::nextWrite;
- }
return true;
}
diff --git a/src/functionObjects/utilities/stopAt/stopAtTimeStep/stopAtTimeStep.C b/src/functionObjects/utilities/stopAt/stopAtTimeStep/stopAtTimeStep.C
new file mode 100644
index 0000000000..8ca4fc7ee4
--- /dev/null
+++ b/src/functionObjects/utilities/stopAt/stopAtTimeStep/stopAtTimeStep.C
@@ -0,0 +1,90 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2023 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 "stopAtTimeStep.H"
+#include "Time.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+ defineTypeNameAndDebug(stopAtTimeStep, 0);
+
+ addToRunTimeSelectionTable
+ (
+ functionObject,
+ stopAtTimeStep,
+ dictionary
+ );
+}
+}
+
+
+// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
+
+bool Foam::functionObjects::stopAtTimeStep::condition() const
+{
+ return time_.deltaTValue() < minDeltaT_;
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::functionObjects::stopAtTimeStep::stopAtTimeStep
+(
+ const word& name,
+ const Time& runTime,
+ const dictionary& dict
+)
+:
+ stopAt(name, runTime, dict),
+ minDeltaT_(0)
+{
+ action_ = actionType::writeNow;
+ read(dict);
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::functionObjects::stopAtTimeStep::~stopAtTimeStep()
+{}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+bool Foam::functionObjects::stopAtTimeStep::read(const dictionary& dict)
+{
+ stopAt::read(dict);
+ dict.lookup("minDeltaT") >> minDeltaT_;
+
+ return true;
+}
+
+
+// ************************************************************************* //
diff --git a/src/functionObjects/utilities/stopAt/stopAtTimeStep/stopAtTimeStep.H b/src/functionObjects/utilities/stopAt/stopAtTimeStep/stopAtTimeStep.H
new file mode 100644
index 0000000000..5806b7d985
--- /dev/null
+++ b/src/functionObjects/utilities/stopAt/stopAtTimeStep/stopAtTimeStep.H
@@ -0,0 +1,141 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration | Website: https://openfoam.org
+ \\ / A nd | Copyright (C) 2023 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::stopAtTimeStep
+
+Description
+ Stops the run if the time-step drops below the specified value in seconds
+ and optionally write results before stopping.
+
+ The following actions are supported:
+ - noWriteNow
+ - writeNow (default)
+ - nextWrite
+
+ Examples of function object specification:
+ \verbatim
+ stop
+ {
+ type stopAtTimeStep;
+
+ libs ("libutilityFunctionObjects.so");
+
+ minDeltaT 1e-8;
+ action writeNow;
+ }
+ \endverbatim
+ will write the fields and stop if the time-step drops below 1e-8s.
+
+Usage
+ \table
+ Property | Description | Required | Default value
+ type | type name: stopAtTimeStep | yes |
+ minDeltaT | Minimum time-step [s] | yes |
+ action | Action executed | no | writeNow
+ \endtable
+
+SourceFiles
+ stopAtTimeStep.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef functionObjects_stopAtTimeStep_H
+#define functionObjects_stopAtTimeStep_H
+
+#include "stopAt.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace functionObjects
+{
+
+/*---------------------------------------------------------------------------*\
+ Class stopAtTimeStep Declaration
+\*---------------------------------------------------------------------------*/
+
+class stopAtTimeStep
+:
+ public stopAt
+{
+ // Private Data
+
+ //- Minimum time-step, below which the run is stopped
+ scalar minDeltaT_;
+
+
+ // Private Member Functions
+
+ //- Return true when the stop condition is achieved
+ virtual bool condition() const;
+
+
+public:
+
+ //- Runtime type information
+ TypeName("stopAtTimeStep");
+
+
+ // Constructors
+
+ //- Construct from Time and dictionary
+ stopAtTimeStep
+ (
+ const word& name,
+ const Time& runTime,
+ const dictionary&
+ );
+
+ //- Disallow default bitwise copy construction
+ stopAtTimeStep(const stopAtTimeStep&) = delete;
+
+
+ //- Destructor
+ virtual ~stopAtTimeStep();
+
+
+ // Member Functions
+
+ //- Read the dictionary settings
+ virtual bool read(const dictionary&);
+
+
+ // Member Operators
+
+ //- Disallow default bitwise assignment
+ void operator=(const stopAtTimeStep&) = delete;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace functionObjects
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //