ENH: cloudSolution - updated handling of under-relaxation

- unspecified field names now return a value of 1 by default
- new debug switch can be used to see default selections

STYLE: Minor code reformatting
This commit is contained in:
Andrew Heather
2023-11-14 17:18:30 +00:00
parent 9ac7982d64
commit dfdc2d95a7
2 changed files with 30 additions and 20 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd. Copyright (C) 2020-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,6 +30,13 @@ License
#include "Time.H" #include "Time.H"
#include "localEulerDdtScheme.H" #include "localEulerDdtScheme.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineDebugSwitchWithName(cloudSolution, "cloudSolution", 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cloudSolution::cloudSolution(const fvMesh& mesh, const dictionary& dict) Foam::cloudSolution::cloudSolution(const fvMesh& mesh, const dictionary& dict)
@ -116,12 +123,6 @@ Foam::cloudSolution::cloudSolution(const fvMesh& mesh)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::cloudSolution::~cloudSolution()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cloudSolution::read() void Foam::cloudSolution::read()
@ -209,17 +210,20 @@ void Foam::cloudSolution::read()
Foam::scalar Foam::cloudSolution::relaxCoeff(const word& fieldName) const Foam::scalar Foam::cloudSolution::relaxCoeff(const word& fieldName) const
{ {
forAll(schemes_, i) for (const auto& scheme : schemes_)
{ {
if (fieldName == schemes_[i].first()) if (fieldName == scheme.first())
{ {
return schemes_[i].second().second(); return scheme.second().second();
} }
} }
FatalErrorInFunction if (debug)
<< "Field name " << fieldName << " not found in schemes" {
<< abort(FatalError); WarningInFunction
<< "Field name " << fieldName << " not found in schemes. "
<< "Setting relaxation factor to 1" << endl;
}
return 1.0; return 1.0;
} }
@ -227,17 +231,20 @@ Foam::scalar Foam::cloudSolution::relaxCoeff(const word& fieldName) const
bool Foam::cloudSolution::semiImplicit(const word& fieldName) const bool Foam::cloudSolution::semiImplicit(const word& fieldName) const
{ {
forAll(schemes_, i) for (const auto& scheme : schemes_)
{ {
if (fieldName == schemes_[i].first()) if (fieldName == scheme.first())
{ {
return schemes_[i].second().first(); return scheme.second().first();
} }
} }
FatalErrorInFunction if (debug)
<< "Field name " << fieldName << " not found in schemes" {
<< abort(FatalError); WarningInFunction
<< "Field name " << fieldName << " not found in schemes. "
<< "Setting relaxation factor to 1" << endl;
}
return false; return false;
} }

View File

@ -120,6 +120,9 @@ class cloudSolution
public: public:
//- Debug switch
static int debug;
// Constructors // Constructors
//- Construct null from mesh reference //- Construct null from mesh reference
@ -133,7 +136,7 @@ public:
//- Destructor //- Destructor
virtual ~cloudSolution(); ~cloudSolution() = default;
// Member functions // Member functions