Skip to content

Commit

Permalink
solvers::functions: Prevent creation of a functions sub-solver
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bainbridge committed Mar 15, 2024
1 parent bb77e8e commit d8df578
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions applications/modules/functions/functions.C
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -45,12 +45,21 @@ Foam::solvers::functions::functions(fvMesh& mesh)
movingMesh(mesh)
{
// Read the solverName from the subSolver or solver entry in controlDict
const word solverName
(
runTime.controlDict().found("subSolver")
? runTime.controlDict().lookup("subSolver")
: runTime.controlDict().lookup("solver")
);
word solverName;
if (functionObject::postProcess)
{
solverName = runTime.controlDict().lookup<word>("solver");
}
if (!functionObject::postProcess || solverName == typeName)
{
solverName = runTime.controlDict().lookup<word>("subSolver");
}
if (solverName == typeName)
{
FatalIOErrorInFunction(runTime.controlDict())
<< "Invalid sub-solver type "
<< solverName << exit(FatalIOError);
}

Time& time(const_cast<Time&>(runTime));
const TimeState ts(time);
Expand All @@ -69,7 +78,7 @@ Foam::solvers::functions::functions(fvMesh& mesh)
}

// Instantiate the selected solver
solverPtr = (solver::New(solverName, mesh));
solverPtr = solver::New(solverName, mesh);

if (startTimeChanged)
{
Expand Down

0 comments on commit d8df578

Please sign in to comment.