ENH: support 'if-present' handling of relaxation coefficients

- new

  scalar relaxCoeff = 0;
  if (solution().relaxEquation(name, relaxCoeff))
  {
      relax(relaxCoeff);
  }

  // or
  scalar relaxCoeff = 0;
  solution().relaxEquation(name, relaxCoeff);

- old

  if (solution().relaxEquation(name))
  {
      relax(solution().equationRelaxationFactor(name));
  }

  // or
  scalar relaxCoeff = 0;
  if (solution().relaxEquation(name))
  {
      relaxCoeff = solution().equationRelaxationFactor(name);
  }
This commit is contained in:
Mark Olesen
2023-11-11 09:58:53 +01:00
parent 42feffc794
commit 30a7c22563
10 changed files with 100 additions and 58 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -173,10 +173,7 @@ bool Foam::functionObjects::age::execute()
// Set under-relaxation coeff
scalar relaxCoeff = 0;
if (mesh_.relaxEquation(schemesField_))
{
relaxCoeff = mesh_.equationRelaxationFactor(schemesField_);
}
mesh_.relaxEquation(schemesField_, relaxCoeff);
Foam::fv::options& fvOptions(Foam::fv::options::New(mesh_));

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2022 OpenCFD Ltd.
Copyright (C) 2017-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -371,11 +371,8 @@ bool Foam::functionObjects::energyTransport::execute()
);
// Set under-relaxation coeff
scalar relaxCoeff = 0.0;
if (mesh_.relaxEquation(schemesField_))
{
relaxCoeff = mesh_.equationRelaxationFactor(schemesField_);
}
scalar relaxCoeff = 0;
mesh_.relaxEquation(schemesField_, relaxCoeff);
if (phi.dimensions() == dimMass/dimTime)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd.
Copyright (C) 2015-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -263,11 +263,8 @@ bool Foam::functionObjects::scalarTransport::execute()
word laplacianScheme("laplacian(" + D.name() + "," + schemesField_ + ")");
// Set under-relaxation coeff
scalar relaxCoeff = 0.0;
if (mesh_.relaxEquation(schemesField_))
{
relaxCoeff = mesh_.equationRelaxationFactor(schemesField_);
}
scalar relaxCoeff = 0;
mesh_.relaxEquation(schemesField_, relaxCoeff);
// Two phase scalar transport
if (phaseName_ != "none")