Residuals: New MeshObject class to store solver performance residuals

This is more efficient and modular than the previous approach of storing the
residuals in the mesh data dictionary.
This commit is contained in:
Henry Weller
2019-04-04 19:08:08 +01:00
parent 28cebf7020
commit 2f3d47ad7e
24 changed files with 371 additions and 172 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -112,10 +112,6 @@ int main(int argc, char *argv[])
<< "Detailed SolverPerformance<symmTensor>: " << nl << "Detailed SolverPerformance<symmTensor>: " << nl
<< " " << sP << endl; << " " << sP << endl;
Info<< nl
<< "solverPerformanceDict: "
<< mesh.solverPerformanceDict() << endl;
return 0; return 0;
} }

View File

@ -709,5 +709,6 @@ $(writers)/xmgrGraph/xmgrGraph.C
$(writers)/jplotGraph/jplotGraph.C $(writers)/jplotGraph/jplotGraph.C
meshes/data/data.C meshes/data/data.C
meshes/Residuals/residuals.C
LIB = $(FOAM_LIBBIN)/libOpenFOAM LIB = $(FOAM_LIBBIN)/libOpenFOAM

View File

@ -0,0 +1,120 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "Residuals.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::Residuals<Type>::Residuals(const polyMesh& mesh)
:
MeshObject<polyMesh, GeometricMeshObject, Residuals<Type>>(mesh),
prevTimeIndex_(-1)
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
template<class Type>
Foam::List<Foam::word> Foam::Residuals<Type>::fieldNames(const polyMesh& mesh)
{
return MeshObject<polyMesh, GeometricMeshObject, Residuals<Type>>::New
(
mesh
).HashTable<DynamicList<SolverPerformance<Type>>>::toc();
}
template<class Type>
bool Foam::Residuals<Type>::found(const polyMesh& mesh, const word& fieldName)
{
return MeshObject<polyMesh, GeometricMeshObject, Residuals<Type>>::New
(
mesh
).HashTable<DynamicList<SolverPerformance<Type>>>::found(fieldName);
}
template<class Type>
const Foam::DynamicList<Foam::SolverPerformance<Type>>&
Foam::Residuals<Type>::field
(
const polyMesh& mesh,
const word& fieldName
)
{
return MeshObject<polyMesh, GeometricMeshObject, Residuals<Type>>::New
(
mesh
)[fieldName];
}
template<class Type>
void Foam::Residuals<Type>::append
(
const polyMesh& mesh,
const SolverPerformance<Type>& sp
)
{
Residuals<Type>& residuals = const_cast<Residuals<Type>&>
(
MeshObject<polyMesh, GeometricMeshObject, Residuals<Type>>::New
(
mesh
)
);
HashTable<DynamicList<SolverPerformance<Type>>>& table = residuals;
const label timeIndex =
mesh.time().subCycling()
? mesh.time().prevTimeState().timeIndex()
: mesh.time().timeIndex();
if (residuals.prevTimeIndex_ != timeIndex)
{
// Reset solver performance between iterations
residuals.prevTimeIndex_ = timeIndex;
table.clear();
}
if (table.found(sp.fieldName()))
{
table[sp.fieldName()].append(sp);
}
else
{
table.insert
(
sp.fieldName(),
DynamicList<SolverPerformance<Type>>(1, sp)
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
Class
Foam::Residuals
Description
MeshObject to store the solver performance residuals of all the fields
of the type it is instantiated on.
SourceFiles
Residuals.C
\*---------------------------------------------------------------------------*/
#ifndef Residuals_H
#define Residuals_H
#include "MeshObject.H"
#include "polyMesh.H"
#include "solverPerformance.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class Residuals Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class Residuals
:
public MeshObject<polyMesh, GeometricMeshObject, Residuals<Type>>,
public HashTable<DynamicList<SolverPerformance<Type>>>
{
// Private data
//- Previously used time-index, used for reset between iterations
mutable label prevTimeIndex_;
// Private Member Functions
//- Disallow default bitwise copy construct
Residuals(const Residuals<Type>&);
//- Disallow default bitwise assignment
void operator=(const Residuals<Type>&);
public:
//- Runtime type information
TypeName("residuals");
// Constructors
//- Construct for given mesh
Residuals(const polyMesh& mesh);
// Member Functions
//- Return the list of field names of the particular type
// for which residuals are stored
static List<word> fieldNames(const polyMesh& mesh);
//- Return true if residuals for the given field are stored
static bool found(const polyMesh& mesh, const word& fieldName);
//- Return the list of solver performance residuals for the given field
static const DynamicList<SolverPerformance<Type>>& field
(
const polyMesh& mesh,
const word& fieldName
);
//- Append the given solver performance residuals
// in the corresponding list
static void append
(
const polyMesh& mesh,
const SolverPerformance<Type>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "Residuals.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation \\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,55 +23,21 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "data.H" #include "Residuals.H"
#include "Time.H" #include "fieldTypes.H"
#include "solverPerformance.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> #define makeResiduals(Type) \
void Foam::data::setSolverPerformance defineTemplateTypeNameAndDebug(Residuals<Type>, 0);
(
const word& name, namespace Foam
const SolverPerformance<Type>& sp
) const
{ {
dictionary& dict = const_cast<dictionary&>(solverPerformanceDict()); makeResiduals(scalar);
makeResiduals(vector);
// Use a DynamicList to improve performance of the append makeResiduals(sphericalTensor);
DynamicList<SolverPerformance<Type>> perfs; makeResiduals(symmTensor);
makeResiduals(tensor);
const label timeIndex =
this->time().subCycling()
? this->time().prevTimeState().timeIndex()
: this->time().timeIndex();
if (prevTimeIndex_ != timeIndex)
{
// Reset solver performance between iterations
prevTimeIndex_ = timeIndex;
dict.clear();
} }
else
{
dict.readIfPresent(name, perfs);
}
// Append to list
perfs.append(sp);
dict.set(name, perfs);
}
template<class Type>
void Foam::data::setSolverPerformance
(
const SolverPerformance<Type>& sp
) const
{
setSolverPerformance(sp.fieldName(), sp);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -44,19 +44,8 @@ Foam::data::data(const objectRegistry& obr)
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
) )
), )
prevTimeIndex_(-1) {}
{
set("solverPerformance", dictionary());
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::dictionary& Foam::data::solverPerformanceDict() const
{
return subDict("solverPerformance");
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,7 +25,7 @@ Class
Foam::data Foam::data
Description Description
Database for solution data, solver performance and other reduced data. Database for solution and other reduced data.
fvMesh is derived from data so that all fields have access to the data from fvMesh is derived from data so that all fields have access to the data from
the mesh reference they hold. the mesh reference they hold.
@ -39,7 +39,6 @@ SourceFiles
#define data_H #define data_H
#include "IOdictionary.H" #include "IOdictionary.H"
#include "solverPerformance.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,12 +53,6 @@ class data
: :
public IOdictionary public IOdictionary
{ {
// Private data
//- Previously used time-index, used for reset between iterations
mutable label prevTimeIndex_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
@ -79,31 +72,6 @@ public:
//- Construct for objectRegistry //- Construct for objectRegistry
data(const objectRegistry& obr); data(const objectRegistry& obr);
// Member Functions
// Access
//- Return the dictionary of solver performance data
// which includes initial and final residuals for convergence
// checking
const dictionary& solverPerformanceDict() const;
//- Add/set the solverPerformance entry for the named field
template<class Type>
void setSolverPerformance
(
const word& name,
const SolverPerformance<Type>&
) const;
//- Add/set the solverPerformance entry, using its fieldName
template<class Type>
void setSolverPerformance
(
const SolverPerformance<Type>&
) const;
}; };
@ -113,12 +81,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "dataTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "staticFvMesh.H" #include "staticFvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -36,29 +36,37 @@ namespace Foam
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::DynamicList<Foam::word> Foam::convergenceControl::getFieldNames
(
const fvMesh& mesh
)
{
DynamicList<word> fieldNames;
getFieldTypeNames<scalar>(mesh, fieldNames);
getFieldTypeNames<vector>(mesh, fieldNames);
getFieldTypeNames<sphericalTensor>(mesh, fieldNames);
getFieldTypeNames<symmTensor>(mesh, fieldNames);
getFieldTypeNames<tensor>(mesh, fieldNames);
return fieldNames;
}
void Foam::convergenceControl::getInitialResiduals void Foam::convergenceControl::getInitialResiduals
( (
const fvMesh& mesh, const fvMesh& mesh,
const word& fieldName, const word& fieldName,
const label solvei, const label solvei,
ITstream& data,
scalar& r0, scalar& r0,
scalar& r scalar& r
) )
{ {
getInitialTypeResiduals<scalar>(mesh, fieldName, solvei, data, r0, r); getInitialTypeResiduals<scalar>(mesh, fieldName, solvei, r0, r);
getInitialTypeResiduals<vector>(mesh, fieldName, solvei, data, r0, r); getInitialTypeResiduals<vector>(mesh, fieldName, solvei, r0, r);
getInitialTypeResiduals<sphericalTensor> getInitialTypeResiduals<sphericalTensor>(mesh, fieldName, solvei, r0, r);
( getInitialTypeResiduals<symmTensor>(mesh, fieldName, solvei, r0, r);
mesh, getInitialTypeResiduals<tensor>(mesh, fieldName, solvei, r0, r);
fieldName,
solvei,
data,
r0,
r
);
getInitialTypeResiduals<symmTensor>(mesh, fieldName, solvei, data, r0, r);
getInitialTypeResiduals<tensor>(mesh, fieldName, solvei, data, r0, r);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -65,6 +65,10 @@ public:
// Static Functions // Static Functions
//- Get the list of names of the fields
// for which residual data is available
static DynamicList<word> getFieldNames(const fvMesh& mesh);
//- Get the initial residuals for the first and the i-th solves in this //- Get the initial residuals for the first and the i-th solves in this
// time-step // time-step
static void getInitialResiduals static void getInitialResiduals
@ -72,7 +76,6 @@ public:
const fvMesh& mesh, const fvMesh& mesh,
const word& fieldName, const word& fieldName,
const label solvei, const label solvei,
ITstream& data,
scalar& r0, scalar& r0,
scalar& r scalar& r
); );
@ -90,6 +93,14 @@ public:
const bool useRegEx=true const bool useRegEx=true
); );
//- Append the of names of the fields of this Type to the given list
template<class Type>
static void getFieldTypeNames
(
const fvMesh& mesh,
DynamicList<word>& fieldNames
);
//- Get the initial residuals for the first and the i-th solves in this //- Get the initial residuals for the first and the i-th solves in this
// time-step // time-step
template<class Type> template<class Type>
@ -98,7 +109,6 @@ public:
const fvMesh& mesh, const fvMesh& mesh,
const word& fieldName, const word& fieldName,
const label solvei, const label solvei,
ITstream& data,
scalar& r0, scalar& r0,
scalar& r scalar& r
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,6 +23,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "Residuals.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class ResidualData> template<class ResidualData>
@ -49,13 +51,23 @@ Foam::label Foam::convergenceControl::residualControlIndex
} }
template<class Type>
void Foam::convergenceControl::getFieldTypeNames
(
const fvMesh& mesh,
DynamicList<word>& fieldNames
)
{
fieldNames.append(Residuals<Type>::fieldNames(mesh));
}
template<class Type> template<class Type>
void Foam::convergenceControl::getInitialTypeResiduals void Foam::convergenceControl::getInitialTypeResiduals
( (
const fvMesh& mesh, const fvMesh& mesh,
const word& fieldName, const word& fieldName,
const label solvei, const label solvei,
ITstream& data,
scalar& r0, scalar& r0,
scalar& r scalar& r
) )
@ -64,7 +76,11 @@ void Foam::convergenceControl::getInitialTypeResiduals
if (mesh.foundObject<fieldType>(fieldName)) if (mesh.foundObject<fieldType>(fieldName))
{ {
const List<SolverPerformance<Type>> sp(data); const DynamicList<SolverPerformance<Type>>& sp
(
Residuals<Type>::field(mesh, fieldName)
);
r0 = cmptMax(sp[0].initialResidual()); r0 = cmptMax(sp[0].initialResidual());
r = cmptMax(sp[solvei].initialResidual()); r = cmptMax(sp[solvei].initialResidual());
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -40,15 +40,14 @@ void Foam::correctorConvergenceControl::getNSolves
( (
const fvMesh& mesh, const fvMesh& mesh,
const word& fieldName, const word& fieldName,
ITstream& data,
label& n label& n
) )
{ {
getNTypeSolves<scalar>(mesh, fieldName, data, n); getNTypeSolves<scalar>(mesh, fieldName, n);
getNTypeSolves<vector>(mesh, fieldName, data, n); getNTypeSolves<vector>(mesh, fieldName, n);
getNTypeSolves<sphericalTensor>(mesh, fieldName, data, n); getNTypeSolves<sphericalTensor>(mesh, fieldName, n);
getNTypeSolves<symmTensor>(mesh, fieldName, data, n); getNTypeSolves<symmTensor>(mesh, fieldName, n);
getNTypeSolves<tensor>(mesh, fieldName, data, n); getNTypeSolves<tensor>(mesh, fieldName, n);
} }

View File

@ -93,7 +93,6 @@ protected:
( (
const fvMesh& mesh, const fvMesh& mesh,
const word& fieldName, const word& fieldName,
ITstream& data,
label& n label& n
); );
@ -107,7 +106,6 @@ protected:
( (
const fvMesh& mesh, const fvMesh& mesh,
const word& fieldName, const word& fieldName,
ITstream& data,
label& n label& n
); );

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,6 +23,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "Residuals.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
@ -30,7 +32,6 @@ void Foam::correctorConvergenceControl::getNTypeSolves
( (
const fvMesh& mesh, const fvMesh& mesh,
const word& fieldName, const word& fieldName,
ITstream& data,
label& n label& n
) )
{ {
@ -38,7 +39,11 @@ void Foam::correctorConvergenceControl::getNTypeSolves
if (mesh.foundObject<fieldType>(fieldName)) if (mesh.foundObject<fieldType>(fieldName))
{ {
const List<SolverPerformance<Type>> sp(data); const DynamicList<SolverPerformance<Type>>& sp
(
Residuals<Type>::field(mesh, fieldName)
);
n = sp.size(); n = sp.size();
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -151,21 +151,21 @@ bool Foam::singleRegionConvergenceControl::criteriaSatisfied() const
Info<< control_.algorithmName() << ": Residuals" << endl; Info<< control_.algorithmName() << ": Residuals" << endl;
} }
const dictionary& solverDict = mesh_.solverPerformanceDict(); DynamicList<word> fieldNames(getFieldNames(mesh_));
forAllConstIter(dictionary, solverDict, iter)
forAll(fieldNames, i)
{ {
const word& variableName = iter().keyword(); const word& fieldName = fieldNames[i];
const label fieldi = const label fieldi =
residualControlIndex(variableName, residualControl_); residualControlIndex(fieldName, residualControl_);
if (fieldi != -1) if (fieldi != -1)
{ {
scalar residual; scalar residual;
getInitialResiduals getInitialResiduals
( (
mesh_, mesh_,
variableName, fieldName,
0, 0,
iter().stream(),
residual, residual,
residual residual
); );
@ -178,7 +178,7 @@ bool Foam::singleRegionConvergenceControl::criteriaSatisfied() const
if (control_.debug) if (control_.debug)
{ {
Info<< control_.algorithmSpace() << " " << variableName Info<< control_.algorithmSpace() << " " << fieldName
<< ": tolerance " << residual << " (" << ": tolerance " << residual << " ("
<< residualControl_[fieldi].absTol << ")" << residualControl_[fieldi].absTol << ")"
<< (absCheck ? " CONVERGED" : "") << endl; << (absCheck ? " CONVERGED" : "") << endl;

View File

@ -173,10 +173,11 @@ corrCriteriaSatisfied() const
Info<< control_.algorithmName() << ": Correction residuals" << endl; Info<< control_.algorithmName() << ": Correction residuals" << endl;
} }
const dictionary& solverDict = mesh_.solverPerformanceDict(); DynamicList<word> fieldNames(convergenceControl::getFieldNames(mesh_));
forAllConstIter(dictionary, solverDict, iter)
forAll(fieldNames, i)
{ {
const word& fieldName = iter().keyword(); const word& fieldName = fieldNames[i];
const label fieldi = const label fieldi =
convergenceControl::residualControlIndex convergenceControl::residualControlIndex
( (
@ -191,7 +192,6 @@ corrCriteriaSatisfied() const
mesh_, mesh_,
fieldName, fieldName,
solveIndex_.found(fieldName) ? solveIndex_[fieldName] : 0, solveIndex_.found(fieldName) ? solveIndex_[fieldName] : 0,
iter().stream(),
firstResidual, firstResidual,
residual residual
); );
@ -230,15 +230,16 @@ void Foam::singleRegionCorrectorConvergenceControl::resetCorrSolveIndex()
void Foam::singleRegionCorrectorConvergenceControl::updateCorrSolveIndex() void Foam::singleRegionCorrectorConvergenceControl::updateCorrSolveIndex()
{ {
const dictionary& solverDict = mesh_.solverPerformanceDict(); DynamicList<word> fieldNames(convergenceControl::getFieldNames(mesh_));
forAllConstIter(dictionary, solverDict, iter)
forAll(fieldNames, i)
{ {
const word& fieldName = iter().keyword(); const word& fieldName = fieldNames[i];
getNSolves getNSolves
( (
mesh_, mesh_,
fieldName, fieldName,
iter().stream(),
solveIndex_(fieldName) solveIndex_(fieldName)
); );
} }

View File

@ -133,7 +133,7 @@ void Foam::freestreamPressureFvPatchScalarField::updateCoeffs()
const Field<scalar> magUp(mag(Up)); const Field<scalar> magUp(mag(Up));
const Field<vector>& nf = patch().nf(); const Field<vector> nf(patch().nf());
Field<scalar>& vf = valueFraction(); Field<scalar>& vf = valueFraction();

View File

@ -109,7 +109,7 @@ void Foam::freestreamVelocityFvPatchVectorField::updateCoeffs()
const Field<vector>& Up = *this; const Field<vector>& Up = *this;
const Field<scalar> magUp(mag(Up)); const Field<scalar> magUp(mag(Up));
const Field<vector>& nf = patch().nf(); const Field<vector> nf(patch().nf());
Field<scalar>& vf = valueFraction(); Field<scalar>& vf = valueFraction();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,6 +25,7 @@ License
#include "LduMatrix.H" #include "LduMatrix.H"
#include "diagTensorField.H" #include "diagTensorField.H"
#include "Residuals.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -209,7 +210,7 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solveSegregated
psi.correctBoundaryConditions(); psi.correctBoundaryConditions();
psi.mesh().setSolverPerformance(psi.name(), solverPerfVec); Residuals<Type>::append(psi.mesh(), solverPerfVec);
return solverPerfVec; return solverPerfVec;
} }
@ -269,7 +270,7 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solveCoupled
psi.correctBoundaryConditions(); psi.correctBoundaryConditions();
psi.mesh().setSolverPerformance(psi.name(), solverPerf); Residuals<Type>::append(psi.mesh(), solverPerf);
return solverPerf; return solverPerf;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fvScalarMatrix.H" #include "fvScalarMatrix.H"
#include "Residuals.H"
#include "extrapolatedCalculatedFvPatchFields.H" #include "extrapolatedCalculatedFvPatchFields.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -127,7 +128,7 @@ Foam::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
psi.correctBoundaryConditions(); psi.correctBoundaryConditions();
psi.mesh().setSolverPerformance(psi.name(), solverPerf); Residuals<scalar>::append(psi.mesh(), solverPerf);
return solverPerf; return solverPerf;
} }
@ -177,7 +178,7 @@ Foam::solverPerformance Foam::fvMatrix<Foam::scalar>::solveSegregated
psi.correctBoundaryConditions(); psi.correctBoundaryConditions();
psi.mesh().setSolverPerformance(psi.name(), solverPerf); Residuals<scalar>::append(psi.mesh(), solverPerf);
return solverPerf; return solverPerf;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "surfaceFieldValue.H" #include "surfaceFieldValue.H"
#include "Time.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,6 +25,7 @@ License
#include "residuals.H" #include "residuals.H"
#include "volFields.H" #include "volFields.H"
#include "Residuals.H"
#include "ListOps.H" #include "ListOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -63,13 +64,11 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
if (obr_.foundObject<fieldType>(fieldName)) if (obr_.foundObject<fieldType>(fieldName))
{ {
const Foam::dictionary& solverDict = mesh_.solverPerformanceDict(); if (Residuals<Type>::found(mesh_, fieldName))
if (solverDict.found(fieldName))
{ {
const List<SolverPerformance<Type>> sp const DynamicList<SolverPerformance<Type>>& sp
( (
solverDict.lookup(fieldName) Residuals<Type>::field(mesh_, fieldName)
); );
const Type& residual = sp.first().initialResidual(); const Type& residual = sp.first().initialResidual();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,6 +25,7 @@ License
#include "surfaceTensionModel.H" #include "surfaceTensionModel.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -14,8 +14,6 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
libs ("libmodifiedInletOutlet.so");
application rhoPimpleFoam; application rhoPimpleFoam;
startFrom latestTime; startFrom latestTime;