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:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -112,10 +112,6 @@ int main(int argc, char *argv[])
|
||||
<< "Detailed SolverPerformance<symmTensor>: " << nl
|
||||
<< " " << sP << endl;
|
||||
|
||||
Info<< nl
|
||||
<< "solverPerformanceDict: "
|
||||
<< mesh.solverPerformanceDict() << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -709,5 +709,6 @@ $(writers)/xmgrGraph/xmgrGraph.C
|
||||
$(writers)/jplotGraph/jplotGraph.C
|
||||
|
||||
meshes/data/data.C
|
||||
meshes/Residuals/residuals.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libOpenFOAM
|
||||
|
||||
120
src/OpenFOAM/meshes/Residuals/Residuals.C
Normal file
120
src/OpenFOAM/meshes/Residuals/Residuals.C
Normal 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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
126
src/OpenFOAM/meshes/Residuals/Residuals.H
Normal file
126
src/OpenFOAM/meshes/Residuals/Residuals.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,55 +23,21 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "data.H"
|
||||
#include "Time.H"
|
||||
#include "solverPerformance.H"
|
||||
#include "Residuals.H"
|
||||
#include "fieldTypes.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::data::setSolverPerformance
|
||||
(
|
||||
const word& name,
|
||||
const SolverPerformance<Type>& sp
|
||||
) const
|
||||
#define makeResiduals(Type) \
|
||||
defineTemplateTypeNameAndDebug(Residuals<Type>, 0);
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
dictionary& dict = const_cast<dictionary&>(solverPerformanceDict());
|
||||
|
||||
// Use a DynamicList to improve performance of the append
|
||||
DynamicList<SolverPerformance<Type>> perfs;
|
||||
|
||||
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();
|
||||
makeResiduals(scalar);
|
||||
makeResiduals(vector);
|
||||
makeResiduals(sphericalTensor);
|
||||
makeResiduals(symmTensor);
|
||||
makeResiduals(tensor);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -44,19 +44,8 @@ Foam::data::data(const objectRegistry& obr)
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
prevTimeIndex_(-1)
|
||||
{
|
||||
set("solverPerformance", dictionary());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::dictionary& Foam::data::solverPerformanceDict() const
|
||||
{
|
||||
return subDict("solverPerformance");
|
||||
}
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::data
|
||||
|
||||
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
|
||||
the mesh reference they hold.
|
||||
@ -39,7 +39,6 @@ SourceFiles
|
||||
#define data_H
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "solverPerformance.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -54,12 +53,6 @@ class data
|
||||
:
|
||||
public IOdictionary
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Previously used time-index, used for reset between iterations
|
||||
mutable label prevTimeIndex_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -79,31 +72,6 @@ public:
|
||||
|
||||
//- Construct for objectRegistry
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "staticFvMesh.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,29 +36,37 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * 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
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& fieldName,
|
||||
const label solvei,
|
||||
ITstream& data,
|
||||
scalar& r0,
|
||||
scalar& r
|
||||
)
|
||||
{
|
||||
getInitialTypeResiduals<scalar>(mesh, fieldName, solvei, data, r0, r);
|
||||
getInitialTypeResiduals<vector>(mesh, fieldName, solvei, data, r0, r);
|
||||
getInitialTypeResiduals<sphericalTensor>
|
||||
(
|
||||
mesh,
|
||||
fieldName,
|
||||
solvei,
|
||||
data,
|
||||
r0,
|
||||
r
|
||||
);
|
||||
getInitialTypeResiduals<symmTensor>(mesh, fieldName, solvei, data, r0, r);
|
||||
getInitialTypeResiduals<tensor>(mesh, fieldName, solvei, data, r0, r);
|
||||
getInitialTypeResiduals<scalar>(mesh, fieldName, solvei, r0, r);
|
||||
getInitialTypeResiduals<vector>(mesh, fieldName, solvei, r0, r);
|
||||
getInitialTypeResiduals<sphericalTensor>(mesh, fieldName, solvei, r0, r);
|
||||
getInitialTypeResiduals<symmTensor>(mesh, fieldName, solvei, r0, r);
|
||||
getInitialTypeResiduals<tensor>(mesh, fieldName, solvei, r0, r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -65,6 +65,10 @@ public:
|
||||
|
||||
// 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
|
||||
// time-step
|
||||
static void getInitialResiduals
|
||||
@ -72,7 +76,6 @@ public:
|
||||
const fvMesh& mesh,
|
||||
const word& fieldName,
|
||||
const label solvei,
|
||||
ITstream& data,
|
||||
scalar& r0,
|
||||
scalar& r
|
||||
);
|
||||
@ -90,6 +93,14 @@ public:
|
||||
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
|
||||
// time-step
|
||||
template<class Type>
|
||||
@ -98,7 +109,6 @@ public:
|
||||
const fvMesh& mesh,
|
||||
const word& fieldName,
|
||||
const label solvei,
|
||||
ITstream& data,
|
||||
scalar& r0,
|
||||
scalar& r
|
||||
);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,6 +23,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Residuals.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
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>
|
||||
void Foam::convergenceControl::getInitialTypeResiduals
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& fieldName,
|
||||
const label solvei,
|
||||
ITstream& data,
|
||||
scalar& r0,
|
||||
scalar& r
|
||||
)
|
||||
@ -64,7 +76,11 @@ void Foam::convergenceControl::getInitialTypeResiduals
|
||||
|
||||
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());
|
||||
r = cmptMax(sp[solvei].initialResidual());
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -40,15 +40,14 @@ void Foam::correctorConvergenceControl::getNSolves
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& fieldName,
|
||||
ITstream& data,
|
||||
label& n
|
||||
)
|
||||
{
|
||||
getNTypeSolves<scalar>(mesh, fieldName, data, n);
|
||||
getNTypeSolves<vector>(mesh, fieldName, data, n);
|
||||
getNTypeSolves<sphericalTensor>(mesh, fieldName, data, n);
|
||||
getNTypeSolves<symmTensor>(mesh, fieldName, data, n);
|
||||
getNTypeSolves<tensor>(mesh, fieldName, data, n);
|
||||
getNTypeSolves<scalar>(mesh, fieldName, n);
|
||||
getNTypeSolves<vector>(mesh, fieldName, n);
|
||||
getNTypeSolves<sphericalTensor>(mesh, fieldName, n);
|
||||
getNTypeSolves<symmTensor>(mesh, fieldName, n);
|
||||
getNTypeSolves<tensor>(mesh, fieldName, n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -93,7 +93,6 @@ protected:
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& fieldName,
|
||||
ITstream& data,
|
||||
label& n
|
||||
);
|
||||
|
||||
@ -107,7 +106,6 @@ protected:
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& fieldName,
|
||||
ITstream& data,
|
||||
label& n
|
||||
);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,6 +23,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "Residuals.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -30,7 +32,6 @@ void Foam::correctorConvergenceControl::getNTypeSolves
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const word& fieldName,
|
||||
ITstream& data,
|
||||
label& n
|
||||
)
|
||||
{
|
||||
@ -38,7 +39,11 @@ void Foam::correctorConvergenceControl::getNTypeSolves
|
||||
|
||||
if (mesh.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const List<SolverPerformance<Type>> sp(data);
|
||||
const DynamicList<SolverPerformance<Type>>& sp
|
||||
(
|
||||
Residuals<Type>::field(mesh, fieldName)
|
||||
);
|
||||
|
||||
n = sp.size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -151,21 +151,21 @@ bool Foam::singleRegionConvergenceControl::criteriaSatisfied() const
|
||||
Info<< control_.algorithmName() << ": Residuals" << endl;
|
||||
}
|
||||
|
||||
const dictionary& solverDict = mesh_.solverPerformanceDict();
|
||||
forAllConstIter(dictionary, solverDict, iter)
|
||||
DynamicList<word> fieldNames(getFieldNames(mesh_));
|
||||
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& variableName = iter().keyword();
|
||||
const word& fieldName = fieldNames[i];
|
||||
const label fieldi =
|
||||
residualControlIndex(variableName, residualControl_);
|
||||
residualControlIndex(fieldName, residualControl_);
|
||||
if (fieldi != -1)
|
||||
{
|
||||
scalar residual;
|
||||
getInitialResiduals
|
||||
(
|
||||
mesh_,
|
||||
variableName,
|
||||
fieldName,
|
||||
0,
|
||||
iter().stream(),
|
||||
residual,
|
||||
residual
|
||||
);
|
||||
@ -178,7 +178,7 @@ bool Foam::singleRegionConvergenceControl::criteriaSatisfied() const
|
||||
|
||||
if (control_.debug)
|
||||
{
|
||||
Info<< control_.algorithmSpace() << " " << variableName
|
||||
Info<< control_.algorithmSpace() << " " << fieldName
|
||||
<< ": tolerance " << residual << " ("
|
||||
<< residualControl_[fieldi].absTol << ")"
|
||||
<< (absCheck ? " CONVERGED" : "") << endl;
|
||||
|
||||
@ -173,10 +173,11 @@ corrCriteriaSatisfied() const
|
||||
Info<< control_.algorithmName() << ": Correction residuals" << endl;
|
||||
}
|
||||
|
||||
const dictionary& solverDict = mesh_.solverPerformanceDict();
|
||||
forAllConstIter(dictionary, solverDict, iter)
|
||||
DynamicList<word> fieldNames(convergenceControl::getFieldNames(mesh_));
|
||||
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = iter().keyword();
|
||||
const word& fieldName = fieldNames[i];
|
||||
const label fieldi =
|
||||
convergenceControl::residualControlIndex
|
||||
(
|
||||
@ -191,7 +192,6 @@ corrCriteriaSatisfied() const
|
||||
mesh_,
|
||||
fieldName,
|
||||
solveIndex_.found(fieldName) ? solveIndex_[fieldName] : 0,
|
||||
iter().stream(),
|
||||
firstResidual,
|
||||
residual
|
||||
);
|
||||
@ -230,15 +230,16 @@ void Foam::singleRegionCorrectorConvergenceControl::resetCorrSolveIndex()
|
||||
|
||||
void Foam::singleRegionCorrectorConvergenceControl::updateCorrSolveIndex()
|
||||
{
|
||||
const dictionary& solverDict = mesh_.solverPerformanceDict();
|
||||
forAllConstIter(dictionary, solverDict, iter)
|
||||
DynamicList<word> fieldNames(convergenceControl::getFieldNames(mesh_));
|
||||
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = iter().keyword();
|
||||
const word& fieldName = fieldNames[i];
|
||||
|
||||
getNSolves
|
||||
(
|
||||
mesh_,
|
||||
fieldName,
|
||||
iter().stream(),
|
||||
solveIndex_(fieldName)
|
||||
);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ void Foam::freestreamPressureFvPatchScalarField::updateCoeffs()
|
||||
|
||||
const Field<scalar> magUp(mag(Up));
|
||||
|
||||
const Field<vector>& nf = patch().nf();
|
||||
const Field<vector> nf(patch().nf());
|
||||
|
||||
Field<scalar>& vf = valueFraction();
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ void Foam::freestreamVelocityFvPatchVectorField::updateCoeffs()
|
||||
const Field<vector>& Up = *this;
|
||||
const Field<scalar> magUp(mag(Up));
|
||||
|
||||
const Field<vector>& nf = patch().nf();
|
||||
const Field<vector> nf(patch().nf());
|
||||
|
||||
Field<scalar>& vf = valueFraction();
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "LduMatrix.H"
|
||||
#include "diagTensorField.H"
|
||||
#include "Residuals.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -209,7 +210,7 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solveSegregated
|
||||
|
||||
psi.correctBoundaryConditions();
|
||||
|
||||
psi.mesh().setSolverPerformance(psi.name(), solverPerfVec);
|
||||
Residuals<Type>::append(psi.mesh(), solverPerfVec);
|
||||
|
||||
return solverPerfVec;
|
||||
}
|
||||
@ -269,7 +270,7 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solveCoupled
|
||||
|
||||
psi.correctBoundaryConditions();
|
||||
|
||||
psi.mesh().setSolverPerformance(psi.name(), solverPerf);
|
||||
Residuals<Type>::append(psi.mesh(), solverPerf);
|
||||
|
||||
return solverPerf;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fvScalarMatrix.H"
|
||||
#include "Residuals.H"
|
||||
#include "extrapolatedCalculatedFvPatchFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -127,7 +128,7 @@ Foam::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
|
||||
|
||||
psi.correctBoundaryConditions();
|
||||
|
||||
psi.mesh().setSolverPerformance(psi.name(), solverPerf);
|
||||
Residuals<scalar>::append(psi.mesh(), solverPerf);
|
||||
|
||||
return solverPerf;
|
||||
}
|
||||
@ -177,7 +178,7 @@ Foam::solverPerformance Foam::fvMatrix<Foam::scalar>::solveSegregated
|
||||
|
||||
psi.correctBoundaryConditions();
|
||||
|
||||
psi.mesh().setSolverPerformance(psi.name(), solverPerf);
|
||||
Residuals<scalar>::append(psi.mesh(), solverPerf);
|
||||
|
||||
return solverPerf;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceFieldValue.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "residuals.H"
|
||||
#include "volFields.H"
|
||||
#include "Residuals.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -63,13 +64,11 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
|
||||
|
||||
if (obr_.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const Foam::dictionary& solverDict = mesh_.solverPerformanceDict();
|
||||
|
||||
if (solverDict.found(fieldName))
|
||||
if (Residuals<Type>::found(mesh_, 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();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "surfaceTensionModel.H"
|
||||
#include "fvMesh.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -14,8 +14,6 @@ FoamFile
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
libs ("libmodifiedInletOutlet.so");
|
||||
|
||||
application rhoPimpleFoam;
|
||||
|
||||
startFrom latestTime;
|
||||
|
||||
Reference in New Issue
Block a user