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) 2016-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -148,7 +148,10 @@ int main(int argc, char *argv[])
if (args.optionFound("list"))
{
functionObjectList::list();
Info<< nl
<< "Available configured functionObjects:"
<< functionObjectList::list()
<< endl;
return 0;
}

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
@ -89,7 +89,7 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
FatalErrorInFunction
<< "Unknown function type "
<< functionType << nl << nl
<< "Table of functionObjects is empty" << endl
<< "Table of functionObjects is empty"
<< exit(FatalError);
}
@ -102,7 +102,7 @@ Foam::autoPtr<Foam::functionObject> Foam::functionObject::New
<< "Unknown function type "
<< functionType << nl << nl
<< "Valid functions are : " << nl
<< dictionaryConstructorTablePtr_->sortedToc() << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}

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())
{

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
@ -174,7 +174,7 @@ public:
//- Find the ID of a given function object by name
label findObjectID(const word& name) const;
//- Print a list of functionObject configuration files in
//- Return the list of functionObject configuration files in
// user/group/shipped directories.
// The search scheme allows for version-specific and
// version-independent files using the following hierarchy:
@ -190,7 +190,7 @@ public:
// - $WM_PROJECT_INST_DIR/site/etc/caseDicts/postProcessing
// - \b other (shipped) settings:
// - $WM_PROJECT_DIR/etc/caseDicts/postProcessing
static void list();
static wordList list();
//- Search for functionObject dictionary file for given region
// and if not present also search the case directory as well as the

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,7 +76,10 @@ if (argList::postProcess(argc, argv))
if (args.optionFound("list"))
{
functionObjectList::list();
Info<< nl
<< "Available configured functionObjects:"
<< functionObjectList::list()
<< endl;
return 0;
}