ENH: Updated wildcard handling for function object field entries

This commit is contained in:
Andrew Heather 2017-12-13 20:57:56 +00:00
parent b37fc2d4b1
commit 3da2aee4ef
8 changed files with 71 additions and 23 deletions

View File

@ -176,7 +176,7 @@ int main(int argc, char *argv[])
args,
runTime,
functionsDict,
fields.selection()
fields
)
);
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
args,
runTime,
functionsDict,
fields.selection()
fields
);
}

View File

@ -54,7 +54,7 @@ bool Foam::functionEntries::includeFuncEntry::execute
)
{
const word fNameArgs(is);
HashSet<word> selectedFields;
HashSet<wordRe> selectedFields;
return functionObjectList::readFunctionObject
(

View File

@ -176,7 +176,7 @@ bool Foam::functionObjectList::readFunctionObject
(
const string& funcNameArgs,
dictionary& functionsDict,
HashSet<word>& requiredFields,
HashSet<wordRe>& requiredFields,
const word& region
)
{
@ -190,7 +190,7 @@ bool Foam::functionObjectList::readFunctionObject
word funcName(funcNameArgs);
int argLevel = 0;
wordList args;
wordReList args;
List<Tuple2<word, string>> namedArgs;
bool namedArg = false;
@ -237,9 +237,12 @@ bool Foam::functionObjectList::readFunctionObject
{
args.append
(
word::validate
wordRe
(
funcNameArgs.substr(start, i - start)
word::validate
(
funcNameArgs.substr(start, i - start)
)
)
);
}
@ -310,11 +313,11 @@ bool Foam::functionObjectList::readFunctionObject
}
else if (funcDict.found("field"))
{
requiredFields.insert(word(funcDict.lookup("field")));
requiredFields.insert(wordRe(funcDict.lookup("field")));
}
else if (funcDict.found("fields"))
{
requiredFields.insert(wordList(funcDict.lookup("fields")));
requiredFields.insert(wordReList(funcDict.lookup("fields")));
}
// Insert named arguments
@ -384,7 +387,7 @@ Foam::autoPtr<Foam::functionObjectList> Foam::functionObjectList::New
const argList& args,
const Time& runTime,
dictionary& controlDict,
HashSet<word>& requiredFields
HashSet<wordRe>& requiredFields
)
{
autoPtr<functionObjectList> functionsPtr;

View File

@ -155,7 +155,7 @@ public:
const argList& args,
const Time& runTime,
dictionary& controlDict,
HashSet<word>& requiredFields
HashSet<wordRe>& requiredFields
);
@ -236,7 +236,7 @@ public:
(
const string& funcNameArgs0,
dictionary& functionsDict,
HashSet<word>& requiredFields,
HashSet<wordRe>& requiredFields,
const word& region = word::null
);

View File

@ -101,12 +101,6 @@ public:
return selection_;
}
//- Return the current field selection
wordHashSet& selection()
{
return selection_;
}
//- Read the fieldSelection data from dictionary
virtual bool read(const dictionary& dict);

View File

@ -29,6 +29,43 @@ License
#include "fvPatchField.H"
#include "surfaceMesh.H"
#include "fvsPatchField.H"
#include "pointMesh.H"
#include "pointPatchField.H"
#include "UniformDimensionedField.H"
void Foam::functionObjects::fileFieldSelection::addInternalFieldTypes
(
wordHashSet& set
) const
{
const fvMesh& mesh = static_cast<const fvMesh&>(obr_);
const IOobjectList allObjects(mesh, mesh.time().timeName());
addFromFile<DimensionedField<scalar, volMesh>>(allObjects, set);
addFromFile<DimensionedField<vector, volMesh>>(allObjects, set);
addFromFile<DimensionedField<sphericalTensor, volMesh>>(allObjects, set);
addFromFile<DimensionedField<symmTensor, volMesh>>(allObjects, set);
addFromFile<DimensionedField<tensor, volMesh>>(allObjects, set);
}
void Foam::functionObjects::fileFieldSelection::addUniformFieldTypes
(
wordHashSet& set
) const
{
const fvMesh& mesh = static_cast<const fvMesh&>(obr_);
const IOobjectList allObjects(mesh, mesh.time().timeName());
addFromFile<UniformDimensionedField<scalar>>(allObjects, set);
addFromFile<UniformDimensionedField<vector>>(allObjects, set);
addFromFile<UniformDimensionedField<sphericalTensor>>(allObjects, set);
addFromFile<UniformDimensionedField<symmTensor>>(allObjects, set);
addFromFile<UniformDimensionedField<tensor>>(allObjects, set);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -54,8 +91,16 @@ bool Foam::functionObjects::fileFieldSelection::updateSelection()
wordHashSet oldSet;
oldSet.swap(selection_);
addFileGeoFields<fvPatchField, volMesh>(selection_);
addFileGeoFields<fvsPatchField, surfaceMesh>(selection_);
// Geometric fields
addGeoFieldTypes<fvPatchField, volMesh>(selection_);
addGeoFieldTypes<fvsPatchField, surfaceMesh>(selection_);
addGeoFieldTypes<pointPatchField, pointMesh>(selection_);
// Internal fields
addInternalFieldTypes(selection_);
// Uniform fields
addUniformFieldTypes(selection_);
return selection_ != oldSet;
}

View File

@ -69,7 +69,13 @@ protected:
//- Add registered GeometricField types to selection
template<template<class> class PatchType, class MeshType>
void addFileGeoFields(wordHashSet& set) const;
void addGeoFieldTypes(wordHashSet& set) const;
//- Add registered Internal types to selection
void addInternalFieldTypes(wordHashSet& set) const;
//- Add registered uniform types to selection
void addUniformFieldTypes(wordHashSet& set) const;
//- Add objects of a given type
template<class Type>

View File

@ -37,7 +37,7 @@ void Foam::functionObjects::fileFieldSelection::addFromFile
wordHashSet& set
) const
{
DynamicList<word> names;
DynamicList<word> names(this->size());
for (const wordRe& fieldName : *this)
{
@ -49,7 +49,7 @@ void Foam::functionObjects::fileFieldSelection::addFromFile
template<template<class> class PatchType, class MeshType>
void Foam::functionObjects::fileFieldSelection::addFileGeoFields
void Foam::functionObjects::fileFieldSelection::addGeoFieldTypes
(
wordHashSet& set
) const