ENH: support alternative registration name for solution "data" (#2797)
This commit is contained in:
parent
1cdba9b269
commit
f4df00a4e9
@ -660,9 +660,9 @@ public:
|
||||
// alpha is read from controlDict
|
||||
void relax();
|
||||
|
||||
//- Select the final iteration parameters if `final' is true
|
||||
// by returning the field name + "Final"
|
||||
// otherwise the standard parameters by returning the field name
|
||||
//- Select the final iteration parameters if \c final is true
|
||||
//- by returning the field name + "Final"
|
||||
//- otherwise the standard parameters by returning the field name
|
||||
word select(bool final) const;
|
||||
|
||||
//- Helper function to write the min and max to an Ostream
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,48 +29,35 @@ License
|
||||
#include "data.H"
|
||||
#include "Time.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
int Foam::data::debug(Foam::debug::debugSwitch("data", 0));
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::data::data(const objectRegistry& obr)
|
||||
Foam::data::data
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary* content
|
||||
)
|
||||
:
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"data",
|
||||
name,
|
||||
obr.time().system(),
|
||||
obr,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
),
|
||||
prevTimeIndex_(0)
|
||||
{
|
||||
set("solverPerformance", dictionary());
|
||||
}
|
||||
|
||||
|
||||
Foam::data::data(const objectRegistry& obr, const dictionary& dict)
|
||||
:
|
||||
IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"data",
|
||||
obr.time().system(),
|
||||
obr,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
IOobject::NO_WRITE,
|
||||
IOobject::REGISTER
|
||||
),
|
||||
dict
|
||||
content
|
||||
),
|
||||
prevTimeIndex_(0)
|
||||
{}
|
||||
prevTimeIndex_(-1)
|
||||
{
|
||||
if (content == nullptr || !findDict("solverPerformance", keyType::LITERAL))
|
||||
{
|
||||
set("solverPerformance", dictionary());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -30,16 +30,17 @@ Class
|
||||
Description
|
||||
Database for solution data, solver performance and other reduced data.
|
||||
|
||||
fvMesh is derived from data so that all fields have access to the data from
|
||||
the mesh reference they hold.
|
||||
Both faMesh and fvMesh are derived from this class so that every
|
||||
GeometricField has access to this data via their mesh reference.
|
||||
|
||||
SourceFiles
|
||||
data.C
|
||||
dataTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef data_H
|
||||
#define data_H
|
||||
#ifndef Foam_data_H
|
||||
#define Foam_data_H
|
||||
|
||||
#include "IOdictionary.H"
|
||||
#include "solverPerformance.H"
|
||||
@ -57,7 +58,7 @@ class data
|
||||
:
|
||||
public IOdictionary
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- Previously used time-index, used for reset between iterations
|
||||
mutable label prevTimeIndex_;
|
||||
@ -65,26 +66,69 @@ class data
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- True if boolean entry exists and is set
|
||||
bool getBoolEntry(const word& keyword) const
|
||||
{
|
||||
bool value = false;
|
||||
return readIfPresent(keyword, value) && value;
|
||||
}
|
||||
|
||||
//- Add/remove boolean entry
|
||||
void setBoolEntry(const word& keyword, bool on)
|
||||
{
|
||||
if (on)
|
||||
{
|
||||
add(keyword, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
remove(keyword);
|
||||
}
|
||||
}
|
||||
|
||||
//- No copy construct
|
||||
data(const data&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const data&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Debug switch
|
||||
static int debug;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for objectRegistry
|
||||
data(const objectRegistry& obr);
|
||||
//- Construct for objectRegistry (registered with specified name)
|
||||
//- optionally with initial content
|
||||
data
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary* content = nullptr
|
||||
);
|
||||
|
||||
//- Construct for objectRegistry and initial contents
|
||||
data(const objectRegistry& obr, const dictionary& dict);
|
||||
//- Construct for objectRegistry (registered as "data")
|
||||
explicit data(const objectRegistry& obr)
|
||||
:
|
||||
data("data", obr)
|
||||
{}
|
||||
|
||||
//- Construct for objectRegistry (registered with specified name)
|
||||
//- copying initial content
|
||||
data
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
data(name, obr, &dict)
|
||||
{}
|
||||
|
||||
//- Construct for objectRegistry (registered as "data")
|
||||
//- copying initial content
|
||||
data(const objectRegistry& obr, const dictionary& dict)
|
||||
:
|
||||
data("data", obr, &dict)
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -93,6 +137,31 @@ public:
|
||||
//- includes initial and final residuals for convergence checking
|
||||
const dictionary& solverPerformanceDict() const;
|
||||
|
||||
//- True if "firstIteration" entry exists and is set
|
||||
bool isFirstIteration() const
|
||||
{
|
||||
return getBoolEntry("firstIteration");
|
||||
}
|
||||
|
||||
//- True if "finalIteration" entry exists and is set
|
||||
bool isFinalIteration() const
|
||||
{
|
||||
return getBoolEntry("finalIteration");
|
||||
}
|
||||
|
||||
//- Add/remove "firstIteration" entry
|
||||
void isFirstIteration(bool on)
|
||||
{
|
||||
return setBoolEntry("firstIteration", on);
|
||||
}
|
||||
|
||||
//- Add/remove "finalIteration" entry
|
||||
void isFinalIteration(bool on)
|
||||
{
|
||||
return setBoolEntry("finalIteration", on);
|
||||
}
|
||||
|
||||
|
||||
//- Add/set the solverPerformance entry for the named field
|
||||
template<class Type>
|
||||
void setSolverPerformance
|
||||
|
@ -53,8 +53,7 @@ void Foam::data::setSolverPerformance
|
||||
dict.readIfPresent(name, perfs);
|
||||
}
|
||||
|
||||
// Append to list
|
||||
perfs.setSize(perfs.size()+1, sp);
|
||||
perfs.push_back(sp);
|
||||
|
||||
dict.set(name, perfs);
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ Foam::faMesh::faMesh
|
||||
faSchemes(mesh()),
|
||||
edgeInterpolation(*this),
|
||||
faSolution(mesh()),
|
||||
data(mesh()), // Always NO_READ, NO_WRITE
|
||||
data(faMesh::thisDb()), // Always NO_READ, NO_WRITE
|
||||
faceLabels_
|
||||
(
|
||||
IOobject
|
||||
@ -473,7 +473,7 @@ Foam::faMesh::faMesh
|
||||
faSchemes(mesh(), io.readOpt()),
|
||||
edgeInterpolation(*this),
|
||||
faSolution(mesh(), io.readOpt()),
|
||||
data(mesh()), // Always NO_READ, NO_WRITE
|
||||
data(faMesh::thisDb()), // Always NO_READ, NO_WRITE
|
||||
faceLabels_
|
||||
(
|
||||
IOobject
|
||||
@ -558,7 +558,7 @@ Foam::faMesh::faMesh
|
||||
),
|
||||
data
|
||||
(
|
||||
mesh(),
|
||||
faMesh::thisDb(),
|
||||
static_cast<const data&>(baseMesh)
|
||||
),
|
||||
faceLabels_
|
||||
|
Loading…
Reference in New Issue
Block a user