diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index f82f91a368e4fad79ee13bb2b816695aa0eabab8..66741868bafa6fd5b99ec4a51f191e54f0620667 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Time.H" +#include "argList.H" #include "Pstream.H" #include "simpleObjectRegistry.H" #include "dimensionedConstants.H" @@ -42,192 +43,285 @@ void Foam::Time::readDict() setEnv("FOAM_APPLICATION", application, false); } - // Check for local switches and settings - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // - echo values, unless the application was invoked with noBanner + const bool echo = argList::bannerEnabled(); + + const dictionary* localDict = nullptr; - // Debug switches - if (controlDict_.found("DebugSwitches")) + // DebugSwitches + if + ( + (localDict = controlDict_.subDictPtr("DebugSwitches")) != nullptr + && localDict->size() + ) { - Info<< "Overriding DebugSwitches according to " << controlDict_.name() - << endl; + if (echo) + { + Info<< "Overriding DebugSwitches according to " + << controlDict_.name() << nl; + } + + simpleObjectRegistry& objs = debug::debugObjects(); - simpleObjectRegistry& objects = debug::debugObjects(); - const dictionary& localSettings = controlDict_.subDict("DebugSwitches"); - forAllConstIter(dictionary, localSettings, iter) + forAllConstIters(*localDict, iter) { const word& name = iter().keyword(); - simpleObjectRegistryEntry* objPtr = objects.lookupPtr(name); + simpleObjectRegistryEntry* objPtr = objs.lookupPtr(name); if (objPtr) { - Info<< " " << iter() << endl; - const List<simpleRegIOobject*>& objects = *objPtr; + if (echo) + { + Info<< " " << iter() << nl; + } + if (iter().isDict()) { - forAll(objects, i) + for (simpleRegIOobject* obj : objects) { OStringStream os(IOstream::ASCII); os << iter().dict(); IStringStream is(os.str()); - objects[i]->readData(is); + obj->readData(is); } } else { - forAll(objects, i) + for (simpleRegIOobject* obj : objects) { - objects[i]->readData(iter().stream()); + obj->readData(iter().stream()); } } } } } - // Optimisation Switches - if (controlDict_.found("OptimisationSwitches")) + + // InfoSwitches + if + ( + (localDict = controlDict_.subDictPtr("InfoSwitches")) != nullptr + && localDict->size() + ) { - Info<< "Overriding OptimisationSwitches according to " - << controlDict_.name() << endl; + if (echo) + { + Info<< "Overriding InfoSwitches according to " + << controlDict_.name() << nl; + } - simpleObjectRegistry& objects = debug::optimisationObjects(); - const dictionary& localSettings = controlDict_.subDict - ( - "OptimisationSwitches" - ); - forAllConstIter(dictionary, localSettings, iter) + simpleObjectRegistry& objs = debug::infoObjects(); + + forAllConstIters(*localDict, iter) { const word& name = iter().keyword(); - simpleObjectRegistryEntry* objPtr = objects.lookupPtr(name); + simpleObjectRegistryEntry* objPtr = objs.lookupPtr(name); if (objPtr) { - Info<< " " << iter() << endl; - const List<simpleRegIOobject*>& objects = *objPtr; + if (echo) + { + Info<< " " << iter() << nl; + } + if (iter().isDict()) { - forAll(objects, i) + for (simpleRegIOobject* obj : objects) { OStringStream os(IOstream::ASCII); os << iter().dict(); IStringStream is(os.str()); - objects[i]->readData(is); + obj->readData(is); } } else { - forAll(objects, i) + for (simpleRegIOobject* obj : objects) { - objects[i]->readData(iter().stream()); + obj->readData(iter().stream()); } } } } + } + // OptimisationSwitches + if + ( + (localDict = controlDict_.subDictPtr("OptimisationSwitches")) != nullptr + && localDict->size() + ) + { + if (echo) + { + Info<< "Overriding OptimisationSwitches according to " + << controlDict_.name() << nl; + } - // Handle fileHandler override explicitly since interacts with - // local dictionary monitoring. - word fileHandlerName; - if - ( - localSettings.readIfPresent("fileHandler", fileHandlerName) - && fileHandler().type() != fileHandlerName - ) + simpleObjectRegistry& objs = debug::optimisationObjects(); + + forAllConstIters(*localDict, iter) { - // Remove the old watches since destroying the file - fileNameList oldWatchedFiles(controlDict_.watchIndices().size()); - forAllReverse(controlDict_.watchIndices(), i) + const word& name = iter().keyword(); + + simpleObjectRegistryEntry* objPtr = objs.lookupPtr(name); + + if (objPtr) { - const label watchi = controlDict_.watchIndices()[i]; - oldWatchedFiles[i] = fileHandler().getFile(watchi); - fileHandler().removeWatch(watchi); - } - controlDict_.watchIndices().clear(); + if (echo) + { + Info<< " " << iter() << nl; + } - // Installing the new handler - Info<< "Overriding fileHandler to " << fileHandlerName << endl; + const List<simpleRegIOobject*>& objects = *objPtr; - autoPtr<fileOperation> handler - ( - fileOperation::New - ( - fileHandlerName, - true - ) - ); - Foam::fileHandler(handler); - - // Reinstall old watches - fileHandler().addWatches(controlDict_, oldWatchedFiles); + if (iter().isDict()) + { + for (simpleRegIOobject* obj : objects) + { + OStringStream os(IOstream::ASCII); + os << iter().dict(); + IStringStream is(os.str()); + obj->readData(is); + } + } + else + { + for (simpleRegIOobject* obj : objects) + { + obj->readData(iter().stream()); + } + } + } } } - // DimensionedConstants. Handled as a special case since both e.g. - // the 'unitSet' might be changed and the individual values - if (controlDict_.found("DimensionedConstants")) + // Handle fileHandler explicitly since it affects local dictionary + // monitoring. + word fileHandlerName; + if + ( + localDict + && localDict->readIfPresent("fileHandler", fileHandlerName) + && fileHandler().type() != fileHandlerName + ) { - Info<< "Overriding DimensionedConstants according to " - << controlDict_.name() << endl; + if (echo) + { + Info<< "Overriding fileHandler to " << fileHandlerName << nl; + } - // Change in-memory - dimensionedConstants().merge + // Remove old watches since destroying the file + fileNameList oldWatched(controlDict_.watchIndices().size()); + forAllReverse(controlDict_.watchIndices(), i) + { + const label watchi = controlDict_.watchIndices()[i]; + oldWatched[i] = fileHandler().getFile(watchi); + fileHandler().removeWatch(watchi); + } + controlDict_.watchIndices().clear(); + + // Installing the new handler + autoPtr<fileOperation> handler ( - controlDict_.subDict("DimensionedConstants") + fileOperation::New + ( + fileHandlerName, + true + ) ); + Foam::fileHandler(handler); + + // Reinstall old watches + fileHandler().addWatches(controlDict_, oldWatched); + } + + + // DimensionedConstants. + // - special case since it may change both the 'unitSet' and the + // individual values + if + ( + + (localDict = controlDict_.subDictPtr("DimensionedConstants")) != nullptr + && localDict->size() + ) + { + if (echo) + { + Info<< "Overriding DimensionedConstants according to " + << controlDict_.name() << nl; + } + simpleObjectRegistry& objs = debug::dimensionedConstantObjects(); - simpleObjectRegistry& objects = debug::dimensionedConstantObjects(); + // Change in-memory + dimensionedConstants().merge(*localDict); IStringStream dummyIs(""); - forAllConstIter(simpleObjectRegistry, objects, iter) + forAllConstIter(simpleObjectRegistry, objs, iter) { const List<simpleRegIOobject*>& objects = *iter; - forAll(objects, i) + for (simpleRegIOobject* obj : objects) { - objects[i]->readData(dummyIs); + obj->readData(dummyIs); - Info<< " "; - objects[i]->writeData(Info); - Info<< endl; + if (echo) + { + Info<< " "; + obj->writeData(Info); + Info<< nl; + } } } } - // Dimension sets - if (controlDict_.found("DimensionSets")) + // DimensionSets + if + ( + (localDict = controlDict_.subDictPtr("DimensionSets")) != nullptr + && localDict->size() + ) { - Info<< "Overriding DimensionSets according to " - << controlDict_.name() << endl; + if (echo) + { + Info<< "Overriding DimensionSets according to " + << controlDict_.name() << nl; + } - dictionary dict(Foam::dimensionSystems()); - dict.merge(controlDict_.subDict("DimensionSets")); + simpleObjectRegistry& objs = debug::dimensionSetObjects(); - simpleObjectRegistry& objects = debug::dimensionSetObjects(); + dictionary dict(Foam::dimensionSystems()); + dict.merge(*localDict); - simpleObjectRegistryEntry* objPtr = objects.lookupPtr("DimensionSets"); + simpleObjectRegistryEntry* objPtr = objs.lookupPtr("DimensionSets"); if (objPtr) { - Info<< controlDict_.subDict("DimensionSets") << endl; + if (echo) + { + Info<< *localDict << nl; + } const List<simpleRegIOobject*>& objects = *objPtr; - forAll(objects, i) + for (simpleRegIOobject* obj : objects) { OStringStream os(IOstream::ASCII); os << dict; IStringStream is(os.str()); - objects[i]->readData(is); + obj->readData(is); } } } diff --git a/src/lagrangian/basic/injectedParticle/injectedParticleIO.C b/src/lagrangian/basic/injectedParticle/injectedParticleIO.C index 066eb6444df1426aaa88dcf7389a6e1c7f4e3250..d1410b31035a413d6ca6057e772d41bcb43ea4d8 100644 --- a/src/lagrangian/basic/injectedParticle/injectedParticleIO.C +++ b/src/lagrangian/basic/injectedParticle/injectedParticleIO.C @@ -126,6 +126,9 @@ void Foam::injectedParticle::readFields(Cloud<injectedParticle>& c) void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c) { // Force writing positions instead of coordinates + const bool oldWriteCoordinates = particle::writeLagrangianCoordinates; + const bool oldWritePositions = particle::writeLagrangianPositions; + particle::writeLagrangianCoordinates = false; particle::writeLagrangianPositions = true; @@ -151,13 +154,17 @@ void Foam::injectedParticle::writeFields(const Cloud<injectedParticle>& c) d[i] = p.d(); U[i] = p.U(); - i++; + ++i; } tag.write(); soi.write(); d.write(); U.write(); + + // Restore + particle::writeLagrangianCoordinates = oldWriteCoordinates; + particle::writeLagrangianPositions = oldWritePositions; } @@ -168,6 +175,9 @@ void Foam::injectedParticle::writeObjects ) { // Force writing positions instead of coordinates + const bool oldWriteCoordinates = particle::writeLagrangianCoordinates; + const bool oldWritePositions = particle::writeLagrangianPositions; + particle::writeLagrangianCoordinates = false; particle::writeLagrangianPositions = true; @@ -191,8 +201,12 @@ void Foam::injectedParticle::writeObjects d[i] = p.d(); U[i] = p.U(); - i++; + ++i; } + + // Restore + particle::writeLagrangianCoordinates = oldWriteCoordinates; + particle::writeLagrangianPositions = oldWritePositions; } diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index d9e8ebdabbd7f742cb3fd8314ab5b393ee5669be..8bdd665de2c186386ddcabd4dbaa1f8b38a9e871 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,26 +27,33 @@ License #include "transform.H" #include "treeDataCell.H" #include "cubicEqn.H" +#include "registerSwitch.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::scalar Foam::particle::negativeSpaceDisplacementFactor = 1.01; - -Foam::label Foam::particle::particleCount_ = 0; - namespace Foam { defineTypeNameAndDebug(particle, 0); - bool particle::writeLagrangianCoordinates - ( - debug::infoSwitch("writeLagrangianCoordinates", 1) - ); - bool particle::writeLagrangianPositions - ( - debug::infoSwitch("writeLagrangianPositions", 0) - ); } +const Foam::scalar Foam::particle::negativeSpaceDisplacementFactor = 1.01; + +Foam::label Foam::particle::particleCount_ = 0; + +bool Foam::particle::writeLagrangianCoordinates = true; + +bool Foam::particle::writeLagrangianPositions +( + Foam::debug::infoSwitch("writeLagrangianPositions", 0) +); + +registerInfoSwitch +( + "writeLagrangianPositions", + bool, + Foam::particle::writeLagrangianPositions +); + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 35da9c8d03ab1a1776dfa30fb019ef23e2f82334..ef9feafde3fc570a7e2177bebf49eaaf7591f59a 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -443,8 +443,7 @@ public: //- Destructor - virtual ~particle() - {} + virtual ~particle() = default; // Member Functions diff --git a/src/lagrangian/coalCombustion/coalCloudList/coalCloudList.C b/src/lagrangian/coalCombustion/coalCloudList/coalCloudList.C index 548e81d2169106a706a65ced78c77f7ce5b44d46..76fc018f2594011c3614423c2a9e91b8cd6e73ba 100644 --- a/src/lagrangian/coalCombustion/coalCloudList/coalCloudList.C +++ b/src/lagrangian/coalCombustion/coalCloudList/coalCloudList.C @@ -54,10 +54,8 @@ Foam::coalCloudList::coalCloudList setSize(cloudNames.size()); label i = 0; - forAllConstIter(wordHashSet, cloudNames, iter) + for (const word& name : cloudNames) { - const word& name = iter.key(); - Info<< "creating cloud: " << name << endl; set diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun index 1c2a7447eb1a13bb49cdc3fc5c801535e5a15e50..61c2efb007f6b15459808b5982a1ebbb929122fe 100755 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/Allrun @@ -2,10 +2,9 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions -# create mesh runApplication blockMesh -# create ignition cells cellSet +# Create ignition cells cellSet runApplication topoSet runApplication $(getApplication) diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/decomposeParDict b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/decomposeParDict index 12a2e8b434d8d798bb52d61272f1457095543c68..d731400f8592f428e3e4351eb0a056c46df50b10 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/decomposeParDict +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/system/decomposeParDict @@ -21,13 +21,10 @@ method scotch; coeffs { n (2 2 1); - //delta 0.001; // default=0.001 - //order xyz; // default=xzy } distributed no; roots ( ); - // ************************************************************************* //