mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Removed residualControl function object
This commit is contained in:
@ -1,7 +1,4 @@
|
|||||||
abortCalculation/abortCalculation.C
|
abortCalculation/abortCalculation.C
|
||||||
abortCalculation/abortCalculationFunctionObject.C
|
abortCalculation/abortCalculationFunctionObject.C
|
||||||
|
|
||||||
residualControl/residualControl.C
|
|
||||||
residualControl/residualControlFunctionObject.C
|
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libjobControl
|
LIB = $(FOAM_LIBBIN)/libjobControl
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2010-2010 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/>.
|
|
||||||
|
|
||||||
Typedef
|
|
||||||
Foam::IOresidualControl
|
|
||||||
|
|
||||||
Description
|
|
||||||
Instance of the generic IOOutputFilter for residualControl.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef IOresidualControl_H
|
|
||||||
#define IOresidualControl_H
|
|
||||||
|
|
||||||
#include "residualControl.H"
|
|
||||||
#include "IOOutputFilter.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
typedef IOOutputFilter<residualControl> IOresidualControl;
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,68 +0,0 @@
|
|||||||
/*--------------------------------*- C++ -*----------------------------------*\
|
|
||||||
| ========= | |
|
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
|
||||||
| \\ / O peration | Version: dev |
|
|
||||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
|
||||||
| \\/ M anipulation | |
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
FoamFile
|
|
||||||
{
|
|
||||||
version 2.0;
|
|
||||||
format ascii;
|
|
||||||
class dictionary;
|
|
||||||
location "system";
|
|
||||||
object controlDict;
|
|
||||||
}
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
application icoFoam;
|
|
||||||
|
|
||||||
startFrom startTime;
|
|
||||||
|
|
||||||
startTime 0;
|
|
||||||
|
|
||||||
stopAt endTime;
|
|
||||||
|
|
||||||
endTime 0.5;
|
|
||||||
|
|
||||||
deltaT 0.005;
|
|
||||||
|
|
||||||
writeControl timeStep;
|
|
||||||
|
|
||||||
writeInterval 20;
|
|
||||||
|
|
||||||
purgeWrite 0;
|
|
||||||
|
|
||||||
writeFormat ascii;
|
|
||||||
|
|
||||||
writePrecision 6;
|
|
||||||
|
|
||||||
writeCompression off;
|
|
||||||
|
|
||||||
timeFormat general;
|
|
||||||
|
|
||||||
timePrecision 6;
|
|
||||||
|
|
||||||
runTimeModifiable true;
|
|
||||||
|
|
||||||
functions
|
|
||||||
{
|
|
||||||
convergenceChecks
|
|
||||||
{
|
|
||||||
type residualControl;
|
|
||||||
functionObjectLibs ( "libjobControl.so" );
|
|
||||||
outputControl timeStep;
|
|
||||||
outputInterval 1;
|
|
||||||
|
|
||||||
maxResiduals
|
|
||||||
{
|
|
||||||
p 5e-4;
|
|
||||||
U 1e-3;
|
|
||||||
|
|
||||||
// possibly check turbulence fields
|
|
||||||
"(k|epsilon|omega)" 1e-3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,173 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2010-2010 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/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "residualControl.H"
|
|
||||||
#include "fvMesh.H"
|
|
||||||
#include "Time.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
defineTypeNameAndDebug(Foam::residualControl, 0);
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
bool Foam::residualControl::checkCriteria(const bool verbose) const
|
|
||||||
{
|
|
||||||
bool achieved = true;
|
|
||||||
const fvMesh& mesh = static_cast<const fvMesh&>(obr_);
|
|
||||||
const dictionary& solverDict = mesh.solverPerformanceDict();
|
|
||||||
|
|
||||||
forAllConstIter(dictionary, solverDict, iter)
|
|
||||||
{
|
|
||||||
const word& variableName = iter().keyword();
|
|
||||||
scalar maxResidual;
|
|
||||||
|
|
||||||
if (maxResiduals_.readIfPresent(variableName, maxResidual))
|
|
||||||
{
|
|
||||||
// use the residual from the first solution
|
|
||||||
const scalar eqnResidual =
|
|
||||||
List<lduMatrix::solverPerformance>
|
|
||||||
(
|
|
||||||
iter().stream()
|
|
||||||
).first().initialResidual();
|
|
||||||
|
|
||||||
achieved = achieved && (eqnResidual < maxResidual);
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
Info<< " " << variableName
|
|
||||||
<< ": requested max residual = " << maxResidual
|
|
||||||
<< ", eqn residual = " << eqnResidual << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return achieved;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::residualControl::residualControl
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const objectRegistry& obr,
|
|
||||||
const dictionary& dict,
|
|
||||||
const bool
|
|
||||||
)
|
|
||||||
:
|
|
||||||
name_(name),
|
|
||||||
obr_(obr),
|
|
||||||
active_(true),
|
|
||||||
maxResiduals_(),
|
|
||||||
criteriaSatisfied_(false)
|
|
||||||
{
|
|
||||||
// Only active if a fvMesh is available
|
|
||||||
if (isA<fvMesh>(obr_))
|
|
||||||
{
|
|
||||||
read(dict);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
active_ = false;
|
|
||||||
WarningIn
|
|
||||||
(
|
|
||||||
"residualControl::residualControl"
|
|
||||||
"("
|
|
||||||
"const word&, "
|
|
||||||
"const objectRegistry&, "
|
|
||||||
"const dictionary&, "
|
|
||||||
"const bool"
|
|
||||||
")"
|
|
||||||
) << "No fvMesh available, deactivating."
|
|
||||||
<< nl << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::residualControl::~residualControl()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
void Foam::residualControl::read(const dictionary& dict)
|
|
||||||
{
|
|
||||||
if (active_)
|
|
||||||
{
|
|
||||||
maxResiduals_ = dict.subDict("maxResiduals");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::residualControl::execute()
|
|
||||||
{
|
|
||||||
if (active_)
|
|
||||||
{
|
|
||||||
criteriaSatisfied_ = checkCriteria(false);
|
|
||||||
|
|
||||||
if (criteriaSatisfied_)
|
|
||||||
{
|
|
||||||
Info<< "Convergence criteria satisfied - finalising run" << nl
|
|
||||||
<< endl;
|
|
||||||
|
|
||||||
checkCriteria(true);
|
|
||||||
|
|
||||||
Info<< endl;
|
|
||||||
|
|
||||||
const fvMesh& mesh = static_cast<const fvMesh&>(obr_);
|
|
||||||
Time& time = const_cast<Time&>(mesh.time());
|
|
||||||
time.writeAndEnd();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::residualControl::end()
|
|
||||||
{
|
|
||||||
if (active_)
|
|
||||||
{
|
|
||||||
if (criteriaSatisfied_)
|
|
||||||
{
|
|
||||||
Info<< "Residual control criteria satisfied" << nl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< "Residual control criteria not satisfied" << nl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::residualControl::write()
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,152 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2010-2010 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/>.
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::residualControl
|
|
||||||
|
|
||||||
Description
|
|
||||||
Function object that allows users to set target convergence criteria, and
|
|
||||||
stop the run if the conditions are satisfied.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
residualControl.C
|
|
||||||
IOresidualControl.H
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef residualControl_H
|
|
||||||
#define residualControl_H
|
|
||||||
|
|
||||||
#include "dictionary.H"
|
|
||||||
#include "pointFieldFwd.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
// Forward declaration of classes
|
|
||||||
class objectRegistry;
|
|
||||||
class dictionary;
|
|
||||||
class mapPolyMesh;
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class residualControl Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class residualControl
|
|
||||||
{
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Private data
|
|
||||||
|
|
||||||
//- Name of this object
|
|
||||||
word name_;
|
|
||||||
|
|
||||||
//- Reference to object registry
|
|
||||||
const objectRegistry& obr_;
|
|
||||||
|
|
||||||
//- On/off switch - on if obr_ is an fvMesh object
|
|
||||||
bool active_;
|
|
||||||
|
|
||||||
//- Dictionary of variable names vs max residual
|
|
||||||
dictionary maxResiduals_;
|
|
||||||
|
|
||||||
//- Flag to indicate whether convergence criteria have been met
|
|
||||||
bool criteriaSatisfied_;
|
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
|
||||||
|
|
||||||
//- Perform residual control checks
|
|
||||||
bool checkCriteria(const bool verbose) const;
|
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
|
||||||
residualControl(const residualControl&);
|
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const residualControl&);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
//- Runtime type information
|
|
||||||
TypeName("residualControl");
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct for given objectRegistry and dictionary.
|
|
||||||
// Allow the possibility to load fields from files
|
|
||||||
residualControl
|
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const objectRegistry& obr,
|
|
||||||
const dictionary& dict,
|
|
||||||
const bool loadFromFilesUnused = false
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
|
||||||
virtual ~residualControl();
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
//- Return name of the residual criteria check name
|
|
||||||
virtual const word& name() const
|
|
||||||
{
|
|
||||||
return name_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Read the system calls
|
|
||||||
virtual void read(const dictionary&);
|
|
||||||
|
|
||||||
//- Check the residual criteria at each time-step
|
|
||||||
virtual void execute();
|
|
||||||
|
|
||||||
//- Report residual criteria check at the final time-loop
|
|
||||||
virtual void end();
|
|
||||||
|
|
||||||
//- Write, not used
|
|
||||||
virtual void write();
|
|
||||||
|
|
||||||
//- Update for changes of mesh
|
|
||||||
virtual void updateMesh(const mapPolyMesh&)
|
|
||||||
{}
|
|
||||||
|
|
||||||
//- Update for changes of mesh
|
|
||||||
virtual void movePoints(const pointField&)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2010-2010 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/>.
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "residualControlFunctionObject.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
defineNamedTemplateTypeNameAndDebug(residualControlFunctionObject, 0);
|
|
||||||
|
|
||||||
addToRunTimeSelectionTable
|
|
||||||
(
|
|
||||||
functionObject,
|
|
||||||
residualControlFunctionObject,
|
|
||||||
dictionary
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -1,54 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2010-2010 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/>.
|
|
||||||
|
|
||||||
Typedef
|
|
||||||
Foam::residualControlFunctionObject
|
|
||||||
|
|
||||||
Description
|
|
||||||
FunctionObject wrapper around residualControl to allow them to be created
|
|
||||||
via the functions entry within controlDict.
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
residualControlFunctionObject.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef residualControlFunctionObject_H
|
|
||||||
#define residualControlFunctionObject_H
|
|
||||||
|
|
||||||
#include "residualControl.H"
|
|
||||||
#include "OutputFilterFunctionObject.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
typedef OutputFilterFunctionObject<residualControl>
|
|
||||||
residualControlFunctionObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
Reference in New Issue
Block a user