functionObjectList: Improved error message if a functionObject configuration file is not foundation

e.g. if streamlinesLines is specified rather than the correct streamlinesLine in
the controlDict::functions list:

functions
{
    #includeFunc streamlinesLines
    (
        funcName=streamlines,
        start=(-0.0205 0.001 0.00001),
        end=(-0.0205 0.0251 0.00001),
        nPoints=10,
        fields=(p k U)
    )
}

the following error message is generated providing a list of all the
functionObject configuration files available and the run stops rather than
continuing regardless of the error:

--> FOAM FATAL IO ERROR:
Cannot find functionObject configuration file streamlinesLines

Available configured functionObjects:
88
(
CourantNo
Lambda2
MachNo
PecletNo
Q
Qdot
XiReactionRate
add
age
boundaryProbes
cellMax
cellMaxMag
cellMin
cellMinMag
components
cutPlaneSurface
ddt
div
divide
dsmcFields
enstrophy
faceZoneAverage
faceZoneFlowRate
fieldAverage
flowType
forceCoeffsCompressible
forceCoeffsIncompressible
forcesCompressible
forcesIncompressible
grad
graphCell
graphCellFace
graphFace
graphLayerAverage
graphUniform
interfaceHeight
internalProbes
isoSurface
log
mag
magSqr
moments
multiply
particles
patchAverage
patchDifference
patchFlowRate
patchIntegrate
patchSurface
phaseForces
phaseMap
phaseScalarTransport
probes
randomise
residuals
scalarTransport
scale
shearStress
sizeDistribution
staticPressureIncompressible
stopAtClockTime
stopAtFile
streamFunction
streamlinesLine
streamlinesPatch
streamlinesPoints
streamlinesSphere
subtract
surfaceInterpolate
time
timeStep
totalEnthalpy
totalPressureCompressible
totalPressureIncompressible
triSurfaceDifference
triSurfaceVolumetricFlowRate
turbulenceFields
turbulenceIntensity
uniform
vorticity
wallHeatFlux
wallHeatTransferCoeff
wallShearStress
writeCellCentres
writeCellVolumes
writeObjects
writeVTK
yPlus
)

file: /home/dm2/henry/OpenFOAM/OpenFOAM-dev/tutorials/incompressible/simpleFoam/pitzDaily/system/controlDict/functions

    From function static bool Foam::functionObjectList::readFunctionObject(const Foam::string&, Foam::dictionary&, const Foam::Pair<Foam::string>&, const Foam::word&)
    in file db/functionObjects/functionObjectList/functionObjectList.C at line 250.

FOAM exiting
This commit is contained in:
Henry Weller
2022-01-26 12:02:07 +00:00
parent f2d4d82c34
commit 8cb90dab4f
5 changed files with 36 additions and 46 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -99,7 +99,7 @@ void Foam::functionObjectList::listDir
}
void Foam::functionObjectList::list()
Foam::wordList Foam::functionObjectList::list()
{
HashSet<word> foMap;
@ -110,10 +110,7 @@ void Foam::functionObjectList::list()
listDir(etcDirs[ed], foMap);
}
Info<< nl
<< "Available configured functionObjects:"
<< foMap.sortedToc()
<< nl;
return foMap.sortedToc();
}
@ -250,8 +247,12 @@ bool Foam::functionObjectList::readFunctionObject
if (path == fileName::null)
{
WarningInFunction
<< "Cannot find functionObject file " << funcType << endl;
FatalIOErrorInFunction(functionsDict)
<< "Cannot find functionObject configuration file "
<< funcType << nl << nl
<< "Available configured functionObjects:"
<< list()
<< exit(FatalIOError);
return false;
}
@ -759,7 +760,7 @@ bool Foam::functionObjectList::read()
}
const dictionary& dict = iter().dict();
bool enabled = dict.lookupOrDefault("enabled", true);
const bool enabled = dict.lookupOrDefault("enabled", true);
newDigs[nFunc] = dict.digest();
@ -788,38 +789,21 @@ bool Foam::functionObjectList::read()
{
autoPtr<functionObject> foPtr;
FatalError.throwExceptions();
FatalIOError.throwExceptions();
try
if
(
dict.found("writeControl")
|| dict.found("outputControl")
)
{
if
foPtr.set
(
dict.found("writeControl")
|| dict.found("outputControl")
)
{
foPtr.set
(
new functionObjects::timeControl(key, time_, dict)
);
}
else
{
foPtr = functionObject::New(key, time_, dict);
}
new functionObjects::timeControl(key, time_, dict)
);
}
catch (Foam::IOerror& ioErr)
else
{
Info<< ioErr << nl << endl;
::exit(1);
foPtr = functionObject::New(key, time_, dict);
}
catch (Foam::error& err)
{
WarningInFunction
<< "Caught FatalError " << err << nl << endl;
}
FatalError.dontThrowExceptions();
FatalIOError.dontThrowExceptions();
if (foPtr.valid())
{