Commit 2941d038 authored by Andrew Heather's avatar Andrew Heather
Browse files

Merge branch 'issue-1452-solverInfo-writeResidualFields' into 'develop'

BUG: fixing various bugs for v2106

See merge request !420
parents 9dda3626 d92edabc
......@@ -24,6 +24,7 @@ It is likely incomplete...
- Hrvoje Jasak
- Alexander Kabat vel Job
- Thilo Knacke
- Shannon Leakey
- Tommaso Lucchini
- Graham Macpherson
- Alexey Matveichev
......
......@@ -105,7 +105,7 @@ Foam::solverPerformance Foam::PBiCG::solve
(
ConstPrecisionAdaptor<scalar, solveScalar>(rA)(),
fieldName_,
false
true
);
// --- Calculate normalisation factor
......
......@@ -104,7 +104,7 @@ Foam::solverPerformance Foam::PCG::scalarSolve
(
ConstPrecisionAdaptor<scalar, solveScalar>(rA)(),
fieldName_,
false
true
);
// --- Calculate normalisation factor
......
......@@ -140,7 +140,7 @@ Foam::solverPerformance Foam::smoothSolver::solve
(
ConstPrecisionAdaptor<scalar, solveScalar>(residual)(),
fieldName_,
false
true
);
// Calculate residual magnitude
......
......@@ -255,7 +255,7 @@ Foam::scalar Foam::Math::incGammaRatio_Q(const scalar a, const scalar x)
scalar sum = 0;
for (int n = 1; n <= 10; n++)
for (label n = 1; n <= 10; ++n)
{
sum += pow((-x), n)/((a + n)*factorial(n));
}
......@@ -393,7 +393,7 @@ Foam::scalar Foam::Math::incGammaRatio_Q(const scalar a, const scalar x)
{
scalar sum = 0;
for (int n = 0; n <= (a - 1); n++)
for (label n = 0; n <= (a - 1); ++n)
{
sum += pow(x, n)/factorial(n);
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -222,7 +222,7 @@ class DEShybrid
CH2_*max
(
scalar(0),
CDES_*delta/max(lTurb*g, 1.0e-15*L0_) - 0.5
CDES_*delta/max(lTurb*g, SMALL*L0_) - 0.5
)
);
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -66,12 +66,10 @@ Foam::LESModel<BasicTurbulenceModel>::LESModel
transport,
propertiesName
),
LESDict_(this->subOrEmptyDict("LES")),
turbulence_(LESDict_.get<Switch>("turbulence")),
turbulence_(LESDict_.getOrDefault<Switch>("turbulence", true)),
printCoeffs_(LESDict_.getOrDefault<Switch>("printCoeffs", false)),
coeffDict_(LESDict_.optionalSubDict(type + "Coeffs")),
kMin_
(
dimensioned<scalar>::getOrAddToDict
......@@ -82,7 +80,6 @@ Foam::LESModel<BasicTurbulenceModel>::LESModel
SMALL
)
),
epsilonMin_
(
dimensioned<scalar>::getOrAddToDict
......@@ -93,7 +90,6 @@ Foam::LESModel<BasicTurbulenceModel>::LESModel
SMALL
)
),
omegaMin_
(
dimensioned<scalar>::getOrAddToDict
......@@ -104,7 +100,6 @@ Foam::LESModel<BasicTurbulenceModel>::LESModel
SMALL
)
),
delta_
(
LESdelta::New
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2013-2017 OpenFOAM Foundation
Copyright (C) 2019-2020 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -66,12 +66,10 @@ Foam::RASModel<BasicTurbulenceModel>::RASModel
transport,
propertiesName
),
RASDict_(this->subOrEmptyDict("RAS")),
turbulence_(RASDict_.get<Switch>("turbulence")),
turbulence_(RASDict_.getOrDefault<Switch>("turbulence", true)),
printCoeffs_(RASDict_.getOrDefault<Switch>("printCoeffs", false)),
coeffDict_(RASDict_.optionalSubDict(type + "Coeffs")),
kMin_
(
dimensioned<scalar>::getOrAddToDict
......@@ -82,7 +80,6 @@ Foam::RASModel<BasicTurbulenceModel>::RASModel
SMALL
)
),
epsilonMin_
(
dimensioned<scalar>::getOrAddToDict
......@@ -93,7 +90,6 @@ Foam::RASModel<BasicTurbulenceModel>::RASModel
SMALL
)
),
omegaMin_
(
dimensioned<scalar>::getOrAddToDict
......
......@@ -49,8 +49,8 @@ atmBoundaryLayer::atmBoundaryLayer(const Time& time, const polyPatch& pp)
zDir_(time, "zDir"),
Uref_(time, "Uref"),
Zref_(time, "Zref"),
z0_(),
d_()
z0_(nullptr),
d_(nullptr)
{}
......@@ -182,8 +182,14 @@ tmp<scalarField> atmBoundaryLayer::Ustar(const scalarField& z0) const
void atmBoundaryLayer::autoMap(const fvPatchFieldMapper& mapper)
{
z0_->autoMap(mapper);
d_->autoMap(mapper);
if (z0_)
{
z0_->autoMap(mapper);
}
if (d_)
{
d_->autoMap(mapper);
}
}
......@@ -193,8 +199,14 @@ void atmBoundaryLayer::rmap
const labelList& addr
)
{
z0_->rmap(abl.z0_(), addr);
d_->rmap(abl.d_(), addr);
if (z0_)
{
z0_->rmap(abl.z0_(), addr);
}
if (d_)
{
d_->rmap(abl.d_(), addr);
}
}
......@@ -266,8 +278,14 @@ void atmBoundaryLayer::write(Ostream& os) const
zDir_.writeData(os);
Uref_.writeData(os);
Zref_.writeData(os);
z0_->writeData(os) ;
d_->writeData(os);
if (z0_)
{
z0_->writeData(os) ;
}
if (d_)
{
d_->writeData(os);
}
}
......
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -24,7 +25,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fv::gradientLimiters::minmod
Foam::fv::gradientLimiters::cubic
Description
Cubic gradient limiter
......@@ -44,9 +45,11 @@ Description
Michalak, K., & Ollivier-Gooch, C. (2008).
Limiters for unstructured higher-order accurate solutions
of the Euler equations.
In 46th AIAA Aerospace Sciences Meeting and Exhibit (p. 776).
In 46th AIAA Aerospace Sciences Meeting and Exhibition.
DOI:10.2514/6.2008-776
\endverbatim
Usage
Example:
\verbatim
gradSchemes
......@@ -57,8 +60,8 @@ Description
\endverbatim
See also
Foam::fv::cellLimitedGrad
Foam::fv::gradientLimiters::Venkatakrishnan
- Foam::fv::cellLimitedGrad
- Foam::fv::gradientLimiters::Venkatakrishnan
\*---------------------------------------------------------------------------*/
......@@ -102,8 +105,8 @@ public:
cubic(Istream& schemeData)
:
rt_(readScalar(schemeData)),
a_(2.0/sqr(rt_) - 2.0/pow3(rt_)),
b_(-(3.0/2.0)*a_*rt_)
a_((rt_ - 2)/pow3(rt_)),
b_(-(3*a_*sqr(rt_) + 1)/(2*rt_))
{
if (rt_ < 1)
{
......@@ -123,10 +126,8 @@ public:
{
return ((a_*r + b_)*r + 1)*r;
}
else
{
return 1;
}
return 1;
}
};
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -36,13 +36,7 @@ namespace Foam
namespace functionObjects
{
defineTypeNameAndDebug(solverInfo, 0);
addToRunTimeSelectionTable
(
functionObject,
solverInfo,
dictionary
);
addToRunTimeSelectionTable(functionObject, solverInfo, dictionary);
}
}
......@@ -96,7 +90,7 @@ void Foam::functionObjects::solverInfo::createResidualField
if (!mesh_.foundObject<IOField<scalar>>(residualName))
{
IOField<scalar>* fieldPtr =
auto* fieldPtr =
new IOField<scalar>
(
IOobject
......@@ -129,8 +123,8 @@ Foam::functionObjects::solverInfo::solverInfo
fvMeshFunctionObject(name, runTime, dict),
writeFile(obr_, name, typeName, dict),
fieldSet_(mesh_),
writeResidualFields_(false),
residualFieldNames_(),
writeResidualFields_(false),
initialised_(false)
{
read(dict);
......@@ -147,8 +141,7 @@ bool Foam::functionObjects::solverInfo::read(const dictionary& dict)
fieldSet_.read(dict);
writeResidualFields_ =
dict.getOrDefault("writeResidualFields", false);
writeResidualFields_ = dict.getOrDefault("writeResidualFields", false);
residualFieldNames_.clear();
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -31,7 +31,7 @@ Group
grpUtilitiesFunctionObjects
Description
Writes solver information for a list of user-specified fields
Writes solver information for a list of user-specified fields.
Information written to file includes:
- residual fields
......@@ -39,39 +39,60 @@ Description
- initial residual
- final residual
- number of solver iterations
- convergecnce flag
- convergence flag
Operands:
\table
Operand | Type | Location
input | - | -
output file | dat <!--
--> | postProcessing/\<FO\>/\<time\>/\<file\>(s)
output field | volScalarField(s) <!--
--> | \<time\>/initialResiduals:\<outField\>(s)
\endtable
Usage
Example of function object specification:
Minimal example by using \c system/controlDict.functions:
\verbatim
solverInfo
solverInfo1
{
// Mandatory entries (unmodifiable)
type solverInfo;
libs (utilityFunctionObjects);
// Mandatory entries (runtime modifiable)
fields (<field1> <field2> ... <fieldN>);
// Optional entries (runtime modifiable)
writeResidualFields true;
// Inherited entries
...
fields (U p);
writeResidualFields yes;
}
\endverbatim
Where the entries comprise:
where the entries mean:
\table
Property | Description | Required | Default value
type | Type name: solverInfo | yes |
fields | List of fields to process | yes |
writeResidualFields | Write the residual fields | no | no
Property | Description | Type | Reqd | Deflt
type | Type name: solverInfo | word | yes | -
libs | Library name: utilityFunctionObjects | word | yes | -
fields | Names of operand fields | wordList | yes | -
writeResidualFields | Flag to write the initial-residual fields <!--
--> | bool | no | false
\endtable
Output data is written to the dir postProcessing/solverInfo/\<timeDir\>/
The inherited entries are elaborated in:
- \link functionObject.H \endlink
- \link writeFile.H \endlink
See also
Foam::functionObject
Foam::functionObjects::fvMeshFunctionObject
Foam::functionObjects::writeFile
Foam::functionObjects::timeControl
- Foam::functionObject
- Foam::functionObjects::fvMeshFunctionObject
- Foam::functionObjects::writeFile
SourceFiles
solverInfo.C
solverInfoTemplates.C
\*---------------------------------------------------------------------------*/
......@@ -100,17 +121,17 @@ class solverInfo
{
protected:
// Protected data
// Protected Data
//- Fields to process
//- Names of operand fields
solverFieldSelection fieldSet_;
//- Flag to write the residual as a vol field
bool writeResidualFields_;
//- Names of (result) residual fields
wordHashSet residualFieldNames_;
//- Flag to write the initial-residual as a vol field
bool writeResidualFields_;
//- Initialisation flag
bool initialised_;
......@@ -136,9 +157,7 @@ protected:
void updateSolverInfo(const word& fieldName);
private:
// Private member functions
// Generated Methods
//- No copy construct
solverInfo(const solverInfo&) = delete;
......@@ -170,13 +189,13 @@ public:
// Member Functions
//- Read the controls
//- Read solverInfo settings
virtual bool read(const dictionary&);
//- Execute, currently does nothing
//- Execute solverInfo
virtual bool execute();
//- Write the solverInfo
//- Write solverInfo results
virtual bool write();
};
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -51,7 +51,7 @@ void Foam::functionObjects::solverInfo::writeFileHeader
mesh_.validComponents<Type>()
);
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; ++cmpt)
{
if (component(validComponents, cmpt) != -1)
{
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
solverInfo1
{
// Mandatory entries
type solverInfo;
libs (utilityFunctionObjects);
fields
(
k
epsilon
p
U
)
// Optional entries
writeResidualFields true;
// Optional (inherited) entries
writePrecision 16;
writeToFile true;
useUserTime true;
region region0;
enabled true;
log true;
timeStart 0;
timeEnd 1000;
executeControl timeStep;
executeInterval 1;
writeControl writeTime;
writeInterval -1;
}
// ************************************************************************* //
......@@ -47,6 +47,7 @@ runTimeModifiable true;
functions
{
// field function objects
#include "FOfieldAverage"
#include "FOadd"
#include "FOblendingFactor"
......@@ -94,6 +95,9 @@ functions
#include "FOwriteCellVolumes"
#include "FOyPlus"
#include "FOzeroGradient"
// utility function objects
#include "FOsolverInfo"
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment