mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: change wordRes to be a List of wordRe instead of a wrapper (issue #259)
- this permits direct storage of a list with additional matcher capabilities - provide wordRes::matcher class for similar behaviour as previously
This commit is contained in:
@ -81,12 +81,11 @@ int main(int argc, char *argv[])
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
// Find set of patches from the list of regular expressions provided
|
||||
const wordReList patches((IStringStream(args[1])()));
|
||||
const labelHashSet patchSet(mesh.boundaryMesh().patchSet(patches));
|
||||
|
||||
const wordRes patches(args.readList<wordRe>(1));
|
||||
const scalar weight = args.read<scalar>(2);
|
||||
const bool overwrite = args.found("overwrite");
|
||||
|
||||
const labelHashSet patchSet(mesh.boundaryMesh().patchSet(patches));
|
||||
if (!patchSet.size())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
|
||||
@ -1666,7 +1666,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
includePatches = bMesh.patchSet
|
||||
(
|
||||
wordReList(args.lookup("patches")())
|
||||
args.readList<wordRe>("patches")
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@ -414,7 +414,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (args.found("patches"))
|
||||
{
|
||||
const wordReList patchNames(args.opt<wordReList>("patches"));
|
||||
const wordRes patchNames(args.readList<wordRe>("patches"));
|
||||
|
||||
exposedPatchIDs = mesh.boundaryMesh().patchSet(patchNames).sortedToc();
|
||||
|
||||
|
||||
@ -360,10 +360,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (args.found("scale"))
|
||||
List<scalar> scaling;
|
||||
if (args.readListIfPresent("scale", scaling))
|
||||
{
|
||||
// Use readList to handle single or multiple values
|
||||
const List<scalar> scaling = args.readList<scalar>("scale");
|
||||
// readList handles single or multiple values
|
||||
|
||||
if (scaling.size() == 1)
|
||||
{
|
||||
|
||||
@ -127,20 +127,20 @@ int main(int argc, char *argv[])
|
||||
argList::addOption
|
||||
(
|
||||
"patches",
|
||||
"wordReList",
|
||||
"wordRes",
|
||||
"specify particular patches to write - eg '(outlet \"inlet.*\")'. "
|
||||
"An empty list suppresses writing the internalMesh."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"faceZones",
|
||||
"wordReList",
|
||||
"wordRes",
|
||||
"specify faceZones to write - eg '( slice \"mfp-.*\" )'."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"fields",
|
||||
"wordReList",
|
||||
"wordRes",
|
||||
"specify fields to export (all by default) - eg '( \"U.*\" )'."
|
||||
);
|
||||
argList::addOption
|
||||
@ -249,11 +249,8 @@ int main(int argc, char *argv[])
|
||||
//
|
||||
const bool noLagrangian = args.found("noLagrangian");
|
||||
|
||||
wordReList fieldPatterns;
|
||||
if (args.found("fields"))
|
||||
{
|
||||
fieldPatterns = args.readList<wordRe>("fields");
|
||||
}
|
||||
wordRes fieldPatterns;
|
||||
args.readListIfPresent<wordRe>("fields", fieldPatterns);
|
||||
|
||||
word cellZoneName;
|
||||
if (args.readIfPresent("cellZone", cellZoneName))
|
||||
|
||||
@ -79,8 +79,7 @@ Usage
|
||||
#include "tensorIOField.H"
|
||||
#include "passiveParticleCloud.H"
|
||||
#include "faceSet.H"
|
||||
#include "stringOps.H"
|
||||
#include "wordReList.H"
|
||||
#include "wordRes.H"
|
||||
|
||||
#include "meshSubsetHelper.H"
|
||||
#include "readFields.H"
|
||||
@ -117,7 +116,7 @@ void print(Ostream& os, const wordList& flds)
|
||||
labelList getSelectedPatches
|
||||
(
|
||||
const polyBoundaryMesh& patches,
|
||||
const List<wordRe>& excludePatches //HashSet<word>& excludePatches
|
||||
const wordRes& excludePatches
|
||||
)
|
||||
{
|
||||
DynamicList<label> patchIDs(patches.size());
|
||||
@ -137,7 +136,7 @@ labelList getSelectedPatches
|
||||
Info<< " discarding empty/processor patch " << patchi
|
||||
<< " " << pp.name() << endl;
|
||||
}
|
||||
else if (stringOps::match(excludePatches, pp.name()))
|
||||
else if (excludePatches.match(pp.name()))
|
||||
{
|
||||
Info<< " excluding patch " << patchi
|
||||
<< " " << pp.name() << endl;
|
||||
@ -227,11 +226,9 @@ int main(int argc, char *argv[])
|
||||
<< "Outputting cell values only" << nl << endl;
|
||||
}
|
||||
|
||||
List<wordRe> excludePatches;
|
||||
if (args.found("excludePatches"))
|
||||
wordRes excludePatches;
|
||||
if (args.readListIfPresent<wordRe>("excludePatches", excludePatches))
|
||||
{
|
||||
args.lookup("excludePatches")() >> excludePatches;
|
||||
|
||||
Info<< "Not including patches " << excludePatches << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -156,7 +156,7 @@ Note
|
||||
#include "faceZoneMesh.H"
|
||||
#include "Cloud.H"
|
||||
#include "passiveParticle.H"
|
||||
#include "stringOps.H"
|
||||
#include "wordRes.H"
|
||||
#include "areaFields.H"
|
||||
#include "meshSubsetHelper.H"
|
||||
#include "readFields.H"
|
||||
@ -412,7 +412,7 @@ int main(int argc, char *argv[])
|
||||
argList::addOption
|
||||
(
|
||||
"excludePatches",
|
||||
"wordReList",
|
||||
"wordRes",
|
||||
"a list of patches to exclude - eg '( inlet \".*Wall\" )' "
|
||||
);
|
||||
argList::addBoolOption
|
||||
@ -474,11 +474,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
const bool allPatches = args.found("allPatches");
|
||||
|
||||
wordReList excludePatches;
|
||||
if (args.found("excludePatches"))
|
||||
wordRes excludePatches;
|
||||
if (args.readListIfPresent<wordRe>("excludePatches", excludePatches))
|
||||
{
|
||||
args.lookup("excludePatches")() >> excludePatches;
|
||||
|
||||
Info<< "Not including patches " << excludePatches << nl << endl;
|
||||
}
|
||||
|
||||
@ -499,7 +497,7 @@ int main(int argc, char *argv[])
|
||||
else if (Pstream::parRun())
|
||||
{
|
||||
// Strip off leading casename, leaving just processor_DDD ending.
|
||||
string::size_type i = vtkName.rfind("processor");
|
||||
const auto i = vtkName.rfind("processor");
|
||||
|
||||
if (i != string::npos)
|
||||
{
|
||||
@ -1284,7 +1282,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const polyPatch& pp = patches[patchi];
|
||||
|
||||
if (stringOps::match(excludePatches, pp.name()))
|
||||
if (excludePatches.match(pp.name()))
|
||||
{
|
||||
// Skip excluded patch
|
||||
continue;
|
||||
|
||||
@ -446,7 +446,7 @@ int main(int argc, char *argv[])
|
||||
forAll(times, timei)
|
||||
{
|
||||
word instance;
|
||||
if (args.found("instance"))
|
||||
if (args.readIfPresent("instance", instance))
|
||||
{
|
||||
if (times.size() > 1)
|
||||
{
|
||||
@ -454,8 +454,6 @@ int main(int argc, char *argv[])
|
||||
<< "Multiple times selected with 'instance' option"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
args.lookup("instance")() >> instance;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -28,8 +28,6 @@ License
|
||||
#include "IFstream.H"
|
||||
#include "StringStream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::boundaryTemplates::boundaryTemplates
|
||||
|
||||
@ -27,9 +27,9 @@ Class
|
||||
Description
|
||||
Class to store boundary template specifications
|
||||
|
||||
Templates are typically stored centrally, and constructed in a hierarchical
|
||||
manner. The main use is to convert the (user) specified conditions into
|
||||
a form which can be inserted into each field file as dictionary entries.
|
||||
Templates are typically stored centrally, and constructed hierarchically.
|
||||
The main use is to convert the (user) specified conditions into
|
||||
a form that can be inserted into each field file as dictionary entries.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -37,8 +37,6 @@ Description
|
||||
#define boundaryTemplates_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "wordList.H"
|
||||
#include "wordReList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -43,26 +43,26 @@ Foam::label Foam::caseInfo::findPatchConditionID
|
||||
// Assign condition according to last condition applied, wins
|
||||
forAllReverse(conditionNames_, conditionI)
|
||||
{
|
||||
const wordReList& patchNames = patchNames_[conditionI];
|
||||
const wordRes& patchNames = patchNames_[conditionI];
|
||||
|
||||
forAll(patchNames, nameI)
|
||||
for (const wordRe& select : patchNames)
|
||||
{
|
||||
if (patchNames[nameI] == patchName)
|
||||
if (select == patchName)
|
||||
{
|
||||
// Check for explicit match
|
||||
// Literal match
|
||||
return conditionI;
|
||||
}
|
||||
else if (patchNames[nameI].match(patchName))
|
||||
else if (select.match(patchName))
|
||||
{
|
||||
// Check wildcards
|
||||
// Regex match
|
||||
return conditionI;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check for group match
|
||||
forAll(patchGroups, groupI)
|
||||
for (const word& groupName : patchGroups)
|
||||
{
|
||||
if (patchNames[nameI] == patchGroups[groupI])
|
||||
if (select == groupName)
|
||||
{
|
||||
return conditionI;
|
||||
}
|
||||
@ -160,7 +160,7 @@ void Foam::caseInfo::checkPatches
|
||||
}
|
||||
|
||||
|
||||
const Foam::List<Foam::wordReList>& Foam::caseInfo::patchNames() const
|
||||
const Foam::List<Foam::wordRes>& Foam::caseInfo::patchNames() const
|
||||
{
|
||||
return patchNames_;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ Description
|
||||
#include "labelList.H"
|
||||
#include "wordList.H"
|
||||
#include "HashSet.H"
|
||||
#include "wordReList.H"
|
||||
#include "wordRes.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "boundaryInfo.H"
|
||||
|
||||
@ -72,7 +72,7 @@ class caseInfo
|
||||
// Per-condition information
|
||||
|
||||
//- List of patch names
|
||||
List<wordReList> patchNames_;
|
||||
List<wordRes> patchNames_;
|
||||
|
||||
//- Patch category
|
||||
wordList patchCategories_;
|
||||
@ -103,7 +103,7 @@ public:
|
||||
) const;
|
||||
|
||||
//- Return the list of patch names
|
||||
const List<wordReList>& patchNames() const;
|
||||
const List<wordRes>& patchNames() const;
|
||||
|
||||
//- Return the condition name for patch with index patchI
|
||||
const word& conditionName(const label patchI) const;
|
||||
|
||||
@ -200,17 +200,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Source: " << rootDirSource << " " << caseDirSource << endl;
|
||||
word sourceRegion = fvMesh::defaultRegion;
|
||||
if (args.found("sourceRegion"))
|
||||
if (args.readIfPresent("sourceRegion", sourceRegion))
|
||||
{
|
||||
sourceRegion = args["sourceRegion"];
|
||||
Info<< "Source region: " << sourceRegion << endl;
|
||||
}
|
||||
|
||||
Info<< "Target: " << rootDirTarget << " " << caseDirTarget << endl;
|
||||
word targetRegion = fvMesh::defaultRegion;
|
||||
if (args.found("targetRegion"))
|
||||
if (args.readIfPresent("targetRegion", targetRegion))
|
||||
{
|
||||
targetRegion = args["targetRegion"];
|
||||
Info<< "Target region: " << targetRegion << endl;
|
||||
}
|
||||
|
||||
@ -242,10 +240,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Optionally override
|
||||
if (args.found("patchMapMethod"))
|
||||
if (args.readIfPresent("patchMapMethod", patchMapMethod))
|
||||
{
|
||||
patchMapMethod = args["patchMapMethod"];
|
||||
|
||||
Info<< "Patch mapping method: " << patchMapMethod << endl;
|
||||
}
|
||||
|
||||
@ -265,10 +261,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
HashSet<word> selectedFields;
|
||||
if (args.found("fields"))
|
||||
{
|
||||
args.lookup("fields")() >> selectedFields;
|
||||
}
|
||||
args.readIfPresent("fields", selectedFields);
|
||||
|
||||
const bool noLagrangian = args.found("noLagrangian");
|
||||
|
||||
|
||||
@ -175,7 +175,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
includePatches = bMesh.patchSet
|
||||
(
|
||||
wordReList(args.lookup("patches")())
|
||||
args.readList<wordRe>("patches")
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -197,12 +197,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.found("faceZones"))
|
||||
{
|
||||
wordReList zoneNames(args.lookup("faceZones")());
|
||||
wordReList zoneNames(args.readList<wordRe>("faceZones"));
|
||||
const wordList allZoneNames(fzm.names());
|
||||
forAll(zoneNames, i)
|
||||
for (const wordRe& zoneName : zoneNames)
|
||||
{
|
||||
const wordRe& zoneName = zoneNames[i];
|
||||
|
||||
labelList zoneIDs = findStrings(zoneName, allZoneNames);
|
||||
|
||||
forAll(zoneIDs, j)
|
||||
|
||||
@ -277,12 +277,6 @@ Foam::searchableSurfaceModifiers::cut::cut
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::searchableSurfaceModifiers::cut::~cut()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::searchableSurfaceModifiers::cut::modify
|
||||
@ -296,14 +290,12 @@ bool Foam::searchableSurfaceModifiers::cut::modify
|
||||
bool changed = false;
|
||||
|
||||
// Find the surfaces to cut with
|
||||
forAll(cutterNames_, cutNameI)
|
||||
for (const wordRe& cutterName : cutterNames_)
|
||||
{
|
||||
labelList geomIDs =
|
||||
findStrings(cutterNames_[cutNameI], geometry_.names());
|
||||
labelList geomIDs = findStrings(cutterName, geometry_.names());
|
||||
|
||||
forAll(geomIDs, j)
|
||||
for (const label geomI : geomIDs)
|
||||
{
|
||||
label geomI = geomIDs[j];
|
||||
const searchableSurface& cutter = geometry_[geomI];
|
||||
|
||||
// Triangulate
|
||||
|
||||
@ -37,7 +37,7 @@ SourceFiles
|
||||
#define cut_H
|
||||
|
||||
#include "searchableSurfaceModifier.H"
|
||||
#include "wordReList.H"
|
||||
#include "wordRes.H"
|
||||
#include "faceList.H"
|
||||
#include "pointField.H"
|
||||
|
||||
@ -63,7 +63,7 @@ class cut
|
||||
// Private data
|
||||
|
||||
//- Name of surfaces to cut with
|
||||
const wordReList cutterNames_;
|
||||
const wordRes cutterNames_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -105,7 +105,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~cut();
|
||||
virtual ~cut() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -235,10 +235,10 @@ int main(int argc, char *argv[])
|
||||
points = transform(quat, points);
|
||||
}
|
||||
|
||||
if (args.found("scale"))
|
||||
List<scalar> scaling;
|
||||
if (args.readListIfPresent("scale", scaling))
|
||||
{
|
||||
// Use readList to handle single or multiple values
|
||||
const List<scalar> scaling = args.readList<scalar>("scale");
|
||||
// readList handles single or multiple values
|
||||
|
||||
if (scaling.size() == 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user