sampleSet: Improve error message for renamed sets

This commit is contained in:
Will Bainbridge
2018-06-20 16:37:27 +01:00
parent 3ef4c803cd
commit 135e6eb8b9
5 changed files with 53 additions and 11 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -163,12 +163,18 @@ int main(int argc, char *argv[])
// Externally stored dictionary for functionObjectList // Externally stored dictionary for functionObjectList
// if not constructed from runTime // if not constructed from runTime
dictionary functionsDict; dictionary functionsControlDict("controlDict");
// Construct functionObjectList // Construct functionObjectList
autoPtr<functionObjectList> functionsPtr autoPtr<functionObjectList> functionsPtr
( (
functionObjectList::New(args, runTime, functionsDict, selectedFields) functionObjectList::New
(
args,
runTime,
functionsControlDict,
selectedFields
)
); );
forAll(timeDirs, timei) forAll(timeDirs, timei)
@ -184,7 +190,7 @@ int main(int argc, char *argv[])
( (
args, args,
runTime, runTime,
functionsDict, functionsControlDict,
selectedFields selectedFields
); );
} }

View File

@ -335,9 +335,11 @@ bool Foam::functionObjectList::readFunctionObject
} }
// Merge this functionObject dictionary into functionsDict // Merge this functionObject dictionary into functionsDict
const word funcNameArgsWord = string::validate<word>(funcNameArgs);
dictionary funcArgsDict; dictionary funcArgsDict;
funcArgsDict.add(string::validate<word>(funcNameArgs), funcDict); funcArgsDict.add(funcNameArgsWord, funcDict);
functionsDict.merge(funcArgsDict); functionsDict.merge(funcArgsDict);
functionsDict.subDict(funcNameArgsWord).name() = funcDict.name();
return true; return true;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -94,14 +94,20 @@ if (argList::postProcess(argc, argv))
// Externally stored dictionary for functionObjectList // Externally stored dictionary for functionObjectList
// if not constructed from runTime // if not constructed from runTime
dictionary functionsDict; dictionary functionsControlDict("controlDict");
HashSet<word> selectedFields; HashSet<word> selectedFields;
// Construct functionObjectList // Construct functionObjectList
autoPtr<functionObjectList> functionsPtr autoPtr<functionObjectList> functionsPtr
( (
functionObjectList::New(args, runTime, functionsDict, selectedFields) functionObjectList::New
(
args,
runTime,
functionsControlDict,
selectedFields
)
); );
forAll(timeDirs, timei) forAll(timeDirs, timei)
@ -117,7 +123,7 @@ if (argList::postProcess(argc, argv))
( (
args, args,
runTime, runTime,
functionsDict, functionsControlDict,
selectedFields selectedFields
); );
} }

View File

@ -27,6 +27,10 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "meshSearch.H" #include "meshSearch.H"
#include "writer.H" #include "writer.H"
#include "lineCellSet.H"
#include "lineCellFaceSet.H"
#include "lineFaceSet.H"
#include "lineUniformSet.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -138,15 +142,37 @@ Foam::autoPtr<Foam::sampledSet> Foam::sampledSet::New
{ {
const word sampleType(dict.lookup("type")); const word sampleType(dict.lookup("type"));
const HashTable<word> oldToNewType =
{
Tuple2<word, word>("midPoint", lineCellSet::typeName),
Tuple2<word, word>("midPointAndFace", lineCellFaceSet::typeName),
Tuple2<word, word>("face", lineFaceSet::typeName),
Tuple2<word, word>("uniform", lineUniformSet::typeName)
};
if (oldToNewType.found(sampleType))
{
const word newSampleType = oldToNewType[sampleType];
FatalErrorInFunction
<< "Unknown sample set type "
<< sampleType << nl << nl
<< "The sample set type " << sampleType << " has been renamed "
<< newSampleType << nl << nl
<< "Replace \"type " << sampleType << ";\" with \"type "
<< newSampleType << ";\" for the set " << name << " in "
<< dict.name() << exit(FatalError);
}
wordConstructorTable::iterator cstrIter = wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(sampleType); wordConstructorTablePtr_->find(sampleType);
if (cstrIter == wordConstructorTablePtr_->end()) if (cstrIter == wordConstructorTablePtr_->end())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown sample type " << "Unknown sample set type "
<< sampleType << nl << nl << sampleType << nl << nl
<< "Valid sample types : " << endl << "Valid sample set types : " << endl
<< wordConstructorTablePtr_->sortedToc() << wordConstructorTablePtr_->sortedToc()
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -74,6 +74,8 @@ class sampledSet
protected: protected:
// Protected data
//- Segment numbers //- Segment numbers
labelList segments_; labelList segments_;