solvers::functions: Prevent creation of a functions sub-solver

This commit is contained in:
Will Bainbridge
2024-03-15 14:48:51 +00:00
parent bb77e8e66f
commit d8df578920

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 OpenFOAM Foundation \\ / A nd | Copyright (C) 2023-2024 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,12 +45,21 @@ Foam::solvers::functions::functions(fvMesh& mesh)
movingMesh(mesh) movingMesh(mesh)
{ {
// Read the solverName from the subSolver or solver entry in controlDict // Read the solverName from the subSolver or solver entry in controlDict
const word solverName word solverName;
( if (functionObject::postProcess)
runTime.controlDict().found("subSolver") {
? runTime.controlDict().lookup("subSolver") solverName = runTime.controlDict().lookup<word>("solver");
: runTime.controlDict().lookup("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)); Time& time(const_cast<Time&>(runTime));
const TimeState ts(time); const TimeState ts(time);
@ -69,7 +78,7 @@ Foam::solvers::functions::functions(fvMesh& mesh)
} }
// Instantiate the selected solver // Instantiate the selected solver
solverPtr = (solver::New(solverName, mesh)); solverPtr = solver::New(solverName, mesh);
if (startTimeChanged) if (startTimeChanged)
{ {