Compare commits
70 Commits
master
...
maintenanc
| Author | SHA1 | Date | |
|---|---|---|---|
| 5bb5b3adfa | |||
| ead4b73064 | |||
| 696ff79107 | |||
| b833ffec08 | |||
| 553e3f84ab | |||
| 701a3cc7b4 | |||
| 2ff022d3a4 | |||
| 41ebef8209 | |||
| 0d86dc1eb8 | |||
| 9330e4f194 | |||
| 217085d030 | |||
| 1f9462e7c9 | |||
| 1318ecdc60 | |||
| b069e42deb | |||
| 9d3a9268b0 | |||
| 6aa9955d34 | |||
| a8b7ca8151 | |||
| b42424cb88 | |||
| bee685c4bc | |||
| a647063f33 | |||
| bd23037adb | |||
| 29bc0fadd9 | |||
| d939fc873d | |||
| 3415674f26 | |||
| 9f4ef6c1bf | |||
| 5f119e4234 | |||
| 8d0320fe5d | |||
| be4776ea65 | |||
| 80064f42ac | |||
| c74632f022 | |||
| 4cb89e67f5 | |||
| 09086dd289 | |||
| 4cb459f30d | |||
| ff785f60cb | |||
| 38bf08fca0 | |||
| ef60db6d72 | |||
| b7c50cc0e1 | |||
| 99014cc6af | |||
| 25fb05fe45 | |||
| 7b4d3fbe42 | |||
| 1e7244bd17 | |||
| 68ce03377a | |||
| 1abcb4cdb8 | |||
| 033a867f6f | |||
| eca9fefa42 | |||
| 64c91f2a52 | |||
| b061346ad2 | |||
| f72413ac29 | |||
| ed12c73af4 | |||
| 3a1e884bbd | |||
| fcf6fd8257 | |||
| 10afef2025 | |||
| 9035f13710 | |||
| c1e06e145a | |||
| c244279087 | |||
| f2c6964a48 | |||
| a236d1dc2e | |||
| 5566d5d487 | |||
| ea1bd3301d | |||
| 884850bcbb | |||
| 005502fb0e | |||
| 93b51a524c | |||
| 401241bbc1 | |||
| 1582128a9d | |||
| 845682e4bc | |||
| 7c73ca1b12 | |||
| 9ab4318dd9 | |||
| e68219a148 | |||
| cb79d79f2b | |||
| 64df20d94a |
9
META-INFO/.gitignore
vendored
Normal file
9
META-INFO/.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Do not track build information
|
||||
build-info
|
||||
|
||||
# Do not track time-stamp
|
||||
time-stamp
|
||||
|
||||
# Do not track any manifest files
|
||||
Manifest.txt
|
||||
manifest.txt
|
||||
5
META-INFO/README.md
Normal file
5
META-INFO/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# META-INFO
|
||||
|
||||
Meta-information is for OpenFOAM internal use only.
|
||||
|
||||
(Backport from 1812)
|
||||
2
META-INFO/api-info
Normal file
2
META-INFO/api-info
Normal file
@ -0,0 +1,2 @@
|
||||
api=1612
|
||||
patch=180618
|
||||
@ -1,5 +1,5 @@
|
||||
# About OpenFOAM
|
||||
OpenFOAM is a free, open source CFD software [released and developed primarily by OpenCFD Ltd](http://www.openfoam.com) since 2004released and developed primarily by. It has a large user base across most areas of engineering and science, from both commercial and academic organisations. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to acoustics, solid mechanics and electromagnetics. [More...](http://www.openfoam.com/documentation)
|
||||
OpenFOAM is a free, open source CFD software [released and developed primarily by OpenCFD Ltd](http://www.openfoam.com) since 2004. It has a large user base across most areas of engineering and science, from both commercial and academic organisations. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to acoustics, solid mechanics and electromagnetics. [More...](http://www.openfoam.com/documentation)
|
||||
|
||||
OpenFOAM+ is professionally released every six months to include customer sponsored developments and contributions from the community, including the OpenFOAM Foundation. Releases designated OpenFOAM+ contain several man years of client-sponsored developments of which much has been transferred to, but not released in the OpenFOAM Foundation branch.
|
||||
|
||||
@ -9,7 +9,7 @@ OpenFOAM is free software: you can redistribute it and/or modify it under the te
|
||||
|
||||
|
||||
# OpenFOAM Trademark
|
||||
OpenCFD Ltd grants use of the OpenFOAM trademark by Third Parties on a licence basis. ESI Group and the OpenFOAM Foundation Ltd are currently permitted to use the trademark. For information on trademark use, please refer to the [trademark policy guidelines](http://www.openfoam.com/legal/trademark-policy.php).
|
||||
OpenCFD Ltd grants use of the OpenFOAM trademark by Third Parties on a licence basis. ESI Group and the OpenFOAM Foundation Ltd are currently permitted to use the Name and agreed Domain Name. For information on trademark use, please refer to the [trademark policy guidelines](http://www.openfoam.com/legal/trademark-policy.php).
|
||||
|
||||
Please [contact OpenCFD](http://www.openfoam.com/contact) if you have any questions on the use of the OpenFOAM trademark.
|
||||
|
||||
@ -23,4 +23,4 @@ Violations of the Trademark are continuously monitored, and will be duly prosecu
|
||||
- [OpenFOAM Community](http://www.openfoam.com/community/)
|
||||
- [Contacting OpenCFD](http://www.openfoam.com/contact/)
|
||||
|
||||
Copyright 2016 OpenCFD Ltd
|
||||
Copyright 2016-2017 OpenCFD Ltd
|
||||
|
||||
@ -108,6 +108,11 @@
|
||||
);
|
||||
}
|
||||
|
||||
alphaPhi1 = alphaPhi1BD + lambda*alphaPhi1;
|
||||
|
||||
// Reset allLambda to 1.0
|
||||
allLambda = 1.0;
|
||||
|
||||
// Create the complete flux for alpha2
|
||||
surfaceScalarField alphaPhi2
|
||||
(
|
||||
@ -172,7 +177,6 @@
|
||||
}
|
||||
|
||||
// Construct the limited fluxes
|
||||
alphaPhi1 = alphaPhi1BD + lambda*alphaPhi1;
|
||||
alphaPhi2 = alphaPhi2BD + lambda*alphaPhi2;
|
||||
|
||||
// Solve for alpha1
|
||||
|
||||
@ -42,7 +42,7 @@ int main(int argc, char *argv[])
|
||||
"def",
|
||||
"ghi"
|
||||
};
|
||||
words = { "def", "ghi", "xy", "all", "begin", "all" };
|
||||
words = { "def", "ghi", "xy", "all", "end", "all" };
|
||||
|
||||
wordHashSet setA
|
||||
{
|
||||
@ -84,6 +84,26 @@ int main(int argc, char *argv[])
|
||||
Info<< "hashedWordList: " << words << nl
|
||||
<< "with lookup: " << words.lookup() << endl;
|
||||
|
||||
{
|
||||
List<word> input = { "def", "ghi", "xy", "all", "end", "all", "def" };
|
||||
hashedWordList words1(input, true);
|
||||
|
||||
Info<< "input word list: " << input << nl
|
||||
<< "without dup: " << words1 << endl;
|
||||
|
||||
Info<< "from wordHashSet: " << hashedWordList(setA) << endl;
|
||||
Info<< "from HashTable: " << hashedWordList(tableA) << endl;
|
||||
Info<< "from HashTable: " << hashedWordList(tableB) << endl;
|
||||
|
||||
// even this works
|
||||
Info<< "from hashSet: "
|
||||
<< hashedWordList
|
||||
(
|
||||
wordHashSet(setA)
|
||||
| wordHashSet(tableA) | wordHashSet(tableB)
|
||||
) << endl;
|
||||
}
|
||||
|
||||
Info<< "wordHashSet: " << setA << endl;
|
||||
Info<< "Table-HashSet: " << tableA << endl;
|
||||
Info<< "Map<label>: " << mapA << endl;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -42,7 +42,11 @@ See also
|
||||
#include "vector.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
#include<list>
|
||||
#include "labelRange.H"
|
||||
#include "ListOps.H"
|
||||
#include "SubList.H"
|
||||
|
||||
#include <list>
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
@ -61,6 +65,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "setRootCase.H"
|
||||
|
||||
if (false)
|
||||
{
|
||||
labelList intlist(IStringStream("(0 1 2)")());
|
||||
Info<<"construct from Istream: " << intlist << endl;
|
||||
|
||||
IStringStream("(3 4 5)")() >> static_cast<labelUList&>(intlist);
|
||||
Info<<"is >>: " << intlist << endl;
|
||||
|
||||
IStringStream("(6 7 8)")() >> intlist;
|
||||
Info<<"is >>: " << intlist << endl;
|
||||
}
|
||||
|
||||
|
||||
List<vector> list1(IStringStream("1 ((0 1 2))")());
|
||||
Info<< "list1: " << list1 << endl;
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -58,6 +58,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
labelRange range;
|
||||
labelRanges ranges;
|
||||
|
||||
bool removeMode = false;
|
||||
@ -74,14 +75,16 @@ int main(int argc, char *argv[])
|
||||
continue;
|
||||
}
|
||||
|
||||
label start = 0;
|
||||
label size = 0;
|
||||
{
|
||||
label start = 0;
|
||||
label size = 0;
|
||||
|
||||
IStringStream(args[argI])() >> start;
|
||||
++argI;
|
||||
IStringStream(args[argI])() >> size;
|
||||
IStringStream(args[argI])() >> start;
|
||||
++argI;
|
||||
IStringStream(args[argI])() >> size;
|
||||
|
||||
labelRange range(start, size);
|
||||
range.reset(start, size);
|
||||
}
|
||||
|
||||
Info<< "---------------" << nl;
|
||||
if (removeMode)
|
||||
@ -107,10 +110,11 @@ int main(int argc, char *argv[])
|
||||
ranges.add(range);
|
||||
}
|
||||
|
||||
Info<< "<list>" << ranges << "</list>" << nl;
|
||||
forAllConstIter(labelRanges, ranges, iter)
|
||||
Info<< "<list>" << ranges << "</list>" << nl
|
||||
<< "content:";
|
||||
for (auto i : ranges)
|
||||
{
|
||||
Info<< " " << iter();
|
||||
Info<< " " << i;
|
||||
}
|
||||
Info<< nl;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
|
||||
#include "createTime.H"
|
||||
|
||||
Info<< "Create mesh, no clear-out\n" << endl;
|
||||
fvMesh mesh
|
||||
polyMesh mesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -51,12 +51,11 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
Info<< mesh.C() << endl;
|
||||
Info<< mesh.V() << endl;
|
||||
|
||||
surfaceVectorField Cf = mesh.Cf();
|
||||
|
||||
Info<< Cf << endl;
|
||||
Info<< "Cell centres" << nl << mesh.cellCentres() << endl;
|
||||
Info<< "Cell volumes" << nl << mesh.cellVolumes() << endl;
|
||||
Info<< "Cell shapes" << nl << mesh.cellShapes() << endl;
|
||||
Info<< "Cell face centres" << nl << mesh.faceCentres() << endl;
|
||||
|
||||
// Test construct from cellShapes
|
||||
{
|
||||
@ -83,7 +82,7 @@ int main(int argc, char *argv[])
|
||||
word defaultBoundaryPatchName = "defaultFaces";
|
||||
word defaultBoundaryPatchType = emptyPolyPatch::typeName;
|
||||
|
||||
fvMesh newMesh
|
||||
polyMesh newMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -101,12 +100,10 @@ int main(int argc, char *argv[])
|
||||
defaultBoundaryPatchType
|
||||
);
|
||||
|
||||
Info<< newMesh.C() << endl;
|
||||
Info<< newMesh.V() << endl;
|
||||
|
||||
surfaceVectorField Cf = newMesh.Cf();
|
||||
|
||||
Info<< Cf << endl;
|
||||
Info<< "New cell centres" << nl << newMesh.cellCentres() << endl;
|
||||
Info<< "New cell volumes" << nl << newMesh.cellVolumes() << endl;
|
||||
Info<< "New cell shapes" << nl << newMesh.cellShapes() << endl;
|
||||
Info<< "New cell face centres" << nl << newMesh.faceCentres() << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -75,8 +75,8 @@ int main(int argc, char *argv[])
|
||||
wre.info(Info) << " after DETECT" << endl;
|
||||
wre.uncompile();
|
||||
wre.info(Info) << " uncompiled" << endl;
|
||||
wre.recompile();
|
||||
wre.info(Info) << " recompiled" << endl;
|
||||
wre.compile();
|
||||
wre.info(Info) << " re-compiled" << endl;
|
||||
|
||||
wre.set("something .* value", wordRe::LITERAL);
|
||||
wre.info(Info) << " set as LITERAL" << endl;
|
||||
|
||||
@ -11,12 +11,11 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
. $WM_PROJECT_DIR/etc/config.sh/functions
|
||||
_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
|
||||
|
||||
|
||||
# Build libccmio (.a|.so)
|
||||
$WM_THIRD_PARTY_DIR/makeCCMIO lib # libso
|
||||
|
||||
if [ -e $CCMIO_ARCH_PATH/include/libccmio/ccmio.h \
|
||||
-a \( -e $CCMIO_ARCH_PATH/lib/libccmio.a -o $FOAM_EXT_LIBBIN/libccmio.so \) ]
|
||||
-a \( -e $CCMIO_ARCH_PATH/lib/libccmio.a -o -e $FOAM_EXT_LIBBIN/libccmio.so \) ]
|
||||
then
|
||||
wmake $targetType ccm26ToFoam
|
||||
fi
|
||||
|
||||
@ -62,7 +62,7 @@ Foam::tmp<Foam::Field<Type>> filterFarPoints
|
||||
)
|
||||
{
|
||||
tmp<Field<Type>> tNewField(new Field<Type>(field.size()));
|
||||
Field<Type>& newField = tNewField();
|
||||
Field<Type>& newField = tNewField.ref();
|
||||
|
||||
label added = 0;
|
||||
label count = 0;
|
||||
@ -160,7 +160,7 @@ Foam::tmp<Foam::triadField> buildAlignmentField(const T& mesh)
|
||||
(
|
||||
new triadField(mesh.vertexCount(), triad::unset)
|
||||
);
|
||||
triadField& alignments = tAlignments();
|
||||
triadField& alignments = tAlignments.ref();
|
||||
|
||||
for
|
||||
(
|
||||
@ -188,7 +188,7 @@ Foam::tmp<Foam::pointField> buildPointField(const T& mesh)
|
||||
(
|
||||
new pointField(mesh.vertexCount(), point(GREAT, GREAT, GREAT))
|
||||
);
|
||||
pointField& points = tPoints();
|
||||
pointField& points = tPoints.ref();
|
||||
|
||||
for
|
||||
(
|
||||
|
||||
@ -24,6 +24,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "DelaunayMesh.H"
|
||||
#include "polyMesh.H"
|
||||
#include "labelPair.H"
|
||||
#include "PrintTable.H"
|
||||
#include "pointIOField.H"
|
||||
|
||||
@ -35,7 +35,7 @@ Foam::tmp<Foam::Field<Type>> Foam::smoothAlignmentSolver::filterFarPoints
|
||||
)
|
||||
{
|
||||
tmp<Field<Type>> tNewField(new Field<Type>(field.size()));
|
||||
Field<Type>& newField = tNewField();
|
||||
Field<Type>& newField = tNewField.ref();
|
||||
|
||||
label added = 0;
|
||||
label count = 0;
|
||||
|
||||
@ -4,20 +4,35 @@ cd ${0%/*} || exit 1 # Run from this directory
|
||||
# Parse arguments for compilation (at least for error catching)
|
||||
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
|
||||
|
||||
export COMPILE_FLAGS=''
|
||||
export LINK_FLAGS=''
|
||||
unset COMP_FLAGS LINK_FLAGS
|
||||
|
||||
if [ -f "${FOAM_LIBBIN}/libSloanRenumber.so" ]
|
||||
then
|
||||
echo "Found libSloanRenumber.so -- enabling Sloan renumbering support."
|
||||
echo " found libSloanRenumber -- enabling sloan renumbering support."
|
||||
export LINK_FLAGS="${LINK_FLAGS} -lSloanRenumber"
|
||||
fi
|
||||
|
||||
if [ -f "${ZOLTAN_ARCH_PATH}/lib/libzoltan.a" -a -f "${FOAM_LIBBIN}/libzoltanRenumber.so" ]
|
||||
if [ -f "${FOAM_LIBBIN}/libzoltanRenumber.so" ]
|
||||
then
|
||||
echo "Found libzoltanRenumber.so -- enabling zoltan renumbering support."
|
||||
export COMPILE_FLAGS="-DFOAM_USE_ZOLTAN"
|
||||
export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L${ZOLTAN_ARCH_PATH}/lib -lzoltan"
|
||||
if [ -z "$ZOLTAN_ARCH_PATH" ]
|
||||
then
|
||||
# Optional: get ZOLTAN_ARCH_PATH
|
||||
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan)
|
||||
then
|
||||
. $settings
|
||||
fi
|
||||
fi
|
||||
|
||||
for libdir in lib "lib${WM_COMPILER_LIB_ARCH}"
|
||||
do
|
||||
if [ -f "$ZOLTAN_ARCH_PATH/$libdir/libzoltan.a" ]
|
||||
then
|
||||
echo " found libzoltanRenumber -- enabling zoltan renumbering support."
|
||||
export COMP_FLAGS="-DFOAM_USE_ZOLTAN"
|
||||
export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L$ZOLTAN_ARCH_PATH/$libdir -lzoltan"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
wmake $targetType
|
||||
|
||||
@ -23,7 +23,7 @@ if (!fieldsToUse.found(fieldName))
|
||||
).typeHeaderOk<volScalarField>(false, false)
|
||||
);
|
||||
|
||||
if (variableGood)
|
||||
if (!variableGood)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@ -25,6 +25,14 @@ canBuildPlugin()
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -d "$ParaView_INCLUDE_DIR" ] && \
|
||||
[ -f "$ParaView_INCLUDE_DIR/pqServerManagerModel.h" ] || {
|
||||
echo "==> cannot build ParaView plugins without an include directory"
|
||||
echo " ... or without GUI support"
|
||||
echo " ParaView_INCLUDE_DIR=$ParaView_INCLUDE_DIR"
|
||||
return 1
|
||||
}
|
||||
|
||||
type cmake > /dev/null 2>&1 || {
|
||||
echo "==> cannot build ParaView plugins without cmake"
|
||||
return 1
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -106,21 +106,12 @@ int main(int argc, char *argv[])
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
fileName dictName(runTime.system()/"noiseDict");
|
||||
if (args.optionFound("dict"))
|
||||
{
|
||||
dictName = args["dict"];
|
||||
}
|
||||
const word dictName("noiseDict");
|
||||
#include "setSystemRunTimeDictionaryIO.H"
|
||||
|
||||
IOdictionary dict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
dictName.expand(),
|
||||
runTime,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
Info<< "Reading " << dictName << "\n" << endl;
|
||||
|
||||
IOdictionary dict(dictIO);
|
||||
|
||||
autoPtr<noiseModel> model(noiseModel::New(dict));
|
||||
model->calculate();
|
||||
|
||||
566
bin/foamEtcFile
566
bin/foamEtcFile
@ -3,165 +3,314 @@
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# \\ / A nd | Copyright (C) 2008-2011, 2017-2018 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
#------------------------------------------------------------------------------
|
||||
# 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/>.
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# foamEtcFile
|
||||
#
|
||||
# Description
|
||||
# Locate user/group/shipped file with semantics similar to the
|
||||
# ~OpenFOAM/fileName expansion.
|
||||
# Locate user/group/other file as per '#includeEtc'.
|
||||
#
|
||||
# The -mode option can be used to allow chaining from
|
||||
# personal settings to site-wide settings.
|
||||
# The -mode option can be used to allow chaining from personal settings
|
||||
# to site-wide settings.
|
||||
#
|
||||
# For example, within the user ~/.OpenFOAM/<VER>/prefs.sh:
|
||||
# For example, within the user ~/.OpenFOAM/<VER>/config.sh/compiler:
|
||||
# \code
|
||||
# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \
|
||||
# && _foamSource $foamPrefs
|
||||
# eval $(foamEtcFile -sh -mode=go config.sh/compiler)
|
||||
# \endcode
|
||||
#
|
||||
# The -mode option is similarly used within etc/{bashrc,cshrc} to ensure
|
||||
# that system prefs are respected:
|
||||
# \code
|
||||
# eval $(foamEtcFile -sh -mode=o prefs.sh)
|
||||
# eval $(foamEtcFile -sh -mode=ug prefs.sh)
|
||||
# \endcode
|
||||
#
|
||||
# Environment
|
||||
# - WM_PROJECT: (unset defaults to OpenFOAM)
|
||||
# - WM_PROJECT_SITE: (unset defaults to PREFIX/site)
|
||||
# - WM_PROJECT_VERSION: (unset defaults to detect from path)
|
||||
#
|
||||
# Note
|
||||
# This script must exist in $FOAM_INST_DIR/OpenFOAM-<VERSION>/bin/
|
||||
# or $FOAM_INST_DIR/openfoam<VERSION>/bin/ (for the debian version)
|
||||
# This script must exist in one of these locations:
|
||||
# - $WM_PROJECT_INST_DIR/OpenFOAM-<VERSION>/bin
|
||||
# - $WM_PROJECT_INST_DIR/openfoam-<VERSION>/bin
|
||||
# - $WM_PROJECT_INST_DIR/openfoam<VERSION>/bin (debian version)
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
usage() {
|
||||
[ "${optQuiet:-$optSilent}" = true ] && exit 1
|
||||
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
printHelp() {
|
||||
cat<<USAGE
|
||||
|
||||
Usage: ${0##*/} [OPTION] fileName
|
||||
${0##*/} [OPTION] -list
|
||||
Usage: foamEtcFile [OPTION] fileName [-- args]
|
||||
foamEtcFile [OPTION] [-list|-list-test] [fileName]
|
||||
|
||||
options:
|
||||
-all return all files (otherwise stop after the first match)
|
||||
-list list the directories to be searched
|
||||
-mode <mode> any combination of u(user), g(group), o(other)
|
||||
-prefix <dir> specify an alternative installation prefix
|
||||
-quiet suppress all normal output
|
||||
-silent suppress all stderr output
|
||||
-version <ver> specify an alternative OpenFOAM version
|
||||
in the form Maj.Min.Rev (eg, 1.7.0)
|
||||
-help print the usage
|
||||
-all (-a) Return all files (otherwise stop after the first match)
|
||||
-list (-l) List directories or files to be checked
|
||||
-list-test List (existing) directories or files to be checked
|
||||
-mode=MODE Any combination of u(user), g(group), o(other)
|
||||
-prefix=DIR Specify an alternative installation prefix
|
||||
-version=VER Specify alternative OpenFOAM version (eg, 3.0, 1612, ...)
|
||||
-csh Produce 'source FILE' output for a csh eval
|
||||
-sh Produce '. FILE' output for a sh eval
|
||||
-csh-verbose As per -csh, with additional verbosity
|
||||
-sh-verbose As per -sh, with additional verbosity
|
||||
-config Add config directory prefix for shell type:
|
||||
with -csh* for a config.csh/ prefix
|
||||
with -sh* for a config.sh/ prefix
|
||||
-show-api Print api value from wmake/rules, or meta-info and exit
|
||||
-show-patch Print patch value from meta-info and exit
|
||||
-quiet (-q) Suppress all normal output
|
||||
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
|
||||
-help Print the usage
|
||||
|
||||
Locate user/group/shipped file with semantics similar to the
|
||||
~OpenFOAM/fileName expansion.
|
||||
Locate user/group/other file as per '#includeEtc'
|
||||
|
||||
The options can also be specified as a single character
|
||||
(eg, '-q' instead of '-quiet'), but must not be grouped.
|
||||
Do not group single character options.
|
||||
Equivalent options:
|
||||
| -mode=MODE | -mode MODE | -m MODE
|
||||
| -prefix=DIR | -prefix DIR | -p DIR
|
||||
| -version=VER | -version VER | -v VER
|
||||
|
||||
Exit status
|
||||
0 when the file is found. Print resolved path to stdout.
|
||||
1 for miscellaneous errors.
|
||||
2 when the file is not found.
|
||||
Exit status
|
||||
0 when the file is found. Print resolved path to stdout.
|
||||
1 for miscellaneous errors.
|
||||
2 when the file is not found.
|
||||
|
||||
USAGE
|
||||
exit 0 # A clean exit
|
||||
}
|
||||
|
||||
unset optQuiet optSilent
|
||||
# Report error and exit
|
||||
die()
|
||||
{
|
||||
[ "${optQuiet:-$optSilent}" = true ] && exit 1
|
||||
exec 1>&2
|
||||
echo
|
||||
echo "Error encountered:"
|
||||
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||
echo
|
||||
echo "See 'foamEtcFile -help' for usage"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
binDir="${0%/*}" # The bin dir
|
||||
projectDir="${binDir%/bin}" # The project dir
|
||||
prefixDir="${projectDir%/*}" # The prefix dir (same as $WM_PROJECT_INST_DIR)
|
||||
|
||||
# the bin dir:
|
||||
binDir="${0%/*}"
|
||||
# Could not resolve projectDir, prefixDir? (eg, called as ./bin/foamEtcFile)
|
||||
if [ "$prefixDir" = "$projectDir" ]
|
||||
then
|
||||
binDir="$(cd $binDir && pwd -L)"
|
||||
projectDir="${binDir%/bin}"
|
||||
prefixDir="${projectDir%/*}"
|
||||
fi
|
||||
projectDirName="${projectDir##*/}" # The project directory name
|
||||
|
||||
# the project dir:
|
||||
projectDir="${binDir%/bin}"
|
||||
projectVersion="$WM_PROJECT_VERSION" # Empty? - will be treated later
|
||||
userDir="$HOME/.OpenFOAM" # Hard-coded as per foamVersion.H
|
||||
|
||||
# the prefix dir (same as $FOAM_INST_DIR):
|
||||
prefixDir="${projectDir%/*}"
|
||||
|
||||
# the name used for the project directory
|
||||
projectDirName="${projectDir##*/}"
|
||||
|
||||
# version number used for debian packaging
|
||||
unset versionNum
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Guess project version or simply get the stem part of the projectDirName.
|
||||
# Handle standard and debian naming conventions.
|
||||
#
|
||||
# handle standard and debian naming convention
|
||||
# - projectVersion: update unless already set
|
||||
#
|
||||
case "$projectDirName" in
|
||||
OpenFOAM-*) # standard naming convention OpenFOAM-<VERSION>
|
||||
version="${projectDirName##OpenFOAM-}"
|
||||
;;
|
||||
# Helper variables:
|
||||
# - dirBase (for reassembling name) == projectDirName without the version
|
||||
# - versionNum (debian packaging)
|
||||
unset dirBase versionNum
|
||||
guessVersion()
|
||||
{
|
||||
local version
|
||||
|
||||
openfoam[0-9]* | openfoam-dev) # debian naming convention 'openfoam<VERSION>'
|
||||
versionNum="${projectDirName##openfoam}"
|
||||
case "$versionNum" in
|
||||
??) # convert 2 digit version number to decimal delineated
|
||||
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)@\1.\2@')
|
||||
case "$projectDirName" in
|
||||
(OpenFOAM-* | openfoam-*)
|
||||
# Standard naming: OpenFOAM-<VERSION> or openfoam-<VERSION>
|
||||
dirBase="${projectDirName%%-*}-"
|
||||
version="${projectDirName#*-}"
|
||||
version="${version%%*-}" # Extra safety, eg openfoam-version-packager
|
||||
;;
|
||||
???) # convert 3 digit version number to decimal delineated
|
||||
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)@\1.\2.\3@')
|
||||
|
||||
(openfoam[0-9]*)
|
||||
# Debian naming: openfoam<VERSION>
|
||||
dirBase="openfoam"
|
||||
version="${projectDirName#openfoam}"
|
||||
versionNum="$version"
|
||||
|
||||
# Convert digits version number to decimal delineated
|
||||
case "${#versionNum}" in (2|3|4)
|
||||
version=$(echo "$versionNum" | sed -e 's@\([0-9]\)@\1.@g')
|
||||
version="${version%.}"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Ignore special treatment if no decimals were inserted.
|
||||
[ "${#version}" -gt "${#versionNum}" ] || unset versionNum
|
||||
;;
|
||||
????) # convert 4 digit version number to decimal delineated
|
||||
version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)\(.\)@\1.\2.\3.\4@')
|
||||
;;
|
||||
*) # failback - use current environment setting
|
||||
version="$WM_PROJECT_VERSION"
|
||||
|
||||
(*)
|
||||
die "unknown/unsupported naming convention for '$projectDirName'"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Error : unknown/unsupported naming convention"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# Set projectVersion if required
|
||||
: ${projectVersion:=$version}
|
||||
}
|
||||
|
||||
|
||||
# default mode is 'ugo'
|
||||
mode=ugo
|
||||
unset optAll optList optQuiet optSilent
|
||||
# Set projectVersion and update versionNum, projectDirName accordingly
|
||||
setVersion()
|
||||
{
|
||||
projectVersion="$1"
|
||||
|
||||
# parse options
|
||||
# Need dirBase when reassembling projectDirName
|
||||
[ -n "$dirBase" ] || guessVersion
|
||||
|
||||
# Debian: update x.y.z -> xyz version
|
||||
if [ -n "$versionNum" ]
|
||||
then
|
||||
versionNum=$(echo "$projectVersion" | sed -e 's@\.@@g')
|
||||
fi
|
||||
|
||||
projectDirName="$dirBase${versionNum:-$projectVersion}"
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# The API locations. See wmake/wmakeBuildInfo
|
||||
rulesFile="$projectDir/wmake/rules/General/general"
|
||||
metaInfoDir="$projectDir/META-INFO"
|
||||
|
||||
# Get api from rules/General/general
|
||||
#
|
||||
# Failure modes:
|
||||
# - No api information (can't find file etc).
|
||||
# -> Fatal for building, but could be OK for a stripped down version
|
||||
#
|
||||
# Fallback. Get from api-info
|
||||
#
|
||||
getApi()
|
||||
{
|
||||
local value
|
||||
|
||||
value="$(sed -ne '/^ *#/!{ /WM_VERSION.*OPENFOAM=/{ s@^.*OPENFOAM= *\([0-9][0-9]*\).*@\1@p; q }}' $rulesFile 2>/dev/null)"
|
||||
if [ -z "$value" ] && [ -f "$metaInfoDir/api-info" ]
|
||||
then
|
||||
# Fallback. Get from api-info
|
||||
value="$(sed -ne 's@^ *api *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
|
||||
fi
|
||||
|
||||
if [ -n "$value" ]
|
||||
then
|
||||
echo "$value"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Get patch from meta-info / api-info
|
||||
#
|
||||
# Failure modes:
|
||||
# - No patch information (can't find file etc).
|
||||
#
|
||||
getPatchLevel()
|
||||
{
|
||||
local value
|
||||
|
||||
# Fallback. Get from api-info
|
||||
value="$(sed -ne 's@^ *patch *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
|
||||
|
||||
if [ -n "$value" ]
|
||||
then
|
||||
echo "$value"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
optMode=ugo # Default mode is always 'ugo'
|
||||
unset shellOutput verboseOutput
|
||||
unset optAll optConfig optList optVersion
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h | -help)
|
||||
usage
|
||||
-h | -help*)
|
||||
printHelp
|
||||
;;
|
||||
-show-api)
|
||||
# Show API and exit
|
||||
getApi
|
||||
exit $?
|
||||
;;
|
||||
-show-patch)
|
||||
# Show patch level and exit
|
||||
getPatchLevel
|
||||
exit $?
|
||||
;;
|
||||
-a | -all)
|
||||
optAll=true
|
||||
unset shellOutput verboseOutput
|
||||
;;
|
||||
-l | -list)
|
||||
optList=true
|
||||
;;
|
||||
-list-test)
|
||||
optList='test'
|
||||
;;
|
||||
-csh | -sh)
|
||||
shellOutput="${1#-}"
|
||||
unset verboseOutput
|
||||
;;
|
||||
-csh-verbose | -sh-verbose)
|
||||
shellOutput="${1#-}"
|
||||
verboseOutput="source " # Report: "source FILE"
|
||||
;;
|
||||
-config)
|
||||
optConfig=true
|
||||
;;
|
||||
-mode=[ugo]*)
|
||||
optMode="${1#*=}"
|
||||
;;
|
||||
-prefix=/*)
|
||||
prefixDir="${1#*=}"
|
||||
prefixDir="${prefixDir%/}"
|
||||
;;
|
||||
-version=*)
|
||||
optVersion="${1#*=}"
|
||||
;;
|
||||
-m | -mode)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
mode="$2"
|
||||
|
||||
# sanity check:
|
||||
case "$mode" in
|
||||
*u* | *g* | *o* )
|
||||
;;
|
||||
*)
|
||||
usage "'$1' option with invalid mode '$mode'"
|
||||
;;
|
||||
esac
|
||||
optMode="$2"
|
||||
shift
|
||||
# Sanity check. Handles missing argument too.
|
||||
case "$optMode" in
|
||||
([ugo]*)
|
||||
;;
|
||||
(*)
|
||||
die "invalid mode '$optMode'"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-p | -prefix)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
prefixDir="$2"
|
||||
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||
prefixDir="${2%/}"
|
||||
shift
|
||||
;;
|
||||
-q | -quiet)
|
||||
@ -171,13 +320,8 @@ do
|
||||
optSilent=true
|
||||
;;
|
||||
-v | -version)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
version="$2"
|
||||
# convert x.y.z -> xyz version (if installation looked like debian)
|
||||
if [ -n "$versionNum" ]
|
||||
then
|
||||
versionNum=$(echo "$version" | sed -e 's@\.@@g')
|
||||
fi
|
||||
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||
optVersion="$2"
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
@ -185,7 +329,7 @@ do
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
usage "unknown option: '$*'"
|
||||
die "unknown option: '$1'"
|
||||
;;
|
||||
*)
|
||||
break
|
||||
@ -194,100 +338,204 @@ do
|
||||
shift
|
||||
done
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# debugging:
|
||||
# echo "Installed locations:"
|
||||
# for i in projectDir prefixDir projectDirName version versionNum
|
||||
# do
|
||||
# eval echo "$i=\$$i"
|
||||
# done
|
||||
|
||||
|
||||
# Save the essential bits of information
|
||||
# silently remove leading ~OpenFOAM/ (used in Foam::findEtcFile)
|
||||
# Split arguments into filename (for searching) and trailing bits for shell eval
|
||||
# Silently remove leading ~OpenFOAM/ (as per Foam::findEtcFile)
|
||||
nArgs=$#
|
||||
fileName="${1#~OpenFOAM/}"
|
||||
unset evalArgs
|
||||
|
||||
if [ "$nArgs" -eq 1 ]
|
||||
then
|
||||
if [ "$1" = "--" ]
|
||||
then
|
||||
nArgs=0
|
||||
unset fileName
|
||||
fi
|
||||
elif [ "$nArgs" -ge 2 ]
|
||||
then
|
||||
if [ "$2" = "--" ]
|
||||
then
|
||||
nArgs=1
|
||||
shift 2
|
||||
evalArgs="$@"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Get version information
|
||||
if [ -n "$optVersion" ]
|
||||
then
|
||||
setVersion $optVersion
|
||||
elif [ -z "$projectVersion" ]
|
||||
then
|
||||
guessVersion
|
||||
fi
|
||||
|
||||
# Updates:
|
||||
# - projectDir for changes via -prefix or -version
|
||||
# - groupDir for changes via -prefix
|
||||
projectDir="$prefixDir/$projectDirName"
|
||||
groupDir="${WM_PROJECT_SITE:-$prefixDir/site}"
|
||||
|
||||
|
||||
# Debugging:
|
||||
# echo "Installed locations:" 1>&2
|
||||
# for i in projectDir prefixDir projectDirName projectVersion
|
||||
# do
|
||||
# eval echo "$i=\$$i" 1>&2
|
||||
# done
|
||||
|
||||
# Define the various places to be searched:
|
||||
unset dirList
|
||||
case "$mode" in
|
||||
*u*) # user
|
||||
userDir="$HOME/.${WM_PROJECT:-OpenFOAM}"
|
||||
dirList="$dirList $userDir/$version $userDir"
|
||||
case "$optMode" in (*u*) # (U)ser
|
||||
dirList="$dirList $userDir/$projectVersion $userDir"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$mode" in
|
||||
*g*) # group (site)
|
||||
siteDir="${WM_PROJECT_SITE:-$prefixDir/site}"
|
||||
dirList="$dirList $siteDir/$version $siteDir"
|
||||
case "$optMode" in (*g*) # (G)roup == site
|
||||
dirList="$dirList $groupDir/$projectVersion $groupDir"
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$mode" in
|
||||
*o*) # other (shipped)
|
||||
if [ -n "$versionNum" ]
|
||||
then
|
||||
# debian packaging
|
||||
dirList="$dirList $prefixDir/openfoam$versionNum/etc"
|
||||
else
|
||||
# standard packaging
|
||||
dirList="$dirList $prefixDir/${WM_PROJECT:-OpenFOAM}-$version/etc"
|
||||
fi
|
||||
case "$optMode" in (*o*) # (O)ther == shipped
|
||||
dirList="$dirList $projectDir/etc"
|
||||
;;
|
||||
esac
|
||||
set -- $dirList
|
||||
|
||||
[ "$#" -ge 1 ] || die "No directories to scan. Programming error?"
|
||||
exitCode=2 # Fallback is a FileNotFound error
|
||||
|
||||
|
||||
#
|
||||
# Preliminaries
|
||||
#
|
||||
|
||||
# Special handling of config.sh/ , config.csh/ directories
|
||||
if [ -n "$optConfig" -a -n "$shellOutput" -a -n "$fileName" ]
|
||||
then
|
||||
case "$shellOutput" in
|
||||
csh*)
|
||||
optConfig="config.csh/"
|
||||
;;
|
||||
sh*)
|
||||
optConfig="config.sh/"
|
||||
;;
|
||||
*)
|
||||
unset optConfig
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "$optConfig" ]
|
||||
then
|
||||
case "$fileName" in
|
||||
/* | config.csh* | config.sh*)
|
||||
# Does not need or cannot add a prefix
|
||||
unset optConfig
|
||||
;;
|
||||
*)
|
||||
fileName="$optConfig$fileName"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# The main routine
|
||||
#
|
||||
|
||||
exitCode=0
|
||||
if [ "$optList" = true ]
|
||||
if [ -n "$optList" ]
|
||||
then
|
||||
|
||||
# list directories, or potential file locations
|
||||
[ "$nArgs" -le 1 ] || usage
|
||||
# List directories, or potential file locations
|
||||
[ "$nArgs" -le 1 ] || \
|
||||
die "-list options expect 0 or 1 filename, but $nArgs provided"
|
||||
|
||||
# a silly combination, but -quiet does have precedence
|
||||
[ "$optQuiet" = true ] && exit 0
|
||||
# A silly combination, but -quiet has absolute precedence
|
||||
[ -n "$optQuiet" ] && exit 0
|
||||
|
||||
for dir
|
||||
do
|
||||
# Test for directory or file too?
|
||||
if [ "$optList" = "test" ]
|
||||
then
|
||||
if [ "$nArgs" -eq 1 ]
|
||||
then
|
||||
echo "$dir/$fileName"
|
||||
for dir
|
||||
do
|
||||
resolved="$dir/$fileName"
|
||||
if [ -f "$resolved" ]
|
||||
then
|
||||
echo "$resolved"
|
||||
exitCode=0 # OK
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "$dir"
|
||||
for dir
|
||||
do
|
||||
if [ -d "$dir" ]
|
||||
then
|
||||
echo "$dir"
|
||||
exitCode=0 # OK
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
else
|
||||
exitCode=0 # OK, already verified that $# != 0
|
||||
for dir
|
||||
do
|
||||
echo "$dir${fileName:+/}$fileName"
|
||||
done
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
[ "$nArgs" -eq 1 ] || usage
|
||||
[ "$nArgs" -eq 1 ] || die "One filename expected - $nArgs provided"
|
||||
|
||||
# general error, eg file not found
|
||||
exitCode=2
|
||||
# Output for sourcing files ("source" for csh, "." for POSIX shell)
|
||||
# Only allow sourcing a single file (disallow combination with -all)
|
||||
case "$shellOutput" in
|
||||
csh*)
|
||||
shellOutput="source " # eg, "source FILE"
|
||||
;;
|
||||
sh*)
|
||||
shellOutput=". " # eg, ". FILE"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Anti-pattern: -all disables shell commands
|
||||
if [ -n "$optAll" ]
|
||||
then
|
||||
unset shellOutput verboseOutput
|
||||
fi
|
||||
|
||||
for dir
|
||||
do
|
||||
if [ -f "$dir/$fileName" ]
|
||||
resolved="$dir/$fileName"
|
||||
if [ -f "$resolved" ]
|
||||
then
|
||||
exitCode=0
|
||||
if [ "$optQuiet" = true ]
|
||||
exitCode=0 # OK
|
||||
if [ -n "$optQuiet" ]
|
||||
then
|
||||
break
|
||||
else
|
||||
echo "$dir/$fileName"
|
||||
[ "$optAll" = true ] || break
|
||||
elif [ -n "$verboseOutput" ]
|
||||
then
|
||||
echo "$verboseOutput$resolved" 1>&2
|
||||
fi
|
||||
|
||||
if [ -n "$shellOutput" ]
|
||||
then
|
||||
echo "$shellOutput$resolved $evalArgs"
|
||||
else
|
||||
echo "$resolved"
|
||||
fi
|
||||
[ -n "$optAll" ] || break
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
|
||||
exit $exitCode
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -148,8 +148,9 @@ runParallel()
|
||||
|
||||
# Store any parsed additional arguments e.g. decomposeParDict
|
||||
APP_PARARGS=
|
||||
# Check the default decomposeParDict if available
|
||||
nProcs=$(getNumberOfProcessors system/decomposeParDict)
|
||||
|
||||
# Initialise number of procs to unset value
|
||||
nProcs=-1
|
||||
|
||||
# Parse options and executable
|
||||
while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do
|
||||
@ -185,6 +186,8 @@ runParallel()
|
||||
shift
|
||||
done
|
||||
|
||||
[ "$nProcs" -eq -1 ] && nProcs=$(getNumberOfProcessors system/decomposeParDict)
|
||||
|
||||
if [ -f log.$LOG_SUFFIX ] && [ "$LOG_IGNORE" = "false" ]
|
||||
then
|
||||
echo "$APP_NAME already run on $PWD:" \
|
||||
@ -213,7 +216,7 @@ cloneCase()
|
||||
else
|
||||
echo "Cloning $2 case from $1"
|
||||
mkdir $2
|
||||
cpfiles="0 system constant"
|
||||
cpfiles="0.orig 0 system constant"
|
||||
for f in $cpfiles
|
||||
do
|
||||
\cp -r $1/$f $2
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
@ -55,6 +55,7 @@ usage: ${0##*/}
|
||||
-metis-path dir specify 'METIS_ARCH_PATH'
|
||||
-paraview ver specify 'ParaView_VERSION' (eg, 5.0.1)
|
||||
-paraview-path dir specify 'ParaView_DIR' (eg, /opt/paraviewopenfoam3120)
|
||||
-mpi name specify type for 'WM_MPLIB' (eg, FJMPI, INTELMPI, etc)
|
||||
-openmpi ver specify ThirdParty openmpi version for 'FOAM_MPI'
|
||||
-openmpi-system activate system openmpi
|
||||
-openmpi-third activate ThirdParty openmpi (using default version)
|
||||
@ -338,6 +339,15 @@ do
|
||||
shift
|
||||
;;
|
||||
|
||||
-mpi)
|
||||
# Explicitly set WM_MPLIB=...
|
||||
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||
replace etc/bashrc WM_MPLIB "$2"
|
||||
optMpi=system
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-openmpi)
|
||||
# Replace FOAM_MPI=openmpi-<digits>.. and set to use third-party
|
||||
# The edit is slightly fragile, but works
|
||||
|
||||
11
etc/bashrc
11
etc/bashrc
@ -42,7 +42,8 @@ export WM_PROJECT_VERSION=plus
|
||||
#
|
||||
# Please set to the appropriate path if the default is not correct.
|
||||
#
|
||||
[ $BASH_SOURCE ] && FOAM_INST_DIR=$(\cd ${BASH_SOURCE%/*/*/*} && \pwd -P) || \
|
||||
rc="${BASH_SOURCE:-${ZSH_NAME:+$0}}"
|
||||
[ -n "$rc" ] && FOAM_INST_DIR=$(\cd $(dirname $rc)/../.. && \pwd -L) || \
|
||||
FOAM_INST_DIR=$HOME/$WM_PROJECT
|
||||
# FOAM_INST_DIR=~$WM_PROJECT
|
||||
# FOAM_INST_DIR=/opt/$WM_PROJECT
|
||||
@ -61,7 +62,7 @@ export FOAM_INST_DIR
|
||||
export WM_COMPILER_TYPE=system
|
||||
|
||||
#- Compiler:
|
||||
# WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-2] | Clang | Icc
|
||||
# WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-2] | Clang | Icc | IccKNL
|
||||
export WM_COMPILER=Gcc
|
||||
unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH
|
||||
|
||||
@ -135,8 +136,10 @@ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
. $WM_PROJECT_DIR/etc/config.sh/functions
|
||||
|
||||
# Add in preset user or site preferences:
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh`
|
||||
# Override definitions via prefs, with 'other' first so the sys-admin
|
||||
# can provide base values independent of WM_PROJECT_SITE
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode o prefs.sh`
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode ug prefs.sh`
|
||||
|
||||
# Evaluate command-line parameters and record settings for later
|
||||
# these can be used to set/unset values, or specify alternative pref files
|
||||
|
||||
@ -71,8 +71,15 @@ case OPENMPI:
|
||||
_foamAddMan $MPI_ARCH_PATH/share/man
|
||||
breaksw
|
||||
|
||||
case USERMPI:
|
||||
# Use an arbitrary, user-specified mpi implementation
|
||||
setenv FOAM_MPI mpi-user
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi-user`
|
||||
breaksw
|
||||
|
||||
case SYSTEMMPI:
|
||||
setenv FOAM_MPI mpi-system
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi-system`
|
||||
|
||||
if ( ! ($?MPI_ROOT) ) then
|
||||
echo
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
@ -60,11 +60,15 @@ set cmake_version=cmake-system
|
||||
|
||||
if ( ! $?ParaView_DIR ) setenv ParaView_DIR
|
||||
|
||||
# Clean the PATH
|
||||
if ( ! $?ParaView_DIR ) setenv ParaView_DIR
|
||||
set cleaned=`$WM_PROJECT_DIR/bin/foamCleanPath "$PATH" "$ParaView_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-"`
|
||||
# Clean PATH and LD_LIBRARY_PATH
|
||||
set cleaned=`$WM_PROJECT_DIR/bin/foamCleanPath "$PATH" "$ParaView_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/ParaView-"`
|
||||
if ( $status == 0 ) setenv PATH $cleaned
|
||||
|
||||
if ( $?LD_LIBRARY_PATH ) then
|
||||
set cleaned=`$WM_PROJECT_DIR/bin/foamCleanPath "$LD_LIBRARY_PATH" "$ParaView_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/ParaView-"`
|
||||
if ( $status == 0 ) setenv LD_LIBRARY_PATH $cleaned
|
||||
endif
|
||||
|
||||
# ThirdParty cmake
|
||||
set cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version
|
||||
if ( -r $cmake/bin/cmake ) then
|
||||
|
||||
@ -137,7 +137,7 @@ endsw
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Location of the jobControl directory
|
||||
setenv FOAM_JOB_DIR $WM_PROJECT_INST_DIR/jobControl
|
||||
setenv FOAM_JOB_DIR "$HOME/.OpenFOAM/jobControl"
|
||||
|
||||
# wmake configuration
|
||||
setenv WM_DIR $WM_PROJECT_DIR/wmake
|
||||
@ -196,8 +196,11 @@ endif
|
||||
unset siteDir
|
||||
|
||||
_foamAddPath ${FOAM_USER_APPBIN}:${FOAM_SITE_APPBIN}:${FOAM_APPBIN}
|
||||
# Make sure to pick up dummy versions of external libraries last
|
||||
_foamAddLib ${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN}:${FOAM_EXT_LIBBIN}:${FOAM_LIBBIN}/dummy
|
||||
_foamAddLib $FOAM_LIBBIN/dummy # Dummy versions of external libraries last
|
||||
if ( $?FOAM_EXT_LIBBIN ) then # External libraries (allowed to be unset)
|
||||
_foamAddLib $FOAM_EXT_LIBBIN
|
||||
endif
|
||||
_foamAddLib ${FOAM_USER_LIBBIN}:${FOAM_SITE_LIBBIN}:${FOAM_LIBBIN}
|
||||
|
||||
# Compiler settings
|
||||
# ~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -75,8 +75,15 @@ OPENMPI)
|
||||
_foamAddMan $MPI_ARCH_PATH/share/man
|
||||
;;
|
||||
|
||||
USERMPI)
|
||||
# Use an arbitrary, user-specified mpi implementation
|
||||
export FOAM_MPI=mpi-user
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi-user`
|
||||
;;
|
||||
|
||||
SYSTEMMPI)
|
||||
export FOAM_MPI=mpi-system
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi-system`
|
||||
|
||||
if [ -z "$MPI_ROOT" ]
|
||||
then
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
@ -61,13 +61,20 @@ cmake_version=cmake-system
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Clean the PATH
|
||||
# Clean PATH and LD_LIBRARY_PATH
|
||||
cleaned=$($WM_PROJECT_DIR/bin/foamCleanPath "$PATH" \
|
||||
"$ParaView_DIR \
|
||||
$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- \
|
||||
$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/ParaView-" \
|
||||
) && PATH="$cleaned"
|
||||
|
||||
if [ -n "$LD_LIBRARY_PATH" ]
|
||||
then
|
||||
cleaned=$($WM_PROJECT_DIR/bin/foamCleanPath "$LD_LIBRARY_PATH" \
|
||||
"$ParaView_DIR \
|
||||
$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/cmake- \
|
||||
$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/paraview-" \
|
||||
) \
|
||||
&& PATH="$cleaned"
|
||||
$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/ParaView-" \
|
||||
) && LD_LIBRARY_PATH="$cleaned"
|
||||
fi
|
||||
|
||||
# ThirdParty cmake
|
||||
cmake=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version
|
||||
|
||||
@ -141,7 +141,7 @@ esac
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Location of the jobControl directory
|
||||
export FOAM_JOB_DIR=$WM_PROJECT_INST_DIR/jobControl
|
||||
export FOAM_JOB_DIR="$HOME/.OpenFOAM/jobControl"
|
||||
|
||||
# wmake configuration
|
||||
export WM_DIR=$WM_PROJECT_DIR/wmake
|
||||
@ -198,8 +198,12 @@ fi
|
||||
unset siteDir
|
||||
|
||||
_foamAddPath $FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN
|
||||
# Make sure to pick up dummy versions of external libraries last
|
||||
_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_EXT_LIBBIN:$FOAM_LIBBIN/dummy
|
||||
_foamAddLib $FOAM_LIBBIN/dummy # Dummy versions of external libraries last
|
||||
if [ -n "$FOAM_EXT_LIBBIN" ] # External libraries (allowed to be unset)
|
||||
then
|
||||
_foamAddLib $FOAM_EXT_LIBBIN
|
||||
fi
|
||||
_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN
|
||||
|
||||
# Compiler settings
|
||||
# ~~~~~~~~~~~~~~~~~
|
||||
|
||||
@ -60,7 +60,7 @@ setenv FOAM_INST_DIR `lsof +p $$ |& grep -oE '/.*'$WM_PROJECT'[^/]*/etc/cshrc' |
|
||||
setenv WM_COMPILER_TYPE system
|
||||
|
||||
#- Compiler:
|
||||
# WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-2] | Clang | Icc
|
||||
# WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-2] | Clang | Icc | IccKNL
|
||||
setenv WM_COMPILER Gcc
|
||||
setenv WM_COMPILER_ARCH # defined but empty
|
||||
unsetenv WM_COMPILER_LIB_ARCH
|
||||
@ -148,8 +148,10 @@ setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION
|
||||
# Source files, possibly with some verbosity
|
||||
alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*'
|
||||
|
||||
# Add in preset user or site preferences:
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh`
|
||||
# Override definitions via prefs, with 'other' first so the sys-admin
|
||||
# can provide base values independent of WM_PROJECT_SITE
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode o prefs.csh`
|
||||
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -mode ug prefs.csh`
|
||||
|
||||
# Evaluate command-line parameters and record settings for later
|
||||
# these can be used to set/unset values, or specify alternative pref files
|
||||
|
||||
@ -43,4 +43,8 @@ namespace Foam
|
||||
using ISLList = ILList<SLListBase, T>;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -64,7 +64,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List<T>& L)
|
||||
}
|
||||
else if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
L.setSize(s);
|
||||
|
||||
@ -183,7 +183,7 @@ bool Foam::UList<T>::operator<(const UList<T>& a) const
|
||||
(
|
||||
const_iterator vi = begin(), ai = a.begin();
|
||||
vi < end() && ai < a.end();
|
||||
vi++, ai++
|
||||
++vi, ++ai
|
||||
)
|
||||
{
|
||||
if (*vi < *ai)
|
||||
|
||||
@ -427,7 +427,7 @@ inline void reverse(UList<T>&);
|
||||
// \endcode
|
||||
// \sa forAllReverse
|
||||
#define forAll(list, i) \
|
||||
for (Foam::label i=0; i<(list).size(); i++)
|
||||
for (Foam::label i=0; i<(list).size(); ++i)
|
||||
|
||||
//- Reverse loop across all elements in \a list
|
||||
// \par Usage
|
||||
@ -439,7 +439,7 @@ inline void reverse(UList<T>&);
|
||||
// \endcode
|
||||
// \sa forAll
|
||||
#define forAllReverse(list, i) \
|
||||
for (Foam::label i=(list).size()-1; i>=0; i--)
|
||||
for (Foam::label i=(list).size()-1; i>=0; --i)
|
||||
|
||||
//- Iterate across all elements in the \a container object of type
|
||||
// \a Container.
|
||||
@ -472,8 +472,8 @@ inline void reverse(UList<T>&);
|
||||
#define forAllConstIter(Container,container,iter) \
|
||||
for \
|
||||
( \
|
||||
Container::const_iterator iter = (container).begin(); \
|
||||
iter != (container).end(); \
|
||||
Container::const_iterator iter = (container).cbegin(); \
|
||||
iter != (container).cend(); \
|
||||
++iter \
|
||||
)
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -33,7 +33,7 @@ template<class T>
|
||||
inline Foam::UList<T>::UList()
|
||||
:
|
||||
size_(0),
|
||||
v_(0)
|
||||
v_(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
@ -321,7 +321,7 @@ inline bool Foam::UList<T>::empty() const
|
||||
template<class T>
|
||||
inline void Foam::reverse(UList<T>& ul, const label n)
|
||||
{
|
||||
for (int i=0; i<n/2; i++)
|
||||
for (int i=0; i<n/2; ++i)
|
||||
{
|
||||
Swap(ul[i], ul[n-1-i]);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -165,7 +165,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
)
|
||||
);
|
||||
// Check list length
|
||||
label s = elems.size();
|
||||
const label s = elems.size();
|
||||
|
||||
if (s != L.size())
|
||||
{
|
||||
@ -174,14 +174,14 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
<< " expected " << L.size()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
L[i] = elems[i];
|
||||
}
|
||||
}
|
||||
else if (firstToken.isLabel())
|
||||
{
|
||||
label s = firstToken.labelToken();
|
||||
const label s = firstToken.labelToken();
|
||||
|
||||
// Set list length to that read
|
||||
if (s != L.size())
|
||||
@ -203,7 +203,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
{
|
||||
if (delimiter == token::BEGIN_LIST)
|
||||
{
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
is >> L[i];
|
||||
|
||||
@ -226,7 +226,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
"reading the single entry"
|
||||
);
|
||||
|
||||
for (label i=0; i<s; i++)
|
||||
for (label i=0; i<s; ++i)
|
||||
{
|
||||
L[i] = element;
|
||||
}
|
||||
@ -281,7 +281,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList<T>& L)
|
||||
(
|
||||
typename SLList<T>::const_iterator iter = sll.begin();
|
||||
iter != sll.end();
|
||||
++iter
|
||||
++iter, ++i
|
||||
)
|
||||
{
|
||||
L[i] = iter();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -43,27 +43,35 @@ static const unsigned char base64Chars[64] =
|
||||
//! \endcond
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
std::size_t Foam::base64Layer::encodedLength(std::size_t n)
|
||||
{
|
||||
return 4 * ((n / 3) + (n % 3 ? 1 : 0));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode0()
|
||||
inline unsigned char Foam::base64Layer::encode0() const
|
||||
{
|
||||
// Top 6 bits of char0
|
||||
return base64Chars[((group_[0] & 0xFC) >> 2)];
|
||||
}
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode1()
|
||||
inline unsigned char Foam::base64Layer::encode1() const
|
||||
{
|
||||
// Bottom 2 bits of char0, Top 4 bits of char1
|
||||
return base64Chars[((group_[0] & 0x03) << 4) | ((group_[1] & 0xF0) >> 4)];
|
||||
}
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode2()
|
||||
inline unsigned char Foam::base64Layer::encode2() const
|
||||
{
|
||||
// Bottom 4 bits of char1, Top 2 bits of char2
|
||||
return base64Chars[((group_[1] & 0x0F) << 2) | ((group_[2] & 0xC0) >> 6)];
|
||||
}
|
||||
|
||||
inline unsigned char Foam::base64Layer::encode3()
|
||||
inline unsigned char Foam::base64Layer::encode3() const
|
||||
{
|
||||
// Bottom 6 bits of char2
|
||||
return base64Chars[(group_[2] & 0x3F)];
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -30,7 +30,7 @@ Description
|
||||
Base64 encoding accoding to RFC 4648 specification
|
||||
(https://tools.ietf.org/html/rfc4648#page-5).
|
||||
It is the obligation of the caller to avoid using normal output
|
||||
while the base-64 encoding layer is actively being used.
|
||||
while the base-64 encoding layer is actively used.
|
||||
|
||||
SourceFiles
|
||||
base64Layer.C
|
||||
@ -70,10 +70,10 @@ class base64Layer
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
inline unsigned char encode0();
|
||||
inline unsigned char encode1();
|
||||
inline unsigned char encode2();
|
||||
inline unsigned char encode3();
|
||||
inline unsigned char encode0() const;
|
||||
inline unsigned char encode1() const;
|
||||
inline unsigned char encode2() const;
|
||||
inline unsigned char encode3() const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
base64Layer(const base64Layer&) = delete;
|
||||
@ -95,7 +95,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
base64Layer(std::ostream&);
|
||||
base64Layer(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -104,6 +104,10 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- The encoded length has 4 bytes out for every 3 bytes in.
|
||||
static std::size_t encodedLength(std::size_t n);
|
||||
|
||||
|
||||
//- Encode the character sequence, writing when possible.
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
@ -111,7 +115,7 @@ public:
|
||||
void reset();
|
||||
|
||||
//- End the encoding sequence, padding the final characters with '='.
|
||||
// Return false if no encoding layer was actually used.
|
||||
// Return false if no encoding was actually performed.
|
||||
bool close();
|
||||
|
||||
};
|
||||
|
||||
@ -32,7 +32,7 @@ Description
|
||||
Note: cannot access the state dictionary until after construction of the
|
||||
function objects, since the owner container functionObjectList is owned
|
||||
by time, and time owns the state dictionary. I.e. need to wait for time
|
||||
to be fully consttucted.
|
||||
to be fully constructed.
|
||||
|
||||
See also
|
||||
Foam::functionObject
|
||||
|
||||
@ -126,7 +126,8 @@ void Foam::timeControl::read(const dictionary& dict)
|
||||
case ocCpuTime:
|
||||
case ocAdjustableRunTime:
|
||||
{
|
||||
interval_ = readScalar(dict.lookup(intervalName));
|
||||
const scalar userTime = readScalar(dict.lookup(intervalName));
|
||||
interval_ = time_.userTimeToTime(userTime);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,8 +43,15 @@ namespace functionObjects
|
||||
|
||||
void Foam::functionObjects::timeControl::readControls()
|
||||
{
|
||||
dict_.readIfPresent("timeStart", timeStart_);
|
||||
dict_.readIfPresent("timeEnd", timeEnd_);
|
||||
if (dict_.readIfPresent("timeStart", timeStart_))
|
||||
{
|
||||
timeStart_ = time_.userTimeToTime(timeStart_);
|
||||
}
|
||||
if (dict_.readIfPresent("timeEnd", timeEnd_))
|
||||
{
|
||||
timeEnd_ = time_.userTimeToTime(timeEnd_);
|
||||
}
|
||||
|
||||
dict_.readIfPresent("nStepsToStartTimeChange", nStepsToStartTimeChange_);
|
||||
}
|
||||
|
||||
@ -52,8 +59,8 @@ void Foam::functionObjects::timeControl::readControls()
|
||||
bool Foam::functionObjects::timeControl::active() const
|
||||
{
|
||||
return
|
||||
time_.value() >= timeStart_
|
||||
&& time_.value() <= timeEnd_;
|
||||
time_.value() >= (timeStart_ - 0.5*time_.deltaTValue())
|
||||
&& time_.value() <= (timeEnd_ + 0.5*time_.deltaTValue());
|
||||
}
|
||||
|
||||
|
||||
@ -186,7 +193,8 @@ bool Foam::functionObjects::timeControl::read
|
||||
executeControl_.read(dict);
|
||||
readControls();
|
||||
|
||||
return true;
|
||||
// Forward to underlying function object
|
||||
return foPtr_->read(dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -92,8 +92,9 @@ Foam::autoPtr<Foam::OFstream> Foam::functionObjects::writeFile::createFile
|
||||
|
||||
if (Pstream::master() && writeToFile_)
|
||||
{
|
||||
const word startTimeName =
|
||||
fileObr_.time().timeName(fileObr_.time().startTime().value());
|
||||
const scalar startTime = fileObr_.time().startTime().value();
|
||||
const scalar userStartTime = fileObr_.time().timeToUserTime(startTime);
|
||||
const word startTimeName = Time::timeName(userStartTime);
|
||||
|
||||
fileName outputDir(baseFileDir()/prefix_/startTimeName);
|
||||
|
||||
@ -105,7 +106,7 @@ Foam::autoPtr<Foam::OFstream> Foam::functionObjects::writeFile::createFile
|
||||
IFstream is(outputDir/(fName + ".dat"));
|
||||
if (is.good())
|
||||
{
|
||||
fName = fName + "_" + fileObr_.time().timeName();
|
||||
fName = fName + "_" + startTimeName;
|
||||
}
|
||||
|
||||
osPtr.set(new OFstream(outputDir/(fName + ".dat")));
|
||||
@ -258,7 +259,8 @@ void Foam::functionObjects::writeFile::writeHeader
|
||||
|
||||
void Foam::functionObjects::writeFile::writeTime(Ostream& os) const
|
||||
{
|
||||
os << setw(charWidth()) << fileObr_.time().timeName();
|
||||
const scalar timeNow = fileObr_.time().timeOutputValue();
|
||||
os << setw(charWidth()) << Time::timeName(timeNow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -51,7 +51,7 @@ namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjectFile Declaration
|
||||
Class writeFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeFile
|
||||
|
||||
@ -468,7 +468,7 @@ public:
|
||||
// \sa addProfiling
|
||||
// \sa endProfiling
|
||||
#define addProfiling0(name) \
|
||||
::Foam::Profiling::Trigger profilingTriggerFor##name(#name)
|
||||
::Foam::profiling::Trigger profilingTriggerFor##name(#name)
|
||||
|
||||
//- Define profiling with specified name and description correspond to the
|
||||
// compiler-defined function name string:
|
||||
|
||||
@ -20,7 +20,7 @@ if (dictPath.size())
|
||||
{
|
||||
dictIO = IOobject
|
||||
(
|
||||
dictPath,
|
||||
dictPath.expand(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
|
||||
@ -20,7 +20,7 @@ if (dictPath.size())
|
||||
{
|
||||
dictIO = IOobject
|
||||
(
|
||||
dictPath,
|
||||
dictPath.expand(),
|
||||
runTime,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -107,25 +107,30 @@ void Foam::GAMGSolver::interpolate
|
||||
const label nCells = m.diag().size();
|
||||
scalar* __restrict__ psiPtr = psi.begin();
|
||||
const scalar* const __restrict__ diagPtr = m.diag().begin();
|
||||
const scalar* const __restrict__ psiCPtr = psiC.begin();
|
||||
|
||||
|
||||
const label nCCells = psiC.size();
|
||||
scalarField corrC(nCCells, 0);
|
||||
scalar* __restrict__ corrCPtr = corrC.begin();
|
||||
|
||||
scalarField diagC(nCCells, 0);
|
||||
scalar* __restrict__ diagCPtr = diagC.begin();
|
||||
|
||||
for (label celli=0; celli<nCells; celli++)
|
||||
{
|
||||
corrC[restrictAddressing[celli]] += diagPtr[celli]*psiPtr[celli];
|
||||
diagC[restrictAddressing[celli]] += diagPtr[celli];
|
||||
corrCPtr[restrictAddressing[celli]] += diagPtr[celli]*psiPtr[celli];
|
||||
diagCPtr[restrictAddressing[celli]] += diagPtr[celli];
|
||||
}
|
||||
|
||||
for (label ccelli=0; ccelli<nCCells; ccelli++)
|
||||
{
|
||||
corrC[ccelli] = psiC[ccelli] - corrC[ccelli]/diagC[ccelli];
|
||||
corrCPtr[ccelli] = psiCPtr[ccelli] - corrCPtr[ccelli]/diagCPtr[ccelli];
|
||||
}
|
||||
|
||||
for (label celli=0; celli<nCells; celli++)
|
||||
{
|
||||
psiPtr[celli] += corrC[restrictAddressing[celli]];
|
||||
psiPtr[celli] += corrCPtr[restrictAddressing[celli]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,13 +48,20 @@ void Foam::GAMGSolver::scale
|
||||
cmpt
|
||||
);
|
||||
|
||||
|
||||
const label nCells = field.size();
|
||||
scalar* __restrict__ fieldPtr = field.begin();
|
||||
const scalar* const __restrict__ sourcePtr = source.begin();
|
||||
const scalar* const __restrict__ AcfPtr = Acf.begin();
|
||||
|
||||
|
||||
scalar scalingFactorNum = 0.0;
|
||||
scalar scalingFactorDenom = 0.0;
|
||||
|
||||
forAll(field, i)
|
||||
for (label i=0; i<nCells; i++)
|
||||
{
|
||||
scalingFactorNum += source[i]*field[i];
|
||||
scalingFactorDenom += Acf[i]*field[i];
|
||||
scalingFactorNum += sourcePtr[i]*fieldPtr[i];
|
||||
scalingFactorDenom += AcfPtr[i]*fieldPtr[i];
|
||||
}
|
||||
|
||||
vector2D scalingVector(scalingFactorNum, scalingFactorDenom);
|
||||
@ -68,10 +75,11 @@ void Foam::GAMGSolver::scale
|
||||
}
|
||||
|
||||
const scalarField& D = A.diag();
|
||||
const scalar* const __restrict__ DPtr = D.begin();
|
||||
|
||||
forAll(field, i)
|
||||
for (label i=0; i<nCells; i++)
|
||||
{
|
||||
field[i] = sf*field[i] + (source[i] - sf*Acf[i])/D[i];
|
||||
fieldPtr[i] = sf*fieldPtr[i] + (sourcePtr[i] - sf*AcfPtr[i])/DPtr[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -539,7 +539,15 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::cellDeterminant
|
||||
}
|
||||
}
|
||||
|
||||
cellDeterminant[celli] = mag(det(areaTensor));
|
||||
// Note:
|
||||
// - normalise to be 0..1 (since cube has eigenvalues 2 2 2)
|
||||
// - we use the determinant (i.e. 3rd invariant) and not e.g.
|
||||
// condition number (= max ev / min ev) since we are
|
||||
// interested in the minimum connectivity and not the
|
||||
// uniformity. Using the condition number on corner cells
|
||||
// leads to uniformity 1 i.e. equally bad in all three
|
||||
// directions which is not what we want.
|
||||
cellDeterminant[celli] = mag(det(areaTensor))/8.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -119,7 +119,7 @@ public:
|
||||
const pointField& p
|
||||
);
|
||||
|
||||
//- Generate cell determinant field
|
||||
//- Generate cell determinant field. Normalised to 1 for an internal cube.
|
||||
static tmp<scalarField> cellDeterminant
|
||||
(
|
||||
const primitiveMesh& mesh,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,8 +29,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::labelRange::const_iterator Foam::labelRange::endIter_;
|
||||
|
||||
int Foam::labelRange::debug(::Foam::debug::debugSwitch("labelRange", 0));
|
||||
|
||||
|
||||
@ -47,13 +45,24 @@ Foam::labelRange::labelRange(Istream& is)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::labelRange::intersects
|
||||
(
|
||||
const labelRange& range,
|
||||
const bool touches
|
||||
) const
|
||||
void Foam::labelRange::adjust()
|
||||
{
|
||||
label final = touches ? 1 : 0;
|
||||
if (start_ < 0)
|
||||
{
|
||||
size_ += start_;
|
||||
start_ = 0;
|
||||
}
|
||||
|
||||
if (size_ < 0)
|
||||
{
|
||||
size_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::labelRange::overlaps(const labelRange& range, bool touches) const
|
||||
{
|
||||
const label final = touches ? 1 : 0;
|
||||
|
||||
return
|
||||
(
|
||||
@ -97,7 +106,7 @@ Foam::labelRange Foam::labelRange::join(const labelRange& range) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
Foam::labelRange& Foam::labelRange::operator+=(const labelRange& rhs)
|
||||
void Foam::labelRange::operator+=(const labelRange& rhs)
|
||||
{
|
||||
if (!size_)
|
||||
{
|
||||
@ -112,8 +121,6 @@ Foam::labelRange& Foam::labelRange::operator+=(const labelRange& rhs)
|
||||
start_ = lower;
|
||||
size_ = upper - lower + 1;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -127,10 +134,10 @@ Foam::Istream& Foam::operator>>(Istream& is, labelRange& range)
|
||||
|
||||
is.check("operator>>(Istream&, labelRange&)");
|
||||
|
||||
// disallow invalid sizes
|
||||
if (range.size_ <= 0)
|
||||
// Disallow invalid sizes
|
||||
if (range.size_ < 0)
|
||||
{
|
||||
range.clear();
|
||||
range.size_ = 0;
|
||||
}
|
||||
|
||||
return is;
|
||||
@ -139,15 +146,11 @@ Foam::Istream& Foam::operator>>(Istream& is, labelRange& range)
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const labelRange& range)
|
||||
{
|
||||
// write ASCII only for now
|
||||
// Write ASCII only for now
|
||||
os << token::BEGIN_LIST
|
||||
<< range.start_ << token::SPACE << range.size_
|
||||
<< token::END_LIST;
|
||||
|
||||
// os << token::BEGIN_BLOCK
|
||||
// << range.start_ << "-" << range.last()
|
||||
// << token::END_BLOCK;
|
||||
|
||||
os.check("operator<<(Ostream&, const labelRange&)");
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::labelRange
|
||||
|
||||
Description
|
||||
A label range specifier.
|
||||
A range of labels.
|
||||
|
||||
SourceFiles
|
||||
labelRange.C
|
||||
@ -47,8 +47,8 @@ class Ostream;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
class labelRange;
|
||||
Istream& operator>>(Istream&, labelRange&);
|
||||
Ostream& operator<<(Ostream&, const labelRange&);
|
||||
Istream& operator>>(Istream& is, labelRange& range);
|
||||
Ostream& operator<<(Ostream& os, const labelRange& range);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class labelRange Declaration
|
||||
@ -63,7 +63,7 @@ class labelRange
|
||||
|
||||
public:
|
||||
|
||||
static int debug;
|
||||
static int debug;
|
||||
|
||||
|
||||
// Public classes
|
||||
@ -75,31 +75,50 @@ public:
|
||||
|
||||
bool operator()(const labelRange& a, const labelRange& b)
|
||||
{
|
||||
return a.first() < b.first();
|
||||
return a.operator<(b);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct an empty range
|
||||
//- Construct an empty range with zero as start and size.
|
||||
inline labelRange();
|
||||
|
||||
//- Construct a range
|
||||
// A negative size is autmatically changed to zero.
|
||||
inline labelRange(const label start, const label size);
|
||||
//- Construct a range from start and size.
|
||||
// Optionally adjust the start to avoid any negative indices.
|
||||
// Always reduce a negative size to zero.
|
||||
inline labelRange
|
||||
(
|
||||
const label start,
|
||||
const label size,
|
||||
const bool adjustStart = false
|
||||
);
|
||||
|
||||
//- Construct from Istream.
|
||||
labelRange(Istream&);
|
||||
labelRange(Istream& is);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Reset to zero size
|
||||
//- Alias for setSize(const label)
|
||||
inline void resize(const label n);
|
||||
|
||||
//- Adjust size
|
||||
inline void setSize(const label n);
|
||||
|
||||
//- Reset to zero start and zero size
|
||||
inline void clear();
|
||||
|
||||
//- Is the range empty?
|
||||
inline bool empty() const;
|
||||
|
||||
//- Adjust the start to avoid any negative indices
|
||||
void adjust();
|
||||
|
||||
//- Is the range valid (non-empty)?
|
||||
inline bool valid() const;
|
||||
|
||||
//- Return the effective size of the range
|
||||
inline label size() const;
|
||||
|
||||
@ -109,32 +128,44 @@ public:
|
||||
//- The (inclusive) upper value of the range
|
||||
inline label last() const;
|
||||
|
||||
//- Return true if the value is within the range
|
||||
inline bool contains(const label) const;
|
||||
//- Reset start and size.
|
||||
// Optionally adjust the start to avoid any negative indices.
|
||||
// Always reduce a negative size to zero.
|
||||
// Return true if the updated range valid (non-empty).
|
||||
inline bool reset
|
||||
(
|
||||
const label start,
|
||||
const label size,
|
||||
const bool adjustStart = false
|
||||
);
|
||||
|
||||
//- Return true if the ranges intersect
|
||||
//- Return true if the value is within the range
|
||||
inline bool contains(const label value) const;
|
||||
|
||||
//- Return true if the ranges overlap.
|
||||
// Optional test for ranges that also just touch each other
|
||||
bool intersects(const labelRange&, const bool touches = false) const;
|
||||
bool overlaps(const labelRange& range, bool touches=false) const;
|
||||
|
||||
//- Return a joined range, squashing any gaps in between
|
||||
// A prior intersects() check can be used to avoid squashing gaps.
|
||||
labelRange join(const labelRange&) const;
|
||||
// A prior overlaps() check can be used to avoid squashing gaps.
|
||||
labelRange join(const labelRange& range) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return element in range, no bounds checking
|
||||
inline label operator[](const label) const;
|
||||
inline label operator[](const label i) const;
|
||||
|
||||
//- Comparison function for sorting, compares the start
|
||||
//- Comparison function for sorting, compares the start.
|
||||
// If the start values are equal, also compares the size.
|
||||
inline bool operator<(const labelRange& rhs) const;
|
||||
|
||||
//- Join ranges, squashing any gaps in between
|
||||
// A prior intersects() check can be used to avoid squashing gaps.
|
||||
labelRange& operator+=(const labelRange&);
|
||||
// A prior overlaps() check can be used to avoid squashing gaps.
|
||||
void operator+=(const labelRange& rhs);
|
||||
|
||||
inline bool operator==(const labelRange&) const;
|
||||
inline bool operator!=(const labelRange&) const;
|
||||
inline bool operator==(const labelRange& rhs) const;
|
||||
inline bool operator!=(const labelRange& rhs) const;
|
||||
|
||||
|
||||
// STL iterator
|
||||
@ -142,6 +173,8 @@ public:
|
||||
//- An STL const_iterator
|
||||
class const_iterator
|
||||
{
|
||||
friend class labelRange;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the range for which this is an iterator
|
||||
@ -150,54 +183,48 @@ public:
|
||||
//- Current index
|
||||
label index_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null - equivalent to an 'end' position
|
||||
inline const_iterator();
|
||||
|
||||
//- Construct from range, moving to its 'begin' position
|
||||
inline explicit const_iterator(const labelRange&);
|
||||
//- Construct from range at 'begin' or 'end' position
|
||||
inline const_iterator
|
||||
(
|
||||
const labelRange& range,
|
||||
const bool endIter = false
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Member operators
|
||||
|
||||
inline bool operator==(const const_iterator&) const;
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
|
||||
inline bool operator!=(const const_iterator&) const;
|
||||
|
||||
inline label operator*();
|
||||
inline label operator()();
|
||||
inline label operator*() const;
|
||||
inline label operator()() const;
|
||||
|
||||
inline const_iterator& operator++();
|
||||
inline const_iterator operator++(int);
|
||||
};
|
||||
|
||||
|
||||
//- const_iterator set to the beginning of the range
|
||||
//- A const_iterator set to the beginning of the range
|
||||
inline const_iterator cbegin() const;
|
||||
|
||||
//- const_iterator set to beyond the end of the range
|
||||
inline const const_iterator& cend() const;
|
||||
//- A const_iterator set to beyond the end of the range
|
||||
inline const const_iterator cend() const;
|
||||
|
||||
//- const_iterator set to the beginning of the range
|
||||
//- A const_iterator set to the beginning of the range
|
||||
inline const_iterator begin() const;
|
||||
|
||||
//- const_iterator set to beyond the end of the range
|
||||
inline const const_iterator& end() const;
|
||||
//- A const_iterator set to beyond the end of the range
|
||||
inline const const_iterator end() const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>>(Istream&, labelRange&);
|
||||
friend Ostream& operator<<(Ostream&, const labelRange&);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- const_iterator returned by end(), cend()
|
||||
static const const_iterator endIter_;
|
||||
friend Istream& operator>>(Istream& is, labelRange& range);
|
||||
friend Ostream& operator<<(Ostream& os, const labelRange& range);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -33,32 +33,39 @@ inline Foam::labelRange::labelRange()
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::labelRange::labelRange(const label start, const label size)
|
||||
inline Foam::labelRange::labelRange
|
||||
(
|
||||
const label start,
|
||||
const label size,
|
||||
const bool adjustStart
|
||||
)
|
||||
:
|
||||
start_(start),
|
||||
size_(size)
|
||||
{
|
||||
// disallow invalid sizes
|
||||
if (size_ <= 0)
|
||||
if (adjustStart)
|
||||
{
|
||||
this->clear();
|
||||
// Disallow invalid indices and sizes
|
||||
adjust();
|
||||
}
|
||||
else if (size_ < 0)
|
||||
{
|
||||
// Disallow invalid sizes
|
||||
size_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::labelRange::const_iterator::const_iterator()
|
||||
:
|
||||
range_(*reinterpret_cast<Foam::labelRange* >(0)),
|
||||
index_(-1)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::labelRange::const_iterator::const_iterator(const labelRange& range)
|
||||
inline Foam::labelRange::const_iterator::const_iterator
|
||||
(
|
||||
const labelRange& range,
|
||||
const bool endIter
|
||||
)
|
||||
:
|
||||
range_(range),
|
||||
index_(range_.empty() ? -1 : 0)
|
||||
index_(endIter ? range_.size() : 0)
|
||||
{}
|
||||
|
||||
|
||||
@ -76,17 +83,17 @@ inline bool Foam::labelRange::const_iterator::operator!=
|
||||
const const_iterator& iter
|
||||
) const
|
||||
{
|
||||
return !(this->operator==(iter));
|
||||
return (this->index_ != iter.index_);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::labelRange::const_iterator::operator*()
|
||||
inline Foam::label Foam::labelRange::const_iterator::operator*() const
|
||||
{
|
||||
return range_[index_];
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::labelRange::const_iterator::operator()()
|
||||
inline Foam::label Foam::labelRange::const_iterator::operator()() const
|
||||
{
|
||||
return range_[index_];
|
||||
}
|
||||
@ -95,12 +102,7 @@ inline Foam::label Foam::labelRange::const_iterator::operator()()
|
||||
inline Foam::labelRange::const_iterator&
|
||||
Foam::labelRange::const_iterator::operator++()
|
||||
{
|
||||
if (++index_ >= range_.size())
|
||||
{
|
||||
// equivalent to end iterator
|
||||
index_ = -1;
|
||||
}
|
||||
|
||||
++index_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -109,7 +111,7 @@ inline Foam::labelRange::const_iterator
|
||||
Foam::labelRange::const_iterator::operator++(int)
|
||||
{
|
||||
const_iterator old = *this;
|
||||
this->operator++();
|
||||
++index_;
|
||||
return old;
|
||||
}
|
||||
|
||||
@ -120,9 +122,9 @@ inline Foam::labelRange::const_iterator Foam::labelRange::cbegin() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelRange::const_iterator& Foam::labelRange::cend() const
|
||||
inline const Foam::labelRange::const_iterator Foam::labelRange::cend() const
|
||||
{
|
||||
return endIter_;
|
||||
return const_iterator(*this, true);
|
||||
}
|
||||
|
||||
|
||||
@ -132,14 +134,31 @@ inline Foam::labelRange::const_iterator Foam::labelRange::begin() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelRange::const_iterator& Foam::labelRange::end() const
|
||||
inline const Foam::labelRange::const_iterator Foam::labelRange::end() const
|
||||
{
|
||||
return endIter_;
|
||||
return const_iterator(*this, true);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::labelRange::resize(const label n)
|
||||
{
|
||||
setSize(n);
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::labelRange::setSize(const label n)
|
||||
{
|
||||
size_ = n;
|
||||
|
||||
if (size_ < 0)
|
||||
{
|
||||
size_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::labelRange::clear()
|
||||
{
|
||||
start_ = size_ = 0;
|
||||
@ -152,6 +171,12 @@ inline bool Foam::labelRange::empty() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::labelRange::valid() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::labelRange::size() const
|
||||
{
|
||||
return size_;
|
||||
@ -170,6 +195,31 @@ inline Foam::label Foam::labelRange::last() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::labelRange::reset
|
||||
(
|
||||
const label start,
|
||||
const label size,
|
||||
const bool adjustStart
|
||||
)
|
||||
{
|
||||
start_ = start;
|
||||
size_ = size;
|
||||
|
||||
if (adjustStart)
|
||||
{
|
||||
// Disallow invalid indices and sizes
|
||||
adjust();
|
||||
}
|
||||
else if (size_ < 0)
|
||||
{
|
||||
// Disallow invalid sizes
|
||||
size_ = 0;
|
||||
}
|
||||
|
||||
return size_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::labelRange::contains(const label value) const
|
||||
{
|
||||
return value >= this->first() && value <= this->last();
|
||||
@ -186,7 +236,11 @@ inline Foam::label Foam::labelRange::operator[](const label i) const
|
||||
|
||||
inline bool Foam::labelRange::operator<(const labelRange& rhs) const
|
||||
{
|
||||
return this->first() < rhs.first();
|
||||
return
|
||||
(
|
||||
this->first() < rhs.first()
|
||||
|| (this->first() == rhs.first() && this->size() < rhs.size())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,11 +26,6 @@ License
|
||||
#include "labelRanges.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::labelRanges::const_iterator Foam::labelRanges::endIter_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::labelRanges::insertBefore
|
||||
@ -141,7 +136,7 @@ bool Foam::labelRanges::add(const labelRange& range)
|
||||
{
|
||||
labelRange& currRange = ParentType::operator[](elemI);
|
||||
|
||||
if (currRange.intersects(range, true))
|
||||
if (currRange.overlaps(range, true))
|
||||
{
|
||||
// absorb into the existing (adjacent/overlapping) range
|
||||
currRange += range;
|
||||
@ -150,7 +145,7 @@ bool Foam::labelRanges::add(const labelRange& range)
|
||||
for (; elemI < this->size()-1; ++elemI)
|
||||
{
|
||||
labelRange& nextRange = ParentType::operator[](elemI+1);
|
||||
if (currRange.intersects(nextRange, true))
|
||||
if (currRange.overlaps(nextRange, true))
|
||||
{
|
||||
currRange += nextRange;
|
||||
nextRange.clear();
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -49,8 +49,8 @@ class Ostream;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
class labelRanges;
|
||||
Istream& operator>>(Istream&, labelRanges&);
|
||||
Ostream& operator<<(Ostream&, const labelRanges&);
|
||||
Istream& operator>>(Istream& is, labelRanges& ranges);
|
||||
Ostream& operator<<(Ostream& is, const labelRanges& ranges);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class labelRanges Declaration
|
||||
@ -68,13 +68,13 @@ class labelRanges
|
||||
// Private Member Functions
|
||||
|
||||
//- Insert range before specified insertion index, by copying up
|
||||
void insertBefore(const label, const labelRange&);
|
||||
void insertBefore(const label insert, const labelRange& range);
|
||||
|
||||
//- Purge empty ranges, by copying down
|
||||
void purgeEmpty();
|
||||
|
||||
//- Print the range for debugging purposes
|
||||
Ostream& printRange(Ostream&, const labelRange&) const;
|
||||
Ostream& printRange(Ostream& os, const labelRange& range) const;
|
||||
|
||||
|
||||
public:
|
||||
@ -85,10 +85,10 @@ public:
|
||||
inline labelRanges();
|
||||
|
||||
//- Construct given size
|
||||
inline explicit labelRanges(const label);
|
||||
inline explicit labelRanges(const label nElem);
|
||||
|
||||
//- Construct from Istream.
|
||||
labelRanges(Istream&);
|
||||
labelRanges(Istream& is);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -100,19 +100,22 @@ public:
|
||||
using DynamicList<labelRange>::empty;
|
||||
|
||||
//- Return true if the value is within any of the ranges
|
||||
inline bool contains(const label) const;
|
||||
inline bool contains(const label value) const;
|
||||
|
||||
//- Add the range to the list
|
||||
bool add(const labelRange&);
|
||||
bool add(const labelRange& range);
|
||||
|
||||
//- Remove the range from the list
|
||||
bool remove(const labelRange&);
|
||||
bool remove(const labelRange& range);
|
||||
|
||||
|
||||
// STL iterator
|
||||
|
||||
//- An STL const_iterator
|
||||
class const_iterator
|
||||
{
|
||||
friend class labelRanges;
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to the list for which this is an iterator
|
||||
@ -124,22 +127,21 @@ public:
|
||||
//- Index of current element at listIndex
|
||||
label subIndex_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null - equivalent to an 'end' position
|
||||
inline const_iterator();
|
||||
|
||||
//- Construct from list, moving to its 'begin' position
|
||||
inline explicit const_iterator(const labelRanges&);
|
||||
//- Construct from ranges at 'begin' or 'end' position
|
||||
inline const_iterator
|
||||
(
|
||||
const labelRanges& lst,
|
||||
const bool endIter = false
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Member operators
|
||||
|
||||
inline bool operator==(const const_iterator&) const;
|
||||
|
||||
inline bool operator!=(const const_iterator&) const;
|
||||
inline bool operator==(const const_iterator& iter) const;
|
||||
inline bool operator!=(const const_iterator& iter) const;
|
||||
|
||||
inline label operator*();
|
||||
inline label operator()();
|
||||
@ -149,29 +151,23 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//- const_iterator set to the beginning of the list
|
||||
//- A const_iterator set to the beginning of the list
|
||||
inline const_iterator cbegin() const;
|
||||
|
||||
//- const_iterator set to beyond the end of the list
|
||||
inline const const_iterator& cend() const;
|
||||
//- A const_iterator set to beyond the end of the list
|
||||
inline const const_iterator cend() const;
|
||||
|
||||
//- const_iterator set to the beginning of the list
|
||||
//- A const_iterator set to the beginning of the list
|
||||
inline const_iterator begin() const;
|
||||
|
||||
//- const_iterator set to beyond the end of the list
|
||||
inline const const_iterator& end() const;
|
||||
//- A const_iterator set to beyond the end of the list
|
||||
inline const const_iterator end() const;
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>>(Istream&, labelRanges&);
|
||||
friend Ostream& operator<<(Ostream&, const labelRanges&);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- const_iterator returned by end(), cend()
|
||||
static const const_iterator endIter_;
|
||||
friend Istream& operator>>(Istream& is, labelRanges& ranges);
|
||||
friend Ostream& operator<<(Ostream& os, const labelRanges& ranges);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,28 +40,18 @@ inline Foam::labelRanges::labelRanges(const label nElem)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Iterators * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::labelRanges::const_iterator::const_iterator()
|
||||
inline Foam::labelRanges::const_iterator::const_iterator
|
||||
(
|
||||
const labelRanges& lst,
|
||||
const bool endIter
|
||||
)
|
||||
:
|
||||
list_(*reinterpret_cast<Foam::labelRanges* >(0)),
|
||||
index_(-1),
|
||||
subIndex_(-1)
|
||||
list_(lst),
|
||||
index_(endIter ? lst.size() : 0),
|
||||
subIndex_(0)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::labelRanges::const_iterator::const_iterator(const labelRanges& lst)
|
||||
:
|
||||
list_(lst),
|
||||
index_(0),
|
||||
subIndex_(0)
|
||||
{
|
||||
if (list_.empty())
|
||||
{
|
||||
// equivalent to end iterator
|
||||
index_ = subIndex_ = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::labelRanges::const_iterator::operator==
|
||||
(
|
||||
const const_iterator& iter
|
||||
@ -69,7 +59,7 @@ inline bool Foam::labelRanges::const_iterator::operator==
|
||||
{
|
||||
return
|
||||
(
|
||||
this->index_ == iter.index_
|
||||
this->index_ == iter.index_
|
||||
&& this->subIndex_ == iter.subIndex_
|
||||
);
|
||||
}
|
||||
@ -101,13 +91,9 @@ Foam::labelRanges::const_iterator::operator++()
|
||||
{
|
||||
if (++subIndex_ >= list_[index_].size())
|
||||
{
|
||||
// go to next list entry
|
||||
// Next sub-list
|
||||
++index_;
|
||||
subIndex_ = 0;
|
||||
if (++index_ >= list_.size())
|
||||
{
|
||||
// equivalent to end iterator
|
||||
index_ = subIndex_ = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
@ -129,9 +115,9 @@ inline Foam::labelRanges::const_iterator Foam::labelRanges::cbegin() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelRanges::const_iterator& Foam::labelRanges::cend() const
|
||||
inline const Foam::labelRanges::const_iterator Foam::labelRanges::cend() const
|
||||
{
|
||||
return endIter_;
|
||||
return const_iterator(*this, true);
|
||||
}
|
||||
|
||||
|
||||
@ -141,9 +127,9 @@ inline Foam::labelRanges::const_iterator Foam::labelRanges::begin() const
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::labelRanges::const_iterator& Foam::labelRanges::end() const
|
||||
inline const Foam::labelRanges::const_iterator Foam::labelRanges::end() const
|
||||
{
|
||||
return endIter_;
|
||||
return const_iterator(*this, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,94 +25,46 @@ License
|
||||
|
||||
#include "hashedWordList.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::hashedWordList::rehash()
|
||||
{
|
||||
indices_.clear();
|
||||
forAll(*this, i)
|
||||
{
|
||||
indices_.insert(List<word>::operator[](i), i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::hashedWordList::hashedWordList()
|
||||
Foam::hashedWordList::hashedWordList
|
||||
(
|
||||
const label count,
|
||||
const char** lst,
|
||||
const bool removeDuplicates
|
||||
)
|
||||
:
|
||||
List<word>()
|
||||
{}
|
||||
|
||||
|
||||
Foam::hashedWordList::hashedWordList(const UList<word>& names)
|
||||
:
|
||||
List<word>(names)
|
||||
List<word>(count)
|
||||
{
|
||||
rehash();
|
||||
}
|
||||
forAll(*this, i)
|
||||
{
|
||||
List<word>::operator[](i) = lst[i];
|
||||
}
|
||||
|
||||
|
||||
Foam::hashedWordList::hashedWordList(const hashedWordList& names)
|
||||
:
|
||||
List<word>(static_cast<const UList<word>&>(names))
|
||||
{
|
||||
rehash();
|
||||
}
|
||||
|
||||
|
||||
Foam::hashedWordList::hashedWordList(const Xfer<List<word>>& names)
|
||||
:
|
||||
List<word>(names)
|
||||
{
|
||||
rehash();
|
||||
}
|
||||
|
||||
|
||||
Foam::hashedWordList::hashedWordList(std::initializer_list<word> lst)
|
||||
:
|
||||
List<word>(lst)
|
||||
{
|
||||
rehash();
|
||||
rehash(removeDuplicates);
|
||||
}
|
||||
|
||||
|
||||
Foam::hashedWordList::hashedWordList
|
||||
(
|
||||
const label nNames,
|
||||
const char** names
|
||||
)
|
||||
:
|
||||
List<word>(nNames)
|
||||
{
|
||||
forAll(*this, i)
|
||||
{
|
||||
List<word>::operator[](i) = names[i];
|
||||
}
|
||||
|
||||
rehash();
|
||||
}
|
||||
|
||||
|
||||
Foam::hashedWordList::hashedWordList
|
||||
(
|
||||
const char** names
|
||||
const char** lst,
|
||||
const bool removeDuplicates
|
||||
)
|
||||
{
|
||||
// count names
|
||||
label nNames = 0;
|
||||
for (unsigned i = 0; names[i] && *(names[i]); ++i)
|
||||
// Determine the number of entries
|
||||
label count = 0;
|
||||
for (unsigned i = 0; lst[i] && *(lst[i]); ++i)
|
||||
{
|
||||
++nNames;
|
||||
++count;
|
||||
}
|
||||
|
||||
List<word>::setSize(nNames);
|
||||
List<word>::setSize(count);
|
||||
forAll(*this, i)
|
||||
{
|
||||
List<word>::operator[](i) = names[i];
|
||||
List<word>::operator[](i) = lst[i];
|
||||
}
|
||||
|
||||
rehash();
|
||||
rehash(removeDuplicates);
|
||||
}
|
||||
|
||||
|
||||
@ -124,59 +76,48 @@ Foam::hashedWordList::hashedWordList(Istream& is)
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::hashedWordList::clear()
|
||||
{
|
||||
List<word>::clear();
|
||||
indices_.clear();
|
||||
}
|
||||
|
||||
|
||||
void Foam::hashedWordList::append(const word& name)
|
||||
{
|
||||
const label idx = size();
|
||||
List<word>::append(name);
|
||||
indices_.insert(name, idx);
|
||||
}
|
||||
|
||||
|
||||
void Foam::hashedWordList::transfer(List<word>& lst)
|
||||
void Foam::hashedWordList::transfer
|
||||
(
|
||||
List<word>& lst,
|
||||
const bool removeDuplicates
|
||||
)
|
||||
{
|
||||
List<word>::transfer(lst);
|
||||
rehash();
|
||||
rehash(removeDuplicates);
|
||||
}
|
||||
|
||||
|
||||
void Foam::hashedWordList::sort()
|
||||
void Foam::hashedWordList::rehash() const
|
||||
{
|
||||
Foam::sort(*this);
|
||||
rehash();
|
||||
indices_.clear();
|
||||
|
||||
forAll(*this, i)
|
||||
{
|
||||
indices_.insert(List<word>::operator[](i), i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::hashedWordList::uniq()
|
||||
{
|
||||
if (size() != indices_.size())
|
||||
indices_.clear();
|
||||
|
||||
label nElem = 0;
|
||||
forAll(*this, i)
|
||||
{
|
||||
// sizes don't match, which means there appear to be duplicates
|
||||
const word& item = List<word>::operator[](i);
|
||||
|
||||
indices_.clear();
|
||||
label nElem = 0;
|
||||
forAll(*this, i)
|
||||
if (indices_.insert(item, nElem))
|
||||
{
|
||||
const word& item = List<word>::operator[](i);
|
||||
|
||||
if (indices_.insert(item, nElem))
|
||||
if (nElem != i)
|
||||
{
|
||||
if (nElem != i)
|
||||
{
|
||||
List<word>::operator[](nElem) = item;
|
||||
}
|
||||
++nElem;
|
||||
List<word>::operator[](nElem) = item;
|
||||
}
|
||||
++nElem;
|
||||
}
|
||||
|
||||
List<word>::setSize(nElem);
|
||||
}
|
||||
|
||||
List<word>::setSize(nElem);
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +134,7 @@ Foam::Istream& Foam::operator>>(Istream& is, hashedWordList& lst)
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const hashedWordList& lst)
|
||||
{
|
||||
os << static_cast<const List<word>&>(lst);
|
||||
os << static_cast<const UList<word>&>(lst);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::hashedWordList
|
||||
|
||||
Description
|
||||
A wordList with hashed indices for faster lookup by name.
|
||||
A wordList with hashed indices for additional fast lookup by name.
|
||||
|
||||
SourceFiles
|
||||
hashedWordListI.H
|
||||
@ -62,38 +62,64 @@ class hashedWordList
|
||||
// Private data
|
||||
|
||||
//- Hash of words/indices
|
||||
HashTable<label,word> indices_;
|
||||
mutable HashTable<label,word> indices_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Rebuild the hash of indices
|
||||
void rehash();
|
||||
//- Rebuild the lookup hash or make unique entries first.
|
||||
inline void rehash(const bool unique);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
hashedWordList();
|
||||
inline hashedWordList();
|
||||
|
||||
//- Copy constructor.
|
||||
hashedWordList(const hashedWordList&);
|
||||
inline hashedWordList(const hashedWordList& lst);
|
||||
|
||||
//- Construct from list of words
|
||||
hashedWordList(const UList<word>&);
|
||||
//- Construct from list of words,
|
||||
// optionally eliminating duplicates
|
||||
inline hashedWordList
|
||||
(
|
||||
const UList<word>& lst,
|
||||
const bool removeDuplicates=false
|
||||
);
|
||||
|
||||
//- Construct by transferring the parameter contents,
|
||||
// optionally eliminating duplicates
|
||||
inline hashedWordList
|
||||
(
|
||||
const Xfer<List<word>>& lst,
|
||||
const bool removeDuplicates=false
|
||||
);
|
||||
|
||||
//- Construct from an initializer list
|
||||
hashedWordList(std::initializer_list<word>);
|
||||
inline hashedWordList(std::initializer_list<word>);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
hashedWordList(const Xfer<List<word>>&);
|
||||
//- Construct from the word keys of any HashTable, sorting immediately.
|
||||
// This also handles a wordHashSet, which is derived from a HashTable.
|
||||
// The result is similar to a HashTable::sortedToc.
|
||||
template<class AnyType, class AnyHash>
|
||||
explicit inline hashedWordList
|
||||
(
|
||||
const HashTable<AnyType, word, AnyHash>& h
|
||||
);
|
||||
|
||||
//- Construct from number and list of names
|
||||
hashedWordList(const label nNames, const char** names);
|
||||
//- Construct from number and list of words,
|
||||
// optionally eliminating duplicates
|
||||
hashedWordList
|
||||
(
|
||||
const label count,
|
||||
const char** lst,
|
||||
const bool removeDuplicates=false
|
||||
);
|
||||
|
||||
//- Construct from a nullptr-terminated list of names
|
||||
hashedWordList(const char** names);
|
||||
//- Construct from a nullptr-terminated list of words,
|
||||
// optionally eliminating duplicates
|
||||
hashedWordList(const char** lst, const bool removeDuplicates=false);
|
||||
|
||||
//- Construct from Istream
|
||||
hashedWordList(Istream&);
|
||||
@ -102,47 +128,53 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Clear the list, i.e. set size to zero.
|
||||
void clear();
|
||||
inline void clear();
|
||||
|
||||
//- Append an element at the end of the list
|
||||
void append(const word&);
|
||||
//- Append an element at the end of the list,
|
||||
// optionally avoid append if it would be a duplicate entry
|
||||
inline void append(const word& name, const bool avoidDuplicates=false);
|
||||
|
||||
//- Does the list contain the specified name
|
||||
inline bool found(const word&) const;
|
||||
inline bool found(const word& name) const;
|
||||
|
||||
//- Does the list contain the specified name
|
||||
inline bool contains(const word&) const;
|
||||
inline bool contains(const word& name) const;
|
||||
|
||||
//- Return the hash of words/indices for inspection
|
||||
inline const HashTable<label,word>& lookup() const;
|
||||
|
||||
//- Transfer the contents of the argument List into this list
|
||||
// and annul the argument list.
|
||||
void transfer(List<word>&);
|
||||
// and annul the argument list,
|
||||
// optionally eliminating duplicates
|
||||
void transfer(List<word>& lst, const bool removeDuplicates=false);
|
||||
|
||||
//- Rebuild the lookup hash indices
|
||||
void rehash() const;
|
||||
|
||||
//- Sort the list and rehash the indices
|
||||
void sort();
|
||||
inline void sort();
|
||||
|
||||
//- Adjust the list if necessary to eliminate duplicate entries
|
||||
//- Adjust the list if necessary to eliminate duplicate entries,
|
||||
// and rehash the indices
|
||||
void uniq();
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assignment operator from list of words
|
||||
inline void operator=(const UList<word>&);
|
||||
inline void operator=(const UList<word>& lst);
|
||||
|
||||
//- Assignment operator from initializer list
|
||||
inline void operator=(std::initializer_list<word>);
|
||||
inline void operator=(std::initializer_list<word> lst);
|
||||
|
||||
//- Assignment operator.
|
||||
inline void operator=(const hashedWordList&);
|
||||
inline void operator=(const hashedWordList& lst);
|
||||
|
||||
//- Return name corresponding to specified index
|
||||
inline const word& operator[](const label index) const;
|
||||
|
||||
//- Return index corresponding to specified name
|
||||
inline label operator[](const word&) const;
|
||||
inline label operator[](const word& name) const;
|
||||
|
||||
|
||||
// Istream operators
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -23,8 +23,117 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::hashedWordList::rehash(const bool unique)
|
||||
{
|
||||
if (unique)
|
||||
{
|
||||
uniq();
|
||||
}
|
||||
else
|
||||
{
|
||||
rehash();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::hashedWordList::hashedWordList()
|
||||
:
|
||||
List<word>(),
|
||||
indices_()
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::hashedWordList::hashedWordList(const hashedWordList& lst)
|
||||
:
|
||||
List<word>(static_cast<const UList<word>&>(lst))
|
||||
{
|
||||
rehash();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::hashedWordList::hashedWordList
|
||||
(
|
||||
const UList<word>& lst,
|
||||
const bool removeDuplicates
|
||||
)
|
||||
:
|
||||
List<word>(lst)
|
||||
{
|
||||
rehash(removeDuplicates);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::hashedWordList::hashedWordList
|
||||
(
|
||||
const Xfer<List<word>>& lst,
|
||||
const bool removeDuplicates
|
||||
)
|
||||
:
|
||||
List<word>(lst)
|
||||
{
|
||||
rehash(removeDuplicates);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::hashedWordList::hashedWordList(std::initializer_list<word> lst)
|
||||
:
|
||||
List<word>(lst)
|
||||
{
|
||||
rehash();
|
||||
}
|
||||
|
||||
|
||||
template<class AnyType, class AnyHash>
|
||||
inline Foam::hashedWordList::hashedWordList
|
||||
(
|
||||
const HashTable<AnyType, word, AnyHash>& h
|
||||
)
|
||||
:
|
||||
List<word>(h.size())
|
||||
{
|
||||
label nElem = 0;
|
||||
for
|
||||
(
|
||||
typename HashTable<AnyType, word, AnyHash>::const_iterator
|
||||
iter = h.cbegin();
|
||||
iter != h.cend();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
List<word>::operator[](nElem++) = iter.key();
|
||||
}
|
||||
|
||||
this->sort();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::hashedWordList::clear()
|
||||
{
|
||||
List<word>::clear();
|
||||
indices_.clear();
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::hashedWordList::append
|
||||
(
|
||||
const word& name,
|
||||
const bool avoidDuplicates
|
||||
)
|
||||
{
|
||||
// name is either unique or we don't care about duplicates
|
||||
if (indices_.insert(name, size()) || !avoidDuplicates)
|
||||
{
|
||||
List<word>::append(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::HashTable<Foam::label,Foam::word>&
|
||||
Foam::hashedWordList::lookup() const
|
||||
{
|
||||
@ -44,6 +153,13 @@ inline bool Foam::hashedWordList::contains(const word& name) const
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::hashedWordList::sort()
|
||||
{
|
||||
Foam::sort(*this);
|
||||
rehash();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
inline void Foam::hashedWordList::operator=(const UList<word>& lst)
|
||||
@ -75,9 +191,9 @@ inline const Foam::word& Foam::hashedWordList::operator[]
|
||||
}
|
||||
|
||||
|
||||
// could return -1 instead of bombing out
|
||||
inline Foam::label Foam::hashedWordList::operator[](const word& name) const
|
||||
{
|
||||
// Could return -1 instead of bombing out
|
||||
return indices_[name];
|
||||
}
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ Description
|
||||
|
||||
Note
|
||||
If the string contents are changed - eg, by the operator+=() or by
|
||||
string::replace(), etc - it will be necessary to use compile() or
|
||||
recompile() to synchronize the regular expression.
|
||||
string::replace(), etc - it will be necessary to use compile() to
|
||||
synchronize the regular expression.
|
||||
|
||||
SourceFiles
|
||||
wordRe.C
|
||||
@ -161,9 +161,6 @@ public:
|
||||
//- Possibly compile the regular expression, with greater control
|
||||
inline bool compile(const compOption) const;
|
||||
|
||||
//- Recompile an existing regular expression
|
||||
inline bool recompile() const;
|
||||
|
||||
//- Frees precompiled regular expression, making wordRe a literal.
|
||||
// Optionally strips invalid word characters
|
||||
inline void uncompile(const bool doStripInvalid = false) const;
|
||||
|
||||
@ -165,17 +165,6 @@ inline bool Foam::wordRe::compile() const
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::wordRe::recompile() const
|
||||
{
|
||||
if (re_.exists())
|
||||
{
|
||||
re_ = *this;
|
||||
}
|
||||
|
||||
return re_.exists();
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::wordRe::uncompile(const bool doStripInvalid) const
|
||||
{
|
||||
if (re_.clear())
|
||||
@ -265,6 +254,10 @@ inline void Foam::wordRe::operator=(const keyType& str)
|
||||
{
|
||||
compile();
|
||||
}
|
||||
else
|
||||
{
|
||||
re_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ Foam::temperatureCoupledBase::temperatureCoupledBase
|
||||
patch_(patch),
|
||||
method_(KMethodTypeNames_.read(dict.lookup("kappaMethod"))),
|
||||
kappaName_(dict.lookupOrDefault<word>("kappa", "none")),
|
||||
alphaAniName_(dict.lookupOrDefault<word>("alphaAni","Anialpha"))
|
||||
alphaAniName_(dict.lookupOrDefault<word>("alphaAni","none"))
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -254,7 +254,7 @@ bool Foam::ensightOutput::writeField
|
||||
forAll(patchIds, listi)
|
||||
{
|
||||
const label patchId = patchIds[listi];
|
||||
const word& patchName = patchLookup[listi];
|
||||
const word& patchName = patchLookup[patchId];
|
||||
const ensightFaces& ensFaces = patchFaces[patchName];
|
||||
|
||||
writeFaceField
|
||||
|
||||
@ -326,7 +326,7 @@ void Foam::foamVtkCells::correct()
|
||||
nAddVerts += 5;
|
||||
|
||||
vertOffset_[celLoc] = nAddVerts;
|
||||
decompose_.superCells_[nAddCells++] = celLoc;
|
||||
decompose_.superCells_[nAddCells++] = cellI;
|
||||
}
|
||||
|
||||
cellTypes_[celLoc] = foamVtkCore::VTK_PYRAMID;
|
||||
@ -373,7 +373,7 @@ void Foam::foamVtkCells::correct()
|
||||
nAddVerts += 4;
|
||||
|
||||
vertOffset_[celLoc] = nAddVerts;
|
||||
decompose_.superCells_[nAddCells++] = celLoc;
|
||||
decompose_.superCells_[nAddCells++] = cellI;
|
||||
}
|
||||
|
||||
cellTypes_[celLoc] = foamVtkCore::VTK_TETRA;
|
||||
|
||||
@ -1260,20 +1260,36 @@ void Foam::extendedEdgeMesh::add(const extendedEdgeMesh& fem)
|
||||
// ~~~~~~~
|
||||
|
||||
// Combine normals
|
||||
DynamicField<point> newNormals(normals().size()+fem.normals().size());
|
||||
DynamicField<point> newNormals
|
||||
(
|
||||
normals().size()
|
||||
+ fem.normals().size()
|
||||
);
|
||||
newNormals.append(normals());
|
||||
newNormals.append(fem.normals());
|
||||
|
||||
|
||||
// Combine and re-index into newNormals
|
||||
labelListList newEdgeNormals(edgeNormals().size()+fem.edgeNormals().size());
|
||||
UIndirectList<labelList>(newEdgeNormals, reverseEdgeMap) =
|
||||
edgeNormals();
|
||||
UIndirectList<labelList>(newEdgeNormals, reverseFemEdgeMap) =
|
||||
fem.edgeNormals();
|
||||
forAll(reverseFemEdgeMap, i)
|
||||
labelListList newEdgeNormals
|
||||
(
|
||||
edgeNormals().size()
|
||||
+ fem.edgeNormals().size()
|
||||
);
|
||||
|
||||
UIndirectList<labelList>
|
||||
(
|
||||
newEdgeNormals,
|
||||
SubList<label>(reverseEdgeMap, edgeNormals().size())
|
||||
) = edgeNormals();
|
||||
UIndirectList<labelList>
|
||||
(
|
||||
newEdgeNormals,
|
||||
SubList<label>(reverseFemEdgeMap, fem.edgeNormals().size())
|
||||
) = fem.edgeNormals();
|
||||
|
||||
forAll(fem.edgeNormals(), i)
|
||||
{
|
||||
label mapI = reverseFemEdgeMap[i];
|
||||
const label mapI = reverseFemEdgeMap[i];
|
||||
labelList& en = newEdgeNormals[mapI];
|
||||
forAll(en, j)
|
||||
{
|
||||
@ -1300,9 +1316,10 @@ void Foam::extendedEdgeMesh::add(const extendedEdgeMesh& fem)
|
||||
newFeaturePointNormals,
|
||||
SubList<label>(reverseFemPointMap, fem.featurePointNormals().size())
|
||||
) = fem.featurePointNormals();
|
||||
|
||||
forAll(fem.featurePointNormals(), i)
|
||||
{
|
||||
label mapI = reverseFemPointMap[i];
|
||||
const label mapI = reverseFemPointMap[i];
|
||||
labelList& fn = newFeaturePointNormals[mapI];
|
||||
forAll(fn, j)
|
||||
{
|
||||
|
||||
@ -19,6 +19,7 @@ vtk/format/foamVtkAppendBase64Formatter.C
|
||||
vtk/format/foamVtkAppendRawFormatter.C
|
||||
vtk/format/foamVtkAsciiFormatter.C
|
||||
vtk/format/foamVtkBase64Formatter.C
|
||||
vtk/format/foamVtkBase64Layer.C
|
||||
vtk/format/foamVtkLegacyFormatter.C
|
||||
vtk/format/foamVtkFormatter.C
|
||||
vtk/format/foamVtkOutputOptions.C
|
||||
|
||||
@ -34,28 +34,33 @@ Foam::fileFormats::NASCore::NASCore()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::fileFormats::NASCore::parseNASCoord
|
||||
(
|
||||
const string& s
|
||||
)
|
||||
Foam::scalar Foam::fileFormats::NASCore::parseNASCoord(const string& s)
|
||||
{
|
||||
size_t expSign = s.find_last_of("+-");
|
||||
scalar value = 0;
|
||||
|
||||
if (expSign != string::npos && expSign > 0 && !isspace(s[expSign-1]))
|
||||
const size_t expSign = s.find_last_of("+-");
|
||||
|
||||
if (expSign != std::string::npos && expSign > 0 && !isspace(s[expSign-1]))
|
||||
{
|
||||
scalar mantissa = readScalar(IStringStream(s.substr(0, expSign))());
|
||||
scalar exponent = readScalar(IStringStream(s.substr(expSign+1))());
|
||||
scalar exponent = 0;
|
||||
|
||||
// Parse as per strtod/strtof - allowing trailing space or [Ee]
|
||||
readScalar(s.substr(0, expSign).c_str(), value); // mantissa
|
||||
readScalar(s.substr(expSign+1).c_str(), exponent);
|
||||
|
||||
if (s[expSign] == '-')
|
||||
{
|
||||
exponent = -exponent;
|
||||
}
|
||||
return mantissa * pow(10, exponent);
|
||||
|
||||
value *= ::pow(10, exponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
return readScalar(IStringStream(s)());
|
||||
readScalar(s.c_str(), value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -55,8 +55,8 @@ public:
|
||||
|
||||
// Public Member Functions
|
||||
|
||||
//- Do weird things to extract number
|
||||
static scalar parseNASCoord(const string&);
|
||||
//- Extract numbers from things like "-2.358-8" (same as "-2.358e-8")
|
||||
static scalar parseNASCoord(const string& s);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,8 +27,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkAppendBase64Formatter::name_ = "append";
|
||||
const char* Foam::foamVtkAppendBase64Formatter::encoding_ = "base64";
|
||||
const char* Foam::foamVtkAppendBase64Formatter::name_ = "append";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -38,14 +37,16 @@ Foam::foamVtkAppendBase64Formatter::foamVtkAppendBase64Formatter
|
||||
std::ostream& os
|
||||
)
|
||||
:
|
||||
foamVtkBase64Formatter(os)
|
||||
foamVtkBase64Layer(os)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkAppendBase64Formatter::~foamVtkAppendBase64Formatter()
|
||||
{}
|
||||
{
|
||||
base64Layer::close();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
@ -56,10 +57,4 @@ const char* Foam::foamVtkAppendBase64Formatter::name() const
|
||||
}
|
||||
|
||||
|
||||
const char* Foam::foamVtkAppendBase64Formatter::encoding() const
|
||||
{
|
||||
return encoding_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,7 +36,7 @@ SourceFiles
|
||||
#ifndef foamVtkAppendBase64Formatter_H
|
||||
#define foamVtkAppendBase64Formatter_H
|
||||
|
||||
#include "foamVtkBase64Formatter.H"
|
||||
#include "foamVtkBase64Layer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,12 +49,11 @@ namespace Foam
|
||||
|
||||
class foamVtkAppendBase64Formatter
|
||||
:
|
||||
public foamVtkBase64Formatter
|
||||
public foamVtkBase64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
static const char* name_;
|
||||
static const char* encoding_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -71,7 +70,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkAppendBase64Formatter(std::ostream&);
|
||||
foamVtkAppendBase64Formatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -83,9 +82,6 @@ public:
|
||||
//- Output name for XML type ("append")
|
||||
virtual const char* name() const;
|
||||
|
||||
//- Name for the XML append encoding ("base64").
|
||||
virtual const char* encoding() const;
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -71,9 +71,9 @@ const char* Foam::foamVtkAppendRawFormatter::encoding() const
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t val)
|
||||
void Foam::foamVtkAppendRawFormatter::writeSize(const uint64_t nBytes)
|
||||
{
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(uint64_t));
|
||||
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
|
||||
}
|
||||
|
||||
|
||||
@ -85,28 +85,28 @@ void Foam::foamVtkAppendRawFormatter::write(const uint8_t val)
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::write(const label val)
|
||||
{
|
||||
// std::cerr<<"label is:" << sizeof(val) << '\n';
|
||||
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::write(const float val)
|
||||
{
|
||||
// std::cerr<<"float is:" << sizeof(val) << '\n';
|
||||
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::write(const double val)
|
||||
{
|
||||
// std::cerr<<"write double as float:" << val << '\n';
|
||||
// std::cerr<<"double as float=" << val << '\n';
|
||||
float copy(val);
|
||||
write(copy);
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAppendRawFormatter::flush()
|
||||
{}
|
||||
{/*nop*/}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkAppendRawFormatter(std::ostream&);
|
||||
foamVtkAppendRawFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -94,12 +94,14 @@ public:
|
||||
|
||||
|
||||
//- Write leading size for binary output
|
||||
virtual void writeSize(const uint64_t);
|
||||
virtual void writeSize(const uint64_t nBytes);
|
||||
|
||||
virtual void write(const uint8_t);
|
||||
virtual void write(const label);
|
||||
virtual void write(const float);
|
||||
virtual void write(const double);
|
||||
virtual void write(const uint8_t val);
|
||||
virtual void write(const label val);
|
||||
virtual void write(const float val);
|
||||
virtual void write(const double val);
|
||||
|
||||
//- A no-op for this format
|
||||
virtual void flush();
|
||||
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -47,6 +47,16 @@ inline void Foam::foamVtkAsciiFormatter::next()
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::foamVtkAsciiFormatter::done()
|
||||
{
|
||||
if (pos_)
|
||||
{
|
||||
os()<< '\n';
|
||||
}
|
||||
pos_ = 0;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter(std::ostream& os)
|
||||
@ -73,7 +83,7 @@ Foam::foamVtkAsciiFormatter::foamVtkAsciiFormatter
|
||||
|
||||
Foam::foamVtkAsciiFormatter::~foamVtkAsciiFormatter()
|
||||
{
|
||||
flush();
|
||||
done();
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +101,7 @@ const char* Foam::foamVtkAsciiFormatter::encoding() const
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t)
|
||||
void Foam::foamVtkAsciiFormatter::writeSize(const uint64_t ignored)
|
||||
{/*nop*/}
|
||||
|
||||
|
||||
@ -125,11 +135,14 @@ void Foam::foamVtkAsciiFormatter::write(const double val)
|
||||
|
||||
void Foam::foamVtkAsciiFormatter::flush()
|
||||
{
|
||||
if (pos_)
|
||||
{
|
||||
os()<< '\n';
|
||||
}
|
||||
pos_ = 0;
|
||||
done();
|
||||
}
|
||||
|
||||
|
||||
std::size_t
|
||||
Foam::foamVtkAsciiFormatter::encodedLength(std::size_t ignored) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -62,9 +62,12 @@ class foamVtkAsciiFormatter
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Advance to next position, adding space or newline as required
|
||||
//- Advance to next position, adding space or newline as needed
|
||||
inline void next();
|
||||
|
||||
//- Finish an output line, adding newline as needed
|
||||
inline void done();
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamVtkAsciiFormatter(const foamVtkAsciiFormatter&) = delete;
|
||||
@ -78,10 +81,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream, use default precision
|
||||
foamVtkAsciiFormatter(std::ostream&);
|
||||
foamVtkAsciiFormatter(std::ostream& os);
|
||||
|
||||
//- Construct and attach to an output stream, use specified precision
|
||||
foamVtkAsciiFormatter(std::ostream&, unsigned precision);
|
||||
foamVtkAsciiFormatter(std::ostream& os, unsigned precision);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -95,18 +98,24 @@ public:
|
||||
virtual const char* name() const;
|
||||
|
||||
//- Name for the XML append encoding - unused.
|
||||
// Currently simply "ASCII", but this should not be relied upon.
|
||||
// Currently identical to name(), but do not rely on this.
|
||||
virtual const char* encoding() const;
|
||||
|
||||
|
||||
//- Write leading size - this is a no-op for ascii output
|
||||
virtual void writeSize(const uint64_t);
|
||||
virtual void writeSize(const uint64_t ignored);
|
||||
|
||||
virtual void write(const uint8_t);
|
||||
virtual void write(const label);
|
||||
virtual void write(const float);
|
||||
virtual void write(const double);
|
||||
virtual void write(const uint8_t val);
|
||||
virtual void write(const label val);
|
||||
virtual void write(const float val);
|
||||
virtual void write(const double val);
|
||||
|
||||
//- Write a newline if needed to finish a line of output.
|
||||
virtual void flush();
|
||||
|
||||
//- The encoded length for ascii output is not applicable.
|
||||
virtual std::size_t encodedLength(std::size_t ignored) const;
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,28 +27,14 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkBase64Formatter::name_ = "binary";
|
||||
const char* Foam::foamVtkBase64Formatter::encoding_ = "base64";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkBase64Formatter::write
|
||||
(
|
||||
const char* s,
|
||||
std::streamsize n
|
||||
)
|
||||
{
|
||||
base64Layer::write(s, n);
|
||||
}
|
||||
const char* Foam::foamVtkBase64Formatter::name_ = "binary";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
|
||||
:
|
||||
foamVtkFormatter(os),
|
||||
base64Layer(os)
|
||||
foamVtkBase64Layer(os)
|
||||
{}
|
||||
|
||||
|
||||
@ -56,7 +42,10 @@ Foam::foamVtkBase64Formatter::foamVtkBase64Formatter(std::ostream& os)
|
||||
|
||||
Foam::foamVtkBase64Formatter::~foamVtkBase64Formatter()
|
||||
{
|
||||
flush();
|
||||
if (base64Layer::close())
|
||||
{
|
||||
os().put('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -68,46 +57,6 @@ const char* Foam::foamVtkBase64Formatter::name() const
|
||||
}
|
||||
|
||||
|
||||
const char* Foam::foamVtkBase64Formatter::encoding() const
|
||||
{
|
||||
return encoding_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Formatter::writeSize(const uint64_t val)
|
||||
{
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(uint64_t));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Formatter::write(const uint8_t val)
|
||||
{
|
||||
base64Layer::add(val);
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Formatter::write(const label val)
|
||||
{
|
||||
// std::cerr<<"label is:" << sizeof(val) << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Formatter::write(const float val)
|
||||
{
|
||||
// std::cerr<<"float is:" << sizeof(val) << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Formatter::write(const double val)
|
||||
{
|
||||
// std::cerr<<"write double as float:" << val << '\n';
|
||||
float copy(val);
|
||||
write(copy);
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Formatter::flush()
|
||||
{
|
||||
if (base64Layer::close())
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -33,8 +33,7 @@ Description
|
||||
#ifndef foamVtkBase64Formatter_H
|
||||
#define foamVtkBase64Formatter_H
|
||||
|
||||
#include "foamVtkFormatter.H"
|
||||
#include "base64Layer.H"
|
||||
#include "foamVtkBase64Layer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -47,8 +46,7 @@ namespace Foam
|
||||
|
||||
class foamVtkBase64Formatter
|
||||
:
|
||||
public foamVtkFormatter,
|
||||
private base64Layer
|
||||
public foamVtkBase64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
@ -64,20 +62,12 @@ class foamVtkBase64Formatter
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamVtkBase64Formatter&) = delete;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkBase64Formatter(std::ostream&);
|
||||
foamVtkBase64Formatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -90,17 +80,9 @@ public:
|
||||
// The lowercase version of the Legacy output type.
|
||||
virtual const char* name() const;
|
||||
|
||||
//- Name for the XML append encoding.
|
||||
virtual const char* encoding() const;
|
||||
|
||||
|
||||
//- Write leading size for binary output
|
||||
virtual void writeSize(const uint64_t);
|
||||
|
||||
virtual void write(const uint8_t);
|
||||
virtual void write(const label);
|
||||
virtual void write(const float);
|
||||
virtual void write(const double);
|
||||
//- End the encoding sequence (padding the final characters with '=')
|
||||
// and write a newline to the output if any encoding was done.
|
||||
virtual void flush();
|
||||
|
||||
};
|
||||
|
||||
116
src/fileFormats/vtk/format/foamVtkBase64Layer.C
Normal file
116
src/fileFormats/vtk/format/foamVtkBase64Layer.C
Normal file
@ -0,0 +1,116 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "foamVtkBase64Layer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkBase64Layer::encoding_ = "base64";
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkBase64Layer::write
|
||||
(
|
||||
const char* s,
|
||||
std::streamsize n
|
||||
)
|
||||
{
|
||||
base64Layer::write(s, n);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkBase64Layer::foamVtkBase64Layer(std::ostream& os)
|
||||
:
|
||||
foamVtkFormatter(os),
|
||||
base64Layer(os)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::foamVtkBase64Layer::~foamVtkBase64Layer()
|
||||
{
|
||||
base64Layer::close();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const char* Foam::foamVtkBase64Layer::encoding() const
|
||||
{
|
||||
return encoding_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::writeSize(const uint64_t nBytes)
|
||||
{
|
||||
write(reinterpret_cast<const char*>(&nBytes), sizeof(uint64_t));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::write(const uint8_t val)
|
||||
{
|
||||
base64Layer::add(val);
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::write(const label val)
|
||||
{
|
||||
// std::cerr<<"label:" << sizeof(val) << "=" << val << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(label));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::write(const float val)
|
||||
{
|
||||
// std::cerr<<"float:" << sizeof(val) << "=" << val << '\n';
|
||||
write(reinterpret_cast<const char*>(&val), sizeof(float));
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::write(const double val)
|
||||
{
|
||||
// std::cerr<<"double as float=" << val << '\n';
|
||||
float copy(val);
|
||||
write(copy);
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkBase64Layer::flush()
|
||||
{
|
||||
base64Layer::close();
|
||||
}
|
||||
|
||||
|
||||
std::size_t Foam::foamVtkBase64Layer::encodedLength(std::size_t n) const
|
||||
{
|
||||
return base64Layer::encodedLength(n);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
114
src/fileFormats/vtk/format/foamVtkBase64Layer.H
Normal file
114
src/fileFormats/vtk/format/foamVtkBase64Layer.H
Normal file
@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
Class
|
||||
foamVtkBase64Layer
|
||||
|
||||
Description
|
||||
Base-64 encoded output.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef foamVtkBase64Layer_H
|
||||
#define foamVtkBase64Layer_H
|
||||
|
||||
#include "foamVtkFormatter.H"
|
||||
#include "base64Layer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class foamVtkBase64Layer Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class foamVtkBase64Layer
|
||||
:
|
||||
public foamVtkFormatter,
|
||||
protected base64Layer
|
||||
{
|
||||
// Private Data Members
|
||||
|
||||
static const char* encoding_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
foamVtkBase64Layer(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const foamVtkBase64Layer&) = delete;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Write
|
||||
void write(const char* s, std::streamsize n);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkBase64Layer(std::ostream& os);
|
||||
|
||||
public:
|
||||
|
||||
//- Destructor
|
||||
virtual ~foamVtkBase64Layer();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Name for the XML append encoding ("base64").
|
||||
virtual const char* encoding() const;
|
||||
|
||||
|
||||
//- Write leading size for binary output
|
||||
virtual void writeSize(const uint64_t nBytes);
|
||||
|
||||
virtual void write(const uint8_t val);
|
||||
virtual void write(const label val);
|
||||
virtual void write(const float val);
|
||||
virtual void write(const double val);
|
||||
|
||||
//- End the encoding sequence (padding the final characters with '=')
|
||||
virtual void flush();
|
||||
|
||||
//- The encoded length for base64 encoded output.
|
||||
virtual std::size_t encodedLength(std::size_t n) const;
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -52,6 +52,12 @@ Foam::foamVtkFormatter::~foamVtkFormatter()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
std::size_t Foam::foamVtkFormatter::encodedLength(std::size_t n) const
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkFormatter::indent()
|
||||
{
|
||||
label n = xmlTags_.size() * 2;
|
||||
@ -149,7 +155,6 @@ Foam::foamVtkFormatter::tag(const word& tag)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::endTag(const word& tag)
|
||||
{
|
||||
@ -181,7 +186,6 @@ Foam::foamVtkFormatter::endTag(const word& tag)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Foam::foamVtkFormatter&
|
||||
Foam::foamVtkFormatter::xmlAttr
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -74,8 +74,8 @@ class foamVtkFormatter
|
||||
template<class Type>
|
||||
foamVtkFormatter& xmlAttribute
|
||||
(
|
||||
const word&,
|
||||
const Type&,
|
||||
const word& k,
|
||||
const Type& v,
|
||||
const char quote
|
||||
);
|
||||
|
||||
@ -120,14 +120,20 @@ public:
|
||||
|
||||
|
||||
//- Write leading size for binary output
|
||||
virtual void writeSize(const uint64_t) = 0;
|
||||
virtual void writeSize(const uint64_t nBytes) = 0;
|
||||
|
||||
virtual void write(const uint8_t) = 0;
|
||||
virtual void write(const label) = 0;
|
||||
virtual void write(const float) = 0;
|
||||
virtual void write(const double) = 0;
|
||||
virtual void write(const uint8_t val) = 0;
|
||||
virtual void write(const label val) = 0;
|
||||
virtual void write(const float val) = 0;
|
||||
virtual void write(const double val) = 0;
|
||||
|
||||
//- Flush encoding, write newline etc.
|
||||
virtual void flush() = 0;
|
||||
|
||||
//- The encoded length for binary output.
|
||||
// The default is pass-through.
|
||||
virtual std::size_t encodedLength(std::size_t n) const;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -138,7 +144,7 @@ public:
|
||||
foamVtkFormatter& xmlHeader();
|
||||
|
||||
//- Write XML comment (at the current indentation level)
|
||||
foamVtkFormatter& comment(const std::string&);
|
||||
foamVtkFormatter& comment(const std::string& text);
|
||||
|
||||
|
||||
//- Open XML tag
|
||||
@ -177,40 +183,40 @@ public:
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
(
|
||||
const word&,
|
||||
const std::string&,
|
||||
const word& k,
|
||||
const std::string& v,
|
||||
const char quote = '\''
|
||||
);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
(
|
||||
const word&,
|
||||
const int32_t,
|
||||
const word& k,
|
||||
const int32_t v,
|
||||
const char quote = '\''
|
||||
);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
(
|
||||
const word&,
|
||||
const int64_t,
|
||||
const word& k,
|
||||
const int64_t v,
|
||||
const char quote = '\''
|
||||
);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
(
|
||||
const word&,
|
||||
const uint64_t,
|
||||
const word& k,
|
||||
const uint64_t v,
|
||||
const char quote = '\''
|
||||
);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& xmlAttr
|
||||
(
|
||||
const word&,
|
||||
const scalar,
|
||||
const word& k,
|
||||
const scalar v,
|
||||
const char quote = '\''
|
||||
);
|
||||
|
||||
@ -219,19 +225,19 @@ public:
|
||||
// Member Operators
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word&, const std::string&);
|
||||
foamVtkFormatter& operator()(const word& k, const std::string& v);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word&, const int32_t);
|
||||
foamVtkFormatter& operator()(const word& k, const int32_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word&, const int64_t);
|
||||
foamVtkFormatter& operator()(const word& k, const int64_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word&, const uint64_t);
|
||||
foamVtkFormatter& operator()(const word& k, const uint64_t v);
|
||||
|
||||
//- Write XML attribute
|
||||
foamVtkFormatter& operator()(const word&, const scalar);
|
||||
foamVtkFormatter& operator()(const word& k, const scalar v);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -71,8 +71,8 @@ const char* Foam::foamVtkLegacyFormatter::encoding() const
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t)
|
||||
{}
|
||||
void Foam::foamVtkLegacyFormatter::writeSize(const uint64_t ignored)
|
||||
{/*nop*/}
|
||||
|
||||
|
||||
void Foam::foamVtkLegacyFormatter::write(const uint8_t val)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,11 +25,10 @@ Class
|
||||
foamVtkLegacyFormatter
|
||||
|
||||
Description
|
||||
Binary output for the VTK legacy format, always written as big-endian.
|
||||
Binary output for the VTK legacy format, always written as big-endian
|
||||
and with 32-bit integers.
|
||||
|
||||
The legacy files are always written as big endian.
|
||||
Since integers in the legacy format are limited to 32-bit,
|
||||
this format should not be used for OpenFOAM with 64-bit label sizes.
|
||||
This format should never be used for OpenFOAM with 64-bit label sizes.
|
||||
|
||||
SourceFiles
|
||||
foamVtkLegacyFormatter.C
|
||||
@ -81,7 +80,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct and attach to an output stream
|
||||
foamVtkLegacyFormatter(std::ostream&);
|
||||
foamVtkLegacyFormatter(std::ostream& os);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -90,22 +89,25 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Name for the Legacy output type ("BINARY")
|
||||
//- Name for the legacy binary output type ("BINARY")
|
||||
virtual const char* name() const;
|
||||
|
||||
//- Name for the XML append encoding (unused)
|
||||
// Currently simply "BINARY", but this should not be relied upon.
|
||||
// Currently identical to name(), but do not rely on this.
|
||||
virtual const char* encoding() const;
|
||||
|
||||
|
||||
//- Write leading size - a no-op for legacy binary output
|
||||
virtual void writeSize(const uint64_t);
|
||||
virtual void writeSize(const uint64_t ignored);
|
||||
|
||||
virtual void write(const uint8_t);
|
||||
virtual void write(const label);
|
||||
virtual void write(const float);
|
||||
virtual void write(const double);
|
||||
virtual void write(const uint8_t val);
|
||||
virtual void write(const label val);
|
||||
virtual void write(const float val);
|
||||
virtual void write(const double val);
|
||||
|
||||
//- Write a newline to the output
|
||||
virtual void flush();
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -45,10 +45,8 @@ Foam::foamVtkOutputOptions::foamVtkOutputOptions()
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::foamVtkFormatter> Foam::foamVtkOutputOptions::newFormatter
|
||||
(
|
||||
std::ostream& os
|
||||
) const
|
||||
Foam::autoPtr<Foam::foamVtkFormatter>
|
||||
Foam::foamVtkOutputOptions::newFormatter(std::ostream& os) const
|
||||
{
|
||||
switch (type_)
|
||||
{
|
||||
@ -87,9 +85,9 @@ Foam::autoPtr<Foam::foamVtkFormatter> Foam::foamVtkOutputOptions::newFormatter
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::foamVtkOutputOptions::ascii(bool b)
|
||||
void Foam::foamVtkOutputOptions::ascii(bool on)
|
||||
{
|
||||
if (b)
|
||||
if (on)
|
||||
{
|
||||
// Force ASCII:
|
||||
|
||||
@ -132,9 +130,9 @@ void Foam::foamVtkOutputOptions::ascii(bool b)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkOutputOptions::append(bool b)
|
||||
void Foam::foamVtkOutputOptions::append(bool on)
|
||||
{
|
||||
if (b)
|
||||
if (on)
|
||||
{
|
||||
if (!(type_ & APPEND))
|
||||
{
|
||||
@ -153,9 +151,9 @@ void Foam::foamVtkOutputOptions::append(bool b)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkOutputOptions::legacy(bool b)
|
||||
void Foam::foamVtkOutputOptions::legacy(bool on)
|
||||
{
|
||||
if (b)
|
||||
if (on)
|
||||
{
|
||||
if (type_ & APPEND)
|
||||
{
|
||||
@ -180,9 +178,9 @@ void Foam::foamVtkOutputOptions::legacy(bool b)
|
||||
}
|
||||
|
||||
|
||||
void Foam::foamVtkOutputOptions::precision(unsigned val) const
|
||||
void Foam::foamVtkOutputOptions::precision(unsigned prec) const
|
||||
{
|
||||
precision_ = val;
|
||||
precision_ = prec;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -88,7 +88,7 @@ public:
|
||||
// Selectors
|
||||
|
||||
//- Return new data formatter based on the writer options
|
||||
autoPtr<foamVtkFormatter> newFormatter(std::ostream&) const;
|
||||
autoPtr<foamVtkFormatter> newFormatter(std::ostream& os) const;
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -117,16 +117,16 @@ public:
|
||||
// In append mode, this switches between base64 and raw binary.
|
||||
// In XML mode, this switches between ASCII and base64.
|
||||
// In legacy mode, this switches between ASCII and binary.
|
||||
void ascii(bool);
|
||||
void ascii(bool on);
|
||||
|
||||
//- Toggle append mode on/off.
|
||||
void append(bool);
|
||||
void append(bool on);
|
||||
|
||||
//- Toggle legacy mode on/off.
|
||||
void legacy(bool);
|
||||
void legacy(bool on);
|
||||
|
||||
//- Set the write precision to be used for new ASCII formatters
|
||||
void precision(unsigned val) const;
|
||||
void precision(unsigned prec) const;
|
||||
|
||||
|
||||
// Other
|
||||
|
||||
@ -59,11 +59,11 @@ Foam::foamVtkPTraits<double>::typeName = "Float64";
|
||||
#ifdef WM_LITTLE_ENDIAN
|
||||
template<>
|
||||
const char* const
|
||||
Foam::foamVtkPTraits<::Foam::endian>::typeName = "LittleEndian";
|
||||
Foam::foamVtkPTraits<Foam::endian>::typeName = "LittleEndian";
|
||||
#else
|
||||
template<>
|
||||
const char* const
|
||||
Foam::foamVtkPTraits<::Foam::endian>::typeName = "BigEndian";
|
||||
Foam::foamVtkPTraits<Foam::endian>::typeName = "BigEndian";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,28 +58,28 @@ public:
|
||||
|
||||
|
||||
template<>
|
||||
const char* const foamVtkPTraits<uint8_t>::typeName; // = UInt8
|
||||
const char* const foamVtkPTraits<uint8_t>::typeName; // UInt8
|
||||
|
||||
template<>
|
||||
const char* const foamVtkPTraits<int32_t>::typeName; // = Int32
|
||||
const char* const foamVtkPTraits<int32_t>::typeName; // Int32
|
||||
|
||||
template<>
|
||||
const char* const foamVtkPTraits<int32_t>::typeName; // = UInt32
|
||||
const char* const foamVtkPTraits<uint32_t>::typeName; // UInt32
|
||||
|
||||
template<>
|
||||
const char* const foamVtkPTraits<int32_t>::typeName; // = Int64
|
||||
const char* const foamVtkPTraits<int64_t>::typeName; // Int64
|
||||
|
||||
template<>
|
||||
const char* const foamVtkPTraits<int64_t>::typeName; // = UInt64
|
||||
const char* const foamVtkPTraits<uint64_t>::typeName; // UInt64
|
||||
|
||||
template<>
|
||||
const char* const foamVtkPTraits<float>::typeName; // = Float32
|
||||
const char* const foamVtkPTraits<float>::typeName; // Float32
|
||||
|
||||
template<>
|
||||
const char* const foamVtkPTraits<double>::typeName; // = Float64
|
||||
const char* const foamVtkPTraits<double>::typeName; // Float64
|
||||
|
||||
template<>
|
||||
const char* const foamVtkPTraits<::Foam::endian>::typeName;
|
||||
const char* const foamVtkPTraits<Foam::endian>::typeName; // (Big|Little)Endian
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -159,13 +159,6 @@ Foam::tmp<Foam::Field<Type>> Foam::slicedFvPatchField<Type>::snGrad() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::slicedFvPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
NotImplemented;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type>>
|
||||
Foam::slicedFvPatchField<Type>::patchInternalField() const
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -153,10 +153,6 @@ public:
|
||||
//- Return patch-normal gradient
|
||||
virtual tmp<Field<Type>> snGrad() const;
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
// Sets Updated to true
|
||||
virtual void updateCoeffs();
|
||||
|
||||
//- Return internal field next to patch as patch field
|
||||
virtual tmp<Field<Type>> patchInternalField() const;
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::fixedNormalInletOutletVelocityFvPatchVectorField
|
||||
|
||||
Group
|
||||
grpInletletBoundaryConditions grpOutletBoundaryConditions
|
||||
grpInletBoundaryConditions grpOutletBoundaryConditions
|
||||
|
||||
Description
|
||||
This velocity inlet/outlet boundary condition combines a fixed normal
|
||||
|
||||
@ -34,7 +34,7 @@ Description
|
||||
Usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
valueFraction | fraction od value used for boundary [0-1] | yes |
|
||||
valueFraction | fraction of value used for boundary [0-1] | yes |
|
||||
\endtable
|
||||
|
||||
Example of the boundary condition specification:
|
||||
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::pressureInletOutletVelocityFvPatchVectorField
|
||||
|
||||
Group
|
||||
grpInletletBoundaryConditions grpOutletBoundaryConditions
|
||||
grpInletBoundaryConditions grpOutletBoundaryConditions
|
||||
|
||||
Description
|
||||
This velocity inlet/outlet boundary condition is applied to pressure
|
||||
@ -49,7 +49,7 @@ Usage
|
||||
type pressureInletOutletVelocity;
|
||||
phi phi;
|
||||
tangentialVelocity uniform (0 0 0);
|
||||
value uniform 0;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ Foam::slipFvPatchField<Type>::slipFvPatchField
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
basicSymmetryFvPatchField<Type>(p, iF)
|
||||
basicSymmetryFvPatchField<Type>(p, iF)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -416,7 +416,8 @@ void Foam::timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
|
||||
// Reread values and interpolate
|
||||
fileName valsFile
|
||||
(
|
||||
this->db().time().caseConstant()
|
||||
this->db().time().path()
|
||||
/this->db().time().caseConstant()
|
||||
/"boundaryData"
|
||||
/this->patch().name()
|
||||
/sampleTimes_[endSampleTime_].name()
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -311,6 +311,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::initialisePatch()
|
||||
|
||||
// Determine if all eddies spawned from a single processor
|
||||
singleProc_ = patch.size() == returnReduce(patch.size(), sumOp<label>());
|
||||
reduce(singleProc_, orOp<bool>());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ Description
|
||||
|
||||
The weight applies to the first scheme and 1-weight to the second scheme.
|
||||
|
||||
Usage
|
||||
Example of the CoBlended scheme specification using LUST for Courant numbers
|
||||
less than 1 and linearUpwind for Courant numbers greater than 10:
|
||||
\verbatim
|
||||
|
||||
@ -176,8 +176,9 @@ bool Foam::functionObjects::blendingFactor::write()
|
||||
<< " blended cells : " << nCellsBlended << nl
|
||||
<< endl;
|
||||
|
||||
writeTime(file());
|
||||
|
||||
file()
|
||||
<< time_.time().value()
|
||||
<< token::TAB << nCellsScheme1
|
||||
<< token::TAB << nCellsScheme2
|
||||
<< token::TAB << nCellsBlended
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -98,7 +98,7 @@ void Foam::functionObjects::fieldAverage::initialize()
|
||||
}
|
||||
}
|
||||
|
||||
// ensure first averaging works unconditionally
|
||||
// Ensure first averaging works unconditionally
|
||||
prevTimeIndex_ = -1;
|
||||
|
||||
Log << endl;
|
||||
@ -108,7 +108,8 @@ void Foam::functionObjects::fieldAverage::initialize()
|
||||
|
||||
void Foam::functionObjects::fieldAverage::restart()
|
||||
{
|
||||
Log << " Restarting averaging at time " << obr().time().timeName()
|
||||
Log << " Restarting averaging at time "
|
||||
<< obr().time().timeOutputValue()
|
||||
<< nl << endl;
|
||||
|
||||
totalIter_.clear();
|
||||
@ -221,7 +222,8 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
|
||||
if (restartOnRestart_ || restartOnOutput_)
|
||||
{
|
||||
Info<< " Starting averaging at time " << obr().time().timeName()
|
||||
Info<< " Starting averaging at time "
|
||||
<< obr().time().timeOutputValue()
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
@ -240,15 +242,18 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties()
|
||||
totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter"));
|
||||
totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime"));
|
||||
|
||||
scalar userTotalTime =
|
||||
obr().time().timeToUserTime(totalTime_[fieldi]);
|
||||
|
||||
Info<< " " << fieldName
|
||||
<< " iters = " << totalIter_[fieldi]
|
||||
<< " time = " << totalTime_[fieldi] << nl;
|
||||
<< " time = " << userTotalTime << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " " << fieldName
|
||||
<< ": starting averaging at time "
|
||||
<< obr().time().timeName() << endl;
|
||||
<< obr().time().timeOutputValue() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -312,7 +317,8 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
|
||||
if (periodicRestart_)
|
||||
{
|
||||
dict.lookup("restartPeriod") >> restartPeriod_;
|
||||
scalar userRestartPeriod = readScalar(dict.lookup("restartPeriod"));
|
||||
restartPeriod_ = obr().time().userTimeToTime(userRestartPeriod);
|
||||
|
||||
if (restartPeriod_ > 0)
|
||||
{
|
||||
@ -323,22 +329,25 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
++periodIndex_;
|
||||
}
|
||||
|
||||
Info<< " Restart period " << restartPeriod_
|
||||
<< " - next restart at " << (restartPeriod_*periodIndex_)
|
||||
Info<< " Restart period " << userRestartPeriod
|
||||
<< " - next restart at " << (userRestartPeriod*periodIndex_)
|
||||
<< nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
periodicRestart_ = false;
|
||||
|
||||
Info<< " Restart period " << restartPeriod_
|
||||
Info<< " Restart period " << userRestartPeriod
|
||||
<< " - ignored"
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (dict.readIfPresent("restartTime", restartTime_))
|
||||
scalar userRestartTime = 0;
|
||||
if (dict.readIfPresent("restartTime", userRestartTime))
|
||||
{
|
||||
restartTime_ = obr().time().userTimeToTime(userRestartTime);
|
||||
|
||||
if (currentTime > restartTime_)
|
||||
{
|
||||
// The restart time is already in the past - ignore
|
||||
@ -346,7 +355,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict)
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " Restart scheduled at time " << restartTime_
|
||||
Info<< " Restart scheduled at time " << userRestartTime
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,6 +122,8 @@ Foam::functionObjects::wallHeatFlux::wallHeatFlux
|
||||
mesh_.objectRegistry::store(wallHeatFluxPtr);
|
||||
|
||||
read(dict);
|
||||
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
|
||||
@ -267,8 +269,9 @@ bool Foam::functionObjects::wallHeatFlux::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
writeTime(file());
|
||||
|
||||
file()
|
||||
<< mesh_.time().value()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << minHfp
|
||||
<< token::TAB << maxHfp
|
||||
|
||||
@ -249,7 +249,9 @@ bool Foam::functionObjects::wallShearStress::write()
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << mesh_.time().value()
|
||||
writeTime(file());
|
||||
|
||||
file()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << minSsp
|
||||
<< token::TAB << maxSsp
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -186,7 +186,7 @@ void Foam::functionObjects::forceCoeffs::writeBinData
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
os << obr_.time().value();
|
||||
writeTime(os);
|
||||
|
||||
for (label bini = 0; bini < nBin_; bini++)
|
||||
{
|
||||
@ -250,6 +250,14 @@ bool Foam::functionObjects::forceCoeffs::read(const dictionary& dict)
|
||||
// Free stream velocity magnitude
|
||||
dict.lookup("magUInf") >> magUInf_;
|
||||
|
||||
// If case is compressible we must read rhoInf (store in rhoRef_) to
|
||||
// calculate the reference dynamic pressure
|
||||
// - note: for incompressible, rhoRef_ is already initialised
|
||||
if (rhoName_ != "rhoInf")
|
||||
{
|
||||
dict.lookup("rhoInf") >> rhoRef_;
|
||||
}
|
||||
|
||||
// Reference length and area scales
|
||||
dict.lookup("lRef") >> lRef_;
|
||||
dict.lookup("Aref") >> Aref_;
|
||||
|
||||
@ -593,8 +593,9 @@ void Foam::functionObjects::forces::writeIntegratedForceMoment
|
||||
{
|
||||
Ostream& os = osPtr();
|
||||
|
||||
os << obr_.time().value()
|
||||
<< tab << total
|
||||
writeTime(os);
|
||||
|
||||
os << tab << total
|
||||
<< tab << pressure
|
||||
<< tab << viscous;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user