mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -19,6 +19,11 @@ bool massFluxInterpolation
|
|||||||
pimple.dict().lookupOrDefault("massFluxInterpolation", false)
|
pimple.dict().lookupOrDefault("massFluxInterpolation", false)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool adjustFringe
|
||||||
|
(
|
||||||
|
pimple.dict().lookupOrDefault("oversetAdjustPhi", false)
|
||||||
|
);
|
||||||
|
|
||||||
bool ddtCorr
|
bool ddtCorr
|
||||||
(
|
(
|
||||||
pimple.dict().lookupOrDefault("ddtCorr", true)
|
pimple.dict().lookupOrDefault("ddtCorr", true)
|
||||||
|
|||||||
@ -53,6 +53,7 @@ Description
|
|||||||
#include "interpolationCellPoint.H"
|
#include "interpolationCellPoint.H"
|
||||||
#include "transform.H"
|
#include "transform.H"
|
||||||
#include "fvMeshSubset.H"
|
#include "fvMeshSubset.H"
|
||||||
|
#include "oversetAdjustPhi.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,14 @@
|
|||||||
fvc::makeAbsolute(phiHbyA, U);
|
fvc::makeAbsolute(phiHbyA, U);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adjustFringe)
|
||||||
|
{
|
||||||
|
fvc::makeRelative(phiHbyA, U);
|
||||||
|
oversetAdjustPhi(phiHbyA, U);
|
||||||
|
fvc::makeAbsolute(phiHbyA, U);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
surfaceScalarField phig
|
surfaceScalarField phig
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
|
|||||||
@ -14,7 +14,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
convertToMeters 1;
|
scale 1;
|
||||||
|
|
||||||
vertices
|
vertices
|
||||||
(
|
(
|
||||||
|
|||||||
@ -14,7 +14,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
convertToMeters 1;
|
scale 1;
|
||||||
|
|
||||||
vertices
|
vertices
|
||||||
(
|
(
|
||||||
|
|||||||
@ -14,7 +14,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
convertToMeters 0.1;
|
scale 0.1;
|
||||||
|
|
||||||
vertices
|
vertices
|
||||||
(
|
(
|
||||||
|
|||||||
@ -15,7 +15,7 @@ FoamFile
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
convertToMeters 1;
|
scale 1;
|
||||||
|
|
||||||
vertices
|
vertices
|
||||||
(
|
(
|
||||||
|
|||||||
@ -14,7 +14,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
convertToMeters 0.1;
|
scale 0.1;
|
||||||
|
|
||||||
vertices
|
vertices
|
||||||
(
|
(
|
||||||
|
|||||||
@ -35,11 +35,10 @@ Description
|
|||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
|
// Simple utility
|
||||||
template<class String>
|
template<class String>
|
||||||
void printSplitting(const String& str, const char delimiter)
|
void printSubStrings(const String& str, const SubStrings<String>& split)
|
||||||
{
|
{
|
||||||
auto split = stringOps::split(str, delimiter);
|
|
||||||
|
|
||||||
Info<< "string {" << str.size() << " chars} = " << str << nl
|
Info<< "string {" << str.size() << " chars} = " << str << nl
|
||||||
<< split.size() << " elements {" << split.length() << " chars}"
|
<< split.size() << " elements {" << split.length() << " chars}"
|
||||||
<< nl;
|
<< nl;
|
||||||
@ -60,7 +59,28 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
argList::noBanner();
|
argList::noBanner();
|
||||||
argList::noParallel();
|
argList::noParallel();
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"any",
|
||||||
|
"delimChars",
|
||||||
|
"test split on any delimiter characters"
|
||||||
|
);
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"sub",
|
||||||
|
"string",
|
||||||
|
"test split on substring"
|
||||||
|
);
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"slash",
|
||||||
|
"test split on slash (default)"
|
||||||
|
);
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"space",
|
||||||
|
"test split on space"
|
||||||
|
);
|
||||||
argList args(argc, argv, false, true);
|
argList args(argc, argv, false, true);
|
||||||
|
|
||||||
if (args.size() <= 1 && args.options().empty())
|
if (args.size() <= 1 && args.options().empty())
|
||||||
@ -68,12 +88,83 @@ int main(int argc, char *argv[])
|
|||||||
args.printUsage();
|
args.printUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (label argi=1; argi < args.size(); ++argi)
|
int nopts = 0;
|
||||||
|
for (auto optName : { "any", "slash", "space", "sub" })
|
||||||
{
|
{
|
||||||
printSplitting(args[argi], '/');
|
if (args.optionFound(optName))
|
||||||
|
{
|
||||||
|
++nopts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.optionFound("any"))
|
||||||
|
{
|
||||||
|
const std::string& str = args["any"];
|
||||||
|
Info<< "split on any chars" << nl
|
||||||
|
<< "=" << str << nl
|
||||||
|
<< "~~~~~~~~~~~~~~~" << nl;
|
||||||
|
|
||||||
|
for (label argi=1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
const auto split = stringOps::splitAny(args[argi], str);
|
||||||
|
printSubStrings(args[argi], split);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nopts == 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.optionFound("sub"))
|
||||||
|
{
|
||||||
|
const std::string& str = args["sub"];
|
||||||
|
Info<< "split on substring" << nl
|
||||||
|
<< "=" << str << nl
|
||||||
|
<< "~~~~~~~~~~~~~~~" << nl;
|
||||||
|
|
||||||
|
for (label argi=1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
const auto split = stringOps::split(args[argi], str);
|
||||||
|
printSubStrings(args[argi], split);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nopts == 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.optionFound("space"))
|
||||||
|
{
|
||||||
|
Info<< "split on space" << nl
|
||||||
|
<< "~~~~~~~~~~~~~~" << nl;
|
||||||
|
|
||||||
|
for (label argi=1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
const auto split = stringOps::splitSpace(args[argi]);
|
||||||
|
printSubStrings(args[argi], split);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nopts == 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default
|
||||||
|
if (!nopts || args.optionFound("slash"))
|
||||||
|
{
|
||||||
|
Info<< "split on slash" << nl
|
||||||
|
<< "~~~~~~~~~~~~~~" << nl;
|
||||||
|
|
||||||
|
for (label argi=1; argi < args.size(); ++argi)
|
||||||
|
{
|
||||||
|
const auto split = stringOps::split(args[argi], '/');
|
||||||
|
printSubStrings(args[argi], split);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
convertToMeters 0.1;
|
scale 0.1;
|
||||||
|
|
||||||
vertices
|
vertices
|
||||||
(
|
(
|
||||||
|
|||||||
@ -85,7 +85,7 @@ void writeVTK
|
|||||||
vtk::writeFaceSet
|
vtk::writeFaceSet
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
currentSet,
|
dynamicCast<const faceSet&>(currentSet),
|
||||||
mesh.time().path()/vtkBaseName,
|
mesh.time().path()/vtkBaseName,
|
||||||
vtk::formatType::LEGACY_BINARY
|
vtk::formatType::LEGACY_BINARY
|
||||||
);
|
);
|
||||||
@ -96,7 +96,7 @@ void writeVTK
|
|||||||
vtk::writeCellSetFaces
|
vtk::writeCellSetFaces
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
currentSet,
|
dynamicCast<const cellSet&>(currentSet),
|
||||||
mesh.time().path()/vtkBaseName,
|
mesh.time().path()/vtkBaseName,
|
||||||
vtk::formatType::LEGACY_BINARY
|
vtk::formatType::LEGACY_BINARY
|
||||||
);
|
);
|
||||||
@ -106,7 +106,7 @@ void writeVTK
|
|||||||
vtk::writePointSet
|
vtk::writePointSet
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
currentSet,
|
dynamicCast<const pointSet&>(currentSet),
|
||||||
mesh.time().path()/vtkBaseName,
|
mesh.time().path()/vtkBaseName,
|
||||||
vtk::formatType::LEGACY_BINARY
|
vtk::formatType::LEGACY_BINARY
|
||||||
);
|
);
|
||||||
|
|||||||
@ -68,7 +68,7 @@ EXE_LIBS = \
|
|||||||
-lrigidBodyDynamics \
|
-lrigidBodyDynamics \
|
||||||
-lrigidBodyMeshMotion \
|
-lrigidBodyMeshMotion \
|
||||||
-lsampling \
|
-lsampling \
|
||||||
-lscotchDecomp \
|
-L$(FOAM_LIBBIN)/dummy -lscotchDecomp \
|
||||||
-lsixDoFRigidBodyMotion \
|
-lsixDoFRigidBodyMotion \
|
||||||
-lSLGThermo \
|
-lSLGThermo \
|
||||||
-lsnappyHexMesh \
|
-lsnappyHexMesh \
|
||||||
|
|||||||
@ -89,11 +89,7 @@ int main(int argc, char *argv[])
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if
|
if (!fieldName.isWord() || fieldName.wordToken() != "CELL")
|
||||||
(
|
|
||||||
fieldName.type() != token::WORD
|
|
||||||
&& fieldName.wordToken() != "CELL"
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Expected first CELL, found "
|
<< "Expected first CELL, found "
|
||||||
@ -103,7 +99,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
label nCols = 0;
|
label nCols = 0;
|
||||||
smapFile >> fieldName;
|
smapFile >> fieldName;
|
||||||
while (fieldName.type() == token::WORD)
|
while (fieldName.isWord())
|
||||||
{
|
{
|
||||||
starFieldNames[nCols++] = fieldName.wordToken();
|
starFieldNames[nCols++] = fieldName.wordToken();
|
||||||
smapFile >> fieldName;
|
smapFile >> fieldName;
|
||||||
|
|||||||
@ -48,8 +48,11 @@ surfaceNoiseCoeffs
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// Input file
|
// Input file(s)
|
||||||
inputFile "postProcessing/faceSource1/surface/patch_motorBike_rider-helmet%65/patch_motorBike_rider-helmet%65.case";
|
file "postProcessing/faceSource1/surface/patch1/patch1.case";
|
||||||
|
// Multiple inputs
|
||||||
|
//files ( "postProcessing/faceSource1/surface/patch1/patch1.case"
|
||||||
|
// "postProcessing/faceSource2/surface/patch2/patch2.case" );
|
||||||
|
|
||||||
// Surface reader
|
// Surface reader
|
||||||
reader ensight;
|
reader ensight;
|
||||||
@ -83,20 +86,25 @@ surfaceNoiseCoeffs
|
|||||||
//startTime 0;
|
//startTime 0;
|
||||||
|
|
||||||
// Write interval for FFT data, default = 1
|
// Write interval for FFT data, default = 1
|
||||||
// fftWriteInterval 100;
|
//fftWriteInterval 100;
|
||||||
|
|
||||||
|
// Bounds for valid pressure from input source
|
||||||
|
// Maximum pressure, default 0.5*VGREAT
|
||||||
|
//maxPressure 150e5;
|
||||||
|
|
||||||
|
// Minimum pressure, default -0.5*VGREAT
|
||||||
|
//minPressure -150e5;
|
||||||
}
|
}
|
||||||
|
|
||||||
pointNoiseCoeffs
|
pointNoiseCoeffs
|
||||||
{
|
{
|
||||||
csvFileData
|
file "pressureData";
|
||||||
{
|
//files ( "pressureData" "pressureData2");
|
||||||
file "pressureData";
|
nHeaderLine 1;
|
||||||
nHeaderLine 1;
|
refColumn 0;
|
||||||
refColumn 0;
|
componentColumns (1);
|
||||||
componentColumns (1);
|
separator " ";
|
||||||
separator " ";
|
mergeSeparators yes;
|
||||||
mergeSeparators yes;
|
|
||||||
}
|
|
||||||
|
|
||||||
HanningCoeffs
|
HanningCoeffs
|
||||||
{
|
{
|
||||||
@ -130,6 +138,13 @@ pointNoiseCoeffs
|
|||||||
|
|
||||||
// Write interval for FFT data, default = 1
|
// Write interval for FFT data, default = 1
|
||||||
fftWriteInterval 100;
|
fftWriteInterval 100;
|
||||||
|
|
||||||
|
// Bounds for valid pressure from input source
|
||||||
|
// Maximum pressure, default 0.5*VGREAT
|
||||||
|
//maxPressure 150e5;
|
||||||
|
|
||||||
|
// Minimum pressure, default -0.5*VGREAT
|
||||||
|
//minPressure -150e5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,274 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# ========= |
|
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
# \\ / O peration |
|
|
||||||
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
|
||||||
# \\/ M anipulation |
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
# License
|
|
||||||
# This file is part of OpenFOAM.
|
|
||||||
#
|
|
||||||
# OpenFOAM is free software: you can redistribute it and/or modify it
|
|
||||||
# under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
# for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# Script
|
|
||||||
# foamCreateBashCompletions
|
|
||||||
#
|
|
||||||
# Description
|
|
||||||
# Create bash completions for OpenFOAM applications
|
|
||||||
#
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
usage() {
|
|
||||||
exec 1>&2
|
|
||||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
|
||||||
cat<<USAGE
|
|
||||||
|
|
||||||
Usage: ${0##*/} [OPTION] [appName .. [appNameN]]
|
|
||||||
options:
|
|
||||||
-d dir | -dir dir Directory to process
|
|
||||||
-u | -user Add \$FOAM_USER_APPBIN to the search directories
|
|
||||||
-head | -header Generate header
|
|
||||||
-h | -help Print the usage
|
|
||||||
|
|
||||||
Create bash completions for OpenFOAM applications and write to stdout.
|
|
||||||
By default searches \$FOAM_APPBIN only.
|
|
||||||
Alternatively, scan the output from individual applications for single completion
|
|
||||||
commands (using the '_of_complete_' backend).
|
|
||||||
|
|
||||||
USAGE
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
searchDirs="$FOAM_APPBIN"
|
|
||||||
unset optHeader
|
|
||||||
while [ "$#" -gt 0 ]
|
|
||||||
do
|
|
||||||
case "$1" in
|
|
||||||
-h | -help)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
-d | -dir)
|
|
||||||
searchDirs="$2"
|
|
||||||
[ -d $searchDirs ] || usage "directory not found '$searchDirs'"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-u | -user)
|
|
||||||
searchDirs="$searchDirs $FOAM_USER_APPBIN"
|
|
||||||
;;
|
|
||||||
-head | -header)
|
|
||||||
optHeader=true
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
usage "unknown option: '$1'"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
# No applications given, then always generate a header
|
|
||||||
if [ "$#" -eq 0 ]
|
|
||||||
then
|
|
||||||
optHeader=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Header requested or required
|
|
||||||
[ "$optHeader" = true ] && cat << HEADER
|
|
||||||
#----------------------------------*-sh-*--------------------------------------
|
|
||||||
# Bash completions for OpenFOAM applications
|
|
||||||
# Recreate with "${0##*/}"
|
|
||||||
#
|
|
||||||
# Formatted as "complete ... -F _of_APPNAME APPNAME
|
|
||||||
|
|
||||||
#
|
|
||||||
# Generic completion handler for OpenFOAM applications
|
|
||||||
# - arg1 = command-name
|
|
||||||
# - arg2 = current word
|
|
||||||
# - arg3 = previous word
|
|
||||||
# - arg4 = options with args
|
|
||||||
# - arg5 = boolean options
|
|
||||||
#
|
|
||||||
unset -f _of_complete_ 2>/dev/null
|
|
||||||
_of_complete_()
|
|
||||||
{
|
|
||||||
# Unused: local cmd=\$1
|
|
||||||
local cur=\$2
|
|
||||||
local prev=\$3
|
|
||||||
local optsWithArgs="\$4 " # Trailing space added for easier matching
|
|
||||||
local opts="\$5 "
|
|
||||||
local choices
|
|
||||||
|
|
||||||
case \${prev} in
|
|
||||||
-help|-doc|-srcDoc)
|
|
||||||
# These options are usage and we can stop here.
|
|
||||||
COMPREPLY=()
|
|
||||||
return 0
|
|
||||||
;;
|
|
||||||
-case)
|
|
||||||
COMPREPLY=(\$(compgen -d -- \${cur}))
|
|
||||||
;;
|
|
||||||
-time)
|
|
||||||
# Could use "foamListTimes -withZero", but still doesn't address ranges
|
|
||||||
COMPREPLY=(\$(compgen -d -X '![-0-9]*' -- \${cur}))
|
|
||||||
;;
|
|
||||||
-region)
|
|
||||||
choices=\$(\ls -d system/*/ 2>/dev/null | sed -e 's#/\$##' -e 's#^.*/##')
|
|
||||||
COMPREPLY=(\$(compgen -W "\$choices" -- \${cur}))
|
|
||||||
;;
|
|
||||||
-fileHandler)
|
|
||||||
choices="collated uncollated masterUncollated"
|
|
||||||
COMPREPLY=(\$(compgen -W "\$choices" -- \${cur}))
|
|
||||||
;;
|
|
||||||
*Dict)
|
|
||||||
# local dirs=\$(\ls -d s*/)
|
|
||||||
# local files=\$(\ls -f | grep Dict)
|
|
||||||
# COMPREPLY=(\$(compgen -W \"\$dirs \$files\" -- \${cur}))
|
|
||||||
COMPREPLY=(\$(compgen -f -- \${cur}))
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
if [ "\${optsWithArgs/\${prev} /}" != "\${optsWithArgs}" ]
|
|
||||||
then
|
|
||||||
# Option with unknown type of arg - set to files.
|
|
||||||
# Not always correct but can still navigate path if needed...
|
|
||||||
COMPREPLY=(\$(compgen -f -- \${cur}))
|
|
||||||
elif [ -n "\$cur" -a "\${cur#-}" = "\${cur}" ]
|
|
||||||
then
|
|
||||||
# Already started a (non-empty) word that isn't an option,
|
|
||||||
# use files in which case revert to filenames.
|
|
||||||
COMPREPLY=(\$(compgen -f -- \${cur}))
|
|
||||||
else
|
|
||||||
# Catchall
|
|
||||||
# - Present remaining options (not already seen in \$COMP_LINE)
|
|
||||||
choices=\$(
|
|
||||||
for o in \${opts} \${optsWithArgs}
|
|
||||||
do
|
|
||||||
[ "\${COMP_LINE/\$o/}" = "\${COMP_LINE}" ] && echo \$o
|
|
||||||
done
|
|
||||||
)
|
|
||||||
COMPREPLY=(\$(compgen -W "\$choices" -- \${cur}))
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
HEADER
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Scans the output of the application -help to detect options with/without
|
|
||||||
# arguments. Dispatch via _of_complete_
|
|
||||||
#
|
|
||||||
generateCompletion()
|
|
||||||
{
|
|
||||||
local fullName="$1"
|
|
||||||
local appName="${1##*/}"
|
|
||||||
local appHelp
|
|
||||||
|
|
||||||
[ -f "$fullName" -a -x "$fullName" ] || {
|
|
||||||
echo "skip $fullName" 1>&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
if [ "$appName" = "complete_" ]
|
|
||||||
then
|
|
||||||
echo "skip $appName ... reserved name?" 1>&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
appHelp=$($fullName -help) || {
|
|
||||||
echo "error calling $fullName" 1>&2
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Options with args - as array
|
|
||||||
local optsWithArgs=($(awk '/^ {0,4}-[a-z]/ && /</ {print $1}' <<< "$appHelp"))
|
|
||||||
|
|
||||||
# Options without args - as array
|
|
||||||
local opts=($(awk '/^ {0,4}-[a-z]/ && !/</ {print $1}' <<< "$appHelp"))
|
|
||||||
|
|
||||||
# See bash(1) for some details. Completion functions are called with
|
|
||||||
# arg1 = command-name, arg2 = current word, arg3 = previous word
|
|
||||||
#
|
|
||||||
# Append known option types and dispatch to _of_complete_
|
|
||||||
echo " $appName" 1>&2
|
|
||||||
cat << COMPLETION
|
|
||||||
|
|
||||||
# [$appName]
|
|
||||||
unset -f _of_${appName} 2>/dev/null
|
|
||||||
_of_${appName}() {
|
|
||||||
_of_complete_ "\$@" \\
|
|
||||||
"${optsWithArgs[@]}" \\
|
|
||||||
"${opts[@]}"
|
|
||||||
}
|
|
||||||
complete -o filenames -F _of_${appName} $appName
|
|
||||||
|
|
||||||
COMPLETION
|
|
||||||
}
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$#" -eq 0 ]
|
|
||||||
then
|
|
||||||
|
|
||||||
for dir in ${searchDirs}
|
|
||||||
do
|
|
||||||
if [ -d "$dir" ]
|
|
||||||
then
|
|
||||||
echo "Processing directory $dir" 1>&2
|
|
||||||
else
|
|
||||||
echo "No such directory: $dir" 1>&2
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Sort with ignore-case
|
|
||||||
set -- $(\ls $dir | sort -f)
|
|
||||||
for appName
|
|
||||||
do
|
|
||||||
generateCompletion "$dir/$appName"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
for appName
|
|
||||||
do
|
|
||||||
if [ -f "$appName" -a -x "$appName" ]
|
|
||||||
then
|
|
||||||
generateCompletion "$appName"
|
|
||||||
elif fullName=$(command -v $appName 2>/dev/null)
|
|
||||||
then
|
|
||||||
generateCompletion "$fullName"
|
|
||||||
else
|
|
||||||
echo "No application found: $appName" 1>&2
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Generate footer
|
|
||||||
[ "$optHeader" = true ] && cat << FOOTER
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
FOOTER
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
199
bin/tools/foamCreateCompletionCache
Executable file
199
bin/tools/foamCreateCompletionCache
Executable file
@ -0,0 +1,199 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
# \\/ M anipulation |
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# License
|
||||||
|
# This file is part of OpenFOAM.
|
||||||
|
#
|
||||||
|
# OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
# for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# foamCreateCompletionCache
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Create cache of bash completion values for OpenFOAM applications
|
||||||
|
# The cached values are typically used by the tcsh completion wrapper.
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
defaultOutputFile="$WM_PROJECT_DIR/etc/config.sh/completion_cache"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
exec 1>&2
|
||||||
|
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||||
|
cat<<USAGE
|
||||||
|
|
||||||
|
Usage: ${0##*/} [OPTION] [appName .. [appNameN]]
|
||||||
|
options:
|
||||||
|
-d dir | -dir dir Directory to process
|
||||||
|
-u | -user Add \$FOAM_USER_APPBIN to the search directories
|
||||||
|
-no-header Suppress header generation
|
||||||
|
-o FILE Write to alternative output
|
||||||
|
-h | -help Print the usage
|
||||||
|
|
||||||
|
Create cache of bash completion values for OpenFOAM applications.
|
||||||
|
The cached values are typically used by the tcsh completion wrapper.
|
||||||
|
Default search: \$FOAM_APPBIN only.
|
||||||
|
Default output: $defaultOutputFile
|
||||||
|
|
||||||
|
Uses the search directory if applications are specified.
|
||||||
|
|
||||||
|
USAGE
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Report error and exit
|
||||||
|
die()
|
||||||
|
{
|
||||||
|
exec 1>&2
|
||||||
|
echo
|
||||||
|
echo "Error encountered:"
|
||||||
|
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||||
|
echo
|
||||||
|
echo "See '${0##*/} -help' for usage"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
searchDirs="$FOAM_APPBIN"
|
||||||
|
optHeader=true
|
||||||
|
unset outputFile
|
||||||
|
while [ "$#" -gt 0 ]
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
-h | -help)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
-d | -dir)
|
||||||
|
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||||
|
searchDirs="$2"
|
||||||
|
[ -d "$searchDirs" ] || die "directory not found '$searchDirs'"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-u | -user)
|
||||||
|
searchDirs="$searchDirs $FOAM_USER_APPBIN"
|
||||||
|
;;
|
||||||
|
-no-head*)
|
||||||
|
optHeader=false
|
||||||
|
;;
|
||||||
|
-o | -output)
|
||||||
|
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||||
|
outputFile="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
usage "unknown option: '$1'"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
: ${outputFile:=$defaultOutputFile}
|
||||||
|
|
||||||
|
# Verify that output is writeable
|
||||||
|
if [ -e "$outputFile" ]
|
||||||
|
then
|
||||||
|
[ -f "$outputFile" ] || \
|
||||||
|
die "Cannot overwrite $outputFile" "Not a file"
|
||||||
|
[ -w "$outputFile" ] || \
|
||||||
|
die "Cannot overwrite $outputFile" "No permission?"
|
||||||
|
else
|
||||||
|
[ -w "$(dirname $outputFile)" ] || \
|
||||||
|
die "Cannot write $outputFile" "directory is not writeble"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec 1>| $outputFile || exit $?
|
||||||
|
echo "Writing $outputFile" 1>&2
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
# Header not disabled
|
||||||
|
[ "$optHeader" = true ] && cat << HEADER
|
||||||
|
#----------------------------------*-sh-*--------------------------------------
|
||||||
|
# Cached options for bash completion of OpenFOAM applications.
|
||||||
|
# These are the values expected by the '_of_complete_' function
|
||||||
|
#
|
||||||
|
# Recreate with "${0##*/}"
|
||||||
|
|
||||||
|
# Global associative array (cached options for OpenFOAM applications)
|
||||||
|
declare -gA _of_complete_cache_;
|
||||||
|
|
||||||
|
# Clear existing cache.
|
||||||
|
_of_complete_cache_=()
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
HEADER
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Scans the output of the application -help to detect options with/without
|
||||||
|
# arguments. Dispatch via _of_complete_
|
||||||
|
#
|
||||||
|
extractOptions()
|
||||||
|
{
|
||||||
|
local appName="$1"
|
||||||
|
local helpText=$($appName -help 2>/dev/null | sed -ne '/^ *-/p')
|
||||||
|
|
||||||
|
[ -n "$helpText" ] || {
|
||||||
|
echo "Error calling $appName" 1>&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Array of options with args
|
||||||
|
local argOpts=($(awk '/^ {0,4}-[a-z]/ && /</ {print $1}' <<< "$helpText"))
|
||||||
|
|
||||||
|
# Array of options without args
|
||||||
|
local boolOpts=($(awk '/^ {0,4}-[a-z]/ && !/</ {print $1}' <<< "$helpText"))
|
||||||
|
|
||||||
|
appName="${appName##*/}"
|
||||||
|
echo "$appName" 1>&2
|
||||||
|
echo "_of_complete_cache_[${appName}]=\"${argOpts[@]} | ${boolOpts[@]}\""
|
||||||
|
}
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
[ "$#" -gt 0 ] || set -- ${searchDirs}
|
||||||
|
|
||||||
|
for item
|
||||||
|
do
|
||||||
|
if [ -d "$item" ]
|
||||||
|
then
|
||||||
|
# Process directory for applications - sort with ignore-case
|
||||||
|
echo "[directory] $item" 1>&2
|
||||||
|
choices="$(find $item -maxdepth 1 -executable -type f | sort -f 2>/dev/null)"
|
||||||
|
for appName in $choices
|
||||||
|
do
|
||||||
|
extractOptions $appName
|
||||||
|
done
|
||||||
|
elif command -v "$item" > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
extractOptions $item
|
||||||
|
else
|
||||||
|
echo "No such file or directory: $item" 1>&2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Generate footer
|
||||||
|
[ "$optHeader" = true ] && cat << FOOTER
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
FOOTER
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
@ -175,7 +175,7 @@ then
|
|||||||
_foamEtc config.sh/aliases
|
_foamEtc config.sh/aliases
|
||||||
|
|
||||||
# Bash completions
|
# Bash completions
|
||||||
if command -v complete > /dev/null 2>&1
|
if [ "${BASH_VERSINFO:-0}" -ge 4 ]
|
||||||
then
|
then
|
||||||
_foamEtc config.sh/bash_completion
|
_foamEtc config.sh/bash_completion
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -1,59 +0,0 @@
|
|||||||
#!bash
|
|
||||||
# A bash -*- sh -*- adapter for re-using OpenFOAM bash completions with tcsh
|
|
||||||
#
|
|
||||||
# Called with appName and COMMAND_LINE
|
|
||||||
#
|
|
||||||
# Source the bash completions
|
|
||||||
. $WM_PROJECT_DIR/etc/config.sh/bash_completion
|
|
||||||
|
|
||||||
appName=$1
|
|
||||||
|
|
||||||
# Ensure COMP_LINE is available for bash function
|
|
||||||
if [ "$#" -eq 2 ]
|
|
||||||
then
|
|
||||||
COMP_LINE=$2
|
|
||||||
else
|
|
||||||
COMP_LINE=$COMMAND_LINE
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove the colon as a completion separator because tcsh cannot handle it
|
|
||||||
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
|
|
||||||
|
|
||||||
# Set COMP_WORDS in a way that can be handled by the bash script.
|
|
||||||
COMP_WORDS=($COMP_LINE)
|
|
||||||
|
|
||||||
# The cursor is at the end of parameter #1.
|
|
||||||
# We must check for a space as the last character which will
|
|
||||||
# tell us that the previous word is complete and the cursor
|
|
||||||
# is on the next word.
|
|
||||||
if [ "${COMP_LINE: -1}" = " " ]
|
|
||||||
then
|
|
||||||
# The last character is a space, so our location is at the end
|
|
||||||
# of the command-line array
|
|
||||||
COMP_CWORD=${#COMP_WORDS[@]}
|
|
||||||
else
|
|
||||||
# The last character is not a space, so our location is on the
|
|
||||||
# last word of the command-line array, so we must decrement the
|
|
||||||
# count by 1
|
|
||||||
COMP_CWORD=$((${#COMP_WORDS[@]}-1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# bash completions are "complete ... -F _of_APPNAME APPNAME
|
|
||||||
_of_${appName} \
|
|
||||||
"$appName" "${COMP_WORDS[COMP_CWORD]}" "${COMP_WORDS[COMP_CWORD-1]}"
|
|
||||||
|
|
||||||
# Need slash on the end of directories for tcsh
|
|
||||||
reply=($(for i in ${COMPREPLY[@]}
|
|
||||||
do
|
|
||||||
if [ -d "$i" -a "${i#/}" = "$i" ]
|
|
||||||
then
|
|
||||||
echo "$i/"
|
|
||||||
else
|
|
||||||
echo "$i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
))
|
|
||||||
|
|
||||||
echo ${reply[@]}
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
|
||||||
102
etc/config.csh/complete-wrapper
Normal file
102
etc/config.csh/complete-wrapper
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
#!bash
|
||||||
|
#----------------------------------*-sh-*--------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
# \\/ M anipulation |
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# This file is part of OpenFOAM, licensed under the GNU General Public License
|
||||||
|
# <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# File
|
||||||
|
# etc/config.csh/complete-wrapper
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# A wrapper for using OpenFOAM bash completions with tcsh.
|
||||||
|
#
|
||||||
|
# Arguments
|
||||||
|
# appName = the application name
|
||||||
|
#
|
||||||
|
# Environment
|
||||||
|
# The tcsh COMMAND_LINE is passed in via the environment.
|
||||||
|
# This corresponds to the bash COMP_LINE variable
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
[ "$#" -ge 1 ] || exit 1
|
||||||
|
|
||||||
|
# Support '-test' option to check bash version
|
||||||
|
if [ "$1" = "-test" ]
|
||||||
|
then
|
||||||
|
# Uses 'declare -gA' for the implementation
|
||||||
|
# The '-A' requires bash >= 4.0 and the '-g' requires bash >= 4.2
|
||||||
|
[ "${BASH_VERSINFO[0]:-0}${BASH_VERSINFO[1]:-0}" -ge 42 ]
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Preload completion cache
|
||||||
|
if [ -f $WM_PROJECT_DIR/etc/config.sh/completion_cache ]
|
||||||
|
then . $WM_PROJECT_DIR/etc/config.sh/completion_cache
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use the bash completion function, but retain cache etc.
|
||||||
|
_of_complete_tcsh=true
|
||||||
|
if [ -f $WM_PROJECT_DIR/etc/config.sh/bash_completion ]
|
||||||
|
then . $WM_PROJECT_DIR/etc/config.sh/bash_completion
|
||||||
|
else
|
||||||
|
# Could warn about missing file, or treat silently
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
appName=$1
|
||||||
|
|
||||||
|
# Ensure COMP_LINE is available for bash function
|
||||||
|
if [ "$#" -eq 2 ]
|
||||||
|
then
|
||||||
|
COMP_LINE=$2
|
||||||
|
else
|
||||||
|
COMP_LINE=$COMMAND_LINE
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove the colon as a completion separator because tcsh cannot handle it
|
||||||
|
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
|
||||||
|
|
||||||
|
# Set COMP_WORDS in a way that can be handled by the bash script.
|
||||||
|
COMP_WORDS=($COMP_LINE)
|
||||||
|
|
||||||
|
# The cursor is at the end of parameter #1.
|
||||||
|
# We must check for a space as the last character which will
|
||||||
|
# tell us that the previous word is complete and the cursor
|
||||||
|
# is on the next word.
|
||||||
|
if [ "${COMP_LINE: -1}" = " " ]
|
||||||
|
then
|
||||||
|
# The last character is a space, so our location is at the end
|
||||||
|
# of the command-line array
|
||||||
|
COMP_CWORD=${#COMP_WORDS[@]}
|
||||||
|
else
|
||||||
|
# The last character is not a space, so our location is on the
|
||||||
|
# last word of the command-line array, so we must decrement the
|
||||||
|
# count by 1
|
||||||
|
COMP_CWORD=$((${#COMP_WORDS[@]}-1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Call _of_complete_ APPNAME Current Previous
|
||||||
|
_of_complete_ \
|
||||||
|
"$appName" "${COMP_WORDS[COMP_CWORD]}" "${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
# Tcsh needs slash on the end of directories
|
||||||
|
reply=($(for i in ${COMPREPLY[@]}
|
||||||
|
do
|
||||||
|
if [ -d "$i" -a "${i#/}" = "$i" ]
|
||||||
|
then
|
||||||
|
echo "$i/"
|
||||||
|
else
|
||||||
|
echo "$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
))
|
||||||
|
|
||||||
|
echo ${reply[@]}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
@ -1,17 +1,47 @@
|
|||||||
#----------------------------------*-sh-*--------------------------------------
|
#----------------------------------*-sh-*--------------------------------------
|
||||||
# Tcsh completions for OpenFOAM applications
|
# ========= |
|
||||||
# Using bash_completion functions for the hard work
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
# \\/ M anipulation |
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# This file is part of OpenFOAM, licensed under the GNU General Public License
|
||||||
|
# <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# File
|
||||||
|
# etc/config.csh/tcsh_completion
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Tcsh completions for OpenFOAM applications
|
||||||
|
# Using bash completion for the hard work
|
||||||
|
#
|
||||||
|
# Requires
|
||||||
|
# bash 4.2 or newer
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
if ($?tcsh) then # tcsh only
|
if ($?tcsh) then # tcsh only
|
||||||
if ( -f $WM_PROJECT_DIR/etc/config.sh/bash_completion \
|
|
||||||
&& -f $WM_PROJECT_DIR/etc/config.csh/complete) then
|
# Remove old completions, which look like:
|
||||||
foreach appName (`sed -ne 's/^complete.* //p' $WM_PROJECT_DIR/etc/config.sh/bash_completion`)
|
# complete APPNAME 'p,*,`bash $WM_PROJECT_DIR/etc/ ...
|
||||||
# Pass explicitly
|
foreach appName (`complete | sed -ne '/WM_PROJECT/s/\t.*$//p'`)
|
||||||
## complete $appName 'p,*,`bash $WM_PROJECT_DIR/etc/config.csh/complete '$appName' "${COMMAND_LINE}"`,'
|
uncomplete $appName
|
||||||
# Pass via environment
|
end
|
||||||
complete $appName 'p,*,`bash $WM_PROJECT_DIR/etc/config.csh/complete '$appName'`,'
|
|
||||||
|
# Generate completions for predefined directories (if support is possible)
|
||||||
|
bash $WM_PROJECT_DIR/etc/config.csh/complete-wrapper -test
|
||||||
|
if ($status == 0) then
|
||||||
|
foreach dirName ("$FOAM_APPBIN")
|
||||||
|
if ( ! -d $dirName ) continue
|
||||||
|
foreach appName (`find $dirName -maxdepth 1 -executable -type f`)
|
||||||
|
# Pass explicitly
|
||||||
|
## complete $appName:t 'p,*,`bash $WM_PROJECT_DIR/etc/config.csh/complete-wrapper '$appName:t' "${COMMAND_LINE}"`,'
|
||||||
|
# Pass via environment
|
||||||
|
complete $appName:t 'p,*,`bash $WM_PROJECT_DIR/etc/config.csh/complete-wrapper '$appName:t'`,'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -196,11 +196,10 @@ unalias wmRefresh
|
|||||||
unalias foamVersion
|
unalias foamVersion
|
||||||
unalias foamPV
|
unalias foamPV
|
||||||
|
|
||||||
# Cleanup completions, which look like this:
|
# Remove old completions, which look like:
|
||||||
# complete blockMesh 'p,*,`bash $WM_PROJECT_DIR/etc/ ...
|
# complete APPNAME 'p,*,`bash $WM_PROJECT_DIR/etc/ ...
|
||||||
|
|
||||||
if ($?prompt && $?tcsh) then # Interactive tcsh only
|
if ($?prompt && $?tcsh) then # Interactive tcsh only
|
||||||
foreach cleaned (`complete | sed -n -e '/WM_PROJECT/s/\t.*$//p'`)
|
foreach cleaned (`complete | sed -ne '/WM_PROJECT/s/\t.*$//p'`)
|
||||||
uncomplete $cleaned
|
uncomplete $cleaned
|
||||||
end
|
end
|
||||||
endif
|
endif
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
259
etc/config.sh/completion_cache
Normal file
259
etc/config.sh/completion_cache
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
#----------------------------------*-sh-*--------------------------------------
|
||||||
|
# Cached options for bash completion of OpenFOAM applications.
|
||||||
|
# These are the values expected by the '_of_complete_' function
|
||||||
|
#
|
||||||
|
# Recreate with "foamCreateCompletionCache"
|
||||||
|
|
||||||
|
# Global associative array (cached options for OpenFOAM applications)
|
||||||
|
declare -gA _of_complete_cache_;
|
||||||
|
|
||||||
|
# Clear existing cache.
|
||||||
|
_of_complete_cache_=()
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
_of_complete_cache_[adiabaticFlameT]="-case | -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[adjointShapeOptimizationFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[ansysToFoam]="-case -scale | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[applyBoundaryLayer]="-case -decomposeParDict -region -roots -ybl | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[attachMesh]="-case | -noFunctionObjects -overwrite -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[autoPatch]="-case | -noFunctionObjects -overwrite -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[blockMesh]="-case -dict -region | -blockTopology -noClean -noFunctionObjects -sets -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[boundaryFoam]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[boxTurb]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[buoyantBoussinesqPimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[buoyantBoussinesqSimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[buoyantPimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[buoyantSimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[cavitatingDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[cavitatingFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[cfx4ToFoam]="-case -scale | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[changeDictionary]="-case -decomposeParDict -dict -instance -region -roots -subDict -time | -constant -disablePatchGroups -enableFunctionEntries -latestTime -literalRE -newTimes -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[checkMesh]="-case -decomposeParDict -region -roots -time -writeFields -writeSets | -allGeometry -allTopology -constant -latestTime -meshQuality -newTimes -noFunctionObjects -noTopology -noZero -parallel -writeAllFields -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[chemFoam]="-case | -noFunctionObjects -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[chemkinToFoam]="-case | -newFormat -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[chtMultiRegionFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[chtMultiRegionSimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[coalChemistryFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[coldEngineFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[collapseEdges]="-case -collapseFaceSet -decomposeParDict -dict -roots -time | -collapseFaces -constant -latestTime -newTimes -noFunctionObjects -noZero -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[combinePatchFaces]="-case -concaveAngle -decomposeParDict -roots | -meshQuality -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[compressibleInterDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[compressibleInterFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[compressibleMultiphaseInterFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[createBaffles]="-case -decomposeParDict -dict -region -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[createExternalCoupledPatchGeometry]="-case -commsDir -decomposeParDict -region -regions -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[createPatch]="-case -decomposeParDict -dict -region -roots | -noFunctionObjects -overwrite -parallel -writeObj -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[createZeroDirectory]="-case -decomposeParDict -roots -templateDir | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[datToFoam]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[decomposePar]="-case -decomposeParDict -region -time | -allRegions -cellDist -constant -copyUniform -copyZero -fields -force -ifRequired -latestTime -newTimes -noFunctionObjects -noSets -noZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[deformedGeom]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[dnsFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[DPMDyMFoam]="-case -cloudName -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[DPMFoam]="-case -cloud -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[driftFluxFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[dsmcFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[dsmcInitialise]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[electrostaticFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[engineCompRatio]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[engineFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[engineSwirl]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[equilibriumCO]="-case | -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[equilibriumFlameT]="-case | -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[extrude2DMesh]="-case -decomposeParDict -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[extrudeMesh]="-case -decomposeParDict -region -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[extrudeToRegionMesh]="-case -decomposeParDict -dict -region -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[faceAgglomerate]="-case -decomposeParDict -dict -region -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[financialFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[fireFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[fireToFoam]="-case -scale | -ascii -check -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[flattenMesh]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[fluent3DMeshToFoam]="-case -ignoreCellGroups -ignoreFaceGroups -scale | -cubit -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[fluentMeshToFoam]="-case -scale | -noFunctionObjects -writeSets -writeZones -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamDataToFluent]="-case -time | -latestTime -newTimes -noFunctionObjects -noZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamDictionary]="-add -case -decomposeParDict -diff -entry -roots -set | -disableFunctionEntries -expand -includes -keywords -noFunctionObjects -parallel -remove -value -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamFormatConvert]="-case -decomposeParDict -region -roots -time | -constant -enableFunctionEntries -latestTime -newTimes -noConstant -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamHelp]="-case -decomposeParDict -region -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamList]="-case -scalarBCs -vectorBCs | -compressibleTurbulenceModels -functionObjects -fvOptions -incompressibleTurbulenceModels -noFunctionObjects -registeredSwitches -switches -unset -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamListTimes]="-case -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -processor -rm -withZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamMeshToFluent]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToEnsight]="-case -cellZone -decomposeParDict -faceZones -fields -name -patches -region -roots -time -width | -ascii -constant -latestTime -newTimes -noFunctionObjects -noLagrangian -noPatches -noZero -nodeValues -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToEnsightParts]="-case -index -name -time -width | -ascii -constant -latestTime -newTimes -noFunctionObjects -noLagrangian -noMesh -noZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToFireMesh]="-case -scale -time | -ascii -constant -latestTime -newTimes -noFunctionObjects -noZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToGMV]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToStarMesh]="-case -scale -time | -constant -latestTime -newTimes -noBnd -noFunctionObjects -noZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToSurface]="-case -scale -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -tri -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToTecplot360]="-case -cellSet -decomposeParDict -excludePatches -faceSet -fields -region -roots -time | -constant -latestTime -nearCellValue -newTimes -noFaceZones -noFunctionObjects -noInternal -noPointValues -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToTetDualMesh]="-case -decomposeParDict -roots -time | -constant -latestTime -noFunctionObjects -noZero -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamToVTK]="-case -cellSet -decomposeParDict -excludePatches -faceSet -fields -name -pointSet -region -roots -time | -allPatches -ascii -constant -latestTime -nearCellValue -newTimes -noFaceZones -noFunctionObjects -noInternal -noLagrangian -noLinks -noPointValues -noZero -parallel -poly -surfaceFields -useTimeName -xml -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamUpgradeCyclics]="-case -decomposeParDict -region -roots -time | -constant -enableFunctionEntries -latestTime -newTimes -noFunctionObjects -noZero -parallel -test -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamyHexMesh]="-case -decomposeParDict -roots | -checkGeometry -conformationOnly -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[foamyQuadMesh]="-case -pointsFile | -noFunctionObjects -overwrite -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[gambitToFoam]="-case -scale | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[gmshToFoam]="-case -region | -keepOrientation -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[icoFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[icoUncoupledKinematicParcelDyMFoam]="-case -cloud -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[icoUncoupledKinematicParcelFoam]="-case -cloud -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[ideasUnvToFoam]="-case | -dump -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[insideCells]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[interCondensatingEvaporatingFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[interDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[interFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[interIsoFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[interMixingFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[interPhaseChangeDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[interPhaseChangeFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[kivaToFoam]="-case -file -version -zHeadMin | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[laplacianFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[lumpedPointForces]="-case -decomposeParDict -region -roots -time | -constant -latestTime -newTimes -noZero -parallel -vtk -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[lumpedPointMovement]="-case -max -scale -span | -removeLock -slave -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[lumpedPointZones]="-case -region | -verbose -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[magneticFoam]="-case -decomposeParDict -roots | -noB -noFunctionObjects -noH -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mapFields]="-case -mapMethod -sourceDecomposeParDict -sourceRegion -sourceTime -targetDecomposeParDict -targetRegion | -consistent -noFunctionObjects -parallelSource -parallelTarget -subtract -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mapFieldsPar]="-case -decomposeParDict -fields -mapMethod -patchMapMethod -roots -sourceRegion -sourceTime -targetRegion | -consistent -noFunctionObjects -noLagrangian -parallel -subtract -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mdEquilibrationFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mdFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mdInitialise]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mergeMeshes]="-addRegion -case -decomposeParDict -masterRegion -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mergeOrSplitBaffles]="-case -decomposeParDict -dict -region -roots | -detectOnly -noFunctionObjects -overwrite -parallel -split -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mhdFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mirrorMesh]="-case -decomposeParDict -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mixtureAdiabaticFlameT]="-case | -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[modifyMesh]="-case -decomposeParDict -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[moveDynamicMesh]="-case -decomposeParDict -region -roots | -checkAMI -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[moveEngineMesh]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[moveMesh]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[MPPICDyMFoam]="-case -cloudName -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[MPPICFoam]="-case -cloud -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[MPPICInterFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[mshToFoam]="-case | -hex -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[multiphaseEulerFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[multiphaseInterDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[multiphaseInterFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[netgenNeutralToFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[noise]="-case -decomposeParDict -dict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[nonNewtonianIcoFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[objToVTK]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[orientFaceZone]="-case -decomposeParDict -region -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[overInterDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[overLaplacianDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[overPimpleDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[overRhoPimpleDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[overSimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[particleTracks]="-case -decomposeParDict -region -roots -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[patchSummary]="-case -decomposeParDict -region -roots -time | -constant -expand -latestTime -newTimes -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[pdfPlot]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[PDRFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[PDRMesh]="-case -decomposeParDict -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[pimpleDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[pimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[pisoFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[plot3dToFoam]="-case -scale | -noBlank -noFunctionObjects -singleBlock -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[polyDualMesh]="-case | -concaveMultiCells -doNotPreserveFaceZones -noFunctionObjects -overwrite -splitAllFaces -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[porousSimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[postChannel]="-case -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[postProcess]="-case -decomposeParDict -dict -field -fields -func -funcs -region -roots -time | -constant -latestTime -list -newTimes -noFunctionObjects -noZero -parallel -profiling -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[potentialFoam]="-case -decomposeParDict -pName -roots | -initialiseUBCs -noFunctionObjects -parallel -withFunctionObjects -writePhi -writep -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[potentialFreeSurfaceDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[potentialFreeSurfaceFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[reactingFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[reactingMultiphaseEulerFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[reactingParcelFilmFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[reactingParcelFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[reactingTwoPhaseEulerFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[reconstructPar]="-case -fields -lagrangianFields -region -time | -allRegions -constant -latestTime -newTimes -noFields -noFunctionObjects -noLagrangian -noSets -noZero -withZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[reconstructParMesh]="-case -mergeTol -region -time | -cellDist -constant -fullMatch -latestTime -newTimes -noFunctionObjects -noZero -withZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[redistributePar]="-case -decomposeParDict -mergeTol -region -roots -time | -cellDist -constant -decompose -latestTime -newTimes -noFunctionObjects -noZero -overwrite -parallel -reconstruct -withZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[refineHexMesh]="-case -decomposeParDict -region -roots | -minSet -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[refinementLevel]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -readLevel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[refineMesh]="-case -decomposeParDict -dict -region -roots | -all -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[refineWallLayer]="-case -decomposeParDict -roots -useSet | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[removeFaces]="-case -decomposeParDict -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[renumberMesh]="-case -decomposeParDict -dict -region -roots -time | -constant -frontWidth -latestTime -noFunctionObjects -noZero -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoCentralDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoCentralFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoPimpleAdiabaticFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoPimpleDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoPimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoPorousSimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoReactingBuoyantFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoReactingFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rhoSimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[rotateMesh]="-case -decomposeParDict -roots -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[scalarTransportFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[selectCells]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[setAlphaField]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[setFields]="-case -decomposeParDict -dict -region -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[setSet]="-batch -case -decomposeParDict -region -roots -time | -constant -latestTime -loop -newTimes -noFunctionObjects -noSync -noVTK -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[setsToZones]="-case -decomposeParDict -region -roots -time | -constant -latestTime -newTimes -noFlipMap -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[shallowWaterFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[simpleCoalParcelFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[simpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[simpleReactingParcelFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[singleCellMesh]="-case -decomposeParDict -roots -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[smapToFoam]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[snappyHexMesh]="-case -decomposeParDict -dict -outFile -patches -region -roots -surfaceSimplify | -checkGeometry -noFunctionObjects -overwrite -parallel -profiling -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[snappyRefineMesh]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[solidDisplacementFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[solidEquilibriumDisplacementFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[sonicDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[sonicFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[sonicLiquidFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[splitCells]="-case -set -tol | -geometry -noFunctionObjects -overwrite -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[splitMesh]="-case | -noFunctionObjects -overwrite -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[splitMeshRegions]="-blockedFaces -case -cellZonesFileOnly -decomposeParDict -insidePoint -region -roots | -cellZones -cellZonesOnly -detectOnly -largestOnly -makeCellZones -noFunctionObjects -overwrite -parallel -prefixRegion -sloppyCellZones -useFaceZones -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[sprayDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[sprayEngineFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[sprayFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[SRFPimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[SRFSimpleFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[star4ToFoam]="-case -scale | -ascii -noFunctionObjects -solids -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[steadyParticleTracks]="-case -dict -region -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[stitchMesh]="-case -region -toleranceDict | -noFunctionObjects -overwrite -partial -perfect -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[subsetMesh]="-case -decomposeParDict -patch -patches -region -resultTime -roots | -noFunctionObjects -overwrite -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceAdd]="-case -points | -mergeRegions -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceBooleanFeatures]="-case -trim | -invertedSpace -noFunctionObjects -perturb -surf1Baffle -surf2Baffle -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceCheck]="-case -outputThreshold | -blockMesh -checkSelfIntersection -noFunctionObjects -splitNonManifold -verbose -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceClean]="-case | -noClean -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceCoarsen]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceConvert]="-case -scale -writePrecision | -clean -group -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceFeatureConvert]="-case -scale | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceFeatureExtract]="-case -dict | -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceFind]="-case -x -y -z | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceHookUp]="-case -dict | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceInertia]="-case -density -referencePoint | -noFunctionObjects -shellProperties -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceInflate]="-case -featureAngle -nSmooth | -checkSelfIntersection -debug -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceLambdaMuSmooth]="-featureFile | -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceMeshConvert]="-case -dict -from -scaleIn -scaleOut -to | -clean -noFunctionObjects -tri -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceMeshConvertTesting]="-case -scale | -clean -noFunctionObjects -orient -stdout -surfMesh -testModify -triFace -triSurface -unsorted -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceMeshExport]="-case -dict -from -name -scaleIn -scaleOut -to | -clean -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceMeshImport]="-case -dict -from -name -scaleIn -scaleOut -to | -clean -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceMeshInfo]="-case -scale | -areas -noFunctionObjects -xml -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceMeshTriangulate]="-case -decomposeParDict -faceZones -patches -region -roots -time | -constant -excludeProcPatches -latestTime -newTimes -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceOrient]="-case | -inside -noFunctionObjects -usePierceTest -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfacePatch]="-case -dict | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfacePointMerge]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceRedistributePar]="-case -decomposeParDict -roots | -keepNonMapped -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceRefineRedGreen]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceSplitByPatch]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceSplitByTopology]=" | -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceSplitNonManifolds]="-case | -debug -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceSubset]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceToPatch]="-case -faceSet -tol | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[surfaceTransformPoints]="-case -rollPitchYaw -rotate -scale -translate -yawPitchRoll | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[temporalInterpolate]="-case -decomposeParDict -divisions -fields -interpolationType -region -roots -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[tetgenToFoam]="-case -decomposeParDict -roots | -noFaceFile -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[thermoFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[topoSet]="-case -decomposeParDict -dict -region -roots -time | -constant -latestTime -newTimes -noFunctionObjects -noSync -noZero -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[transformPoints]="-case -decomposeParDict -region -rollPitchYaw -roots -rotate -scale -translate -yawPitchRoll | -noFunctionObjects -parallel -rotateFields -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[twoLiquidMixingFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[twoPhaseEulerFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[uncoupledKinematicParcelFoam]="-case -cloud -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[viewFactorsGen]="-case -decomposeParDict -region -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[vtkUnstructuredToFoam]="-case | -noFunctionObjects -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[wallFunctionTable]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[writeMeshObj]="-case -cell -cellSet -decomposeParDict -face -faceSet -point -region -roots -time | -constant -latestTime -newTimes -noFunctionObjects -noZero -parallel -patchEdges -patchFaces -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[XiDyMFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[XiFoam]="-case -decomposeParDict -roots | -noFunctionObjects -parallel -postProcess -srcDoc -doc -help"
|
||||||
|
_of_complete_cache_[zipUpMesh]="-case -decomposeParDict -region -roots | -noFunctionObjects -parallel -srcDoc -doc -help"
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
@ -181,16 +181,21 @@ unset -f wmRefresh 2>/dev/null
|
|||||||
unset -f foamVersion 2>/dev/null
|
unset -f foamVersion 2>/dev/null
|
||||||
unset -f foamPV 2>/dev/null
|
unset -f foamPV 2>/dev/null
|
||||||
|
|
||||||
# Cleanup bash completions, which look like this:
|
# Remove old completions, which look like
|
||||||
# "complete ... -F _of_APPNAME APPNAME
|
# "complete ... -F _of_complete_ APPNAME
|
||||||
# For economy, obtain list first but also remove the 'of_complete_' backend
|
# For economy, obtain list first
|
||||||
foamClean="$(complete 2>/dev/null | sed -n -e 's/complete.*-F _of_.* \(..*\)$/\1/p')"
|
foamOldDirs="$(complete 2>/dev/null | sed -ne 's/^.*-F _of_.* \(..*\)$/\1/p')"
|
||||||
for cleaned in $foamClean complete_
|
for cleaned in $foamOldDirs
|
||||||
do
|
do
|
||||||
unset -f _of_$cleaned 2>/dev/null
|
complete -r $cleaned 2>/dev/null
|
||||||
complete -r $cleaned 2>/dev/null
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Completion functions
|
||||||
|
unset -f foamAddCompletion 2>/dev/null
|
||||||
|
unset -f _of_complete_ 2>/dev/null
|
||||||
|
|
||||||
|
# Completion cache
|
||||||
|
unset _of_complete_cache_
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Intermediate variables (do as last for a clean exit code)
|
# Intermediate variables (do as last for a clean exit code)
|
||||||
|
|||||||
@ -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 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -24,102 +24,61 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "cpuInfo.H"
|
#include "cpuInfo.H"
|
||||||
#include "IFstream.H"
|
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
// file-scope function
|
// file-scope function
|
||||||
template<class T>
|
// split things like "a key word\t: value information"
|
||||||
inline static void writeEntry
|
// into ("a_key_word", "value information")
|
||||||
(
|
//
|
||||||
Foam::Ostream& os, const Foam::word& key, const T& value
|
static bool split(const std::string& line, std::string& key, std::string& val)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
os.writeKeyword(key) << value << Foam::token::END_STATEMENT << '\n';
|
key.clear();
|
||||||
}
|
val.clear();
|
||||||
|
|
||||||
|
const auto keyLen = line.find_first_of("\t:");
|
||||||
|
const auto sep = line.find(':');
|
||||||
|
|
||||||
// file-scope function
|
if (keyLen == std::string::npos || sep == std::string::npos)
|
||||||
static bool split(std::string& line, std::string& key, std::string& val)
|
|
||||||
{
|
|
||||||
std::string::size_type sep = line.find(':');
|
|
||||||
|
|
||||||
if (sep == std::string::npos)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string::size_type endKey = line.find_last_not_of("\t:", sep);
|
const auto begVal = line.find_first_not_of(" :", sep);
|
||||||
std::string::size_type begVal = line.find_first_not_of(" :", sep);
|
|
||||||
|
|
||||||
if (endKey == std::string::npos || begVal == std::string::npos)
|
if (begVal == std::string::npos)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
++endKey;
|
|
||||||
|
|
||||||
// replace spaces in key with '_' for ease of use/consistency
|
key = line.substr(0, keyLen);
|
||||||
for
|
val = line.substr(begVal);
|
||||||
(
|
|
||||||
std::string::iterator iter = line.begin();
|
// Avoid spaces in key - replace with '_'
|
||||||
iter != line.end();
|
for (auto iter = key.begin(); iter < key.end(); ++iter)
|
||||||
++iter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (*iter == ' ')
|
if (*iter == ' ')
|
||||||
{
|
{
|
||||||
*iter = '_';
|
*iter = '_';
|
||||||
}
|
}
|
||||||
else if (*iter == ':')
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
key = line.substr(0, endKey);
|
// std::cerr<<"key=<" << key << "> val=<" << val << ">\n";
|
||||||
val = line.substr(begVal);
|
|
||||||
|
|
||||||
// std::cerr<<"key=" << key << " val= " << val << '\n';
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// file-scope function - get int
|
|
||||||
static inline bool getInt(const std::string& str, int& val)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if (sscanf(str.c_str(), "%d", &i) == 1)
|
|
||||||
{
|
|
||||||
val = i;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// file-scope function - get float
|
|
||||||
static inline bool getFlt(const std::string& str, float& val)
|
|
||||||
{
|
|
||||||
float f;
|
|
||||||
if (sscanf(str.c_str(), "%f", &f) == 1)
|
|
||||||
{
|
|
||||||
val = f;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
// parse this type of content:
|
// Parse the following type of content.
|
||||||
|
// A TAB separates the keyword from content. Eg,
|
||||||
|
//
|
||||||
|
// "cpu cores\t: 6"
|
||||||
|
//
|
||||||
// ===========================
|
// ===========================
|
||||||
// processor : 0
|
// processor : 0
|
||||||
// vendor_id : GenuineIntel
|
// vendor_id : GenuineIntel
|
||||||
@ -151,14 +110,14 @@ static inline bool getFlt(const std::string& str, float& val)
|
|||||||
void Foam::cpuInfo::parse()
|
void Foam::cpuInfo::parse()
|
||||||
{
|
{
|
||||||
int ncpu = 0;
|
int ncpu = 0;
|
||||||
|
std::string line, key, val;
|
||||||
|
|
||||||
IFstream is("/proc/cpuinfo");
|
std::ifstream is("/proc/cpuinfo");
|
||||||
while (is.good())
|
while (is.good())
|
||||||
{
|
{
|
||||||
string line, key, value;
|
std::getline(is, line);
|
||||||
is.getLine(line);
|
|
||||||
|
|
||||||
if (!split(line, key, value))
|
if (!split(line, key, val))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -170,13 +129,13 @@ void Foam::cpuInfo::parse()
|
|||||||
break; // stop after the first cpu
|
break; // stop after the first cpu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (key == "vendor_id") { vendor_id = value; }
|
else if (key == "vendor_id") { vendor_id = val; }
|
||||||
else if (key == "model_name") { model_name = value; }
|
else if (key == "model_name") { model_name = val; }
|
||||||
else if (key == "cpu_family") { getInt(value, cpu_family); }
|
else if (key == "cpu_family") { cpu_family = std::stoi(val); }
|
||||||
else if (key == "model") { getInt(value, model); }
|
else if (key == "model") { model = std::stoi(val); }
|
||||||
else if (key == "cpu_MHz") { getFlt(value, cpu_MHz); }
|
else if (key == "cpu_MHz") { cpu_MHz = std::stof(val); }
|
||||||
else if (key == "cpu_cores") { getInt(value, cpu_cores); }
|
else if (key == "cpu_cores") { cpu_cores = std::stoi(val); }
|
||||||
else if (key == "siblings") { getInt(value, siblings); }
|
else if (key == "siblings") { siblings = std::stoi(val); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,31 +168,31 @@ void Foam::cpuInfo::write(Ostream& os) const
|
|||||||
{
|
{
|
||||||
if (!vendor_id.empty())
|
if (!vendor_id.empty())
|
||||||
{
|
{
|
||||||
writeEntry(os, "vendor_id", vendor_id);
|
os.writeEntry("vendor_id", vendor_id);
|
||||||
}
|
}
|
||||||
if (!model_name.empty())
|
if (!model_name.empty())
|
||||||
{
|
{
|
||||||
writeEntry(os, "model_name", model_name);
|
os.writeEntry("model_name", model_name);
|
||||||
}
|
}
|
||||||
if (cpu_family != -1)
|
if (cpu_family != -1)
|
||||||
{
|
{
|
||||||
writeEntry(os, "cpu_family", cpu_family);
|
os.writeEntry("cpu_family", cpu_family);
|
||||||
}
|
}
|
||||||
if (model != -1)
|
if (model != -1)
|
||||||
{
|
{
|
||||||
writeEntry(os, "model", model);
|
os.writeEntry("model", model);
|
||||||
}
|
}
|
||||||
if (cpu_MHz > 0)
|
if (cpu_MHz > 0)
|
||||||
{
|
{
|
||||||
writeEntry(os, "cpu_MHz", cpu_MHz);
|
os.writeEntry("cpu_MHz", cpu_MHz);
|
||||||
}
|
}
|
||||||
if (cpu_cores > 0)
|
if (cpu_cores > 0)
|
||||||
{
|
{
|
||||||
writeEntry(os, "cpu_cores", cpu_cores);
|
os.writeEntry("cpu_cores", cpu_cores);
|
||||||
}
|
}
|
||||||
if (siblings > 0)
|
if (siblings > 0)
|
||||||
{
|
{
|
||||||
writeEntry(os, "siblings", siblings);
|
os.writeEntry("siblings", siblings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,8 @@ SourceFiles
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
// forward declarations
|
|
||||||
|
// Forward declarations
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
@ -68,6 +69,7 @@ class cpuInfo
|
|||||||
int siblings;
|
int siblings;
|
||||||
int cpu_cores;
|
int cpu_cores;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Parse /proc/cpuinfo
|
//- Parse /proc/cpuinfo
|
||||||
@ -83,7 +85,7 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct null
|
//- Construct and populate with information
|
||||||
cpuInfo();
|
cpuInfo();
|
||||||
|
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ public:
|
|||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Write content as dictionary entries
|
//- Write content as dictionary entries
|
||||||
void write(Ostream&) const;
|
void write(Ostream& os) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -24,21 +24,11 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "memInfo.H"
|
#include "memInfo.H"
|
||||||
#include "IFstream.H"
|
#include "OSspecific.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
// file-scope function
|
|
||||||
template<class T>
|
|
||||||
inline static void writeEntry
|
|
||||||
(
|
|
||||||
Foam::Ostream& os, const Foam::word& key, const T& value
|
|
||||||
)
|
|
||||||
{
|
|
||||||
os.writeKeyword(key) << value << Foam::token::END_STATEMENT << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -59,34 +49,64 @@ Foam::memInfo::~memInfo()
|
|||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
//
|
||||||
|
// Parse the following type of content.
|
||||||
|
//
|
||||||
|
// ===========================
|
||||||
|
// VmPeak: 15920 kB
|
||||||
|
// VmSize: 15916 kB
|
||||||
|
// VmLck: 0 kB
|
||||||
|
// VmPin: 0 kB
|
||||||
|
// VmHWM: 6972 kB
|
||||||
|
// VmRSS: 6972 kB
|
||||||
|
// VmLib: 2208 kB
|
||||||
|
// VmPTE: 52 kB
|
||||||
|
// VmPMD: 12 kB
|
||||||
|
// VmSwap: 0 kB
|
||||||
|
|
||||||
const Foam::memInfo& Foam::memInfo::update()
|
const Foam::memInfo& Foam::memInfo::update()
|
||||||
{
|
{
|
||||||
// reset to invalid values first
|
// Clear (invalidate) values first
|
||||||
peak_ = size_ = rss_ = 0;
|
peak_ = size_ = rss_ = 0;
|
||||||
IFstream is("/proc/" + name(pid()) + "/status");
|
std::string line;
|
||||||
|
|
||||||
while (is.good())
|
unsigned nKeys = 0;
|
||||||
|
|
||||||
|
std::ifstream is("/proc/" + std::to_string(Foam::pid()) + "/status");
|
||||||
|
while (is.good() && nKeys < 3) // Stop after getting the known keys
|
||||||
{
|
{
|
||||||
string line;
|
std::getline(is, line);
|
||||||
is.getLine(line);
|
|
||||||
char tag[32];
|
|
||||||
int value;
|
|
||||||
|
|
||||||
if (sscanf(line.c_str(), "%30s %d", tag, &value) == 2)
|
const auto keyLen = line.find(':');
|
||||||
|
if (keyLen == std::string::npos)
|
||||||
{
|
{
|
||||||
if (!strcmp(tag, "VmPeak:"))
|
continue;
|
||||||
{
|
}
|
||||||
peak_ = value;
|
|
||||||
}
|
// Value is after the ':', but skip any leading whitespace since
|
||||||
else if (!strcmp(tag, "VmSize:"))
|
// strtoi will do it anyhow
|
||||||
{
|
const auto begVal = line.find_first_not_of("\t :", keyLen);
|
||||||
size_ = value;
|
if (begVal == std::string::npos)
|
||||||
}
|
{
|
||||||
else if (!strcmp(tag, "VmRSS:"))
|
continue;
|
||||||
{
|
}
|
||||||
rss_ = value;
|
|
||||||
}
|
const std::string key = line.substr(0, keyLen);
|
||||||
|
|
||||||
|
if (key == "VmPeak")
|
||||||
|
{
|
||||||
|
peak_ = std::stoi(line.substr(begVal));
|
||||||
|
++nKeys;
|
||||||
|
}
|
||||||
|
else if (key == "VmSize")
|
||||||
|
{
|
||||||
|
size_ = std::stoi(line.substr(begVal));
|
||||||
|
++nKeys;
|
||||||
|
}
|
||||||
|
else if (key == "VmRSS")
|
||||||
|
{
|
||||||
|
rss_ = std::stoi(line.substr(begVal));
|
||||||
|
++nKeys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,9 +122,9 @@ bool Foam::memInfo::valid() const
|
|||||||
|
|
||||||
void Foam::memInfo::write(Ostream& os) const
|
void Foam::memInfo::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
writeEntry(os, "size", size_);
|
os.writeEntry("size", size_);
|
||||||
writeEntry(os, "peak", peak_);
|
os.writeEntry("peak", peak_);
|
||||||
writeEntry(os, "rss", rss_);
|
os.writeEntry("rss", rss_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -113,9 +133,7 @@ void Foam::memInfo::write(Ostream& os) const
|
|||||||
Foam::Istream& Foam::operator>>(Istream& is, memInfo& m)
|
Foam::Istream& Foam::operator>>(Istream& is, memInfo& m)
|
||||||
{
|
{
|
||||||
is.readBegin("memInfo");
|
is.readBegin("memInfo");
|
||||||
|
|
||||||
is >> m.peak_ >> m.size_ >> m.rss_;
|
is >> m.peak_ >> m.size_ >> m.rss_;
|
||||||
|
|
||||||
is.readEnd("memInfo");
|
is.readEnd("memInfo");
|
||||||
|
|
||||||
is.check(FUNCTION_NAME);
|
is.check(FUNCTION_NAME);
|
||||||
|
|||||||
@ -38,27 +38,20 @@ SourceFiles
|
|||||||
#ifndef memInfo_H
|
#ifndef memInfo_H
|
||||||
#define memInfo_H
|
#define memInfo_H
|
||||||
|
|
||||||
#include "OSspecific.H"
|
|
||||||
#include "POSIX.H"
|
|
||||||
#include "IFstream.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
class memInfo;
|
class memInfo;
|
||||||
|
|
||||||
Istream& operator>>(Istream&, memInfo&);
|
|
||||||
Ostream& operator<<(Ostream&, const memInfo&);
|
|
||||||
|
|
||||||
|
|
||||||
// forward declarations
|
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
|
Istream& operator>>(Istream& is, memInfo& m);
|
||||||
|
Ostream& operator<<(Ostream& os, const memInfo& m);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class memInfo Declaration
|
Class memInfo Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -76,12 +69,6 @@ class memInfo
|
|||||||
//- Resident set size of the process (VmRSS in /proc/PID/status)
|
//- Resident set size of the process (VmRSS in /proc/PID/status)
|
||||||
int rss_;
|
int rss_;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
|
||||||
void operator=(const memInfo&) = delete;
|
|
||||||
|
|
||||||
//- Disallow default copy constructor
|
|
||||||
memInfo(const memInfo&) = delete;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
@ -96,44 +83,47 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Parse /proc/PID/status and update accordingly
|
//- Update according to /proc/PID/status contents
|
||||||
const memInfo& update();
|
const memInfo& update();
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
//- Peak memory (VmPeak in /proc/PID/status) at last update()
|
// Access
|
||||||
int peak() const
|
|
||||||
{
|
|
||||||
return peak_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Memory size (VmSize in /proc/PID/status) at last update()
|
//- Peak memory (VmPeak in /proc/PID/status) at last update()
|
||||||
int size() const
|
inline int peak() const
|
||||||
{
|
{
|
||||||
return size_;
|
return peak_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Resident set size (VmRSS in /proc/PID/status) at last update()
|
//- Memory size (VmSize in /proc/PID/status) at last update()
|
||||||
int rss() const
|
inline int size() const
|
||||||
{
|
{
|
||||||
return rss_;
|
return size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- True if the memory information appears valid
|
//- Resident set size (VmRSS in /proc/PID/status) at last update()
|
||||||
bool valid() const;
|
inline int rss() const
|
||||||
|
{
|
||||||
|
return rss_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- True if the memory information appears valid
|
||||||
|
bool valid() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
//- Write content as dictionary entries
|
//- Write content as dictionary entries
|
||||||
void write(Ostream&) const;
|
void write(Ostream& os) const;
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
// IOstream Operators
|
||||||
|
|
||||||
//- Read peak/size/rss from stream
|
//- Read peak/size/rss from stream
|
||||||
friend Istream& operator>>(Istream&, memInfo&);
|
friend Istream& operator>>(Istream& is, memInfo& m);
|
||||||
|
|
||||||
//- Write peak/size/rss to stream
|
//- Write peak/size/rss to stream
|
||||||
friend Ostream& operator<<(Ostream&, const memInfo&);
|
friend Ostream& operator<<(Ostream& os, const memInfo& m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -154,14 +154,14 @@ Foam::IOobjectList::IOobjectList
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a list of file names in this directory
|
// Create a list of file names in this directory
|
||||||
fileNameList objNames =
|
const auto objNames =
|
||||||
readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
|
readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
|
||||||
|
|
||||||
forAll(objNames, i)
|
for (const auto& objName : objNames)
|
||||||
{
|
{
|
||||||
IOobject* objectPtr = new IOobject
|
IOobject* objectPtr = new IOobject
|
||||||
(
|
(
|
||||||
objNames[i],
|
objName,
|
||||||
newInstance,
|
newInstance,
|
||||||
local,
|
local,
|
||||||
db,
|
db,
|
||||||
@ -170,8 +170,23 @@ Foam::IOobjectList::IOobjectList
|
|||||||
registerObject
|
registerObject
|
||||||
);
|
);
|
||||||
|
|
||||||
// Use object with local scope
|
bool ok = false;
|
||||||
if (objectPtr->typeHeaderOk<IOList<label>>(false))
|
const bool throwingIOerr = FatalIOError.throwExceptions();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Use object with local scope and current instance (no searching)
|
||||||
|
ok = objectPtr->typeHeaderOk<IOList<label>>(false, false);
|
||||||
|
}
|
||||||
|
catch (Foam::IOerror& err)
|
||||||
|
{
|
||||||
|
Warning
|
||||||
|
<< err << nl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
FatalIOError.throwExceptions(throwingIOerr);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
{
|
{
|
||||||
insert(objectPtr->name(), objectPtr);
|
insert(objectPtr->name(), objectPtr);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,8 +56,8 @@ inline void Foam::UIPstream::readFromBuffer(T& t)
|
|||||||
inline void Foam::UIPstream::readFromBuffer
|
inline void Foam::UIPstream::readFromBuffer
|
||||||
(
|
(
|
||||||
void* data,
|
void* data,
|
||||||
size_t count,
|
const size_t count,
|
||||||
size_t align
|
const size_t align
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (align > 1)
|
if (align > 1)
|
||||||
@ -76,6 +76,22 @@ inline void Foam::UIPstream::readFromBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::Istream& Foam::UIPstream::readStringFromBuffer(std::string& str)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
readFromBuffer(len);
|
||||||
|
// Uses the underlying std::string::operator=()
|
||||||
|
// - no stripInvalid invoked (the sending side should have done that)
|
||||||
|
// - relies on trailing '\0' char (so cannot send anything with an embedded
|
||||||
|
// nul char)
|
||||||
|
str = &externalBuf_[externalBufPosition_];
|
||||||
|
externalBufPosition_ += len + 1;
|
||||||
|
checkEof();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::UIPstream::~UIPstream()
|
Foam::UIPstream::~UIPstream()
|
||||||
@ -107,7 +123,7 @@ Foam::Istream& Foam::UIPstream::read(token& t)
|
|||||||
|
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
// return on error
|
// Return on error
|
||||||
if (!read(c))
|
if (!read(c))
|
||||||
{
|
{
|
||||||
t.setBad();
|
t.setBad();
|
||||||
@ -141,7 +157,7 @@ Foam::Istream& Foam::UIPstream::read(token& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Word
|
// Word
|
||||||
case token::WORD :
|
case token::tokenType::WORD :
|
||||||
{
|
{
|
||||||
word* pval = new word;
|
word* pval = new word;
|
||||||
if (read(*pval))
|
if (read(*pval))
|
||||||
@ -165,30 +181,26 @@ Foam::Istream& Foam::UIPstream::read(token& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// String
|
// String
|
||||||
case token::VERBATIMSTRING :
|
case token::tokenType::VERBATIMSTRING :
|
||||||
{
|
{
|
||||||
// Recurse to read actual string
|
// Recurse to read actual string
|
||||||
read(t);
|
read(t);
|
||||||
t.type() = token::VERBATIMSTRING;
|
t.type() = token::tokenType::VERBATIMSTRING;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
case token::VARIABLE :
|
case token::tokenType::VARIABLE :
|
||||||
{
|
{
|
||||||
// Recurse to read actual string
|
// Recurse to read actual string
|
||||||
read(t);
|
read(t);
|
||||||
t.type() = token::VARIABLE;
|
t.type() = token::tokenType::VARIABLE;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
case token::STRING :
|
case token::tokenType::STRING :
|
||||||
{
|
{
|
||||||
string* pval = new string;
|
string* pval = new string;
|
||||||
if (read(*pval))
|
if (read(*pval))
|
||||||
{
|
{
|
||||||
t = pval;
|
t = pval;
|
||||||
if (c == token::VERBATIMSTRING)
|
|
||||||
{
|
|
||||||
t.type() = token::VERBATIMSTRING;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -199,7 +211,7 @@ Foam::Istream& Foam::UIPstream::read(token& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
case token::LABEL :
|
case token::tokenType::LABEL :
|
||||||
{
|
{
|
||||||
label val;
|
label val;
|
||||||
if (read(val))
|
if (read(val))
|
||||||
@ -214,7 +226,7 @@ Foam::Istream& Foam::UIPstream::read(token& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// floatScalar
|
// floatScalar
|
||||||
case token::FLOAT_SCALAR :
|
case token::tokenType::FLOAT_SCALAR :
|
||||||
{
|
{
|
||||||
floatScalar val;
|
floatScalar val;
|
||||||
if (read(val))
|
if (read(val))
|
||||||
@ -229,7 +241,7 @@ Foam::Istream& Foam::UIPstream::read(token& t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// doubleScalar
|
// doubleScalar
|
||||||
case token::DOUBLE_SCALAR :
|
case token::tokenType::DOUBLE_SCALAR :
|
||||||
{
|
{
|
||||||
doubleScalar val;
|
doubleScalar val;
|
||||||
if (read(val))
|
if (read(val))
|
||||||
@ -272,23 +284,13 @@ Foam::Istream& Foam::UIPstream::read(char& c)
|
|||||||
|
|
||||||
Foam::Istream& Foam::UIPstream::read(word& str)
|
Foam::Istream& Foam::UIPstream::read(word& str)
|
||||||
{
|
{
|
||||||
size_t len;
|
return readStringFromBuffer(str);
|
||||||
readFromBuffer(len);
|
|
||||||
str = &externalBuf_[externalBufPosition_];
|
|
||||||
externalBufPosition_ += len + 1;
|
|
||||||
checkEof();
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::UIPstream::read(string& str)
|
Foam::Istream& Foam::UIPstream::read(string& str)
|
||||||
{
|
{
|
||||||
size_t len;
|
return readStringFromBuffer(str);
|
||||||
readFromBuffer(len);
|
|
||||||
str = &externalBuf_[externalBufPosition_];
|
|
||||||
externalBufPosition_ += len + 1;
|
|
||||||
checkEof();
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -80,10 +80,19 @@ class UIPstream
|
|||||||
|
|
||||||
//- Read a T from the transfer buffer
|
//- Read a T from the transfer buffer
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void readFromBuffer(T&);
|
inline void readFromBuffer(T& t);
|
||||||
|
|
||||||
//- Read data from the transfer buffer
|
//- Read count bytes of data from the transfer buffer
|
||||||
inline void readFromBuffer(void* data, size_t count, size_t align);
|
// using align byte alignment
|
||||||
|
inline void readFromBuffer
|
||||||
|
(
|
||||||
|
void* data,
|
||||||
|
const size_t count,
|
||||||
|
const size_t align
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Read string length and its content.
|
||||||
|
inline Istream& readStringFromBuffer(std::string& str);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -139,28 +148,28 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Return next token from stream
|
//- Return next token from stream
|
||||||
Istream& read(token&);
|
Istream& read(token& t);
|
||||||
|
|
||||||
//- Read a character
|
//- Read a character
|
||||||
Istream& read(char&);
|
Istream& read(char& c);
|
||||||
|
|
||||||
//- Read a word
|
//- Read a word
|
||||||
Istream& read(word&);
|
Istream& read(word& str);
|
||||||
|
|
||||||
// Read a string (including enclosing double-quotes)
|
// Read a string
|
||||||
Istream& read(string&);
|
Istream& read(string& str);
|
||||||
|
|
||||||
//- Read a label
|
//- Read a label
|
||||||
Istream& read(label&);
|
Istream& read(label& val);
|
||||||
|
|
||||||
//- Read a floatScalar
|
//- Read a floatScalar
|
||||||
Istream& read(floatScalar&);
|
Istream& read(floatScalar& val);
|
||||||
|
|
||||||
//- Read a doubleScalar
|
//- Read a doubleScalar
|
||||||
Istream& read(doubleScalar&);
|
Istream& read(doubleScalar& val);
|
||||||
|
|
||||||
//- Read binary block
|
//- Read binary block with 8-byte alignment.
|
||||||
Istream& read(char*, std::streamsize);
|
Istream& read(char* data, const std::streamsize count);
|
||||||
|
|
||||||
//- Rewind and return the stream so that it may be read again
|
//- Rewind and return the stream so that it may be read again
|
||||||
Istream& rewind();
|
Istream& rewind();
|
||||||
|
|||||||
@ -51,8 +51,8 @@ inline void Foam::UOPstream::writeToBuffer(const char& c)
|
|||||||
inline void Foam::UOPstream::writeToBuffer
|
inline void Foam::UOPstream::writeToBuffer
|
||||||
(
|
(
|
||||||
const void* data,
|
const void* data,
|
||||||
size_t count,
|
const size_t count,
|
||||||
size_t align
|
const size_t align
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!sendBuf_.capacity())
|
if (!sendBuf_.capacity())
|
||||||
@ -77,6 +77,13 @@ inline void Foam::UOPstream::writeToBuffer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::UOPstream::writeStringToBuffer(const std::string& str)
|
||||||
|
{
|
||||||
|
const size_t len = str.size();
|
||||||
|
writeToBuffer(len);
|
||||||
|
writeToBuffer(str.c_str(), len + 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -153,14 +160,14 @@ Foam::UOPstream::~UOPstream()
|
|||||||
Foam::Ostream& Foam::UOPstream::write(const token& t)
|
Foam::Ostream& Foam::UOPstream::write(const token& t)
|
||||||
{
|
{
|
||||||
// Raw token output only supported for verbatim strings for now
|
// Raw token output only supported for verbatim strings for now
|
||||||
if (t.type() == token::VERBATIMSTRING)
|
if (t.type() == token::tokenType::VERBATIMSTRING)
|
||||||
{
|
{
|
||||||
write(char(token::VERBATIMSTRING));
|
writeToBuffer(char(token::tokenType::VERBATIMSTRING));
|
||||||
write(t.stringToken());
|
write(t.stringToken());
|
||||||
}
|
}
|
||||||
else if (t.type() == token::VARIABLE)
|
else if (t.type() == token::tokenType::VARIABLE)
|
||||||
{
|
{
|
||||||
write(char(token::VARIABLE));
|
writeToBuffer(char(token::tokenType::VARIABLE));
|
||||||
write(t.stringToken());
|
write(t.stringToken());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -204,11 +211,8 @@ Foam::Ostream& Foam::UOPstream::write(const char* str)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::UOPstream::write(const word& str)
|
Foam::Ostream& Foam::UOPstream::write(const word& str)
|
||||||
{
|
{
|
||||||
write(char(token::WORD));
|
writeToBuffer(char(token::tokenType::WORD));
|
||||||
|
writeStringToBuffer(str);
|
||||||
size_t len = str.size();
|
|
||||||
writeToBuffer(len);
|
|
||||||
writeToBuffer(str.c_str(), len + 1, 1);
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -216,11 +220,8 @@ Foam::Ostream& Foam::UOPstream::write(const word& str)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::UOPstream::write(const string& str)
|
Foam::Ostream& Foam::UOPstream::write(const string& str)
|
||||||
{
|
{
|
||||||
write(char(token::STRING));
|
writeToBuffer(char(token::tokenType::STRING));
|
||||||
|
writeStringToBuffer(str);
|
||||||
size_t len = str.size();
|
|
||||||
writeToBuffer(len);
|
|
||||||
writeToBuffer(str.c_str(), len + 1, 1);
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -234,16 +235,13 @@ Foam::Ostream& Foam::UOPstream::writeQuoted
|
|||||||
{
|
{
|
||||||
if (quoted)
|
if (quoted)
|
||||||
{
|
{
|
||||||
write(char(token::STRING));
|
writeToBuffer(char(token::tokenType::STRING));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write(char(token::WORD));
|
writeToBuffer(char(token::tokenType::WORD));
|
||||||
}
|
}
|
||||||
|
writeStringToBuffer(str);
|
||||||
size_t len = str.size();
|
|
||||||
writeToBuffer(len);
|
|
||||||
writeToBuffer(str.c_str(), len + 1, 1);
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -251,7 +249,7 @@ Foam::Ostream& Foam::UOPstream::writeQuoted
|
|||||||
|
|
||||||
Foam::Ostream& Foam::UOPstream::write(const int32_t val)
|
Foam::Ostream& Foam::UOPstream::write(const int32_t val)
|
||||||
{
|
{
|
||||||
write(char(token::LABEL));
|
writeToBuffer(char(token::tokenType::LABEL));
|
||||||
writeToBuffer(val);
|
writeToBuffer(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -259,7 +257,7 @@ Foam::Ostream& Foam::UOPstream::write(const int32_t val)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::UOPstream::write(const int64_t val)
|
Foam::Ostream& Foam::UOPstream::write(const int64_t val)
|
||||||
{
|
{
|
||||||
write(char(token::LABEL));
|
writeToBuffer(char(token::tokenType::LABEL));
|
||||||
writeToBuffer(val);
|
writeToBuffer(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -267,7 +265,7 @@ Foam::Ostream& Foam::UOPstream::write(const int64_t val)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::UOPstream::write(const floatScalar val)
|
Foam::Ostream& Foam::UOPstream::write(const floatScalar val)
|
||||||
{
|
{
|
||||||
write(char(token::FLOAT_SCALAR));
|
writeToBuffer(char(token::tokenType::FLOAT_SCALAR));
|
||||||
writeToBuffer(val);
|
writeToBuffer(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -275,13 +273,17 @@ Foam::Ostream& Foam::UOPstream::write(const floatScalar val)
|
|||||||
|
|
||||||
Foam::Ostream& Foam::UOPstream::write(const doubleScalar val)
|
Foam::Ostream& Foam::UOPstream::write(const doubleScalar val)
|
||||||
{
|
{
|
||||||
write(char(token::DOUBLE_SCALAR));
|
writeToBuffer(char(token::tokenType::DOUBLE_SCALAR));
|
||||||
writeToBuffer(val);
|
writeToBuffer(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::UOPstream::write(const char* data, std::streamsize count)
|
Foam::Ostream& Foam::UOPstream::write
|
||||||
|
(
|
||||||
|
const char* data,
|
||||||
|
const std::streamsize count
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (format() != BINARY)
|
if (format() != BINARY)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -74,13 +74,23 @@ class UOPstream
|
|||||||
|
|
||||||
//- Write a T to the transfer buffer
|
//- Write a T to the transfer buffer
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void writeToBuffer(const T&);
|
inline void writeToBuffer(const T& t);
|
||||||
|
|
||||||
//- Write a char to the transfer buffer
|
//- Write a char to the transfer buffer
|
||||||
inline void writeToBuffer(const char&);
|
inline void writeToBuffer(const char& c);
|
||||||
|
|
||||||
//- Write data to the transfer buffer
|
//- Write count bytes of data to the transfer buffer
|
||||||
inline void writeToBuffer(const void* data, size_t count, size_t align);
|
// using align byte alignment
|
||||||
|
inline void writeToBuffer
|
||||||
|
(
|
||||||
|
const void* data,
|
||||||
|
const size_t count,
|
||||||
|
const size_t align
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Write string length and content.
|
||||||
|
// The content includes the trailing nul char.
|
||||||
|
inline void writeStringToBuffer(const std::string& str);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -102,7 +112,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Construct given buffers
|
//- Construct given buffers
|
||||||
UOPstream(const int toProcNo, PstreamBuffers&);
|
UOPstream(const int toProcNo, PstreamBuffers& buffers);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -134,42 +144,43 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Write next token to stream
|
//- Write next token to stream
|
||||||
Ostream& write(const token&);
|
Ostream& write(const token& t);
|
||||||
|
|
||||||
//- Write character
|
//- Write single character. Whitespace is suppressed.
|
||||||
Ostream& write(const char);
|
Ostream& write(const char c);
|
||||||
|
|
||||||
//- Write character string
|
//- Write the word-characters of a character string.
|
||||||
Ostream& write(const char*);
|
// Sends as a single char, or as word.
|
||||||
|
Ostream& write(const char* str);
|
||||||
|
|
||||||
//- Write word
|
//- Write word
|
||||||
Ostream& write(const word&);
|
Ostream& write(const word& str);
|
||||||
|
|
||||||
//- Write string
|
//- Write string
|
||||||
Ostream& write(const string&);
|
Ostream& write(const string& str);
|
||||||
|
|
||||||
//- Write std::string surrounded by quotes.
|
//- Write std::string surrounded by quotes.
|
||||||
// Optional write without quotes.
|
// Optional write without quotes.
|
||||||
Ostream& writeQuoted
|
Ostream& writeQuoted
|
||||||
(
|
(
|
||||||
const std::string&,
|
const std::string& str,
|
||||||
const bool quoted=true
|
const bool quoted=true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write int32_t
|
//- Write int32_t as a label
|
||||||
virtual Ostream& write(const int32_t);
|
virtual Ostream& write(const int32_t val);
|
||||||
|
|
||||||
//- Write int64_t
|
//- Write int64_t as a label
|
||||||
Ostream& write(const int64_t);
|
Ostream& write(const int64_t val);
|
||||||
|
|
||||||
//- Write floatScalar
|
//- Write floatScalar
|
||||||
Ostream& write(const floatScalar);
|
Ostream& write(const floatScalar val);
|
||||||
|
|
||||||
//- Write doubleScalar
|
//- Write doubleScalar
|
||||||
Ostream& write(const doubleScalar);
|
Ostream& write(const doubleScalar val);
|
||||||
|
|
||||||
//- Write binary block
|
//- Write binary block with 8-byte alignment.
|
||||||
Ostream& write(const char*, std::streamsize);
|
Ostream& write(const char* data, const std::streamsize count);
|
||||||
|
|
||||||
//- Add indentation characters
|
//- Add indentation characters
|
||||||
void indent()
|
void indent()
|
||||||
@ -223,7 +234,7 @@ public:
|
|||||||
// Print
|
// Print
|
||||||
|
|
||||||
//- Print description of IOstream to Ostream
|
//- Print description of IOstream to Ostream
|
||||||
void print(Ostream&) const;
|
void print(Ostream& os) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright 2015-2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
|
|||||||
@ -224,7 +224,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = sPtr;
|
t = sPtr;
|
||||||
t.type() = token::VERBATIMSTRING;
|
t.type() = token::tokenType::VERBATIMSTRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
@ -266,7 +266,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = sPtr;
|
t = sPtr;
|
||||||
t.type() = token::VARIABLE;
|
t.type() = token::tokenType::VARIABLE;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ License
|
|||||||
|
|
||||||
Foam::Ostream& Foam::OSstream::write(const token& t)
|
Foam::Ostream& Foam::OSstream::write(const token& t)
|
||||||
{
|
{
|
||||||
if (t.type() == token::VERBATIMSTRING)
|
if (t.type() == token::tokenType::VERBATIMSTRING)
|
||||||
{
|
{
|
||||||
write(char(token::HASH));
|
write(char(token::HASH));
|
||||||
write(char(token::BEGIN_BLOCK));
|
write(char(token::BEGIN_BLOCK));
|
||||||
@ -39,9 +39,9 @@ Foam::Ostream& Foam::OSstream::write(const token& t)
|
|||||||
write(char(token::HASH));
|
write(char(token::HASH));
|
||||||
write(char(token::END_BLOCK));
|
write(char(token::END_BLOCK));
|
||||||
}
|
}
|
||||||
else if (t.type() == token::VARIABLE)
|
else if (t.type() == token::tokenType::VARIABLE)
|
||||||
{
|
{
|
||||||
writeQuoted( t.stringToken(), false);
|
writeQuoted(t.stringToken(), false);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,7 @@ void Foam::prefixOSstream::print(Ostream& os) const
|
|||||||
|
|
||||||
Foam::Ostream& Foam::prefixOSstream::write(const token& t)
|
Foam::Ostream& Foam::prefixOSstream::write(const token& t)
|
||||||
{
|
{
|
||||||
if (t.type() == token::VERBATIMSTRING)
|
if (t.type() == token::tokenType::VERBATIMSTRING)
|
||||||
{
|
{
|
||||||
write(char(token::HASH));
|
write(char(token::HASH));
|
||||||
write(char(token::BEGIN_BLOCK));
|
write(char(token::BEGIN_BLOCK));
|
||||||
@ -75,7 +75,7 @@ Foam::Ostream& Foam::prefixOSstream::write(const token& t)
|
|||||||
write(char(token::HASH));
|
write(char(token::HASH));
|
||||||
write(char(token::END_BLOCK));
|
write(char(token::END_BLOCK));
|
||||||
}
|
}
|
||||||
else if (t.type() == token::VARIABLE)
|
else if (t.type() == token::tokenType::VARIABLE)
|
||||||
{
|
{
|
||||||
writeQuoted(t.stringToken(), false);
|
writeQuoted(t.stringToken(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,7 +92,7 @@ bool Foam::token::compound::isCompound(const word& name)
|
|||||||
|
|
||||||
Foam::token::compound& Foam::token::transferCompoundToken(const Istream& is)
|
Foam::token::compound& Foam::token::transferCompoundToken(const Istream& is)
|
||||||
{
|
{
|
||||||
if (type_ == COMPOUND)
|
if (type_ == tokenType::COMPOUND)
|
||||||
{
|
{
|
||||||
if (compoundTokenPtr_->empty())
|
if (compoundTokenPtr_->empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -197,7 +197,7 @@ public:
|
|||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
virtual void write(Ostream&) const = 0;
|
virtual void write(Ostream& os) const = 0;
|
||||||
|
|
||||||
|
|
||||||
// IOstream Operators
|
// IOstream Operators
|
||||||
@ -284,28 +284,47 @@ public:
|
|||||||
inline token();
|
inline token();
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
inline token(const token&);
|
inline token(const token& t);
|
||||||
|
|
||||||
//- Construct punctuation character token
|
//- Construct punctuation character token
|
||||||
inline token(punctuationToken, label lineNumber=0);
|
inline explicit token(punctuationToken p);
|
||||||
|
|
||||||
//- Construct word token
|
//- Construct word token
|
||||||
inline token(const word&, label lineNumber=0);
|
inline explicit token(const word& w);
|
||||||
|
|
||||||
//- Construct string token
|
//- Construct string token
|
||||||
inline token(const string&, label lineNumber=0);
|
inline explicit token(const string& str);
|
||||||
|
|
||||||
//- Construct label token
|
//- Construct label token
|
||||||
inline token(const label, label lineNumber=0);
|
inline explicit token(const label val);
|
||||||
|
|
||||||
//- Construct floatScalar token
|
//- Construct floatScalar token
|
||||||
inline token(const floatScalar, label lineNumber=0);
|
inline explicit token(const floatScalar val);
|
||||||
|
|
||||||
//- Construct doubleScalar token
|
//- Construct doubleScalar token
|
||||||
inline token(const doubleScalar, label lineNumber=0);
|
inline explicit token(const doubleScalar val);
|
||||||
|
|
||||||
|
|
||||||
|
//- Construct punctuation character token
|
||||||
|
inline token(punctuationToken p, const label lineNumber);
|
||||||
|
|
||||||
|
//- Construct word token
|
||||||
|
inline token(const word& w, const label lineNumber);
|
||||||
|
|
||||||
|
//- Construct string token
|
||||||
|
inline token(const string& str, const label lineNumber);
|
||||||
|
|
||||||
|
//- Construct label token
|
||||||
|
inline token(const label val, const label lineNumber);
|
||||||
|
|
||||||
|
//- Construct floatScalar token
|
||||||
|
inline token(const floatScalar val, const label lineNumber);
|
||||||
|
|
||||||
|
//- Construct doubleScalar token
|
||||||
|
inline token(const doubleScalar val, const label lineNumber);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
token(Istream&);
|
token(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -377,43 +396,43 @@ public:
|
|||||||
|
|
||||||
// Assignment
|
// Assignment
|
||||||
|
|
||||||
inline void operator=(const token&);
|
inline void operator=(const token& t);
|
||||||
|
|
||||||
inline void operator=(const punctuationToken);
|
inline void operator=(const punctuationToken p);
|
||||||
|
|
||||||
inline void operator=(word*);
|
inline void operator=(word* wPtr);
|
||||||
inline void operator=(const word&);
|
inline void operator=(const word& w);
|
||||||
|
|
||||||
inline void operator=(string*);
|
inline void operator=(string* strPtr);
|
||||||
inline void operator=(const string&);
|
inline void operator=(const string& str);
|
||||||
|
|
||||||
inline void operator=(const label);
|
inline void operator=(const label val);
|
||||||
inline void operator=(const floatScalar);
|
inline void operator=(const floatScalar val);
|
||||||
inline void operator=(const doubleScalar);
|
inline void operator=(const doubleScalar val);
|
||||||
|
|
||||||
inline void operator=(compound*);
|
inline void operator=(compound* compPtr);
|
||||||
|
|
||||||
|
|
||||||
// Equality
|
// Equality
|
||||||
|
|
||||||
inline bool operator==(const token&) const;
|
inline bool operator==(const token& t) const;
|
||||||
inline bool operator==(const punctuationToken) const;
|
inline bool operator==(const punctuationToken p) const;
|
||||||
inline bool operator==(const word&) const;
|
inline bool operator==(const word& w) const;
|
||||||
inline bool operator==(const string&) const;
|
inline bool operator==(const string& str) const;
|
||||||
inline bool operator==(const label) const;
|
inline bool operator==(const label val) const;
|
||||||
inline bool operator==(const floatScalar) const;
|
inline bool operator==(const floatScalar val) const;
|
||||||
inline bool operator==(const doubleScalar) const;
|
inline bool operator==(const doubleScalar val) const;
|
||||||
|
|
||||||
|
|
||||||
// Inequality
|
// Inequality
|
||||||
|
|
||||||
inline bool operator!=(const token&) const;
|
inline bool operator!=(const token& t) const;
|
||||||
inline bool operator!=(const punctuationToken) const;
|
inline bool operator!=(const punctuationToken p) const;
|
||||||
inline bool operator!=(const word&) const;
|
inline bool operator!=(const word& w) const;
|
||||||
inline bool operator!=(const string&) const;
|
inline bool operator!=(const string& str) const;
|
||||||
inline bool operator!=(const label) const;
|
inline bool operator!=(const label val) const;
|
||||||
inline bool operator!=(const floatScalar) const;
|
inline bool operator!=(const floatScalar val) const;
|
||||||
inline bool operator!=(const doubleScalar) const;
|
inline bool operator!=(const doubleScalar val) const;
|
||||||
|
|
||||||
|
|
||||||
// IOstream operators
|
// IOstream operators
|
||||||
|
|||||||
@ -27,15 +27,20 @@ License
|
|||||||
|
|
||||||
inline void Foam::token::clear()
|
inline void Foam::token::clear()
|
||||||
{
|
{
|
||||||
if (type_ == WORD)
|
if (type_ == tokenType::WORD)
|
||||||
{
|
{
|
||||||
delete wordTokenPtr_;
|
delete wordTokenPtr_;
|
||||||
}
|
}
|
||||||
else if (type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING)
|
else if
|
||||||
|
(
|
||||||
|
type_ == tokenType::STRING
|
||||||
|
|| type_ == tokenType::VARIABLE
|
||||||
|
|| type_ == tokenType::VERBATIMSTRING
|
||||||
|
)
|
||||||
{
|
{
|
||||||
delete stringTokenPtr_;
|
delete stringTokenPtr_;
|
||||||
}
|
}
|
||||||
else if (type_ == COMPOUND)
|
else if (type_ == tokenType::COMPOUND)
|
||||||
{
|
{
|
||||||
if (compoundTokenPtr_->unique())
|
if (compoundTokenPtr_->unique())
|
||||||
{
|
{
|
||||||
@ -47,7 +52,7 @@ inline void Foam::token::clear()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type_ = UNDEFINED;
|
type_ = tokenType::UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +60,7 @@ inline void Foam::token::clear()
|
|||||||
|
|
||||||
inline Foam::token::token()
|
inline Foam::token::token()
|
||||||
:
|
:
|
||||||
type_(UNDEFINED),
|
type_(tokenType::UNDEFINED),
|
||||||
lineNumber_(0)
|
lineNumber_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -67,49 +72,85 @@ inline Foam::token::token(const token& t)
|
|||||||
{
|
{
|
||||||
switch (type_)
|
switch (type_)
|
||||||
{
|
{
|
||||||
case token::UNDEFINED:
|
case tokenType::UNDEFINED:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUNCTUATION:
|
case tokenType::PUNCTUATION:
|
||||||
punctuationToken_ = t.punctuationToken_;
|
punctuationToken_ = t.punctuationToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WORD:
|
case tokenType::WORD:
|
||||||
wordTokenPtr_ = new word(*t.wordTokenPtr_);
|
wordTokenPtr_ = new word(*t.wordTokenPtr_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STRING:
|
case tokenType::STRING:
|
||||||
case VARIABLE:
|
case tokenType::VARIABLE:
|
||||||
case VERBATIMSTRING:
|
case tokenType::VERBATIMSTRING:
|
||||||
stringTokenPtr_ = new string(*t.stringTokenPtr_);
|
stringTokenPtr_ = new string(*t.stringTokenPtr_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LABEL:
|
case tokenType::LABEL:
|
||||||
labelToken_ = t.labelToken_;
|
labelToken_ = t.labelToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FLOAT_SCALAR:
|
case tokenType::FLOAT_SCALAR:
|
||||||
floatScalarToken_ = t.floatScalarToken_;
|
floatScalarToken_ = t.floatScalarToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DOUBLE_SCALAR:
|
case tokenType::DOUBLE_SCALAR:
|
||||||
doubleScalarToken_ = t.doubleScalarToken_;
|
doubleScalarToken_ = t.doubleScalarToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPOUND:
|
case tokenType::COMPOUND:
|
||||||
compoundTokenPtr_ = t.compoundTokenPtr_;
|
compoundTokenPtr_ = t.compoundTokenPtr_;
|
||||||
compoundTokenPtr_->refCount::operator++();
|
compoundTokenPtr_->refCount::operator++();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::ERROR:
|
case tokenType::ERROR:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::token::token(punctuationToken p)
|
||||||
|
:
|
||||||
|
token(p, 0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::token::token(const word& w)
|
||||||
|
:
|
||||||
|
token(w, 0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::token::token(const string& str)
|
||||||
|
:
|
||||||
|
token(str, 0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::token::token(const label val)
|
||||||
|
:
|
||||||
|
token(val, 0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::token::token(const floatScalar val)
|
||||||
|
:
|
||||||
|
token(val, 0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::token::token(const doubleScalar val)
|
||||||
|
:
|
||||||
|
token(val, 0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::token::token(punctuationToken p, label lineNumber)
|
inline Foam::token::token(punctuationToken p, label lineNumber)
|
||||||
:
|
:
|
||||||
type_(PUNCTUATION),
|
type_(tokenType::PUNCTUATION),
|
||||||
punctuationToken_(p),
|
punctuationToken_(p),
|
||||||
lineNumber_(lineNumber)
|
lineNumber_(lineNumber)
|
||||||
{}
|
{}
|
||||||
@ -117,40 +158,40 @@ inline Foam::token::token(punctuationToken p, label lineNumber)
|
|||||||
|
|
||||||
inline Foam::token::token(const word& w, label lineNumber)
|
inline Foam::token::token(const word& w, label lineNumber)
|
||||||
:
|
:
|
||||||
type_(WORD),
|
type_(tokenType::WORD),
|
||||||
wordTokenPtr_(new word(w)),
|
wordTokenPtr_(new word(w)),
|
||||||
lineNumber_(lineNumber)
|
lineNumber_(lineNumber)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::token::token(const string& s, label lineNumber)
|
inline Foam::token::token(const string& str, label lineNumber)
|
||||||
:
|
:
|
||||||
type_(STRING),
|
type_(tokenType::STRING),
|
||||||
stringTokenPtr_(new string(s)),
|
stringTokenPtr_(new string(str)),
|
||||||
lineNumber_(lineNumber)
|
lineNumber_(lineNumber)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::token::token(const label l, label lineNumber)
|
inline Foam::token::token(const label val, label lineNumber)
|
||||||
:
|
:
|
||||||
type_(LABEL),
|
type_(tokenType::LABEL),
|
||||||
labelToken_(l),
|
labelToken_(val),
|
||||||
lineNumber_(lineNumber)
|
lineNumber_(lineNumber)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::token::token(const floatScalar s, label lineNumber)
|
inline Foam::token::token(const floatScalar val, label lineNumber)
|
||||||
:
|
:
|
||||||
type_(FLOAT_SCALAR),
|
type_(tokenType::FLOAT_SCALAR),
|
||||||
floatScalarToken_(s),
|
floatScalarToken_(val),
|
||||||
lineNumber_(lineNumber)
|
lineNumber_(lineNumber)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::token::token(const doubleScalar s, label lineNumber)
|
inline Foam::token::token(const doubleScalar val, label lineNumber)
|
||||||
:
|
:
|
||||||
type_(DOUBLE_SCALAR),
|
type_(tokenType::DOUBLE_SCALAR),
|
||||||
doubleScalarToken_(s),
|
doubleScalarToken_(val),
|
||||||
lineNumber_(lineNumber)
|
lineNumber_(lineNumber)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -177,27 +218,27 @@ inline Foam::token::tokenType& Foam::token::type()
|
|||||||
|
|
||||||
inline bool Foam::token::good() const
|
inline bool Foam::token::good() const
|
||||||
{
|
{
|
||||||
return (type_ != ERROR && type_ != UNDEFINED);
|
return (type_ != tokenType::ERROR && type_ != tokenType::UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::undefined() const
|
inline bool Foam::token::undefined() const
|
||||||
{
|
{
|
||||||
return (type_ == UNDEFINED);
|
return (type_ == tokenType::UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::error() const
|
inline bool Foam::token::error() const
|
||||||
{
|
{
|
||||||
return (type_ == ERROR);
|
return (type_ == tokenType::ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::isPunctuation() const
|
inline bool Foam::token::isPunctuation() const
|
||||||
{
|
{
|
||||||
return (type_ == PUNCTUATION);
|
return (type_ == tokenType::PUNCTUATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Foam::token::punctuationToken Foam::token::pToken() const
|
inline Foam::token::punctuationToken Foam::token::pToken() const
|
||||||
{
|
{
|
||||||
if (type_ == PUNCTUATION)
|
if (type_ == tokenType::PUNCTUATION)
|
||||||
{
|
{
|
||||||
return punctuationToken_;
|
return punctuationToken_;
|
||||||
}
|
}
|
||||||
@ -210,12 +251,12 @@ inline Foam::token::punctuationToken Foam::token::pToken() const
|
|||||||
|
|
||||||
inline bool Foam::token::isWord() const
|
inline bool Foam::token::isWord() const
|
||||||
{
|
{
|
||||||
return (type_ == WORD);
|
return (type_ == tokenType::WORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Foam::word& Foam::token::wordToken() const
|
inline const Foam::word& Foam::token::wordToken() const
|
||||||
{
|
{
|
||||||
if (type_ == WORD)
|
if (type_ == tokenType::WORD)
|
||||||
{
|
{
|
||||||
return *wordTokenPtr_;
|
return *wordTokenPtr_;
|
||||||
}
|
}
|
||||||
@ -228,17 +269,27 @@ inline const Foam::word& Foam::token::wordToken() const
|
|||||||
|
|
||||||
inline bool Foam::token::isVariable() const
|
inline bool Foam::token::isVariable() const
|
||||||
{
|
{
|
||||||
return (type_ == VARIABLE);
|
return (type_ == tokenType::VARIABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::isString() const
|
inline bool Foam::token::isString() const
|
||||||
{
|
{
|
||||||
return (type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING);
|
return
|
||||||
|
(
|
||||||
|
type_ == tokenType::STRING
|
||||||
|
|| type_ == tokenType::VARIABLE
|
||||||
|
|| type_ == tokenType::VERBATIMSTRING
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Foam::string& Foam::token::stringToken() const
|
inline const Foam::string& Foam::token::stringToken() const
|
||||||
{
|
{
|
||||||
if (type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING)
|
if
|
||||||
|
(
|
||||||
|
type_ == tokenType::STRING
|
||||||
|
|| type_ == tokenType::VARIABLE
|
||||||
|
|| type_ == tokenType::VERBATIMSTRING
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return *stringTokenPtr_;
|
return *stringTokenPtr_;
|
||||||
}
|
}
|
||||||
@ -251,12 +302,12 @@ inline const Foam::string& Foam::token::stringToken() const
|
|||||||
|
|
||||||
inline bool Foam::token::isLabel() const
|
inline bool Foam::token::isLabel() const
|
||||||
{
|
{
|
||||||
return (type_ == LABEL);
|
return (type_ == tokenType::LABEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Foam::label Foam::token::labelToken() const
|
inline Foam::label Foam::token::labelToken() const
|
||||||
{
|
{
|
||||||
if (type_ == LABEL)
|
if (type_ == tokenType::LABEL)
|
||||||
{
|
{
|
||||||
return labelToken_;
|
return labelToken_;
|
||||||
}
|
}
|
||||||
@ -269,12 +320,12 @@ inline Foam::label Foam::token::labelToken() const
|
|||||||
|
|
||||||
inline bool Foam::token::isFloatScalar() const
|
inline bool Foam::token::isFloatScalar() const
|
||||||
{
|
{
|
||||||
return (type_ == FLOAT_SCALAR);
|
return (type_ == tokenType::FLOAT_SCALAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Foam::floatScalar Foam::token::floatScalarToken() const
|
inline Foam::floatScalar Foam::token::floatScalarToken() const
|
||||||
{
|
{
|
||||||
if (type_ == FLOAT_SCALAR)
|
if (type_ == tokenType::FLOAT_SCALAR)
|
||||||
{
|
{
|
||||||
return floatScalarToken_;
|
return floatScalarToken_;
|
||||||
}
|
}
|
||||||
@ -288,12 +339,12 @@ inline Foam::floatScalar Foam::token::floatScalarToken() const
|
|||||||
|
|
||||||
inline bool Foam::token::isDoubleScalar() const
|
inline bool Foam::token::isDoubleScalar() const
|
||||||
{
|
{
|
||||||
return (type_ == DOUBLE_SCALAR);
|
return (type_ == tokenType::DOUBLE_SCALAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Foam::doubleScalar Foam::token::doubleScalarToken() const
|
inline Foam::doubleScalar Foam::token::doubleScalarToken() const
|
||||||
{
|
{
|
||||||
if (type_ == DOUBLE_SCALAR)
|
if (type_ == tokenType::DOUBLE_SCALAR)
|
||||||
{
|
{
|
||||||
return doubleScalarToken_;
|
return doubleScalarToken_;
|
||||||
}
|
}
|
||||||
@ -307,16 +358,20 @@ inline Foam::doubleScalar Foam::token::doubleScalarToken() const
|
|||||||
|
|
||||||
inline bool Foam::token::isScalar() const
|
inline bool Foam::token::isScalar() const
|
||||||
{
|
{
|
||||||
return (type_ == FLOAT_SCALAR || type_ == DOUBLE_SCALAR);
|
return
|
||||||
|
(
|
||||||
|
type_ == tokenType::FLOAT_SCALAR
|
||||||
|
|| type_ == tokenType::DOUBLE_SCALAR
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Foam::scalar Foam::token::scalarToken() const
|
inline Foam::scalar Foam::token::scalarToken() const
|
||||||
{
|
{
|
||||||
if (type_ == FLOAT_SCALAR)
|
if (type_ == tokenType::FLOAT_SCALAR)
|
||||||
{
|
{
|
||||||
return floatScalarToken_;
|
return floatScalarToken_;
|
||||||
}
|
}
|
||||||
else if (type_ == DOUBLE_SCALAR)
|
else if (type_ == tokenType::DOUBLE_SCALAR)
|
||||||
{
|
{
|
||||||
return doubleScalarToken_;
|
return doubleScalarToken_;
|
||||||
}
|
}
|
||||||
@ -329,12 +384,12 @@ inline Foam::scalar Foam::token::scalarToken() const
|
|||||||
|
|
||||||
inline bool Foam::token::isNumber() const
|
inline bool Foam::token::isNumber() const
|
||||||
{
|
{
|
||||||
return (type_ == LABEL || isScalar());
|
return (type_ == tokenType::LABEL || isScalar());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Foam::scalar Foam::token::number() const
|
inline Foam::scalar Foam::token::number() const
|
||||||
{
|
{
|
||||||
if (type_ == LABEL)
|
if (type_ == tokenType::LABEL)
|
||||||
{
|
{
|
||||||
return labelToken_;
|
return labelToken_;
|
||||||
}
|
}
|
||||||
@ -351,12 +406,12 @@ inline Foam::scalar Foam::token::number() const
|
|||||||
|
|
||||||
inline bool Foam::token::isCompound() const
|
inline bool Foam::token::isCompound() const
|
||||||
{
|
{
|
||||||
return (type_ == COMPOUND);
|
return (type_ == tokenType::COMPOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Foam::token::compound& Foam::token::compoundToken() const
|
inline const Foam::token::compound& Foam::token::compoundToken() const
|
||||||
{
|
{
|
||||||
if (type_ == COMPOUND)
|
if (type_ == tokenType::COMPOUND)
|
||||||
{
|
{
|
||||||
return *compoundTokenPtr_;
|
return *compoundTokenPtr_;
|
||||||
}
|
}
|
||||||
@ -382,7 +437,7 @@ inline Foam::label& Foam::token::lineNumber()
|
|||||||
inline void Foam::token::setBad()
|
inline void Foam::token::setBad()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type_ = ERROR;
|
type_ = tokenType::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -395,41 +450,41 @@ inline void Foam::token::operator=(const token& t)
|
|||||||
|
|
||||||
switch (type_)
|
switch (type_)
|
||||||
{
|
{
|
||||||
case token::UNDEFINED:
|
case tokenType::UNDEFINED:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUNCTUATION:
|
case tokenType::PUNCTUATION:
|
||||||
punctuationToken_ = t.punctuationToken_;
|
punctuationToken_ = t.punctuationToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WORD:
|
case tokenType::WORD:
|
||||||
wordTokenPtr_ = new word(*t.wordTokenPtr_);
|
wordTokenPtr_ = new word(*t.wordTokenPtr_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STRING:
|
case tokenType::STRING:
|
||||||
case VARIABLE:
|
case tokenType::VARIABLE:
|
||||||
case VERBATIMSTRING:
|
case tokenType::VERBATIMSTRING:
|
||||||
stringTokenPtr_ = new string(*t.stringTokenPtr_);
|
stringTokenPtr_ = new string(*t.stringTokenPtr_);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LABEL:
|
case tokenType::LABEL:
|
||||||
labelToken_ = t.labelToken_;
|
labelToken_ = t.labelToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FLOAT_SCALAR:
|
case tokenType::FLOAT_SCALAR:
|
||||||
floatScalarToken_ = t.floatScalarToken_;
|
floatScalarToken_ = t.floatScalarToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DOUBLE_SCALAR:
|
case tokenType::DOUBLE_SCALAR:
|
||||||
doubleScalarToken_ = t.doubleScalarToken_;
|
doubleScalarToken_ = t.doubleScalarToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPOUND:
|
case tokenType::COMPOUND:
|
||||||
compoundTokenPtr_ = t.compoundTokenPtr_;
|
compoundTokenPtr_ = t.compoundTokenPtr_;
|
||||||
compoundTokenPtr_->refCount::operator++();
|
compoundTokenPtr_->refCount::operator++();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::ERROR:
|
case tokenType::ERROR:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,14 +494,14 @@ inline void Foam::token::operator=(const token& t)
|
|||||||
inline void Foam::token::operator=(const punctuationToken p)
|
inline void Foam::token::operator=(const punctuationToken p)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type_ = PUNCTUATION;
|
type_ = tokenType::PUNCTUATION;
|
||||||
punctuationToken_ = p;
|
punctuationToken_ = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Foam::token::operator=(word* wPtr)
|
inline void Foam::token::operator=(word* wPtr)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type_ = WORD;
|
type_ = tokenType::WORD;
|
||||||
wordTokenPtr_ = wPtr;
|
wordTokenPtr_ = wPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,44 +510,44 @@ inline void Foam::token::operator=(const word& w)
|
|||||||
operator=(new word(w));
|
operator=(new word(w));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Foam::token::operator=(string* sPtr)
|
inline void Foam::token::operator=(string* strPtr)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type_ = STRING;
|
type_ = tokenType::STRING;
|
||||||
stringTokenPtr_ = sPtr;
|
stringTokenPtr_ = strPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Foam::token::operator=(const string& s)
|
inline void Foam::token::operator=(const string& str)
|
||||||
{
|
{
|
||||||
operator=(new string(s));
|
operator=(new string(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Foam::token::operator=(const label l)
|
inline void Foam::token::operator=(const label val)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type_ = LABEL;
|
type_ = tokenType::LABEL;
|
||||||
labelToken_ = l;
|
labelToken_ = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Foam::token::operator=(const floatScalar s)
|
inline void Foam::token::operator=(const floatScalar val)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type_ = FLOAT_SCALAR;
|
type_ = tokenType::FLOAT_SCALAR;
|
||||||
floatScalarToken_ = s;
|
floatScalarToken_ = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Foam::token::operator=(const doubleScalar s)
|
inline void Foam::token::operator=(const doubleScalar val)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type_ = DOUBLE_SCALAR;
|
type_ = tokenType::DOUBLE_SCALAR;
|
||||||
doubleScalarToken_ = s;
|
doubleScalarToken_ = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Foam::token::operator=(Foam::token::compound* cPtr)
|
inline void Foam::token::operator=(Foam::token::compound* compPtr)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
type_ = COMPOUND;
|
type_ = tokenType::COMPOUND;
|
||||||
compoundTokenPtr_ = cPtr;
|
compoundTokenPtr_ = compPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -505,33 +560,33 @@ inline bool Foam::token::operator==(const token& t) const
|
|||||||
|
|
||||||
switch (type_)
|
switch (type_)
|
||||||
{
|
{
|
||||||
case token::UNDEFINED:
|
case tokenType::UNDEFINED:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case PUNCTUATION:
|
case tokenType::PUNCTUATION:
|
||||||
return punctuationToken_ == t.punctuationToken_;
|
return punctuationToken_ == t.punctuationToken_;
|
||||||
|
|
||||||
case WORD:
|
case tokenType::WORD:
|
||||||
return *wordTokenPtr_ == *t.wordTokenPtr_;
|
return *wordTokenPtr_ == *t.wordTokenPtr_;
|
||||||
|
|
||||||
case STRING:
|
case tokenType::STRING:
|
||||||
case VARIABLE:
|
case tokenType::VARIABLE:
|
||||||
case VERBATIMSTRING:
|
case tokenType::VERBATIMSTRING:
|
||||||
return *stringTokenPtr_ == *t.stringTokenPtr_;
|
return *stringTokenPtr_ == *t.stringTokenPtr_;
|
||||||
|
|
||||||
case LABEL:
|
case tokenType::LABEL:
|
||||||
return labelToken_ == t.labelToken_;
|
return labelToken_ == t.labelToken_;
|
||||||
|
|
||||||
case FLOAT_SCALAR:
|
case tokenType::FLOAT_SCALAR:
|
||||||
return equal(floatScalarToken_, t.floatScalarToken_);
|
return equal(floatScalarToken_, t.floatScalarToken_);
|
||||||
|
|
||||||
case DOUBLE_SCALAR:
|
case tokenType::DOUBLE_SCALAR:
|
||||||
return equal(doubleScalarToken_, t.doubleScalarToken_);
|
return equal(doubleScalarToken_, t.doubleScalarToken_);
|
||||||
|
|
||||||
case COMPOUND:
|
case tokenType::COMPOUND:
|
||||||
return compoundTokenPtr_ == t.compoundTokenPtr_;
|
return compoundTokenPtr_ == t.compoundTokenPtr_;
|
||||||
|
|
||||||
case token::ERROR:
|
case tokenType::ERROR:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,36 +595,52 @@ inline bool Foam::token::operator==(const token& t) const
|
|||||||
|
|
||||||
inline bool Foam::token::operator==(const punctuationToken p) const
|
inline bool Foam::token::operator==(const punctuationToken p) const
|
||||||
{
|
{
|
||||||
return (type_ == PUNCTUATION && punctuationToken_ == p);
|
return (type_ == tokenType::PUNCTUATION && punctuationToken_ == p);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator==(const word& w) const
|
inline bool Foam::token::operator==(const word& w) const
|
||||||
{
|
{
|
||||||
return (type_ == WORD && wordToken() == w);
|
return (type_ == tokenType::WORD && wordToken() == w);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator==(const string& s) const
|
inline bool Foam::token::operator==(const string& str) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
(type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING)
|
(
|
||||||
&& stringToken() == s
|
type_ == tokenType::STRING
|
||||||
|
|| type_ == tokenType::VARIABLE
|
||||||
|
|| type_ == tokenType::VERBATIMSTRING
|
||||||
|
)
|
||||||
|
&& stringToken() == str
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator==(const label l) const
|
inline bool Foam::token::operator==(const label val) const
|
||||||
{
|
{
|
||||||
return (type_ == LABEL && labelToken_ == l);
|
return
|
||||||
|
(
|
||||||
|
type_ == tokenType::LABEL
|
||||||
|
&& labelToken_ == val
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator==(const floatScalar s) const
|
inline bool Foam::token::operator==(const floatScalar val) const
|
||||||
{
|
{
|
||||||
return (type_ == FLOAT_SCALAR && equal(floatScalarToken_, s));
|
return
|
||||||
|
(
|
||||||
|
type_ == tokenType::FLOAT_SCALAR
|
||||||
|
&& equal(floatScalarToken_, val)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator==(const doubleScalar s) const
|
inline bool Foam::token::operator==(const doubleScalar val) const
|
||||||
{
|
{
|
||||||
return (type_ == DOUBLE_SCALAR && equal(doubleScalarToken_, s));
|
return
|
||||||
|
(
|
||||||
|
type_ == tokenType::DOUBLE_SCALAR
|
||||||
|
&& equal(doubleScalarToken_, val)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator!=(const token& t) const
|
inline bool Foam::token::operator!=(const token& t) const
|
||||||
@ -587,24 +658,24 @@ inline bool Foam::token::operator!=(const word& w) const
|
|||||||
return !operator==(w);
|
return !operator==(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator!=(const string& s) const
|
inline bool Foam::token::operator!=(const string& str) const
|
||||||
{
|
{
|
||||||
return !operator==(s);
|
return !operator==(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator!=(const floatScalar s) const
|
inline bool Foam::token::operator!=(const label val) const
|
||||||
{
|
{
|
||||||
return !operator==(s);
|
return !operator==(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator!=(const doubleScalar s) const
|
inline bool Foam::token::operator!=(const floatScalar val) const
|
||||||
{
|
{
|
||||||
return !operator==(s);
|
return !operator==(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Foam::token::operator!=(const label l) const
|
inline bool Foam::token::operator!=(const doubleScalar val) const
|
||||||
{
|
{
|
||||||
return !operator==(l);
|
return !operator==(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ License
|
|||||||
|
|
||||||
Foam::token::token(Istream& is)
|
Foam::token::token(Istream& is)
|
||||||
:
|
:
|
||||||
type_(UNDEFINED)
|
type_(tokenType::UNDEFINED)
|
||||||
{
|
{
|
||||||
is.read(*this);
|
is.read(*this);
|
||||||
}
|
}
|
||||||
@ -52,47 +52,47 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& t)
|
|||||||
{
|
{
|
||||||
switch (t.type_)
|
switch (t.type_)
|
||||||
{
|
{
|
||||||
case token::UNDEFINED:
|
case token::tokenType::UNDEFINED:
|
||||||
os << "UNDEFINED";
|
os << "UNDEFINED";
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Undefined token" << endl;
|
<< "Undefined token" << endl;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::PUNCTUATION:
|
case token::tokenType::PUNCTUATION:
|
||||||
os << t.punctuationToken_;
|
os << t.punctuationToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::WORD:
|
case token::tokenType::WORD:
|
||||||
os << *t.wordTokenPtr_;
|
os << *t.wordTokenPtr_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::STRING:
|
case token::tokenType::STRING:
|
||||||
case token::VERBATIMSTRING:
|
case token::tokenType::VERBATIMSTRING:
|
||||||
os << *t.stringTokenPtr_;
|
os << *t.stringTokenPtr_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::VARIABLE:
|
case token::tokenType::VARIABLE:
|
||||||
// Behaviour differs according to stream type
|
// Behaviour differs according to stream type
|
||||||
os.write(t);
|
os.write(t);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::LABEL:
|
case token::tokenType::LABEL:
|
||||||
os << t.labelToken_;
|
os << t.labelToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::FLOAT_SCALAR:
|
case token::tokenType::FLOAT_SCALAR:
|
||||||
os << t.floatScalarToken_;
|
os << t.floatScalarToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::DOUBLE_SCALAR:
|
case token::tokenType::DOUBLE_SCALAR:
|
||||||
os << t.doubleScalarToken_;
|
os << t.doubleScalarToken_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::COMPOUND:
|
case token::tokenType::COMPOUND:
|
||||||
os << *t.compoundTokenPtr_;
|
os << *t.compoundTokenPtr_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::ERROR:
|
case token::tokenType::ERROR:
|
||||||
os << "ERROR";
|
os << "ERROR";
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "Error token" << endl;
|
<< "Error token" << endl;
|
||||||
@ -141,43 +141,43 @@ ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip)
|
|||||||
|
|
||||||
switch (t.type())
|
switch (t.type())
|
||||||
{
|
{
|
||||||
case token::UNDEFINED:
|
case token::tokenType::UNDEFINED:
|
||||||
os << " an undefined token";
|
os << " an undefined token";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::PUNCTUATION:
|
case token::tokenType::PUNCTUATION:
|
||||||
os << " the punctuation token " << '\'' << t.pToken() << '\'';
|
os << " the punctuation token " << '\'' << t.pToken() << '\'';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::WORD:
|
case token::tokenType::WORD:
|
||||||
os << " the word " << '\'' << t.wordToken() << '\'';
|
os << " the word " << '\'' << t.wordToken() << '\'';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::STRING:
|
case token::tokenType::STRING:
|
||||||
os << " the string " << t.stringToken();
|
os << " the string " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::VARIABLE:
|
case token::tokenType::VARIABLE:
|
||||||
os << " the variable " << t.stringToken();
|
os << " the variable " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::VERBATIMSTRING:
|
case token::tokenType::VERBATIMSTRING:
|
||||||
os << " the verbatim string " << t.stringToken();
|
os << " the verbatim string " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::LABEL:
|
case token::tokenType::LABEL:
|
||||||
os << " the label " << t.labelToken();
|
os << " the label " << t.labelToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::FLOAT_SCALAR:
|
case token::tokenType::FLOAT_SCALAR:
|
||||||
os << " the floatScalar " << t.floatScalarToken();
|
os << " the floatScalar " << t.floatScalarToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::DOUBLE_SCALAR:
|
case token::tokenType::DOUBLE_SCALAR:
|
||||||
os << " the doubleScalar " << t.doubleScalarToken();
|
os << " the doubleScalar " << t.doubleScalarToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::COMPOUND:
|
case token::tokenType::COMPOUND:
|
||||||
{
|
{
|
||||||
if (t.compoundToken().empty())
|
if (t.compoundToken().empty())
|
||||||
{
|
{
|
||||||
@ -192,7 +192,7 @@ ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::ERROR:
|
case token::tokenType::ERROR:
|
||||||
os << " an error";
|
os << " an error";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -213,43 +213,43 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<token>& ip)
|
|||||||
|
|
||||||
switch (t.type())
|
switch (t.type())
|
||||||
{
|
{
|
||||||
case token::UNDEFINED:
|
case token::tokenType::UNDEFINED:
|
||||||
os << " an undefined token";
|
os << " an undefined token";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::PUNCTUATION:
|
case token::tokenType::PUNCTUATION:
|
||||||
os << " the punctuation token " << '\'' << t.pToken() << '\'';
|
os << " the punctuation token " << '\'' << t.pToken() << '\'';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::WORD:
|
case token::tokenType::WORD:
|
||||||
os << " the word " << '\'' << t.wordToken() << '\'';
|
os << " the word " << '\'' << t.wordToken() << '\'';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::STRING:
|
case token::tokenType::STRING:
|
||||||
os << " the string " << t.stringToken();
|
os << " the string " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::VARIABLE:
|
case token::tokenType::VARIABLE:
|
||||||
os << " the variable " << t.stringToken();
|
os << " the variable " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::VERBATIMSTRING:
|
case token::tokenType::VERBATIMSTRING:
|
||||||
os << " the verbatim string " << t.stringToken();
|
os << " the verbatim string " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::LABEL:
|
case token::tokenType::LABEL:
|
||||||
os << " the label " << t.labelToken();
|
os << " the label " << t.labelToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::FLOAT_SCALAR:
|
case token::tokenType::FLOAT_SCALAR:
|
||||||
os << " the floatScalar " << t.floatScalarToken();
|
os << " the floatScalar " << t.floatScalarToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::DOUBLE_SCALAR:
|
case token::tokenType::DOUBLE_SCALAR:
|
||||||
os << " the doubleScalar " << t.doubleScalarToken();
|
os << " the doubleScalar " << t.doubleScalarToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::COMPOUND:
|
case token::tokenType::COMPOUND:
|
||||||
{
|
{
|
||||||
if (t.compoundToken().empty())
|
if (t.compoundToken().empty())
|
||||||
{
|
{
|
||||||
@ -264,7 +264,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<token>& ip)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case token::ERROR:
|
case token::tokenType::ERROR:
|
||||||
os << " an error";
|
os << " an error";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@ -236,7 +236,7 @@ void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const
|
|||||||
}
|
}
|
||||||
space = true; // Prefix any following tokens
|
space = true; // Prefix any following tokens
|
||||||
|
|
||||||
if (t.type() == token::VERBATIMSTRING)
|
if (t.type() == token::tokenType::VERBATIMSTRING)
|
||||||
{
|
{
|
||||||
// Bypass token output operator to avoid losing verbatimness.
|
// Bypass token output operator to avoid losing verbatimness.
|
||||||
// Handle in Ostreams themselves
|
// Handle in Ostreams themselves
|
||||||
|
|||||||
@ -158,7 +158,7 @@ void Foam::dimensionSet::tokeniser::splitWord(const word& w)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
push(token::punctuationToken(w[i]));
|
push(token(token::punctuationToken(w[i])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start = i+1;
|
start = i+1;
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -32,10 +32,8 @@ License
|
|||||||
const char* Foam::Switch::names[Foam::Switch::INVALID+1] =
|
const char* Foam::Switch::names[Foam::Switch::INVALID+1] =
|
||||||
{
|
{
|
||||||
"false", "true",
|
"false", "true",
|
||||||
"off", "on",
|
|
||||||
"no", "yes",
|
"no", "yes",
|
||||||
"n", "y",
|
"off", "on",
|
||||||
"f", "t",
|
|
||||||
"none", "true", // Is there a reasonable counterpart to "none"?
|
"none", "true", // Is there a reasonable counterpart to "none"?
|
||||||
"invalid"
|
"invalid"
|
||||||
};
|
};
|
||||||
@ -49,55 +47,53 @@ Foam::Switch::switchType Foam::Switch::asEnum
|
|||||||
const bool allowInvalid
|
const bool allowInvalid
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (int sw = 0; sw < Switch::INVALID; ++sw)
|
const std::string::size_type len = str.size();
|
||||||
|
switch (len)
|
||||||
{
|
{
|
||||||
if (str == names[sw])
|
case 1: // (f|n|t|y) - single-character forms
|
||||||
{
|
{
|
||||||
// handle aliases
|
switch (str[0])
|
||||||
switch (sw)
|
|
||||||
{
|
{
|
||||||
case Switch::NO_1:
|
case 'f': return switchType::FALSE;
|
||||||
case Switch::NONE:
|
case 'n': return switchType::NO;
|
||||||
{
|
case 't': return switchType::TRUE;
|
||||||
return Switch::NO;
|
case 'y': return switchType::YES;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Switch::YES_1:
|
|
||||||
{
|
|
||||||
return Switch::YES;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Switch::FALSE_1:
|
|
||||||
{
|
|
||||||
return Switch::FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Switch::TRUE_1:
|
|
||||||
{
|
|
||||||
return Switch::TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
return switchType(sw);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: // (no|on)
|
||||||
|
{
|
||||||
|
if (str == names[switchType::NO]) return switchType::NO;
|
||||||
|
if (str == names[switchType::ON]) return switchType::ON;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: // (off|yes)
|
||||||
|
{
|
||||||
|
if (str == names[switchType::OFF]) return switchType::OFF;
|
||||||
|
if (str == names[switchType::YES]) return switchType::YES;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: // (none|true)
|
||||||
|
{
|
||||||
|
if (str == names[switchType::NONE]) return switchType::NONE;
|
||||||
|
if (str == names[switchType::TRUE]) return switchType::TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: // (false)
|
||||||
|
{
|
||||||
|
if (str == names[switchType::FALSE]) return switchType::FALSE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allowInvalid)
|
if (!allowInvalid)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "unknown switch word " << str << nl
|
<< "Unknown switch word " << str << nl
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Switch::INVALID;
|
return switchType::INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -116,7 +112,7 @@ Foam::Switch Foam::Switch::lookupOrAddToDict
|
|||||||
|
|
||||||
bool Foam::Switch::valid() const
|
bool Foam::Switch::valid() const
|
||||||
{
|
{
|
||||||
return switch_ <= Switch::NONE;
|
return switch_ <= switchType::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -69,17 +69,13 @@ public:
|
|||||||
|
|
||||||
// Public data types
|
// Public data types
|
||||||
|
|
||||||
// avoid issues with pre-processor defines
|
// Avoid issues with possible pre-processor defines
|
||||||
#undef FALSE
|
#undef FALSE
|
||||||
#undef TRUE
|
#undef TRUE
|
||||||
#undef OFF
|
|
||||||
#undef ON
|
|
||||||
#undef NO
|
#undef NO
|
||||||
#undef YES
|
#undef YES
|
||||||
#undef NO_1
|
#undef OFF
|
||||||
#undef YES_1
|
#undef ON
|
||||||
#undef FALSE_1
|
|
||||||
#undef TRUE_1
|
|
||||||
#undef NONE
|
#undef NONE
|
||||||
#undef PLACEHOLDER
|
#undef PLACEHOLDER
|
||||||
#undef INVALID
|
#undef INVALID
|
||||||
@ -89,11 +85,9 @@ public:
|
|||||||
enum switchType
|
enum switchType
|
||||||
{
|
{
|
||||||
FALSE = 0, TRUE = 1,
|
FALSE = 0, TRUE = 1,
|
||||||
OFF = 2, ON = 3,
|
NO = 2, YES = 3,
|
||||||
NO = 4, YES = 5,
|
OFF = 4, ON = 5,
|
||||||
NO_1 = 6, YES_1 = 7,
|
NONE = 6, PLACEHOLDER = 7,
|
||||||
FALSE_1 = 8, TRUE_1 = 9,
|
|
||||||
NONE = 10, PLACEHOLDER = 11,
|
|
||||||
INVALID
|
INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -123,7 +117,7 @@ public:
|
|||||||
//- Construct null as false
|
//- Construct null as false
|
||||||
Switch()
|
Switch()
|
||||||
:
|
:
|
||||||
switch_(Switch::FALSE)
|
switch_(switchType::FALSE)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from enumerated value
|
//- Construct from enumerated value
|
||||||
@ -135,25 +129,37 @@ public:
|
|||||||
//- Construct from bool
|
//- Construct from bool
|
||||||
Switch(const bool b)
|
Switch(const bool b)
|
||||||
:
|
:
|
||||||
switch_(b ? Switch::TRUE : Switch::FALSE)
|
switch_(b ? switchType::TRUE : switchType::FALSE)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from integer values (treats integer as bool value)
|
//- Construct from integer values (treats integer as bool value)
|
||||||
Switch(const int i)
|
Switch(const int i)
|
||||||
:
|
:
|
||||||
switch_(i ? Switch::TRUE : Switch::FALSE)
|
switch_(i ? switchType::TRUE : switchType::FALSE)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from std::string, string, word
|
//- Construct from string - catches bad input.
|
||||||
|
explicit Switch(const std::string& str)
|
||||||
|
:
|
||||||
|
switch_(asEnum(str, false))
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from character array - catches bad input.
|
||||||
|
explicit Switch(const char* str)
|
||||||
|
:
|
||||||
|
switch_(asEnum(std::string(str), false))
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Construct from string.
|
||||||
// Optionally allow bad words, and catch the error elsewhere
|
// Optionally allow bad words, and catch the error elsewhere
|
||||||
Switch(const std::string& str, const bool allowInvalid=false)
|
Switch(const std::string& str, const bool allowInvalid)
|
||||||
:
|
:
|
||||||
switch_(asEnum(str, allowInvalid))
|
switch_(asEnum(str, allowInvalid))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//- Construct from character array
|
//- Construct from character array.
|
||||||
// Optionally allow bad words, and catch the error elsewhere
|
// Optionally allow bad words, and catch the error elsewhere
|
||||||
Switch(const char* str, const bool allowInvalid=false)
|
Switch(const char* str, const bool allowInvalid)
|
||||||
:
|
:
|
||||||
switch_(asEnum(std::string(str), allowInvalid))
|
switch_(asEnum(std::string(str), allowInvalid))
|
||||||
{}
|
{}
|
||||||
@ -167,7 +173,7 @@ public:
|
|||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
dictionary& dict,
|
dictionary& dict,
|
||||||
const Switch& defaultValue = false
|
const Switch& defaultValue = switchType::FALSE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -304,15 +304,44 @@ namespace stringOps
|
|||||||
Foam::word name(const std::string& fmt, const PrimitiveType& val);
|
Foam::word name(const std::string& fmt, const PrimitiveType& val);
|
||||||
|
|
||||||
|
|
||||||
//- Split a string into sub-strings at the delimiter character.
|
//- Split string into sub-strings at the delimiter character.
|
||||||
// An empty sub-strings are suppressed.
|
// Empty sub-strings are suppressed.
|
||||||
template<class StringType>
|
template<class StringType>
|
||||||
Foam::SubStrings<StringType> split
|
Foam::SubStrings<StringType> split
|
||||||
(
|
(
|
||||||
const StringType& str,
|
const StringType& str,
|
||||||
const char delimiter
|
const char delim
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Split string into sub-strings using delimiter string.
|
||||||
|
// Empty sub-strings are suppressed.
|
||||||
|
template<class StringType>
|
||||||
|
Foam::SubStrings<StringType> split
|
||||||
|
(
|
||||||
|
const StringType& str,
|
||||||
|
const std::string& delim
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Split string into sub-strings using any characters in delimiter.
|
||||||
|
// Empty sub-strings are suppressed.
|
||||||
|
template<class StringType>
|
||||||
|
Foam::SubStrings<StringType> splitAny
|
||||||
|
(
|
||||||
|
const StringType& str,
|
||||||
|
const std::string& delim
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)
|
||||||
|
// Empty sub-strings are suppressed.
|
||||||
|
template<class StringType>
|
||||||
|
Foam::SubStrings<StringType> splitSpace
|
||||||
|
(
|
||||||
|
const StringType& str
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
} // End namespace stringOps
|
} // End namespace stringOps
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -69,7 +69,7 @@ template<class StringType>
|
|||||||
Foam::SubStrings<StringType> Foam::stringOps::split
|
Foam::SubStrings<StringType> Foam::stringOps::split
|
||||||
(
|
(
|
||||||
const StringType& str,
|
const StringType& str,
|
||||||
const char delimiter
|
const char delim
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Foam::SubStrings<StringType> lst;
|
Foam::SubStrings<StringType> lst;
|
||||||
@ -77,7 +77,7 @@ Foam::SubStrings<StringType> Foam::stringOps::split
|
|||||||
|
|
||||||
std::string::size_type beg = 0, end = 0;
|
std::string::size_type beg = 0, end = 0;
|
||||||
|
|
||||||
while ((end = str.find(delimiter, beg)) != std::string::npos)
|
while ((end = str.find(delim, beg)) != std::string::npos)
|
||||||
{
|
{
|
||||||
if (beg < end)
|
if (beg < end)
|
||||||
{
|
{
|
||||||
@ -97,4 +97,84 @@ Foam::SubStrings<StringType> Foam::stringOps::split
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType>
|
||||||
|
Foam::SubStrings<StringType> Foam::stringOps::split
|
||||||
|
(
|
||||||
|
const StringType& str,
|
||||||
|
const std::string& delim
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Foam::SubStrings<StringType> lst;
|
||||||
|
lst.reserve(20);
|
||||||
|
|
||||||
|
std::string::size_type beg = 0, end = 0;
|
||||||
|
|
||||||
|
while ((end = str.find(delim, beg)) != std::string::npos)
|
||||||
|
{
|
||||||
|
if (beg < end)
|
||||||
|
{
|
||||||
|
// (Non-empty) intermediate element
|
||||||
|
lst.append(str.cbegin() + beg, str.cbegin() + end);
|
||||||
|
}
|
||||||
|
beg = end + delim.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// (Non-empty) trailing element
|
||||||
|
if (beg < str.size())
|
||||||
|
{
|
||||||
|
lst.append(str.cbegin() + beg, str.cbegin() + str.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType>
|
||||||
|
Foam::SubStrings<StringType> Foam::stringOps::splitAny
|
||||||
|
(
|
||||||
|
const StringType& str,
|
||||||
|
const std::string& delim
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Foam::SubStrings<StringType> lst;
|
||||||
|
lst.reserve(20);
|
||||||
|
|
||||||
|
std::string::size_type beg = 0;
|
||||||
|
|
||||||
|
while
|
||||||
|
(
|
||||||
|
(beg = str.find_first_not_of(delim, beg))
|
||||||
|
!= std::string::npos
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const auto end = str.find_first_of(delim, beg);
|
||||||
|
|
||||||
|
if (end == std::string::npos)
|
||||||
|
{
|
||||||
|
// Trailing element
|
||||||
|
lst.append(str.cbegin() + beg, str.cbegin() + str.size());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Intermediate element
|
||||||
|
lst.append(str.cbegin() + beg, str.cbegin() + end);
|
||||||
|
beg = end + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class StringType>
|
||||||
|
Foam::SubStrings<StringType> Foam::stringOps::splitSpace
|
||||||
|
(
|
||||||
|
const StringType& str
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return splitAny(str, "\t\n\v\f\r ");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -88,7 +88,6 @@ Usage
|
|||||||
operation | operation to perform | yes |
|
operation | operation to perform | yes |
|
||||||
postOperation | post-operation to perform | no | none |
|
postOperation | post-operation to perform | no | none |
|
||||||
weightField | name of field to apply weighting | no |
|
weightField | name of field to apply weighting | no |
|
||||||
orientedWeightField | name of oriented field to apply weighting | no |
|
|
||||||
scaleFactor | scale factor | no | 1
|
scaleFactor | scale factor | no | 1
|
||||||
fields | list of fields to operate on | yes |
|
fields | list of fields to operate on | yes |
|
||||||
\endtable
|
\endtable
|
||||||
|
|||||||
@ -82,7 +82,7 @@ Foam::autoPtr<Foam::block> Foam::block::New
|
|||||||
|
|
||||||
if (!cstrIter.found())
|
if (!cstrIter.found())
|
||||||
{
|
{
|
||||||
is.putBack(blockOrCellShapeType);
|
is.putBack(token(blockOrCellShapeType));
|
||||||
return autoPtr<block>(new block(dict, index, points, edges, faces, is));
|
return autoPtr<block>(new block(dict, index, points, edges, faces, is));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -26,7 +26,7 @@ InNamespace
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
Write faceSet to vtk polydata file.
|
Write faceSet to vtk polydata file.
|
||||||
The data are the original point ids.
|
The data are the mesh face ids.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkWritePointSet.C
|
foamVtkWritePointSet.C
|
||||||
@ -49,7 +49,7 @@ class fileName;
|
|||||||
namespace vtk
|
namespace vtk
|
||||||
{
|
{
|
||||||
|
|
||||||
//- Write pointSet to vtk polydata file.
|
//- Write faceSet to vtk polydata file.
|
||||||
// Only one data which is original pointID.
|
// Only one data which is original pointID.
|
||||||
void writeFaceSet
|
void writeFaceSet
|
||||||
(
|
(
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from IOobject. No checking.
|
//- Construct from IOobject. No checking.
|
||||||
cellSet(const IOobject& obj);
|
explicit cellSet(const IOobject& obj);
|
||||||
|
|
||||||
//- Construct from polyMesh and name. Checks for valid cell ids.
|
//- Construct from polyMesh and name. Checks for valid cell ids.
|
||||||
cellSet
|
cellSet
|
||||||
|
|||||||
@ -59,9 +59,8 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
|
||||||
//- Construct from IOobject
|
//- Construct from IOobject
|
||||||
faceSet(const IOobject& obj);
|
explicit faceSet(const IOobject& obj);
|
||||||
|
|
||||||
//- Construct from objectRegistry and name
|
//- Construct from objectRegistry and name
|
||||||
faceSet
|
faceSet
|
||||||
|
|||||||
@ -60,9 +60,8 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
|
|
||||||
//- Construct from IOobject
|
//- Construct from IOobject
|
||||||
pointSet(const IOobject& obj);
|
explicit pointSet(const IOobject& obj);
|
||||||
|
|
||||||
//- Construct from objectRegistry and name
|
//- Construct from objectRegistry and name
|
||||||
pointSet
|
pointSet
|
||||||
|
|||||||
@ -14,7 +14,7 @@ FoamFile
|
|||||||
}
|
}
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
convertUoMeters 1;
|
scale 1;
|
||||||
|
|
||||||
r0 34;
|
r0 34;
|
||||||
r1 39;
|
r1 39;
|
||||||
|
|||||||
Reference in New Issue
Block a user