mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow "<case>", "<system>" ... in the string expansions (issue #792)
- the expansions were previously required as slash to follow, but
now either are possible.
"<case>", "<case>/" both yield the same as "$FOAM_CASE" and
will not have a trailing slash in the result. The expansion of
"$FOAM_CASE/" will however have a trailing slash.
- adjust additional files using these expansions
This commit is contained in:
@ -72,26 +72,28 @@ int main(int argc, char *argv[])
|
|||||||
const auto& cstr
|
const auto& cstr
|
||||||
:
|
:
|
||||||
{
|
{
|
||||||
"~OpenFOAM/controlDict",
|
"~OpenFOAM/controlDict", "<etc>/controlDict",
|
||||||
"<etc>/controlDict",
|
"$FOAM_CASE/xyz", "<case>/xyz",
|
||||||
|
"$FOAM_CASE/constant/xyz", "<constant>/xyz",
|
||||||
|
"$FOAM_CASE/system/xyz", "<system>/xyz",
|
||||||
|
|
||||||
"$FOAM_CASE/test",
|
// corner cases
|
||||||
"<case>/test",
|
"~OpenFOAM", "<etc>",
|
||||||
|
"~OpenFOAM/", "<etc>/",
|
||||||
|
"$FOAM_CASE", "<case>",
|
||||||
|
"$FOAM_CASE/constant", "<constant>",
|
||||||
|
"$FOAM_CASE/system", "<system>",
|
||||||
|
|
||||||
"$FOAM_CASE/constant/test",
|
"$FOAM_CASE/", "<case>/",
|
||||||
"<case>/constant/test",
|
"$FOAM_CASE/constant/", "<constant>/",
|
||||||
"<constant>/test",
|
"$FOAM_CASE/system/", "<system>/",
|
||||||
|
|
||||||
"$FOAM_CASE/system/test",
|
|
||||||
"<case>/system/test",
|
|
||||||
"<system>/test",
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
string input(cstr);
|
string input(cstr);
|
||||||
string output(stringOps::expand(input));
|
string output(stringOps::expand(input));
|
||||||
|
|
||||||
Info<<"input: " << input << nl
|
Info<< "input: " << input << nl
|
||||||
<< "expand: " << output << nl << nl;
|
<< "expand: " << output << nl << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,10 +112,10 @@ sigmaRadialCoeffs
|
|||||||
offsetSurfaceCoeffs
|
offsetSurfaceCoeffs
|
||||||
{
|
{
|
||||||
// Surface that mesh has been meshed to
|
// Surface that mesh has been meshed to
|
||||||
baseSurface "$FOAM_CASE/constant/triSurface/DTC-scaled-inflated.obj";
|
baseSurface "<constant>/triSurface/DTC-scaled-inflated.obj";
|
||||||
|
|
||||||
// Surface to fill in to
|
// Surface to fill in to
|
||||||
offsetSurface "$FOAM_CASE/constant/triSurface/DTC-scaled.obj";
|
offsetSurface "<constant>/triSurface/DTC-scaled.obj";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -150,7 +150,7 @@ void createFieldFiles
|
|||||||
field.add
|
field.add
|
||||||
(
|
(
|
||||||
"#include",
|
"#include",
|
||||||
"${FOAM_CASE}/system" + regionPath + "caseProperties"
|
"$FOAM_CASE/system" + regionPath + "caseProperties"
|
||||||
);
|
);
|
||||||
|
|
||||||
field.add("dimensions", fieldDimensions[i]);
|
field.add("dimensions", fieldDimensions[i]);
|
||||||
|
|||||||
@ -74,7 +74,7 @@ addLayersControls
|
|||||||
|
|
||||||
meshQualityControls
|
meshQualityControls
|
||||||
{
|
{
|
||||||
#include "${FOAM_CASE}/system/meshQualityDict"
|
#include "<system>/meshQualityDict"
|
||||||
}
|
}
|
||||||
|
|
||||||
debug 0;
|
debug 0;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ FoamFile
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
constructFrom patch;
|
constructFrom patch;
|
||||||
sourceCase "$FOAM_CASE";
|
sourceCase "<case>";
|
||||||
|
|
||||||
sourcePatches (front);
|
sourcePatches (front);
|
||||||
exposedPatchName back;
|
exposedPatchName back;
|
||||||
@ -30,6 +30,7 @@ sectorCoeffs
|
|||||||
}
|
}
|
||||||
|
|
||||||
flipNormals false;
|
flipNormals false;
|
||||||
|
|
||||||
mergeFaces false;
|
mergeFaces false;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -42,7 +42,7 @@ Description
|
|||||||
Read csv format:
|
Read csv format:
|
||||||
\verbatim
|
\verbatim
|
||||||
readerType csv;
|
readerType csv;
|
||||||
file "$FOAM_CASE/constant/p0vsTime.csv";
|
file "<constant>/p0vsTime.csv";
|
||||||
hasHeaderLine true; // skip first line
|
hasHeaderLine true; // skip first line
|
||||||
timeColumn 0; // time is in column 0
|
timeColumn 0; // time is in column 0
|
||||||
valueColumns (1); // value starts in column 1
|
valueColumns (1); // value starts in column 1
|
||||||
|
|||||||
@ -50,13 +50,29 @@ static void expandLeadingTag(std::string& s, const char b, const char e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto delim = s.find(e);
|
auto delim = s.find(e);
|
||||||
if (delim == std::string::npos || s[++delim] != '/')
|
if (delim == std::string::npos)
|
||||||
{
|
{
|
||||||
return; // Ignore if there is no '/' after <tag>
|
return; // Error: no closing delim - ignore expansion
|
||||||
|
}
|
||||||
|
|
||||||
|
fileName file;
|
||||||
|
|
||||||
|
const char nextC = s[++delim];
|
||||||
|
|
||||||
|
// Require the following character to be '/' or the end of string.
|
||||||
|
if (nextC)
|
||||||
|
{
|
||||||
|
if (nextC != '/')
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.assign(s.substr(delim + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string tag(s, 1, delim-2);
|
const std::string tag(s, 1, delim-2);
|
||||||
fileName file(s.substr(delim + 1));
|
|
||||||
|
// Note that file is also allowed to be an empty string.
|
||||||
|
|
||||||
if (tag == "etc")
|
if (tag == "etc")
|
||||||
{
|
{
|
||||||
@ -120,7 +136,10 @@ static void expandLeading(std::string& s)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (s[0] == '.')
|
|
||||||
|
switch (s[0])
|
||||||
|
{
|
||||||
|
case '.':
|
||||||
{
|
{
|
||||||
// Expand a lone '.' and an initial './' into cwd
|
// Expand a lone '.' and an initial './' into cwd
|
||||||
if (s.size() == 1)
|
if (s.size() == 1)
|
||||||
@ -131,14 +150,18 @@ static void expandLeading(std::string& s)
|
|||||||
{
|
{
|
||||||
s.std::string::replace(0, 1, cwd());
|
s.std::string::replace(0, 1, cwd());
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (s[0] == '<')
|
case '<':
|
||||||
{
|
{
|
||||||
expandLeadingTag(s, '<', '>');
|
expandLeadingTag(s, '<', '>');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (s[0] == '~')
|
case '~':
|
||||||
{
|
{
|
||||||
expandLeadingTilde(s);
|
expandLeadingTilde(s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ Description
|
|||||||
inlet
|
inlet
|
||||||
{
|
{
|
||||||
type timeVaryingUniformFixedValue;
|
type timeVaryingUniformFixedValue;
|
||||||
fileName "$FOAM_CASE/time-series";
|
fileName "<case>/time-series";
|
||||||
outOfBounds clamp; // (error|warn|clamp|repeat)
|
outOfBounds clamp; // (error|warn|clamp|repeat)
|
||||||
}
|
}
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|||||||
@ -50,7 +50,7 @@ Description
|
|||||||
\verbatim
|
\verbatim
|
||||||
communication
|
communication
|
||||||
{
|
{
|
||||||
commsDir "${FOAM_CASE}/comms";
|
commsDir "<case>/comms";
|
||||||
waitInterval 1;
|
waitInterval 1;
|
||||||
timeOut 100;
|
timeOut 100;
|
||||||
initByExternal no;
|
initByExternal no;
|
||||||
|
|||||||
@ -80,7 +80,7 @@ Usage
|
|||||||
componentColumns 1(1);
|
componentColumns 1(1);
|
||||||
separator ",";
|
separator ",";
|
||||||
mergeSeparators no;
|
mergeSeparators no;
|
||||||
file "$FOAM_CASE/constant/pressureVsU";
|
file "<constant>/pressureVsU";
|
||||||
}
|
}
|
||||||
value uniform 0;
|
value uniform 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,7 +86,7 @@ Usage
|
|||||||
type externalCoupled;
|
type externalCoupled;
|
||||||
...
|
...
|
||||||
log yes;
|
log yes;
|
||||||
commsDir "${FOAM_CASE}/comms";
|
commsDir "<case>/comms";
|
||||||
initByExternal yes;
|
initByExternal yes;
|
||||||
stateEnd remove; // (remove | done)
|
stateEnd remove; // (remove | done)
|
||||||
|
|
||||||
|
|||||||
@ -40,13 +40,13 @@ Usage
|
|||||||
libs ("libutilityFunctionObjects.so");
|
libs ("libutilityFunctionObjects.so");
|
||||||
writeControl timeStep;
|
writeControl timeStep;
|
||||||
writeInterval 1;
|
writeInterval 1;
|
||||||
fileToUpdate "$FOAM_CASE/system/fvSolution";
|
fileToUpdate "<system>/fvSolution";
|
||||||
timeVsFile
|
timeVsFile
|
||||||
(
|
(
|
||||||
(-1 "$FOAM_CASE/system/fvSolution.0")
|
(-1 "<system>/fvSolution.0")
|
||||||
(0.10 "$FOAM_CASE/system/fvSolution.10")
|
(0.10 "<system>/fvSolution.10")
|
||||||
(0.20 "$FOAM_CASE/system/fvSolution.20")
|
(0.20 "<system>/fvSolution.20")
|
||||||
(0.35 "$FOAM_CASE/system/fvSolution.35")
|
(0.35 "<system>/fvSolution.35")
|
||||||
);
|
);
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ FoamFile
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
constructFrom mesh;
|
constructFrom mesh;
|
||||||
sourceCase "$FOAM_CASE";
|
sourceCase "<case>";
|
||||||
sourcePatches (outlet);
|
sourcePatches (outlet);
|
||||||
|
|
||||||
flipNormals false;
|
flipNormals false;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ FoamFile
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
constructFrom mesh;
|
constructFrom mesh;
|
||||||
sourceCase "$FOAM_CASE";
|
sourceCase "<case>";
|
||||||
sourcePatches (outlet);
|
sourcePatches (outlet);
|
||||||
|
|
||||||
flipNormals false;
|
flipNormals false;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ FoamFile
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
constructFrom mesh;
|
constructFrom mesh;
|
||||||
sourceCase "$FOAM_CASE";
|
sourceCase "<case>";
|
||||||
sourcePatches (outlet);
|
sourcePatches (outlet);
|
||||||
|
|
||||||
flipNormals false;
|
flipNormals false;
|
||||||
|
|||||||
Reference in New Issue
Block a user