diff --git a/applications/test/parallel/Test-parallel.C b/applications/test/parallel/Test-parallel.C index 62d6150ce4..9b10ae6107 100644 --- a/applications/test/parallel/Test-parallel.C +++ b/applications/test/parallel/Test-parallel.C @@ -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) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,154 +42,235 @@ Description using namespace Foam; + +void testMapDistribute() +{ + Random rndGen(43544*Pstream::myProcNo()); + + // Generate random data. + List>> complexData(100); + forAll(complexData, i) + { + complexData[i].first() = rndGen.integer(0, Pstream::nProcs()-1); + complexData[i].second().setSize(3); + complexData[i].second()[0] = 1; + complexData[i].second()[1] = 2; + complexData[i].second()[2] = 3; + } + + // Send all ones to processor indicated by .first() + + // Count how many to send + labelList nSend(Pstream::nProcs(), 0); + forAll(complexData, i) + { + label procI = complexData[i].first(); + nSend[procI]++; + } + + // Collect items to be sent + labelListList sendMap(Pstream::nProcs()); + forAll(sendMap, procI) + { + sendMap[procI].setSize(nSend[procI]); + } + nSend = 0; + forAll(complexData, i) + { + label procI = complexData[i].first(); + sendMap[procI][nSend[procI]++] = i; + } + + // Sync how many to send + labelList nRecv; + Pstream::exchangeSizes(sendMap, nRecv); + + // Collect items to be received + labelListList recvMap(Pstream::nProcs()); + forAll(recvMap, procI) + { + recvMap[procI].setSize(nRecv[procI]); + } + + label constructSize = 0; + // Construct with my own elements first + forAll(recvMap[Pstream::myProcNo()], i) + { + recvMap[Pstream::myProcNo()][i] = constructSize++; + } + // Construct from other processors + forAll(recvMap, procI) + { + if (procI != Pstream::myProcNo()) + { + forAll(recvMap[procI], i) + { + recvMap[procI][i] = constructSize++; + } + } + } + + // Construct distribute map (destructively) + mapDistribute map(constructSize, sendMap.xfer(), recvMap.xfer()); + + // Distribute complexData + map.distribute(complexData); + + Pout<< "complexData:" << complexData << endl; +} + + +template +void testTransfer(const T& input) +{ + T data = input; + + if (Pstream::master()) + { + Perr<<"test transfer (" << (typeid(T).name()) << "): " << data << nl << endl; + } + + if (Pstream::myProcNo() != Pstream::masterNo()) + { + { + Perr<< "slave sending to master " << Pstream::masterNo() << endl; + OPstream toMaster(Pstream::blocking, Pstream::masterNo()); + toMaster << data; + } + + Perr<< "slave receiving from master " << Pstream::masterNo() << endl; + IPstream fromMaster(Pstream::blocking, Pstream::masterNo()); + fromMaster >> data; + Perr<< data << endl; + } + else + { + for + ( + int slave = Pstream::firstSlave(); + slave <= Pstream::lastSlave(); + ++slave + ) + { + Perr<< "master receiving from slave " << slave << endl; + IPstream fromSlave(Pstream::blocking, slave); + fromSlave >> data; + Perr<< data << endl; + } + + for + ( + int slave = Pstream::firstSlave(); + slave <= Pstream::lastSlave(); + ++slave + ) + { + Perr<< "master sending to slave " << slave << endl; + OPstream toSlave(Pstream::blocking, slave); + toSlave << data; + } + } +} + + +template +void testTokenized(const T& data) +{ + token tok; + + if (Pstream::master()) + { + Perr<<"test tokenized \"" << data << "\"" << nl << endl; + } + + if (Pstream::myProcNo() != Pstream::masterNo()) + { + { + Perr<< "slave sending to master " << Pstream::masterNo() << endl; + OPstream toMaster(Pstream::blocking, Pstream::masterNo()); + toMaster << data; + } + + Perr<< "slave receiving from master " << Pstream::masterNo() << endl; + IPstream fromMaster(Pstream::blocking, Pstream::masterNo()); + + fromMaster >> tok; + Perr<< tok.info() << endl; + } + else + { + for + ( + int slave = Pstream::firstSlave(); + slave <= Pstream::lastSlave(); + ++slave + ) + { + Perr<< "master receiving from slave " << slave << endl; + IPstream fromSlave(Pstream::blocking, slave); + fromSlave >> tok; + Perr<< tok.info() << endl; + } + + for + ( + int slave = Pstream::firstSlave(); + slave <= Pstream::lastSlave(); + ++slave + ) + { + Perr<< "master sending to slave " << slave << endl; + OPstream toSlave(Pstream::blocking, slave); + toSlave << data; + } + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { - #include "setRootCase.H" #include "createTime.H" + testMapDistribute(); - // Test mapDistribute - // ~~~~~~~~~~~~~~~~~~ - - if (true) + if (!Pstream::parRun()) { - Random rndGen(43544*Pstream::myProcNo()); - - // Generate random data. - List>> complexData(100); - forAll(complexData, i) - { - complexData[i].first() = rndGen.integer(0, Pstream::nProcs()-1); - complexData[i].second().setSize(3); - complexData[i].second()[0] = 1; - complexData[i].second()[1] = 2; - complexData[i].second()[2] = 3; - } - - // Send all ones to processor indicated by .first() - - - // Count how many to send - labelList nSend(Pstream::nProcs(), 0); - forAll(complexData, i) - { - label procI = complexData[i].first(); - nSend[procI]++; - } - - // Collect items to be sent - labelListList sendMap(Pstream::nProcs()); - forAll(sendMap, procI) - { - sendMap[procI].setSize(nSend[procI]); - } - nSend = 0; - forAll(complexData, i) - { - label procI = complexData[i].first(); - sendMap[procI][nSend[procI]++] = i; - } - - // Sync how many to send - labelList nRecv; - Pstream::exchangeSizes(sendMap, nRecv); - - // Collect items to be received - labelListList recvMap(Pstream::nProcs()); - forAll(recvMap, procI) - { - recvMap[procI].setSize(nRecv[procI]); - } - - label constructSize = 0; - // Construct with my own elements first - forAll(recvMap[Pstream::myProcNo()], i) - { - recvMap[Pstream::myProcNo()][i] = constructSize++; - } - // Construct from other processors - forAll(recvMap, procI) - { - if (procI != Pstream::myProcNo()) - { - forAll(recvMap[procI], i) - { - recvMap[procI][i] = constructSize++; - } - } - } - - - - // Construct distribute map (destructively) - mapDistribute map(constructSize, sendMap.xfer(), recvMap.xfer()); - - // Distribute complexData - map.distribute(complexData); - - Pout<< "complexData:" << complexData << endl; + Info<< "\nWarning: not parallel - skipping further tests\n" << endl; + return 0; } + Info<< "\nStarting transfers\n\n" << endl; -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + testTransfer(vector(0, 1, 2)); + testTransfer(label(1234)); + testTransfer(scalar(3.14159)); + testTransfer(string("test string")); + testTransfer(string(" x ")); + testTransfer(word("3.141 59")); // bad word, but transfer doesn't care - Perr<< "\nStarting transfers\n" << endl; + testTokenized(label(1234)); + testTokenized(scalar(3.14159)); + testTokenized('a'); + testTokenized('$'); // will not tokenize well - vector data(0, 1, 2); + testTokenized(string("test string1")); + testTokenized("test string1"); + testTokenized(word("3.141 59")); // bad word, but transfer doesn't care - if (Pstream::parRun()) - { - if (Pstream::myProcNo() != Pstream::masterNo()) - { - { - Perr<< "slave sending to master " - << Pstream::masterNo() << endl; - OPstream toMaster(Pstream::blocking, Pstream::masterNo()); - toMaster << data; - } + testTokenized(string(" a ")); + testTokenized(" a "); - Perr<< "slave receiving from master " - << Pstream::masterNo() << endl; - IPstream fromMaster(Pstream::blocking, Pstream::masterNo()); - fromMaster >> data; + testTokenized(string(" $ ")); + testTokenized(" $ "); // reduces to 'char' and will not tokenize well - Perr<< data << endl; - } - else - { - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) - { - Perr << "master receiving from slave " << slave << endl; - IPstream fromSlave(Pstream::blocking, slave); - fromSlave >> data; + testTokenized(string(" $$ ")); + testTokenized(" $$ "); // reduces to 'word' and is tagged as such - Perr<< data << endl; - } - - for - ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); - slave++ - ) - { - Perr << "master sending to slave " << slave << endl; - OPstream toSlave(Pstream::blocking, slave); - toSlave << data; - } - } - } Info<< "End\n" << endl; - return 0; } diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 8c744e7d84..b90dc64d65 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -285,14 +285,18 @@ castellatedMeshControls // after refinement. // // There are two different ways of specifying the regions to keep: - // 1. a single locationInMesh. All the 'zoned' surfaces are marked as such + // 1. a single locationInMesh. This is the unzoned part of the mesh. + // All the 'zoned' surfaces are marked as such // in the refinementSurfaces with the faceZone and cellZone keywords. + // It is illegal to have the locationInMesh inside a surface for which + // a cellZone is specified. // // or // // 2. multiple locationsInMesh, with per location the name of the cellZone. // This uses walking to determine zones and automatically creates - // faceZones on the outside of cellZones. + // faceZones on the outside of cellZones. The special name 'none' is + // used to indicate the unzoned/background part of the mesh. // Ad 1. Specify a single location and how to treat faces inbetween diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H index a85c911ebe..d343567722 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightBinaryStream.H @@ -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) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -97,8 +97,8 @@ public: virtual void write(const char* val) { - char buffer[80] = {0}; - strcpy(buffer, val); + char buffer[80]; + strncpy(buffer, val, 80); str_().write(buffer, 80*sizeof(char)); } diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoamVolFields.H b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoamVolFields.H index ea4287beb0..7a34bbca1c 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoamVolFields.H +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoamVolFields.H @@ -2,11 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | -<<<<<<< HEAD:applications/utilities/postProcessing/graphics/PV4Readers/PV4FoamReader/vtkPV4Foam/vtkPV4FoamVolFields.H - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation -======= \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation ->>>>>>> foundation:applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoamVolFields.H \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,18 +44,10 @@ InClass // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -<<<<<<< HEAD:applications/utilities/postProcessing/graphics/PV4Readers/PV4FoamReader/vtkPV4Foam/vtkPV4FoamVolFields.H -void Foam::vtkPV4Foam::convertVolField +void Foam::vtkPVFoam::convertVolField ( const PtrList>& ppInterpList, const GeometricField& tf, -======= -void Foam::vtkPVFoam::convertVolFields -( - const fvMesh& mesh, - const PtrList>& ppInterpList, - const IOobjectList& objects, ->>>>>>> foundation:applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoamVolFields.H const bool interpFields, vtkMultiBlockDataSet* output ) @@ -81,27 +69,7 @@ void Foam::vtkPVFoam::convertVolFields ( volPointInterpolation::New(mesh).interpolate(tf).ptr() ); -<<<<<<< HEAD:applications/utilities/postProcessing/graphics/PV4Readers/PV4FoamReader/vtkPV4Foam/vtkPV4FoamVolFields.H } -======= - - // Interpolated field (demand driven) - autoPtr> ptfPtr; - if (interpFields) - { - if (debug) - { - Info<< "convertVolFieldBlock interpolating:" << tf.name() - << endl; - } - - ptfPtr.reset - ( - volPointInterpolation::New(tf.mesh()).interpolate(tf).ptr() - ); - } ->>>>>>> foundation:applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoamVolFields.H - // Convert activated internalMesh regions convertVolFieldBlock @@ -169,7 +137,6 @@ void Foam::vtkPVFoam::convertVolFields tmp> tpptf ( -<<<<<<< HEAD:applications/utilities/postProcessing/graphics/PV4Readers/PV4FoamReader/vtkPV4Foam/vtkPV4FoamVolFields.H fvPatchField(p, tf).patchInternalField() ); @@ -181,22 +148,6 @@ void Foam::vtkPVFoam::convertVolFields arrayRangePatches_, datasetNo ); -======= - isType>(ptf) - || - ( - reader_->GetExtrapolatePatches() - && !polyPatch::constraintType(patches[patchId].type()) - ) - ) - { - fvPatch p(ptf.patch().patch(), tf.mesh().boundary()); - - tmp> tpptf - ( - fvPatchField(p, tf).patchInternalField() - ); ->>>>>>> foundation:applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/vtkPVFoam/vtkPVFoamVolFields.H if (interpFields) { @@ -310,7 +261,7 @@ void Foam::vtkPVFoam::convertVolFields template -void Foam::vtkPV4Foam::convertVolFields +void Foam::vtkPVFoam::convertVolFields ( const fvMesh& mesh, const PtrList>& ppInterpList, @@ -345,7 +296,7 @@ void Foam::vtkPV4Foam::convertVolFields template -void Foam::vtkPV4Foam::convertDimFields +void Foam::vtkPVFoam::convertDimFields ( const fvMesh& mesh, const PtrList>& ppInterpList, diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index d23f8a380f..8e77428d6a 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -74,6 +74,11 @@ formatOptions //collateTimes true; // write single file containing multiple timesteps // (only for static surfaces) } + vtk + { + // Non-default write precision for floating point numbers + writePrecision 10; + } nastran { // From OpenFOAM field name to Nastran field name diff --git a/applications/utilities/surface/surfaceInflate/surfaceInflate.C b/applications/utilities/surface/surfaceInflate/surfaceInflate.C index 2990c26a18..e30ff5fc55 100644 --- a/applications/utilities/surface/surfaceInflate/surfaceInflate.C +++ b/applications/utilities/surface/surfaceInflate/surfaceInflate.C @@ -88,7 +88,7 @@ tmp calcVertexNormals(const triSurface& surf) // Weight = fA / (mag(e0)^2 * mag(e1)^2); tmp tpointNormals ( - new pointField(surf.nPoints(), vector::zero) + new pointField(surf.nPoints(), Zero) ); vectorField& pointNormals = tpointNormals.ref(); @@ -151,7 +151,7 @@ tmp calcPointNormals { if (!isFeaturePoint[e[i]]) { - pointNormals[e[i]] = vector::zero; + pointNormals[e[i]] = Zero; } } } @@ -164,7 +164,7 @@ tmp calcPointNormals const labelList& eFaces = edgeFaces[edgeI]; // Get average edge normal - vector n = vector::zero; + vector n = Zero; forAll(eFaces, i) { n += s.faceNormals()[eFaces[i]]; @@ -483,7 +483,7 @@ void lloydsSmoothing { const labelList& pFaces = pointFaces[pointI]; - point avg = point::zero; + point avg(Zero); forAll(pFaces, pFaceI) { avg += faceCentres[pFaces[pFaceI]]; @@ -498,7 +498,7 @@ void lloydsSmoothing const pointField& points = s.points(); - vectorField pointSum(s.nPoints(), vector::zero); + vectorField pointSum(s.nPoints(), Zero); labelList nPointSum(s.nPoints(), 0); forAll(edges, edgeI) diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions old mode 100644 new mode 100755 index 6a73aa99b1..407800e791 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -2,9 +2,8 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -42,8 +41,10 @@ isTest() getNumberOfProcessors() { - expandDictionary system/decomposeParDict \ - | sed -ne 's/^numberOfSubdomains\s*\(.*\);/\1/p' + if [ -f $1 ] + then + expandDictionary $1 | sed -ne 's/^numberOfSubdomains\s*\(.*\);/\1/p' + fi } getApplication() @@ -101,13 +102,16 @@ runParallel() { LOG_NAME= APP_RUN= + # Store any parsed additional arguments e.g. decomposeParDict + APP_PARARGS= LOG_IGNORE=false LOG_APPEND=false LOG_SUFFIX= - nProcs=$(getNumberOfProcessors) + # Check the default decomposeParDict if available + nProcs=$(getNumberOfProcessors "system/decomposeParDict") # Parse options and executable - while [ $# -gt 0 ] && [ -z "$APP_RUN" ]; do + while [ $# -gt 0 ] && [ -z "$APP_RUN" ] ; do key="$1" case "$key" in -append|-a) @@ -125,6 +129,11 @@ runParallel() nProcs="$2" shift ;; + -decomposeParDict) + nProcs=$(getNumberOfProcessors "$2") + APP_PARARGS="$APP_PARARGS -decomposeParDict $2" + shift + ;; *) APP_RUN="$key" APP_NAME="${key##*/}" @@ -142,9 +151,9 @@ runParallel() else echo "Running $APP_RUN in parallel on $PWD using $nProcs processes" if [ "$LOG_APPEND" = "true" ]; then - ( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null >> log.$LOG_SUFFIX 2>&1 ) + ( mpirun -np $nProcs $APP_RUN $APP_PARARGS -parallel "$@" < /dev/null >> log.$LOG_SUFFIX 2>&1 ) else - ( mpirun -np $nProcs $APP_RUN -parallel "$@" < /dev/null > log.$LOG_SUFFIX 2>&1 ) + ( mpirun -np $nProcs $APP_RUN $APP_PARARGS -parallel "$@" < /dev/null > log.$LOG_SUFFIX 2>&1 ) fi fi } diff --git a/etc/bashrc b/etc/bashrc index 897f7e96ec..9a190e2548 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -179,6 +179,7 @@ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools` _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL` +_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch` # Clean environment paths again. Only remove duplicates diff --git a/src/Allwmake b/src/Allwmake index 750691e799..e07067fb66 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -21,7 +21,7 @@ wmakeCheckPwd "$WM_PROJECT_DIR/src" || { set -x # Update OpenFOAM version strings if required -wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/*/global.? 2>/dev/null +wmakePrintBuild -check || wrmo OpenFOAM/global/global.o wmakeLnInclude OpenFOAM wmakeLnInclude OSspecific/${WM_OSTYPE:-POSIX} diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C index ab95c8c19f..4131da7af4 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.C @@ -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) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,7 +40,7 @@ void Foam::Ostream::decrIndent() } else { - indentLevel_--; + --indentLevel_; } } @@ -79,4 +79,35 @@ Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw) } +Foam::Ostream& Foam::Ostream::beginBlock(const word& keyword) +{ + indent(); + write(keyword); + endl(); + beginBlock(); + + return *this; +} + + +Foam::Ostream& Foam::Ostream::beginBlock() +{ + indent(); + write(char(token::BEGIN_BLOCK)); + incrIndent(); + + return *this; +} + + +Foam::Ostream& Foam::Ostream::endBlock() +{ + decrIndent(); + indent(); + write(char(token::END_BLOCK)); + + return *this; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index aada0b4f9a..0bd02a5b55 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -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) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -109,8 +109,8 @@ public: virtual Ostream& write(const word&) = 0; //- Write keyType - // write regular expression as quoted string - // write plain word as word (unquoted) + // A plain word is written unquoted. + // A regular expression is written as a quoted string. virtual Ostream& write(const keyType&); //- Write string @@ -157,14 +157,29 @@ public: //- Incrememt the indent level void incrIndent() { - indentLevel_++; + ++indentLevel_; } //- Decrememt the indent level void decrIndent(); //- Write the keyword followed by an appropriate indentation - Ostream& writeKeyword(const keyType&); + virtual Ostream& writeKeyword(const keyType&); + + //- Write begin block group with the given name + // Uses the appropriate indentation, + // does not include a trailing newline. + virtual Ostream& beginBlock(const word&); + + //- Write begin block group without a name + // Uses the appropriate indentation, + // does not include a trailing newline. + virtual Ostream& beginBlock(); + + //- Write end block group + // Uses the appropriate indentation, + // does not include a trailing newline. + virtual Ostream& endBlock(); // Stream state functions diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index 0671d69eca..1b1738d1ad 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -194,7 +194,7 @@ Foam::Ostream& Foam::UOPstream::write(const char* str) if (nonWhiteChars.size() == 1) { - return write(nonWhiteChars.c_str()[1]); + return write(nonWhiteChars[0]); } else if (nonWhiteChars.size()) { diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C index 657f0636bd..d8954cb1c9 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C @@ -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-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -95,157 +95,6 @@ void Foam::UPstream::setParRun(const label nProcs) } -Foam::List Foam::UPstream::calcLinearComm -( - const label nProcs -) -{ - List linearCommunication(nProcs); - - // Master - labelList belowIDs(nProcs - 1); - forAll(belowIDs, i) - { - belowIDs[i] = i + 1; - } - - linearCommunication[0] = commsStruct - ( - nProcs, - 0, - -1, - belowIDs, - labelList(0) - ); - - // Slaves. Have no below processors, only communicate up to master - for (label procID = 1; procID < nProcs; procID++) - { - linearCommunication[procID] = commsStruct - ( - nProcs, - procID, - 0, - labelList(0), - labelList(0) - ); - } - return linearCommunication; -} - - -void Foam::UPstream::collectReceives -( - const label procID, - const List>& receives, - DynamicList