diff --git a/applications/test/UIndirectListTest/UIndirectListTest.C b/applications/test/UIndirectListTest/UIndirectListTest.C index 575173c51e..9c619a4b99 100644 --- a/applications/test/UIndirectListTest/UIndirectListTest.C +++ b/applications/test/UIndirectListTest/UIndirectListTest.C @@ -28,6 +28,8 @@ Description #include "UIndirectList.H" #include "IOstreams.H" +#include "ListOps.H" +#include "OFstream.H" using namespace Foam; @@ -52,29 +54,32 @@ int main(int argc, char *argv[]) UIndirectList idl(completeList, addresses); - forAll(idl, i) - { - Info<< idl[i] << token::SPACE; - } - - Info<< endl; + Info<< idl << "\n"; idl[1] = -666; - Info<< "idl[1] changed:" << idl() << endl; + Info<< "idl[1] changed:" << idl << endl; idl = -999; - Info<< "idl changed:" << idl() << endl; + Info<< "idl changed:" << idl << endl; UIndirectList idl2(idl); - Info<< "idl2:" << idl2() << endl; + Info<< "idl2: " << idl2 << endl; - idl = idl2(); - Info<< "idl assigned from UList:" << idl() << endl; + { + List ident(idl.size()); + forAll(ident, i) + { + ident[i] = ident.size() - i; + } + idl = ident; + } + + Info<< "idl assigned from UList:" << idl << endl; List realList = UIndirectList(completeList, addresses); diff --git a/applications/test/string/stringTest.C b/applications/test/string/stringTest.C index b8442102f3..2ed59bf88f 100644 --- a/applications/test/string/stringTest.C +++ b/applications/test/string/stringTest.C @@ -70,6 +70,28 @@ int main(int argc, char *argv[]) string test2("~OpenFOAM/controlDict"); Info<< test2 << " => " << test2.expand() << endl; + // replace controlDict with "newName" + { + string::size_type i = test2.rfind('/'); + + if (i == string::npos) + { + test2 = "newName"; + } + else + { + // this uses the std::string::replace + test2.replace(i+1, string::npos, "newName"); + } + Info<< "after replace: " << test2 << endl; + + // do another replace + // this uses the Foam::string::replace + test2.replace("OpenFOAM", "openfoam"); + + Info<< "after replace: " << test2 << endl; + } + string s; Sin.getLine(s); @@ -78,8 +100,7 @@ int main(int argc, char *argv[]) cout<< "output string with " << s2.length() << " characters\n"; cout<< "ostream<< >" << s2 << "<\n"; Info<< "Ostream<< >" << s2 << "<\n"; - Info<< "hash:" << unsigned(string::hash()(s2)) << endl; - + Info<< "hash:" << hex << string::hash()(s2) << endl; Info << "End\n" << endl; diff --git a/applications/utilities/miscellaneous/foamDebugSwitches/foamDebugSwitches.C b/applications/utilities/miscellaneous/foamDebugSwitches/foamDebugSwitches.C index a910b32057..6854ba0b8d 100644 --- a/applications/utilities/miscellaneous/foamDebugSwitches/foamDebugSwitches.C +++ b/applications/utilities/miscellaneous/foamDebugSwitches/foamDebugSwitches.C @@ -29,6 +29,9 @@ Description #include "argList.H" #include "dictionary.H" +#include "IFstream.H" +#include "IOobject.H" +#include "HashSet.H" using namespace Foam; @@ -38,18 +41,108 @@ using namespace Foam; int main(int argc, char *argv[]) { argList::noParallel(); + argList::validOptions.insert("new", ""); + argList::validOptions.insert("old", ""); - wordList ds(debug::debugSwitches().toc()); - sort(ds); - Info<< "debug switches: " << ds << endl; + Foam::argList args(argc, argv); + + wordList currDebug(debug::debugSwitches().toc()); + wordList currInfo(debug::infoSwitches().toc()); + wordList currOpt(debug::optimisationSwitches().toc()); + + if (args.options().found("old") || args.options().found("new")) + { + dictionary controlDict(IFstream(findEtcFile("controlDict", true))()); + + wordHashSet oldDebug + ( + controlDict.subDict("DebugSwitches").toc() + ); + + wordHashSet oldInfo + ( + controlDict.subDict("InfoSwitches").toc() + ); + + wordHashSet oldOpt + ( + controlDict.subDict("OptimisationSwitches").toc() + ); + + + wordHashSet hashset; + wordList listing; + + + // list old switches - but this can't work since the (old) inserted + // switches are in both sets + // Workaround: + // 1. run without any options (get complete list) + // 2. comment out DebugSwitches, run again with -new to find new ones + // and do a diff + if (args.options().found("old")) + { + IOobject::writeDivider(Info); + + hashset = oldDebug; + hashset -= currDebug; + listing = hashset.toc(); + sort(listing); + Info<< "old DebugSwitches: " << listing << endl; + + hashset = oldInfo; + hashset -= currInfo; + listing = hashset.toc(); + sort(listing); + Info<< "old InfoSwitches: " << listing << endl; + + hashset = oldOpt; + hashset -= currOpt; + listing = hashset.toc(); + sort(listing); + Info<< "old OptimisationSwitches: " << listing << endl; + } + + // list new switches + if (args.options().found("new")) + { + IOobject::writeDivider(Info); + + hashset = currDebug; + hashset -= oldDebug; + + listing = hashset.toc(); + sort(listing); + Info<< "new DebugSwitches: " << listing << endl; + + hashset = currInfo; + hashset -= oldInfo; + listing = hashset.toc(); + sort(listing); + Info<< "new InfoSwitches: " << listing << endl; + + hashset = currOpt; + hashset -= oldOpt; + listing = hashset.toc(); + sort(listing); + Info<< "new OptimisationSwitches: " << listing << endl; + } + } + else + { + IOobject::writeDivider(Info); + + sort(currDebug); + Info<< "DebugSwitches: " << currDebug << endl; + + sort(currInfo); + Info<< "InfoSwitches: " << currInfo << endl; + + sort(currOpt); + Info<< "OptimisationSwitches: " << currOpt << endl; + } - wordList is(debug::infoSwitches().toc()); - sort(is); - Info<< "info switches: " << is << endl; - wordList os(debug::optimisationSwitches().toc()); - sort(os); - Info<< "optimisation switches: " << os << endl; Info<< "done" << endl; diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index fff19e006d..5edafcf561 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -312,7 +312,7 @@ int main(int argc, char *argv[]) fileNameList cloudDirs ( - readDir(runTime.timePath()/"lagrangian", fileName::DIRECTORY) + readDir(runTime.timePath()/cloud::prefix, fileName::DIRECTORY) ); // Particles @@ -344,7 +344,7 @@ int main(int argc, char *argv[]) ( mesh, runTime.timeName(), - "lagrangian"/cloudDirs[i] + cloud::prefix/cloudDirs[i] ); IOobject* positionsPtr = sprayObjs.lookup("positions"); @@ -418,7 +418,7 @@ int main(int argc, char *argv[]) ( mesh, runTime.timeName(), - "lagrangian"/cloudDirs[cloudI] + cloud::prefix/cloudDirs[cloudI] ); lagrangianFieldDecomposer::readFields diff --git a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposerDecomposeFields.C b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposerDecomposeFields.C index 4f11f4d53f..ae85229808 100644 --- a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposerDecomposeFields.C +++ b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposerDecomposeFields.C @@ -88,7 +88,7 @@ tmp > lagrangianFieldDecomposer::decomposeField ( field.name(), procMesh_.time().timeName(), - "lagrangian"/cloudName, + cloud::prefix/cloudName, procMesh_, IOobject::NO_READ, IOobject::NO_WRITE diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangian.H b/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangian.H index 0cefe9e641..18d282a909 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangian.H +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangian.H @@ -36,6 +36,7 @@ SourceFiles #ifndef reconstructLagrangian_H #define reconstructLagrangian_H +#include "cloud.H" #include "polyMesh.H" #include "IOobjectList.H" #include "fvMesh.H" diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangianFields.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangianFields.C index 1f357fa64f..a6fc1a49a8 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangianFields.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructLagrangianFields.C @@ -47,7 +47,7 @@ Foam::tmp > Foam::reconstructLagrangianField ( fieldName, mesh.time().timeName(), - "lagrangian"/cloudName, + cloud::prefix/cloudName, mesh, IOobject::NO_READ, IOobject::NO_WRITE @@ -61,10 +61,10 @@ Foam::tmp > Foam::reconstructLagrangianField { // Check object on local mesh IOobject localIOobject - ( + ( fieldName, meshes[i].time().timeName(), - "lagrangian"/cloudName, + cloud::prefix/cloudName, meshes[i], IOobject::MUST_READ, IOobject::NO_WRITE diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index 20def06b9c..8458e7f570 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -277,7 +277,7 @@ int main(int argc, char *argv[]) ( readDir ( - databases[procI].timePath()/regionPrefix/"lagrangian", + databases[procI].timePath()/regionPrefix/cloud::prefix, fileName::DIRECTORY ) ); @@ -295,7 +295,7 @@ int main(int argc, char *argv[]) ( procMeshes.meshes()[procI], databases[procI].timeName(), - "lagrangian"/cloudDirs[i] + cloud::prefix/cloudDirs[i] ); IOobject* positionsPtr = sprayObjs.lookup("positions"); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightCloudField.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightCloudField.H index 3e06a1674d..f6cd858dc6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightCloudField.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightCloudField.H @@ -35,6 +35,7 @@ SourceFiles #ifndef ensightCloudField_H #define ensightCloudField_H +#include "Cloud.H" #include "IOobject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C index bb7c1880f0..10d261bca5 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C @@ -211,7 +211,7 @@ int main(int argc, char *argv[]) fileNameList cloudDirs = readDir ( - runTime.timePath()/regionPrefix/"lagrangian", + runTime.timePath()/regionPrefix/cloud::prefix, fileName::DIRECTORY ); @@ -221,7 +221,7 @@ int main(int argc, char *argv[]) ( mesh, runTime.timeName(), - "lagrangian"/cloudDirs[cloudI] + cloud::prefix/cloudDirs[cloudI] ); IOobject* positionsPtr = cloudObjs.lookup("positions"); @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) ( mesh, runTime.timeName(), - "lagrangian"/cloudIter.key() + cloud::prefix/cloudIter.key() ); forAllConstIter(IOobjectList, cloudObjs, fieldIter) @@ -426,7 +426,7 @@ int main(int argc, char *argv[]) fileNameList currentCloudDirs = readDir ( - runTime.timePath()/regionPrefix/"lagrangian", + runTime.timePath()/regionPrefix/cloud::prefix, fileName::DIRECTORY ); @@ -449,7 +449,7 @@ int main(int argc, char *argv[]) ( fieldName, mesh.time().timeName(), - "lagrangian"/cloudName, + cloud::prefix/cloudName, mesh, IOobject::MUST_READ ); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputCase.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputCase.H index d8f079ea6d..0e3530b9c0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputCase.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputCase.H @@ -42,7 +42,7 @@ forAllConstIter(HashTable >, cloudFields, cloudIter) caseFile << setw(16) << "measured: 2" - << fileName(dataMask/"lagrangian"/cloudName/"positions").c_str() + << fileName(dataMask/cloud::prefix/cloudName/"positions").c_str() << nl; } caseFile @@ -122,7 +122,7 @@ forAllConstIter(HashTable >, cloudFields, cloudIter) ensightType, fieldName, dataMask, - "lagrangian"/cloudName, + cloud::prefix/cloudName, cloudNo, 2 ); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.C index ca472e073c..e62b10064c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.C @@ -27,7 +27,6 @@ License #include "ensightOutputFunctions.H" #include "passiveParticle.H" -#include "Cloud.H" #include "IOField.H" #include "volFields.H" #include "surfaceFields.H" @@ -101,7 +100,7 @@ void ensightParticlePositions { Cloud parcels(mesh, cloudName, false); - fileName cloudDir = subDir/"lagrangian"/cloudName; + fileName cloudDir = subDir/cloud::prefix/cloudName; fileName postFileName = cloudDir/"positions"; // the ITER/lagrangian subdirectory must exist @@ -165,7 +164,7 @@ void ensightLagrangianField { Info<< " " << fieldObject.name() << flush; - fileName cloudDir = subDir/"lagrangian"/cloudName; + fileName cloudDir = subDir/cloud::prefix/cloudName; fileName postFileName = cloudDir/fieldObject.name(); string title = diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.H index 7afc250fe3..75437c2d69 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/ensightOutputFunctions.H @@ -23,9 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - - miscellaneous collection of functions and template related - to Ensight data + Miscellaneous collection of functions and template related to Ensight data SourceFiles ensightOutputFunctions.C @@ -36,6 +34,7 @@ SourceFiles #define ensightOutputFunctions_H #include "ensightFile.H" +#include "Cloud.H" #include "polyMesh.H" #include "IOobject.H" diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H index cca3fbbcd3..edfbb5ae7d 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/findFields.H @@ -36,7 +36,7 @@ if (timeDirs.size() > 1) runTime.path() / timeDirs[timeDirs.size() - 1].name() / regionPrefix - / "lagrangian", + / cloud::prefix, fileName::DIRECTORY ); @@ -55,7 +55,7 @@ if (timeDirs.size() > 1) ( mesh, timeDirs[timeDirs.size() - 1].name(), - "lagrangian"/cloudName + cloud::prefix/cloudName ); bool hasPositions = false; diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C index 329dda87f9..af2dee175a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsightParts/foamToEnsightParts.C @@ -324,7 +324,14 @@ int main(int argc, char *argv[]) { const word& cloudName = cloudIter.key(); - if (!isDir(runTime.timePath()/regionPrefix/"lagrangian"/cloudName)) + if + ( + !isDir + ( + runTime.timePath()/regionPrefix/ + cloud::prefix/cloudName + ) + ) { continue; } @@ -333,7 +340,7 @@ int main(int argc, char *argv[]) ( mesh, runTime.timeName(), - "lagrangian"/cloudName + cloud::prefix/cloudName ); // check that the positions field is present for this time @@ -365,7 +372,8 @@ int main(int argc, char *argv[]) if (!fieldObject) { Info<< "missing " - << runTime.timeName()/"lagrangian"/cloudName/fieldName + << runTime.timeName()/cloud::prefix/cloudName + / fieldName << endl; continue; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/createSprayFields.H b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/createSprayFields.H index e28a04b58c..a5a218de80 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/createSprayFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/createSprayFields.H @@ -21,7 +21,7 @@ List* > sprayVectorFieldPtrs ( sprayScalarNames[fieldI], runTime.timeName(), - "lagrangian", + cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE @@ -53,7 +53,7 @@ List* > sprayVectorFieldPtrs ( sprayVectorNames[fieldI], runTime.timeName(), - "lagrangian", + cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE diff --git a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/getFieldNames.H b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/getFieldNames.H index 9a97899625..129d788738 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToFieldview9/getFieldNames.H +++ b/applications/utilities/postProcessing/dataConversion/foamToFieldview9/getFieldNames.H @@ -42,7 +42,7 @@ forAll(Times, timeI) // Same for spray - IOobjectList sprayObjects(mesh, runTime.timeName(), "lagrangian"); + IOobjectList sprayObjects(mesh, runTime.timeName(), cloud::prefix); { wordList fieldNames(sprayObjects.names(scalarIOField::typeName)); forAll(fieldNames, fieldI) diff --git a/applications/utilities/postProcessing/dataConversion/foamToGMV/foamToGMV.C b/applications/utilities/postProcessing/dataConversion/foamToGMV/foamToGMV.C index b32952e9bb..6c7e23ebae 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToGMV/foamToGMV.C +++ b/applications/utilities/postProcessing/dataConversion/foamToGMV/foamToGMV.C @@ -44,21 +44,21 @@ Description int main(int argc, char *argv[]) { const label nTypes = 4; - const word fieldTypes[] = - { - "volScalarField", - "volVectorField", + const word fieldTypes[] = + { + "volScalarField", + "volVectorField", "surfaceScalarField", - "lagrangian" + cloud::prefix }; # include "setRootCase.H" - + # include "createTime.H" # include "createMesh.H" # include "readConversionProperties.H" - + // get the available time-steps instantList TimeList = runTime.times(); Info << TimeList << endl; @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) // Set Time runTime.setTime(TimeList[n], n); word CurTime = runTime.timeName(); - + IOobjectList objects(mesh, runTime.timeName()); # include "moveMesh.H" @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) // set the filename of the GMV file fileName gmvFileName = "plotGMV." + itoa(n); OFstream gmvFile(args.rootPath()/args.caseName()/gmvFileName); - + # include "gmvOutputHeader.H" # include "gmvOutput.H" # include "gmvOutputTail.H" diff --git a/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutput.H b/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutput.H index 76f834c431..03523ed2de 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutput.H +++ b/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutput.H @@ -1,14 +1,14 @@ -for(label i=0; i < nTypes; i++) +for (label i=0; i < nTypes; i++) { wordList fieldNames = objects.names(fieldTypes[i]); - if ( fieldTypes[i] == "volScalarField" ) + if (fieldTypes[i] == "volScalarField") { gmvFile << "variable" << nl; } - for(label j=0; j < fieldNames.size(); j++) + for (label j=0; j < fieldNames.size(); j++) { - + word fieldName = fieldNames[j]; IOobject fieldObject @@ -19,8 +19,8 @@ for(label i=0; i < nTypes; i++) IOobject::MUST_READ, IOobject::NO_WRITE ); - - if ( fieldTypes[i] == "volScalarField" ) + + if (fieldTypes[i] == "volScalarField") { volScalarField gmvScalarField(fieldObject, mesh); gmvFile << fieldName << " 0" << nl; @@ -30,43 +30,43 @@ for(label i=0; i < nTypes; i++) } gmvFile << nl; } - - if ( fieldTypes[i] == "volVectorField" ) + + if (fieldTypes[i] == "volVectorField") { if (fieldName == vComp) { volVectorField gmvVectorField(fieldObject, mesh); gmvFile << "velocity 0" << nl; - for(label indx=0;indx particles(mesh); - - IOobjectList objects(mesh, runTime.timeName(), "lagrangian"); - + + IOobjectList objects(mesh, runTime.timeName(), cloud::prefix); + wordList lagrangianScalarNames = objects.names("scalarField"); wordList lagrangianVectorNames = objects.names("vectorField"); @@ -87,7 +87,7 @@ for(label i=0; i < nTypes; i++) } } - if ( fieldTypes[i] == "volScalarField" ) + if (fieldTypes[i] == "volScalarField") { gmvFile << "endvars" << nl; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputLagrangian.H b/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputLagrangian.H index 89c126c1e3..a99b94133e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputLagrangian.H +++ b/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputLagrangian.H @@ -42,7 +42,7 @@ forAll(lagrangianScalarNames, i) ( name, runTime.timeName(), - "lagrangian", + cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE @@ -73,7 +73,7 @@ forAll(lagrangianVectorNames, i) ( name, runTime.timeName(), - "lagrangian", + cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE diff --git a/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputSpray.H b/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputSpray.H index f5d5b3c8c6..3c4f629235 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputSpray.H +++ b/applications/utilities/postProcessing/dataConversion/foamToGMV/gmvOutputSpray.H @@ -40,7 +40,7 @@ forAll(lagrangianScalarNames, i) ( name, runTime.timeName(), - "lagrangian", + cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index e03c76c057..793e18c05b 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -914,7 +914,7 @@ int main(int argc, char *argv[]) ( readDir ( - runTime.timePath()/regionPrefix/"lagrangian", + runTime.timePath()/regionPrefix/cloud::prefix, fileName::DIRECTORY ) ); @@ -925,18 +925,18 @@ int main(int argc, char *argv[]) ( mesh, runTime.timeName(), - "lagrangian"/cloudDirs[i] + cloud::prefix/cloudDirs[i] ); IOobject* positionsPtr = sprayObjs.lookup("positions"); if (positionsPtr) { - mkDir(fvPath/"lagrangian"/cloudDirs[i]); + mkDir(fvPath/cloud::prefix/cloudDirs[i]); fileName lagrFileName ( - fvPath/"lagrangian"/cloudDirs[i]/cloudDirs[i] + fvPath/cloud::prefix/cloudDirs[i]/cloudDirs[i] + "_" + name(timeI) + ".vtk" ); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.H index 8923ba8590..bd13ec2571 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriter.H @@ -39,6 +39,7 @@ SourceFiles #include "globalPointPatch.H" #include "OFstream.H" +#include "Cloud.H" #include "volFields.H" #include "pointFields.H" #include "vtkMesh.H" diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriterTemplates.C index 37c8051383..0407a58841 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/lagrangianWriterTemplates.C @@ -41,7 +41,7 @@ void Foam::lagrangianWriter::writeIOField(const wordList& objects) ( object, vMesh_.mesh().time().timeName(), - "lagrangian"/cloudName_, + cloud::prefix/cloudName_, vMesh_.mesh(), IOobject::MUST_READ, IOobject::NO_WRITE, diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index 927415c005..59e7e86b59 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -58,6 +58,11 @@ SourceFiles #ifndef vtkPV3Foam_H #define vtkPV3Foam_H +// do not include legacy strstream headers +#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS +# define VTK_EXCLUDE_STRSTREAM_HEADERS +#endif + #include "className.H" #include "fileName.H" #include "stringList.H" diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C index 9708df9ac1..38cc52f680 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C @@ -266,7 +266,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields ( mesh, dbPtr_().timeName(), - "lagrangian"/cloudName + cloud::prefix/cloudName ); pruneObjectList(objects, selectedFields); diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H index ade6112e61..58422d69f4 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H @@ -30,6 +30,8 @@ InClass #ifndef vtkPV3FoamLagrangianFields_H #define vtkPV3FoamLagrangianFields_H +#include "Cloud.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C index bfcffeb787..07d322d542 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C @@ -53,7 +53,7 @@ vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh if (debug) { Info<< " Foam::vtkPV3Foam::lagrangianVTKMesh - timePath " - << mesh.time().timePath()/"lagrangian"/cloudName << endl; + << mesh.time().timePath()/cloud::prefix/cloudName << endl; printMemory(); } @@ -63,7 +63,7 @@ vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh ( mesh, mesh.time().timeName(), - "lagrangian"/cloudName + cloud::prefix/cloudName ); IOobject* positionsPtr = sprayObjs.lookup("positions"); diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C index e587c0cb1f..310a12efdf 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C +++ b/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C @@ -34,6 +34,7 @@ License #include "IOPtrList.H" #include "polyBoundaryMeshEntries.H" #include "entry.H" +#include "Cloud.H" #include "vtkPV3FoamReader.h" // local headers @@ -148,16 +149,16 @@ void Foam::vtkPV3Foam::updateInfoLagrangian() if (debug) { Info<< " Foam::vtkPV3Foam::updateInfoLagrangian" << nl - << " " << dbPtr_->timePath()/"lagrangian" << endl; + << " " << dbPtr_->timePath()/cloud::prefix << endl; } // use the db directly since this might be called without a mesh, // but the region must get added back in - fileName lagrangianPrefix("lagrangian"); + fileName lagrangianPrefix(cloud::prefix); if (meshRegion_ != polyMesh::defaultRegion) { - lagrangianPrefix = meshRegion_/"lagrangian"; + lagrangianPrefix = meshRegion_/cloud::prefix; } // Search for list of lagrangian objects for this time @@ -463,10 +464,10 @@ void Foam::vtkPV3Foam::updateInfoLagrangianFields() // use the db directly since this might be called without a mesh, // but the region must get added back in - fileName lagrangianPrefix("lagrangian"); + fileName lagrangianPrefix(cloud::prefix); if (meshRegion_ != polyMesh::defaultRegion) { - lagrangianPrefix = meshRegion_/"lagrangian"; + lagrangianPrefix = meshRegion_/cloud::prefix; } IOobjectList objects diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_gold_part_build_info.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_gold_part_build_info.H index 70d5c9f2a7..ca8da4727c 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_gold_part_build_info.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_get_gold_part_build_info.H @@ -35,7 +35,7 @@ int USERD_get_gold_part_build_info for(label i=0; iboundary()[i].name()); - strncpy(part_descriptions[i+1], patchName.c_str(), Z_BUFL); + strncpy(part_descriptions[i+1], patchName.c_str(), Z_BUFL); } label nHex08 = 0; @@ -101,7 +101,7 @@ int USERD_get_gold_part_build_info */ number_of_nodes[0] = meshPtr->nPoints(); - + const polyBoundaryMesh& bMesh = meshPtr->boundaryMesh(); for(label i=0; i nPatches+1) { - strncpy(part_descriptions[nPatches+1], sprayName.c_str(), Z_BUFL); + strncpy + ( + part_descriptions[nPatches+1], + cloud::prefix.c_str(), + Z_BUFL + ); number_of_elements[nPatches+1][Z_POINT] = sprayPtr->size(); number_of_nodes[nPatches+1] = sprayPtr->size(); } diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_set_filenames.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_set_filenames.H index 90f2d3f415..83303fef71 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_set_filenames.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/USERD_set_filenames.H @@ -164,7 +164,7 @@ int USERD_set_filenames ( "positions", runTime.timeName(), - "lagrangian", + cloud::prefix, runTime, IOobject::NO_READ, IOobject::NO_WRITE, @@ -179,7 +179,7 @@ int USERD_set_filenames sprayPtr = new Cloud(*meshPtr); - IOobjectList objects(*meshPtr, runTime.timeName(), "lagrangian"); + IOobjectList objects(*meshPtr, runTime.timeName(), cloud::prefix); lagrangianScalarNames = (const wordList&)objects.names(sprayScalarFieldName); diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/getLagrangianScalar.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/getLagrangianScalar.H index e9259e3cc7..39ccf6c07f 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/getLagrangianScalar.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/getLagrangianScalar.H @@ -12,7 +12,7 @@ if (nVar >= 0) ( name, runTime.timeName(), - "lagrangian", + cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/getLagrangianVector.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/getLagrangianVector.H index 42fcc8560f..80c71ba028 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/getLagrangianVector.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/getLagrangianVector.H @@ -14,7 +14,7 @@ if (nVar >= 0) ( name, runTime.timeName(), - "lagrangian", + cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE diff --git a/applications/utilities/postProcessing/graphics/ensightFoamReader/globalFoam.H b/applications/utilities/postProcessing/graphics/ensightFoamReader/globalFoam.H index 4606671860..d68861b138 100644 --- a/applications/utilities/postProcessing/graphics/ensightFoamReader/globalFoam.H +++ b/applications/utilities/postProcessing/graphics/ensightFoamReader/globalFoam.H @@ -32,7 +32,6 @@ static bool isSpray[maxNames]; static word scalarName = "volScalarField"; static word vectorName = "volVectorField"; static word tensorName = "volTensorField"; -static word sprayName = "lagrangian"; static word sprayScalarFieldName = "scalarField"; static word sprayVectorFieldName = "vectorField"; static word sprayTensorFieldName = "tensorField"; diff --git a/applications/utilities/postProcessing/sampling/sample/Make/options b/applications/utilities/postProcessing/sampling/sample/Make/options index 04b22c08a4..ae583f3388 100644 --- a/applications/utilities/postProcessing/sampling/sample/Make/options +++ b/applications/utilities/postProcessing/sampling/sample/Make/options @@ -2,6 +2,7 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude @@ -9,5 +10,6 @@ EXE_LIBS = \ -lfiniteVolume \ -lmeshTools \ -lsampling \ + -lsurfMesh \ -ltriSurface \ -llagrangian diff --git a/applications/utilities/postProcessing/sampling/sample/sample.C b/applications/utilities/postProcessing/sampling/sample/sample.C index 2735ed2dff..2451522ffe 100644 --- a/applications/utilities/postProcessing/sampling/sample/sample.C +++ b/applications/utilities/postProcessing/sampling/sample/sample.C @@ -40,6 +40,7 @@ Description - dx : DX scalar or vector format - vtk : VTK ascii format - raw : x y z value format for use with e.g. gnuplot 'splot'. + - obj : Wavefron stl. Does not contain values! - stl : ascii stl. Does not contain values! @param interpolationScheme : interpolation scheme, choice of \n diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index 215add79a7..559eb28436 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -30,7 +30,10 @@ setFormat raw; // dx : DX scalar or vector format // vtk : VTK ascii format // raw : x y z value format for use with e.g. gnuplot 'splot'. -// stl : ascii stl. Does not contain values! +// +// Note: +// other formats such as obj, stl, etc can also be written (by proxy) +// but without any values! surfaceFormat vtk; // interpolationScheme. choice of diff --git a/applications/utilities/preProcessing/mapFields/MapLagrangianFields.H b/applications/utilities/preProcessing/mapFields/MapLagrangianFields.H index 830d6d825d..176a25f0f7 100644 --- a/applications/utilities/preProcessing/mapFields/MapLagrangianFields.H +++ b/applications/utilities/preProcessing/mapFields/MapLagrangianFields.H @@ -34,6 +34,7 @@ Description #ifndef MapLagrangianFields_H #define MapLagrangianFields_H +#include "cloud.H" #include "GeometricField.H" #include "meshToMesh.H" #include "IOobjectList.H" @@ -60,8 +61,7 @@ void MapLagrangianFields forAllIter(IOobjectList, fields, fieldIter) { - Info<< " mapping lagrangian field " - << fieldIter()->name() << endl; + Info<< " mapping lagrangian field " << fieldIter()->name() << endl; // Read field (does not need mesh) IOField fieldSource(*fieldIter()); @@ -73,7 +73,7 @@ void MapLagrangianFields ( fieldIter()->name(), meshTarget.time().timeName(), - "lagrangian"/cloudName, + cloud::prefix/cloudName, meshTarget, IOobject::NO_READ, IOobject::NO_WRITE, diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C index e57aa9761c..9d04dcfbec 100644 --- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.C @@ -94,7 +94,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp) ( readDir ( - meshSource.time().timePath()/"lagrangian", + meshSource.time().timePath()/cloud::prefix, fileName::DIRECTORY ) ); @@ -106,7 +106,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp) ( meshSource, meshSource.time().timeName(), - "lagrangian"/cloudDirs[cloudI] + cloud::prefix/cloudDirs[cloudI] ); IOobject* positionsPtr = objects.lookup("positions"); diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C index ccd85d8e5a..f245e4088b 100644 --- a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C +++ b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C @@ -271,13 +271,57 @@ int main(int argc, char *argv[]) args.caseName() ); + // start with "constant" + runTime.setTime(instant(0, runTime.constant()), 0); + + Info<< "runTime.instance() = " << runTime.instance() << endl; + Info<< "runTime.timeName() = " << runTime.timeName() << endl; + + + Info<< "write MeshedSurface 'yetAnother' via proxy as surfMesh" + << endl; + surf.write + ( + runTime, + "yetAnother" + ); + + surfMesh surfIn + ( + IOobject + ( + "default", + runTime.timeName(), + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + + MeshedSurface surfIn2(runTime, "foobar"); + + Info<<"surfIn2 = " << surfIn2.size() << endl; + + Info<< "surfIn = " << surfIn.size() << endl; + + + Info<< "writing surfMesh as obj = oldSurfIn.obj" << endl; + surfIn.write("oldSurfIn.obj"); + + + Info<< "runTime.instance() = " << runTime.instance() << endl; + surfMesh surfOut ( IOobject ( "mySurf", runTime.instance(), - runTime + runTime, + IOobject::NO_READ, + IOobject::NO_WRITE, + false ), surf.xfer() ); @@ -299,6 +343,25 @@ int main(int argc, char *argv[]) dimless ); + Info<<" surf name= " << surfOut.name() < 0; + CentredFitData 0; + CentredFitData 0; + CentredFitData 0; ChomiakInjector 0; + Cloud 0; + Cloud 0; + Cloud 0; Cloud 0; - Cloud 0; Cloud 0; Cloud 0; - Cloud 0; - Cloud 0; Cloud 0; CoEuler 0; CompositionModel 0; + ConeInjection 0; + Constant 0; ConstantRateDevolatilisation 0; CrankNicholson 0; CrossPowerLaw 0; @@ -77,6 +85,7 @@ DebugSwitches DICGaussSeidel 0; DILU 0; DILUGaussSeidel 0; + DataEntry 0; DeardorffDiffStress 0; DispersionModel 0; DispersionRASModel 0; @@ -107,39 +116,40 @@ DebugSwitches H2O 0; HashTable 0; HeatTransferModel 0; + HerschelBulkley 0; HrenyaSinclair 0; IC8H18 0; ICCG 0; + IDDESDelta 0; IDEA 0; IFstream 0; + IOMap 0; IOPtrList 0; IOPtrList 0; IOPtrList 0; IOPtrList 0; IOobject 0; InjectionModel 0; + IntegrationScheme 0; JohnsonJackson 0; KRR4 0; - KinematicCloud 0; - KinematicCloud 0; - KinematicCloud 0; - KinematicParcel 0; - KinematicParcel 0; + KinematicCloud 0; + KinematicCloud 0; + KinematicCloud 0; + KinematicParcel 0; + KinematicParcel 0; + LESModel 0; LESdelta 0; LESfilter 0; - LESmodel 0; LISA 0; LRR 0; LRRDiffStress 0; LamBremhorstKE 0; LaunderGibsonRSTM 0; LaunderSharmaKE 0; - LduMatrix 1; LienCubicKE 0; LienCubicKELowRe 0; LienLeschzinerLowRe 0; - Lun 0; - LunSavage 0; MB 0; MC 0; MCV 0; @@ -191,11 +201,12 @@ DebugSwitches QUICK 0; QUICKV 0; QZeta 0; + RASModel 0; RK 0; RNGkEpsilon 0; RanzMarshall 0; - ReactingCloud 0; - ReactingParcel 0; + ReactingCloud 0; + ReactingParcel 0; Rebound 0; ReitzDiwakar 0; ReitzKHRT 0; @@ -208,6 +219,8 @@ DebugSwitches SIBS 0; SKA 0; SLTS 0; + SRFModel 0; + SRFVelocity 0; STARCDRotation 0; Schaeffer 0; SchillerNaumann 0; @@ -215,8 +228,9 @@ DebugSwitches SingleKineticRateDevolatilisation 0; SingleMixtureFraction 0; Smagorinsky 0; - SmoothSolver 0; SpalartAllmaras 0; + SpalartAllmarasDDES 0; + SpalartAllmarasIDDES 0; SphereDrag 0; StandardWallInteraction 0; StaticHashTable 0; @@ -228,13 +242,17 @@ DebugSwitches SyamlalOBrien 0; SyamlalRogersOBrien 0; TAB 0; - ThermoCloud 0; - ThermoCloud 0; - ThermoParcel 0; - ThermoParcel 0; + Table 0; + ThermoCloud 0; + ThermoCloud 0; + ThermoParcel 0; + ThermoParcel 0; UMIST 0; UMISTV 0; Unix 0; + UpwindFitData 0; + UpwindFitData 0; + UpwindFitData 0; WallInteractionModel 0; WenYu 0; aC11H10 0; @@ -245,6 +263,9 @@ DebugSwitches addPoint 0; advective 0; algebraicPair 0; + alphaContactAngle 0; + alphaFixedPressure 0; + alphatWallFunction 0; angularOscillatingDisplacement 0; angularOscillatingVelocity 0; anisotropic 0; @@ -252,14 +273,21 @@ DebugSwitches atomizationModel 0; attachDetach 0; autoHexMeshDriver 0; + autoLayerDriver 0; + autoRefineDriver 0; + autoSnapDriver 0; bC11H10 0; backward 0; basePatch 0; basicKinematicCloud 0; + basicKinematicParcel 0; basicMixture 0; basicReactingCloud 0; + basicReactingParcel 0; basicThermo 0; basicThermoCloud 0; + basicThermoParcel 0; + biLinearFit 0; binaryAbsorptionEmission 0; blended 0; blobsSheetAtomization 0; @@ -274,7 +302,6 @@ DebugSwitches boxToPoint 0; breakupModel 0; calculated 0; - cartesian 0; cell 0; cellClassification 0; cellCuts 0; @@ -292,6 +319,8 @@ DebugSwitches cellToFace 0; cellToPoint 0; cellZone 0; + centredCECStencil 0; + centredCFCStencil 0; chemistryReader 0; chemistrySolver 0; chemkinReader 0; @@ -304,24 +333,25 @@ DebugSwitches commSchedule 0; commonRailInjector 0; compound 0; - conductivityModel 0; constInjector 0; constant 0; constantAbsorptionEmission 0; - constantGammaContactAngle 0; + constantAlphaContactAngle 0; constantScatter 0; coordinateRotation 0; coordinateSystem 0; + coordinateSystems 0; corrected 0; coupled 0; cubeRootVol 0; cubic 0; + cubicUpwindFit 0; curve 0; cyclic 0; cyclicLduInterface 0; cyclicLduInterfaceField 0; + cylinderToCell 0; cylindrical 0; - dataSchedule 0; decompositionMethod 0; definedHollowConeInjector 0; definedInjector 0; @@ -332,6 +362,7 @@ DebugSwitches dimensionSet 1; directMapped 0; directMappedPatch 0; + directMappedVelocityFlux 0; directionMixed 0; directional 0; disallowDefaultFvsPatchField 0; @@ -345,6 +376,7 @@ DebugSwitches displacementInterpolation 0; displacementLaplacian 0; displacementSBRStress 0; + distanceSurface 0; downwind 0; dragModel 0; duplicatePoints 0; @@ -352,8 +384,8 @@ DebugSwitches dynMixedSmagorinsky 0; dynOneEqEddy 0; dynSmagorinsky 0; + dynamicAlphaContactAngle 0; dynamicFvMesh 0; - dynamicGammaContactAngle 0; dynamicInkJetFvMesh 0; dynamicMotionSolverFvMesh 0; dynamicRefineFvMesh 0; @@ -363,6 +395,7 @@ DebugSwitches empty 0; engineMesh 0; enrichedPatch 0; + epsilonWallFunction 0; errorDrivenRefinement 0; evaporationModel 0; exponential 0; @@ -387,13 +420,20 @@ DebugSwitches filteredLinear 0; filteredLinear2 0; filteredLinear2V 0; + filteredLinear3 0; + filteredLinear3V 0; fixedEnthalpy 0; fixedFluxBuoyantPressure 0; + fixedFluxBoussinesqBuoyantPressure 0; fixedFluxPressure 0; fixedGradient 0; + fixedInternalEnergy 0; + fixedInternalValue 0; fixedNormalSlip 0; + fixedPressureCompressibleDensity 0; fixedUnburntEnthalpy 0; fixedValue 0; + flowRateInletVelocity 0; fluxCorrectedVelocity 0; foamChemistryReader 0; foamFile 0; @@ -416,8 +456,6 @@ DebugSwitches fvTensorMatrix 0; fvVectorMatrix 0; fvsPatchField 0; - gammaContactAngle 0; - gammaFixedPressure 0; general 0; generic 0; genericPatch 0; @@ -429,6 +467,7 @@ DebugSwitches gnuplot 0; gradientDispersionRAS 0; gradientEnthalpy 0; + gradientInternalEnergy 0; gradientUnburntEnthalpy 0; granularPressureModel 0; hCombustionThermo 0; @@ -459,25 +498,29 @@ DebugSwitches hhuMixtureThermo>>>> 0; hierarchical 0; hollowConeInjector 0; + iC3H8O 0; indexedOctree 0; indexedParticle 0; injectorModel 0; injectorType 0; inletOutlet 0; inletOutletTotalTemperature 0; - inputMode 0; interfaceCompression 0; intersectedSurface 0; inverseDistance 0; inverseFaceDistance 0; inversePointDistance 0; inverseVolume 0; + isoSurface 0; + isoSurfaceCell 0; jplot 0; jumpCyclic 0; kEpsilon 0; + kOmega 0; kOmegaSST 0; + kOmegaSSTSAS 0; + kQRWallFunction 0; kinematicCloud 0; - kinematicParcel 0; labelField 0; labelList 0; labelListList 0; @@ -496,6 +539,7 @@ DebugSwitches leastSquares 0; leastSquaresVectors 0; level 2; + limitWith 0; limited 0; limitedCubic 0; limitedCubic01 0; @@ -510,6 +554,7 @@ DebugSwitches limitedSurfaceInterpolationScheme 0; limitedVanLeer 0; linear 0; + linearFit 0; linearUpwind 0; linearUpwindV 0; liquid 0; @@ -520,7 +565,6 @@ DebugSwitches localPointRegion 0; lowReOneEqEddy 0; manual 0; - massFlowRateInletVelocity 0; meshCutAndRemove 0; meshCutter 0; meshModifier 0; @@ -532,6 +576,7 @@ DebugSwitches midPointAndFace 0; mixed 0; mixedEnthalpy 0; + mixedInternalEnergy 0; mixedSmagorinsky 0; mixedUnburntEnthalpy 0; mixerFvMesh 0; @@ -544,22 +589,32 @@ DebugSwitches motionSolver 0; movingConeTopoFvMesh 0; movingWallVelocity 0; - muSgsWallFunction 0; + muSgsSpalartAllmarasWallFunction 0; multiDirRefinement 0; + multiHoleInjector 0; multivariateSelection 0; - mutStandardRoughWallFunction 0; + mutRoughWallFunction 0; + mutSpalartAllmarasStandardRoughWallFunction 0; + mutSpalartAllmarasStandardWallFunction 0; + mutSpalartAllmarasWallFunction 0; + mutWallFunction 0; + nC3H8O 0; nbrToCell 0; nearestToCell 0; + nearestToPoint 0; noAbsorptionEmission 0; noDragModel 0; noRadiation 0; none 0; normal 0; normalToFace 0; - nuSgsWallFunction 0; - nutStandardRoughWallFunction 0; - nutStandardWallFunction 0; + nuSgsSpalartAllmarasWallFunction 0; + nutRoughWallFunction 0; + nutSpalartAllmarasStandardRoughWallFunction 0; + nutSpalartAllmarasStandardWallFunction 0; + nutSpalartAllmarasWallFunction 0; nutWallFunction 0; + obj 0; objectRegistry 0; octree 0; octreeDataEdges 0; @@ -567,7 +622,7 @@ DebugSwitches octreeDataFaceList 0; octreeDataTriSurface 0; off 0; - offsetTriSurfaceMesh 0; + omegaWallFunction 0; oneEqEddy 0; orientedSurface 0; oscillatingDisplacement 0; @@ -609,11 +664,13 @@ DebugSwitches polyMeshInfo 0; polyTopoChange 0; polyTopoChanger 0; + powerLaw 0; pressureDirectedInletOutletVelocity 0; pressureDirectedInletVelocity 0; pressureInletOutletVelocity 0; pressureInletUniformVelocity 0; pressureInletVelocity 0; + pressureNormalInletOutletVelocity 0; pressureSwirlInjector 0; primitiveMesh 0; primitiveMeshGeometry 0; @@ -625,11 +682,13 @@ DebugSwitches pureMixture>>> 0; pureMixture>>> 0; quadratic 0; - radialModel 0; + quadraticFit 0; + quadraticLinearFit 0; + quadraticLinearUpwindFit 0; + quadraticUpwindFit 0; radiationModel 0; raw 0; reactingCloud 0; - reactingParcel 0; reaction 0; realizableKE 0; refinementHistory 0; @@ -637,6 +696,7 @@ DebugSwitches reflect 0; regIOobject 0; regionSplit 0; + regionToCell 0; remove 0; removeCell 0; removeCells 0; @@ -720,11 +780,12 @@ DebugSwitches tensorAverageField 0; tensorField 0; thermoCloud 0; - thermoParcel 0; thermophysicalFunction 0; time 0; - timeVaryingGammaContactAngle 0; + timeVaryingAlphaContactAngle 0; + timeVaryingFlowRateInletVelocity 0; timeVaryingMappedFixedValue 0; + timeVaryingTotalPressure 0; timeVaryingUniformFixedValue 0; timer 0; topoAction 0; @@ -745,17 +806,19 @@ DebugSwitches treeNode 0; triSurface 0; triSurfaceMesh 0; - triSurfaceMeshes 0; turbulenceModel 0; + turbulentHeatFluxTemperature 0; turbulentInlet 0; turbulentIntensityKineticEnergyInlet 0; turbulentMixingLengthDissipationRateInlet 0; + turbulentMixingLengthFrequencyInlet 0; uncorrected 0; undoableMeshCutter 0; uniform 0; uniformFixedValue 0; unitInjector 0; upwind 0; + upwindCFCStencil 0; value 0; vanAlbada 0; vanAlbadaV 0; @@ -817,31 +880,30 @@ DimensionedConstants // SI units //- Universal gas constant [J/(kmol K)] - R 8314.51; + R 8314.51; //- Standard pressure [Pa] - Pstd 1.0e5; + Pstd 1.0e5; //- Standard temperature [K] - Tstd 298.15; + Tstd 298.15; //- Stefan-Boltzmann constant [J/(K4 m2 s)] - sigmaSB sigmaSB [1 0 -3 -4 0 0 0] 5.670e-08; - + sigmaSB sigmaSB [1 0 -3 -4 0 0 0] 5.670e-08; /* USCS units //- Universal gas constant [lbm ft2/(s2 kmol R)] - R 3406.78; + R 3406.78; //- Standard pressure [lbm/(ft2)] - Pstd 2088.6; + Pstd 2088.6; //- Standard temperature [degR] - Tstd 536.67; + Tstd 536.67; //- Stefan-Boltzmann constant [lbm /(degR4 ft s)] - sigmaSB sigmaSB [1 0 -3 -4 0 0 0] 8.2292e-08; + sigmaSB sigmaSB [1 0 -3 -4 0 0 0] 8.2292e-08; */ } diff --git a/etc/settings.csh b/etc/settings.csh index a38ec5eacd..688ade5408 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -87,8 +87,8 @@ switch ("$compilerInstall") case OpenFOAM: switch ("$WM_COMPILER") case Gcc: - setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH - _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + setenv WM_COMPILER_DIR $WM_THIRD_PARTY_DIR/gcc-4.3.3/platforms/$WM_ARCH$WM_COMPILER_ARCH + _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib breaksw case Gcc42: diff --git a/etc/settings.sh b/etc/settings.sh index 7df3f6d590..240b0036a0 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -111,8 +111,8 @@ case "$compilerInstall" in OpenFOAM) case "$WM_COMPILER" in Gcc) - export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH - _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.3.2/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib + export WM_COMPILER_DIR=$WM_THIRD_PARTY_DIR/gcc-4.3.3/platforms/$WM_ARCH$WM_COMPILER_ARCH + _foamAddLib $WM_THIRD_PARTY_DIR/mpfr-2.4.1/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib _foamAddLib $WM_THIRD_PARTY_DIR/gmp-4.2.4/platforms/$WM_ARCH$WM_COMPILER_ARCH/lib ;; Gcc42) diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index c3b09850f9..055f785471 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -152,17 +152,12 @@ inline void Foam::FixedList::checkSize(const label size) const } -// Check index i is within valid range (0 ... size-1). +// Check index i is within valid range (0 ... size-1) +// The check for zero-sized list is already done in static assert template inline void Foam::FixedList::checkIndex(const label i) const { - if (!Size) - { - FatalErrorIn("FixedList::checkIndex(const label)") - << "attempt to access element from zero-sized list" - << abort(FatalError); - } - else if (i < 0 || i >= label(Size)) + if (i < 0 || unsigned(i) >= Size) { FatalErrorIn("FixedList::checkIndex(const label)") << "index " << i << " out of range 0 ... " << (Size-1) diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index a3c17a4890..6d20e2b3b7 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -58,10 +58,6 @@ Foam::List::List(const label s) { this->v_ = new T[this->size_]; } - else - { - this->v_ = 0; - } } @@ -87,10 +83,6 @@ Foam::List::List(const label s, const T& a) List_ELEM((*this), vp, i) = a; List_END_FOR_ALL } - else - { - this->v_ = 0; - } } @@ -119,16 +111,12 @@ Foam::List::List(const List& a) List_END_FOR_ALL } } - else - { - this->v_ = 0; - } } // Construct by transferring the parameter contents template -Foam::List::List(const Xfer >& lst) +Foam::List::List(const Xfer< List >& lst) { transfer(lst()); } @@ -165,10 +153,6 @@ Foam::List::List(List& a, bool reUse) List_END_FOR_ALL } } - else - { - this->v_ = 0; - } } @@ -188,10 +172,6 @@ Foam::List::List(const UList& a, const unallocLabelList& map) List_ELEM((*this), vp, i) = List_ELEM(a, ap, (map[i])); List_END_FOR_ALL } - else - { - this->v_ = 0; - } } @@ -234,7 +214,7 @@ Foam::List::List(const FixedList& lst) : UList(NULL, Size) { - if (Size) + if (this->size_) { this->v_ = new T[this->size_]; @@ -243,10 +223,6 @@ Foam::List::List(const FixedList& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } @@ -265,10 +241,6 @@ Foam::List::List(const PtrList& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } @@ -293,10 +265,6 @@ Foam::List::List(const SLList& lst) this->operator[](i++) = iter(); } } - else - { - this->v_ = 0; - } } @@ -315,10 +283,6 @@ Foam::List::List(const IndirectList& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } @@ -337,10 +301,6 @@ Foam::List::List(const UIndirectList& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } @@ -359,10 +319,6 @@ Foam::List::List(const BiIndirectList& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H index c762bdba7d..ec6a1b9fd6 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H @@ -26,8 +26,8 @@ Class Foam::UIndirectList Description - A List with indirect addressing. Like IndirectList but does not store - addressing. + A List with indirect addressing. + Like IndirectList but does not store addressing. SourceFiles UIndirectListI.H @@ -44,8 +44,12 @@ SourceFiles namespace Foam { +// Forward declaration of friend functions and operators +template class UIndirectList; +template Ostream& operator<<(Ostream&, const UIndirectList&); + /*---------------------------------------------------------------------------*\ - Class UIndirectList Declaration + Class UIndirectList Declaration \*---------------------------------------------------------------------------*/ template @@ -92,6 +96,17 @@ public: //- Assignment of all entries to the given value inline void operator=(const T&); + + // Ostream operator + + //- Write UIndirectList to Ostream + // Binary output is currently still a bit of a problem + friend Ostream& operator<< + #ifndef __CINT__ + + #endif + (Ostream&, const UIndirectList&); + }; @@ -103,6 +118,10 @@ public: #include "UIndirectListI.H" +#ifdef NoRepository +# include "UIndirectListIO.C" +#endif + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C new file mode 100644 index 0000000000..0c3be0e769 --- /dev/null +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "UIndirectList.H" +#include "Ostream.H" +#include "token.H" +#include "contiguous.H" + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Foam::Ostream& os, + const Foam::UIndirectList& L +) +{ + // Write list contents depending on data format + if (os.format() == IOstream::ASCII || !contiguous()) + { + bool uniform = false; + + if (L.size() > 1 && contiguous()) + { + uniform = true; + + forAll(L, i) + { + if (L[i] != L[0]) + { + uniform = false; + break; + } + } + } + + if (uniform) + { + // Write size and start delimiter + os << L.size() << token::BEGIN_BLOCK; + + // Write contents + os << L[0]; + + // Write end delimiter + os << token::END_BLOCK; + } + else if (L.size() < 11 && contiguous()) + { + // Write size and start delimiter + os << L.size() << token::BEGIN_LIST; + + // Write contents + forAll(L, i) + { + if (i) os << token::SPACE; + os << L[i]; + } + + // Write end delimiter + os << token::END_LIST; + } + else + { + // Write size and start delimiter + os << nl << L.size() << nl << token::BEGIN_LIST; + + // Write contents + forAll(L, i) + { + os << nl << L[i]; + } + + // Write end delimiter + os << nl << token::END_LIST << nl; + } + } + else + { + // this is annoying, and wasteful, but there's currently no alternative + + os << nl << L.size() << nl; + + if (L.size()) + { + List lst = L(); + + os.write + ( + reinterpret_cast(lst.cdata()), + lst.byteSize() + ); + } + } + + // Check state of IOstream + os.check("Ostream& operator<<(Ostream&, const UIndirectList&)"); + + return os; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index d2fc9a6ba1..5fc5a839b1 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -359,6 +359,10 @@ public: template static inline Stream& writeDivider(Stream& os); + //- Write the standard end file divider + template + static inline Stream& writeEndDivider(Stream& os); + //- Write header bool writeHeader(Ostream&) const; diff --git a/src/OpenFOAM/db/IOobject/IOobjectI.H b/src/OpenFOAM/db/IOobject/IOobjectI.H index 71af2039f6..4ac1df926b 100644 --- a/src/OpenFOAM/db/IOobject/IOobjectI.H +++ b/src/OpenFOAM/db/IOobject/IOobjectI.H @@ -82,5 +82,14 @@ inline Stream& Foam::IOobject::writeDivider(Stream& os) return os; } +template +inline Stream& Foam::IOobject::writeEndDivider(Stream& os) +{ + os << "\n\n" + "// ************************************************************************* //\n"; + + return os; +} + // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/readHexLabel.H b/src/OpenFOAM/db/IOstreams/Sstreams/readHexLabel.H index fffccc4525..37811c0d67 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/readHexLabel.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/readHexLabel.H @@ -45,7 +45,7 @@ namespace Foam { //- Read a hex label from an input stream -label readHexLabel(ISstream& is); +label readHexLabel(ISstream&); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/Time/instant/instant.C b/src/OpenFOAM/db/Time/instant/instant.C index 0b4389e4b2..80ed886e4d 100644 --- a/src/OpenFOAM/db/Time/instant/instant.C +++ b/src/OpenFOAM/db/Time/instant/instant.C @@ -36,16 +36,16 @@ const char* const Foam::instant::typeName = "instant"; Foam::instant::instant() {} -Foam::instant::instant(const scalar tval, const word& tname) +Foam::instant::instant(const scalar val, const word& tname) : - value_(tval), + value_(val), name_(tname) {} -Foam::instant::instant(const scalar tval) +Foam::instant::instant(const scalar val) : - value_(tval), - name_(Time::timeName(tval)) + value_(val), + name_(Time::timeName(val)) {} Foam::instant::instant(const word& tname) @@ -57,20 +57,19 @@ Foam::instant::instant(const word& tname) // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -int Foam::operator==(const instant& I1, const instant& I2) +bool Foam::operator==(const instant& a, const instant& b) { return ( - I1.value_ < I2.value_ + SMALL - && I1.value_ > I2.value_ - SMALL + a.value_ < b.value_ + SMALL + && a.value_ > b.value_ - SMALL ); } -int Foam::operator != (const instant& I1, const instant& I2) +bool Foam::operator!=(const instant& a, const instant& b) { - // Invert the '==' operator ('0'='false') - return I1 == I2 ? 0 : 1; + return !operator==(a, b); } diff --git a/src/OpenFOAM/db/Time/instant/instant.H b/src/OpenFOAM/db/Time/instant/instant.H index 02c76500e7..032b299987 100644 --- a/src/OpenFOAM/db/Time/instant/instant.H +++ b/src/OpenFOAM/db/Time/instant/instant.H @@ -50,8 +50,8 @@ class instant; // Friend Operators -int operator==(const instant&, const instant&); -int operator!=(const instant&, const instant&); +bool operator==(const instant&, const instant&); +bool operator!=(const instant&, const instant&); // IOstream Operators @@ -79,9 +79,9 @@ public: { public: - bool operator()(const instant& one, const instant& two) const + bool operator()(const instant& a, const instant& b) const { - return one.value() < two.value(); + return a.value() < b.value(); } }; @@ -137,8 +137,8 @@ public: // Friend Operators - friend int operator==(const instant&, const instant&); - friend int operator!=(const instant&, const instant&); + friend bool operator==(const instant&, const instant&); + friend bool operator!=(const instant&, const instant&); // IOstream Operators diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index a757caebcc..8c351510e7 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -117,12 +117,7 @@ Foam::dictionary::dictionary name_(dict.name()), parent_(parentDict) { - for - ( - IDLList::iterator iter = begin(); - iter != end(); - ++iter - ) + forAllIter(IDLList, *this, iter) { hashedEntries_.insert(iter().keyword(), &iter()); @@ -147,12 +142,7 @@ Foam::dictionary::dictionary name_(dict.name()), parent_(dictionary::null) { - for - ( - IDLList::iterator iter = begin(); - iter != end(); - ++iter - ) + forAllIter(IDLList, *this, iter) { hashedEntries_.insert(iter().keyword(), &iter()); @@ -238,12 +228,7 @@ Foam::SHA1Digest Foam::dictionary::digest() const OSHA1stream os; // process entries - for - ( - IDLList::const_iterator iter = begin(); - iter != end(); - ++iter - ) + forAllConstIter(IDLList, *this, iter) { os << *iter; } @@ -262,7 +247,8 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const { if (patternEntries_.size()) { - DLList::const_iterator wcLink = patternEntries_.begin(); + DLList::const_iterator wcLink = + patternEntries_.begin(); DLList >::const_iterator reLink = patternRegexps_.begin(); @@ -475,12 +461,7 @@ Foam::wordList Foam::dictionary::toc() const wordList keys(size()); label nKeys = 0; - for - ( - IDLList::const_iterator iter = begin(); - iter != end(); - ++iter - ) + forAllConstIter(IDLList::const_iterator, *this, iter) { keys[nKeys++] = iter().keyword(); } @@ -494,12 +475,7 @@ Foam::List Foam::dictionary::keys(bool patterns) const List keys(size()); label nKeys = 0; - for - ( - IDLList::const_iterator iter = begin(); - iter != end(); - ++iter - ) + forAllConstIter(IDLList, *this, iter) { if (iter().keyword().isPattern() ? patterns : !patterns) { @@ -665,8 +641,10 @@ bool Foam::dictionary::remove(const word& Keyword) if (iter != hashedEntries_.end()) { // Delete from patterns first - DLList::iterator wcLink = patternEntries_.begin(); - DLList >::iterator reLink = patternRegexps_.begin(); + DLList::iterator wcLink = + patternEntries_.begin(); + DLList >::iterator reLink = + patternRegexps_.begin(); // Find in pattern using exact match only if (findInPatterns(false, Keyword, wcLink, reLink)) @@ -792,12 +770,7 @@ bool Foam::dictionary::merge(const dictionary& dict) bool changed = false; - for - ( - IDLList::const_iterator iter = dict.begin(); - iter != dict.end(); - ++iter - ) + forAllConstIter(IDLList, *this, iter) { HashTable::iterator fnd = hashedEntries_.find(iter().keyword()); @@ -882,12 +855,7 @@ void Foam::dictionary::operator=(const dictionary& rhs) // Create clones of the entries in the given dictionary // resetting the parentDict to this dictionary - for - ( - IDLList::const_iterator iter = rhs.begin(); - iter != rhs.end(); - ++iter - ) + forAllConstIter(IDLList, rhs, iter) { add(iter().clone(*this).ptr()); } @@ -904,12 +872,7 @@ void Foam::dictionary::operator+=(const dictionary& rhs) << abort(FatalError); } - for - ( - IDLList::const_iterator iter = rhs.begin(); - iter != rhs.end(); - ++iter - ) + forAllConstIter(IDLList, rhs, iter) { add(iter().clone(*this).ptr()); } @@ -926,12 +889,7 @@ void Foam::dictionary::operator|=(const dictionary& rhs) << abort(FatalError); } - for - ( - IDLList::const_iterator iter = rhs.begin(); - iter != rhs.end(); - ++iter - ) + forAllConstIter(IDLList, rhs, iter) { if (!found(iter().keyword())) { @@ -951,12 +909,7 @@ void Foam::dictionary::operator<<=(const dictionary& rhs) << abort(FatalError); } - for - ( - IDLList::const_iterator iter = rhs.begin(); - iter != rhs.end(); - ++iter - ) + forAllConstIter(IDLList, rhs, iter) { set(iter().clone(*this).ptr()); } diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index 2f0987d16b..96196e3a11 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -154,12 +154,8 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const // Write entry os << e; - // Add new line if applicable - if - ( - (e.isDict() || (!e.isDict() && parent()==dictionary::null)) - && e != *last() - ) + // Add extra new line between entries for "top-level" dictionaries + if (!subDict && parent() == dictionary::null && e != *last()) { os << nl; } @@ -167,7 +163,7 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const // Check stream before going to next entry. if (!os.good()) { - WarningIn("dictionary::write(Ostream& os, bool subDict)") + WarningIn("dictionary::write(Ostream&, bool subDict)") << "Can't write entry " << iter().keyword() << " for dictionary " << name() << endl; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index 601674ac7e..e36de4108c 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -103,14 +103,13 @@ bool Foam::functionEntry::execute is.fatalCheck ( "functionEntry::execute" - "(const word& functionName, const dictionary& parentDict, " - "primitiveEntry&, Istream&)" + "(const word&, const dictionary&, primitiveEntry&, Istream&)" ); if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_) { cerr<<"functionEntry::execute" - << "(const word&, dictionary&, primitiveEntry&, Istream&)" + << "(const word&, const dictionary&, primitiveEntry&, Istream&)" << " not yet initialized, function = " << functionName.c_str() << std::endl; @@ -126,8 +125,7 @@ bool Foam::functionEntry::execute FatalErrorIn ( "functionEntry::execute" - "(const word& functionName, const dictionary& parentDict, " - "primitiveEntry&, Istream&)" + "(const word&, const dictionary&, primitiveEntry&, Istream&)" ) << "Unknown functionEntry " << functionName << endl << endl << "Valid functionEntries are :" << endl diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H index f4d1702b4f..ebfd49470b 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H @@ -95,7 +95,7 @@ public: ( const word& functionName, dictionary& parentDict, - Istream& is + Istream& ); declareMemberFunctionSelectionTable @@ -117,8 +117,8 @@ public: ( const word& functionName, const dictionary& parentDict, - primitiveEntry& entry, - Istream& is + primitiveEntry&, + Istream& ); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index e9f11d56a5..7879369017 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -62,8 +62,7 @@ namespace functionEntries } } - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // Foam::fileName Foam::functionEntries::includeEntry::includeFileName ( @@ -73,6 +72,7 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName fileName fName(is); fName.expand(); + // relative name if (fName.size() && fName[0] != '/') { fName = fileName(is.name()).path()/fName; @@ -82,17 +82,19 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName } +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + bool Foam::functionEntries::includeEntry::execute ( dictionary& parentDict, Istream& is ) { - IFstream fileStream(includeFileName(is)); + IFstream ifs(includeFileName(is)); - if (fileStream) + if (ifs) { - parentDict.read(fileStream); + parentDict.read(ifs); return true; } else @@ -100,9 +102,9 @@ bool Foam::functionEntries::includeEntry::execute FatalIOErrorIn ( "functionEntries::includeEntry::includeEntry" - "(dictionary& parentDict,Istream& is)", + "(dictionary& parentDict, Istream&)", is - ) << "Cannot open include file " << fileStream.name() + ) << "Cannot open include file " << ifs.name() << " while reading dictionary " << parentDict.name() << exit(FatalIOError); @@ -117,11 +119,11 @@ bool Foam::functionEntries::includeEntry::execute Istream& is ) { - IFstream fileStream(includeFileName(is)); + IFstream ifs(includeFileName(is)); - if (fileStream) + if (ifs) { - entry.read(parentDict, fileStream); + entry.read(parentDict, ifs); return true; } else @@ -129,9 +131,9 @@ bool Foam::functionEntries::includeEntry::execute FatalIOErrorIn ( "functionEntries::includeEntry::includeEntry" - "(dictionary& parentDict, primitiveEntry& entry, Istream& is)", + "(dictionary& parentDict, primitiveEntry& entry, Istream&)", is - ) << "Cannot open include file " << fileStream.name() + ) << "Cannot open include file " << ifs.name() << " while reading dictionary " << parentDict.name() << exit(FatalIOError); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H index effff83a31..b260e3f36c 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H @@ -58,7 +58,7 @@ namespace functionEntries { /*---------------------------------------------------------------------------*\ - Class includeEntry Declaration + Class includeEntry Declaration \*---------------------------------------------------------------------------*/ class includeEntry @@ -68,7 +68,7 @@ class includeEntry // Private Member Functions //- Read the include fileName from Istream, expand and return - static fileName includeFileName(Istream& is); + static fileName includeFileName(Istream&); //- Disallow default bitwise copy construct includeEntry(const includeEntry&); @@ -86,18 +86,14 @@ public: // Member Functions //- Execute the functionEntry in a sub-dict context - static bool execute - ( - dictionary& parentDict, - Istream& is - ); + static bool execute(dictionary& parentDict, Istream&); //- Execute the functionEntry in a primitiveEntry context static bool execute ( const dictionary& parentDict, - primitiveEntry& entry, - Istream& is + primitiveEntry&, + Istream& ); }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C index 60c348e244..f711da80aa 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C @@ -39,6 +39,9 @@ const Foam::word Foam::functionEntries::inputModeEntry::typeName // might include inputModeEntries int Foam::functionEntries::inputModeEntry::debug(0); +Foam::functionEntries::inputModeEntry::inputMode + Foam::functionEntries::inputModeEntry::mode_(MERGE); + namespace Foam { namespace functionEntries @@ -53,10 +56,6 @@ namespace functionEntries } } -// * * * * * * * * * * * * * * * * Private Data * * * * * * * * * * * * * * // - -Foam::label Foam::functionEntries::inputModeEntry::mode_ = imError; - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // we could combine this into execute() directly, but leave it here for now @@ -65,17 +64,17 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is) clear(); word mode(is); - if (mode == "merge") + if (mode == "merge" || mode == "default") { - mode_ = imMerge; + mode_ = MERGE; } else if (mode == "overwrite") { - mode_ = imOverwrite; + mode_ = OVERWRITE; } - else if (mode == "error" || mode == "default") + else if (mode == "error") { - mode_ = imError; + mode_ = ERROR; } else { @@ -101,33 +100,19 @@ bool Foam::functionEntries::inputModeEntry::execute void Foam::functionEntries::inputModeEntry::clear() { - mode_ = imError; + mode_ = MERGE; } bool Foam::functionEntries::inputModeEntry::merge() { - if (mode_ & imMerge) - { - return true; - } - else - { - return false; - } + return mode_ == MERGE; } bool Foam::functionEntries::inputModeEntry::overwrite() { - if (mode_ & imOverwrite) - { - return true; - } - else - { - return false; - } + return mode_ == OVERWRITE; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H index 394ad15779..9ecb558da9 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H @@ -38,7 +38,7 @@ Description @param merge merge sub-dictionaries when possible @param overwrite keep last entry and silently remove previous ones @param error flag duplicate entry as an error - @param default currently the same as error + @param default currently the same as merge SourceFiles inputModeEntry.C @@ -68,13 +68,13 @@ class inputModeEntry //- input mode options enum inputMode { - imError = 0, - imMerge = 0x1, - imOverwrite = 0x2 + ERROR, + MERGE, + OVERWRITE }; //- current input mode - static label mode_; + static inputMode mode_; // Private Member Functions @@ -98,19 +98,15 @@ public: // Member Functions //- Execute the functionEntry in a sub-dict context - static bool execute - ( - dictionary& parentDict, - Istream& - ); + static bool execute(dictionary& parentDict, Istream&); - //- Reset the inputMode to 'default' + //- Reset the inputMode to %default static void clear(); - //- Return true if the inputMode is 'merge' + //- Return true if the inputMode is %merge static bool merge(); - //- Return true if the inputMode is 'overwrite' + //- Return true if the inputMode is %overwrite static bool overwrite(); }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H index 443d28889f..1ed2d99639 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H @@ -80,11 +80,7 @@ public: // Member Functions //- Execute the functionEntry in a sub-dict context - static bool execute - ( - dictionary& parentDict, - Istream& is - ); + static bool execute(dictionary& parentDict, Istream&); }; diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.C b/src/OpenFOAM/db/objectRegistry/objectRegistry.C index cbd841f8ae..9d01de9d90 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.C @@ -101,7 +101,7 @@ Foam::wordList Foam::objectRegistry::names() const wordList objectNames(size()); label count=0; - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { objectNames[count++] = iter()->name(); } @@ -115,7 +115,7 @@ Foam::wordList Foam::objectRegistry::names(const word& ClassName) const wordList objectNames(size()); label count=0; - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { if (iter()->type() == ClassName) { @@ -234,15 +234,33 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const << " in registry " << name() << endl; } + } + + return false; +} - return false; + +void Foam::objectRegistry::rename(const word& newName) +{ + regIOobject::rename(newName); + + // adjust dbDir_ as well + string::size_type i = dbDir_.rfind('/'); + + if (i == string::npos) + { + dbDir_ = newName; + } + else + { + dbDir_.replace(i+1, string::npos, newName); } } bool Foam::objectRegistry::modified() const { - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { if (iter()->modified()) { @@ -287,7 +305,7 @@ bool Foam::objectRegistry::writeObject { bool ok = true; - for (const_iterator iter = begin(); iter != end(); ++iter) + for (const_iterator iter = cbegin(); iter != cend(); ++iter) { if (objectRegistry::debug) { diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index 061f452c0b..1f2d30d93e 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -160,6 +160,9 @@ public: // Edit + //- Rename + virtual void rename(const word& newName); + //- Add an regIOobject to registry bool checkIn(regIOobject&) const; diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C index 646c451317..c58bacf75d 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistryTemplates.C @@ -147,8 +147,7 @@ const Type& Foam::objectRegistry::lookupObject(const word& name) const } } - const Type* dummyPtr_ = NULL; - return *dummyPtr_; + return *reinterpret_cast< const Type* >(0); } diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C b/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C index dc3dcf1478..62df5dafe1 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectWrite.C @@ -103,9 +103,7 @@ bool Foam::regIOobject::writeObject return false; } - os << "\n\n" - "// ************************************************************************* //" - << endl; + writeEndDivider(os); osGood = os.good(); } diff --git a/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H index 1e043399f1..7b27a9a70f 100644 --- a/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H +++ b/src/OpenFOAM/db/runTimeSelection/addToRunTimeSelectionTable.H @@ -41,7 +41,7 @@ Description (baseType,thisType,argNames) \ \ /* Add the thisType constructor function to the table */ \ - baseType::add##argNames##ConstructorToTable \ + baseType::add##argNames##ConstructorToTable< thisType > \ add##thisType##argNames##ConstructorTo##baseType##Table_ @@ -50,7 +50,7 @@ Description (baseType,thisType,argNames,lookup) \ \ /* Add the thisType constructor function to the table, find by lookup */ \ - baseType::add##argNames##ConstructorToTable \ + baseType::add##argNames##ConstructorToTable< thisType > \ add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_(#lookup) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,7 +62,7 @@ Description (baseType,thisType,Targ,argNames) \ \ /* Add the thisType constructor function to the table */ \ - baseType::add##argNames##ConstructorToTable > \ + baseType::add##argNames##ConstructorToTable< thisType< Targ > > \ add##thisType##Targ##argNames##ConstructorTo##baseType##Table_ @@ -72,7 +72,7 @@ Description (baseType,thisType,Targ,argNames,lookup) \ \ /* Add the thisType constructor function to the table, find by lookup */ \ - baseType::add##argNames##ConstructorToTable > \ + baseType::add##argNames##ConstructorToTable< thisType< Targ > > \ add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Table_(#lookup) @@ -85,7 +85,7 @@ Description (baseType,thisType,Targ,argNames) \ \ /* Add the thisType constructor function to the table */ \ - baseType::add##argNames##ConstructorToTable > \ + baseType< Targ >::add##argNames##ConstructorToTable< thisType< Targ > > \ add##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_ @@ -95,7 +95,7 @@ Description (baseType,thisType,Targ,argNames,lookup) \ \ /* Add the thisType constructor function to the table, find by lookup */ \ - baseType::add##argNames##ConstructorToTable > \ + baseType< Targ >::add##argNames##ConstructorToTable< thisType< Targ > > \ add_##lookup##_##thisType##Targ##argNames##ConstructorTo##baseType##Targ##Table_(#lookup) diff --git a/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H index 6518feb29b..8e9b4ea54e 100644 --- a/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H +++ b/src/OpenFOAM/db/runTimeSelection/runTimeSelectionTables.H @@ -54,24 +54,24 @@ Description (autoPtr,baseType,argNames,argList,parList) \ \ /* Construct from argList function pointer type */ \ - typedef autoPtr (*argNames##ConstructorPtr)argList; \ + typedef autoPtr< baseType > (*argNames##ConstructorPtr)argList; \ \ /* Construct from argList function table type */ \ - typedef HashTable \ + typedef HashTable< argNames##ConstructorPtr, word, string::hash > \ argNames##ConstructorTable; \ \ /* Construct from argList function pointer table pointer */ \ static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \ \ /* Class to add constructor from argList to table */ \ - template \ + template< class baseType##Type > \ class add##argNames##ConstructorToTable \ { \ public: \ \ - static autoPtr New argList \ + static autoPtr< baseType > New argList \ { \ - return autoPtr(new baseType##Type parList); \ + return autoPtr< baseType >(new baseType##Type parList); \ } \ \ add##argNames##ConstructorToTable \ @@ -103,24 +103,24 @@ Description (autoPtr,baseType,argNames,argList,parList) \ \ /* Construct from argList function pointer type */ \ - typedef autoPtr (*argNames##ConstructorPtr)argList; \ + typedef autoPtr< baseType > (*argNames##ConstructorPtr)argList; \ \ /* Construct from argList function table type */ \ - typedef HashTable \ + typedef HashTable< argNames##ConstructorPtr, word, string::hash > \ argNames##ConstructorTable; \ \ /* Construct from argList function pointer table pointer */ \ static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \ \ /* Class to add constructor from argList to table */ \ - template \ + template< class baseType##Type > \ class add##argNames##ConstructorToTable \ { \ public: \ \ - static autoPtr New##baseType argList \ + static autoPtr< baseType > New##baseType argList \ { \ - return autoPtr(baseType##Type::New parList.ptr()); \ + return autoPtr< baseType >(baseType##Type::New parList.ptr()); \ } \ \ add##argNames##ConstructorToTable \ @@ -213,7 +213,7 @@ Description (baseType,argNames) \ \ defineRunTimeSelectionTablePtr(baseType,argNames); \ - defineRunTimeSelectionTableConstructor(baseType,argNames) \ + defineRunTimeSelectionTableConstructor(baseType,argNames); \ defineRunTimeSelectionTableDestructor(baseType,argNames) @@ -227,7 +227,7 @@ Description template<> \ defineRunTimeSelectionTablePtr(baseType,argNames); \ template<> \ - defineRunTimeSelectionTableConstructor(baseType,argNames) \ + defineRunTimeSelectionTableConstructor(baseType,argNames); \ template<> \ defineRunTimeSelectionTableDestructor(baseType,argNames) @@ -242,14 +242,14 @@ Description (baseType,argNames,Targ) \ \ /* Table constructor called from the table add function */ \ - void baseType::construct##argNames##ConstructorTables() \ + void baseType< Targ >::construct##argNames##ConstructorTables() \ { \ static bool constructed = false; \ \ if (!constructed) \ { \ - baseType::argNames##ConstructorTablePtr_ \ - = new baseType::argNames##ConstructorTable; \ + baseType< Targ >::argNames##ConstructorTablePtr_ \ + = new baseType< Targ >::argNames##ConstructorTable; \ \ constructed = true; \ } \ @@ -263,12 +263,12 @@ Description (baseType,argNames,Targ) \ \ /* Table destructor called from the table add function destructor */ \ - void baseType::destroy##argNames##ConstructorTables() \ + void baseType< Targ >::destroy##argNames##ConstructorTables() \ { \ - if (baseType::argNames##ConstructorTablePtr_) \ + if (baseType< Targ >::argNames##ConstructorTablePtr_) \ { \ - delete baseType::argNames##ConstructorTablePtr_; \ - baseType::argNames##ConstructorTablePtr_ = NULL; \ + delete baseType< Targ >::argNames##ConstructorTablePtr_; \ + baseType< Targ >::argNames##ConstructorTablePtr_ = NULL; \ } \ } @@ -280,8 +280,8 @@ Description (baseType,argNames,Targ) \ \ /* Define the constructor function table */ \ - baseType::argNames##ConstructorTable* \ - baseType::argNames##ConstructorTablePtr_ = NULL + baseType< Targ >::argNames##ConstructorTable* \ + baseType< Targ >::argNames##ConstructorTablePtr_ = NULL // external use: @@ -294,7 +294,7 @@ Description template<> \ defineTemplatedRunTimeSelectionTablePtr(baseType,argNames,Targ); \ template<> \ - defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ) \ + defineTemplatedRunTimeSelectionTableConstructor(baseType,argNames,Targ); \ template<> \ defineTemplatedRunTimeSelectionTableDestructor(baseType,argNames,Targ) diff --git a/src/OpenFOAM/db/typeInfo/className.H b/src/OpenFOAM/db/typeInfo/className.H index c46c3d9ba1..84536bf1d5 100644 --- a/src/OpenFOAM/db/typeInfo/className.H +++ b/src/OpenFOAM/db/typeInfo/className.H @@ -44,13 +44,13 @@ Description // Without debug information #define ClassNameNoDebug(TypeNameString) \ static const char* typeName_() { return TypeNameString; } \ - static const ::Foam::word typeName; + static const ::Foam::word typeName //- Add typeName information from argument @a TypeNameString to a namespace. // Without debug information. #define NamespaceNameNoDebug(TypeNameString) \ inline const char* typeName_() { return TypeNameString; } \ - extern const ::Foam::word typeName; + extern const ::Foam::word typeName //- Add typeName information from argument @a TemplateNameString to a template class. // Without debug information. @@ -60,7 +60,7 @@ class TemplateNameString##Name \ public: \ TemplateNameString##Name() {} \ ClassNameNoDebug(#TemplateNameString); \ -}; +} @@ -89,7 +89,7 @@ class TemplateNameString##Name \ public: \ TemplateNameString##Name() {} \ ClassName(#TemplateNameString); \ -}; +} @@ -100,30 +100,30 @@ public: \ //- Define the typeName, with alternative lookup as @a Name #define defineTypeNameWithName(Type, Name) \ - const ::Foam::word Type::typeName(Name); + const ::Foam::word Type::typeName(Name) //- Define the typeName #define defineTypeName(Type) \ - defineTypeNameWithName(Type, Type::typeName_()); + defineTypeNameWithName(Type, Type::typeName_()) #ifdef __INTEL_COMPILER //- Define the typeName as @a Name for template classes # define defineTemplateTypeNameWithName(Type, Name) \ - defineTypeNameWithName(Type, Name); + defineTypeNameWithName(Type, Name) #else //- Define the typeName as @a Name for template classes # define defineTemplateTypeNameWithName(Type, Name) \ template<> \ - defineTypeNameWithName(Type, Name); + defineTypeNameWithName(Type, Name) #endif //- Define the typeName for template classes, useful with typedefs #define defineTemplateTypeName(Type) \ - defineTemplateTypeNameWithName(Type, #Type); + defineTemplateTypeNameWithName(Type, #Type) //- Define the typeName directly for template classes #define defineNamedTemplateTypeName(Type) \ - defineTemplateTypeNameWithName(Type, Type::typeName_()); + defineTemplateTypeNameWithName(Type, Type::typeName_()) @@ -134,31 +134,31 @@ public: \ //- Define the debug information, lookup as @a Name #define defineDebugSwitchWithName(Type, Name, DebugSwitch) \ - int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch)); + int Type::debug(::Foam::debug::debugSwitch(Name, DebugSwitch)) //- Define the debug information #define defineDebugSwitch(Type, DebugSwitch) \ - defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch); + defineDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch) #ifdef __INTEL_COMPILER //- Define the debug information for templates, lookup as @a Name # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \ - defineDebugSwitchWithName(Type, Name, DebugSwitch); + defineDebugSwitchWithName(Type, Name, DebugSwitch) #else //- Define the debug information for templates, lookup as @a Name # define defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) \ template<> \ - defineDebugSwitchWithName(Type, Name, DebugSwitch); + defineDebugSwitchWithName(Type, Name, DebugSwitch) #endif //- Define the debug information for templates // Useful with typedefs #define defineTemplateDebugSwitch(Type, DebugSwitch) \ - defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch); + defineTemplateDebugSwitchWithName(Type, #Type, DebugSwitch) //- Define the debug information directly for templates #define defineNamedTemplateDebugSwitch(Type, DebugSwitch) \ - defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch); + defineTemplateDebugSwitchWithName(Type, Type::typeName_(), DebugSwitch) @@ -170,21 +170,21 @@ public: \ //- Define the typeName and debug information #define defineTypeNameAndDebug(Type, DebugSwitch) \ defineTypeName(Type); \ - defineDebugSwitch(Type, DebugSwitch); + defineDebugSwitch(Type, DebugSwitch) //- Define the typeName and debug information, lookup as @a Name #define defineTemplateTypeNameAndDebugWithName(Type, Name, DebugSwitch) \ defineTemplateTypeNameWithName(Type, Name); \ - defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch); + defineTemplateDebugSwitchWithName(Type, Name, DebugSwitch) //- Define the typeName and debug information for templates, useful with typedefs #define defineTemplateTypeNameAndDebug(Type, DebugSwitch) \ - defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch); + defineTemplateTypeNameAndDebugWithName(Type, #Type, DebugSwitch) //- Define the typeName and debug information for templates #define defineNamedTemplateTypeNameAndDebug(Type, DebugSwitch) \ defineNamedTemplateTypeName(Type); \ - defineNamedTemplateDebugSwitch(Type, DebugSwitch); + defineNamedTemplateDebugSwitch(Type, DebugSwitch) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/fields/cloud/cloud.C b/src/OpenFOAM/fields/cloud/cloud.C index 2dd30b5f3c..f2dbb3be4f 100644 --- a/src/OpenFOAM/fields/cloud/cloud.C +++ b/src/OpenFOAM/fields/cloud/cloud.C @@ -29,10 +29,10 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam -{ - defineTypeNameAndDebug(cloud, 0); -} +defineTypeNameAndDebug(Foam::cloud, 0); + +const Foam::word Foam::cloud::prefix("lagrangian"); +Foam::word Foam::cloud::defaultName("defaultCloud"); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -42,9 +42,9 @@ Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName) ( IOobject ( - cloudName, + ( cloudName.size() ? cloudName : defaultName ), obr.time().timeName(), - "lagrangian", + prefix, obr, IOobject::NO_READ, IOobject::AUTO_WRITE diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/OpenFOAM/fields/cloud/cloud.H index 68743e6e96..0c0915464e 100644 --- a/src/OpenFOAM/fields/cloud/cloud.H +++ b/src/OpenFOAM/fields/cloud/cloud.H @@ -47,7 +47,7 @@ namespace Foam class mapPolyMesh; /*---------------------------------------------------------------------------*\ - Class cloud Declaration + Class cloud Declaration \*---------------------------------------------------------------------------*/ class cloud @@ -69,15 +69,16 @@ public: //- Runtime type information TypeName("cloud"); + //- The prefix to local: %lagrangian + static const word prefix; + + //- The default cloud name: %defaultCloud + static word defaultName; // Constructors //- Construct for the given objectRegistry and named cloud instance - cloud - ( - const objectRegistry& obr, - const word& cloudName = "defaultCloud" - ); + cloud(const objectRegistry&, const word& cloudName = ""); // Destructor diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 8672f32753..8c37d28b42 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -162,10 +162,7 @@ bool Foam::solution::read() relaxationFactors_ = dict.subDict("relaxationFactors"); } - if (relaxationFactors_.found("default")) - { - relaxationFactors_.lookup("default") >> defaultRelaxationFactor_; - } + relaxationFactors_.readIfPresent("default", defaultRelaxationFactor_); if (dict.found("solvers")) { @@ -227,7 +224,7 @@ Foam::scalar Foam::solution::relaxationFactor(const word& name) const { FatalIOErrorIn ( - "Foam::solution::relaxationFactor(const word& name)", + "Foam::solution::relaxationFactor(const word&)", relaxationFactors_ ) << "Cannot find relaxationFactor for '" << name << "' or a suitable default value." @@ -242,7 +239,7 @@ const Foam::dictionary& Foam::solution::solverDict(const word& name) const { if (debug) { - InfoIn("solution::solverDict(const word& name)") + InfoIn("solution::solverDict(const word&)") << "Lookup solver for " << name << endl; } @@ -254,7 +251,7 @@ const Foam::dictionary& Foam::solution::solver(const word& name) const { if (debug) { - InfoIn("solution::solver(const word& name)") + InfoIn("solution::solver(const word&)") << "Lookup solver for " << name << endl; } diff --git a/src/OpenFOAM/primitives/bools/Switch/Switch.H b/src/OpenFOAM/primitives/bools/Switch/Switch.H index b37e2bbb40..4eaa2dd12b 100644 --- a/src/OpenFOAM/primitives/bools/Switch/Switch.H +++ b/src/OpenFOAM/primitives/bools/Switch/Switch.H @@ -176,9 +176,10 @@ public: } //- Assignment from bool - void operator=(const bool b) + const Switch& operator=(const bool b) { switch_ = (b ? Switch::TRUE : Switch::FALSE); + return *this; } diff --git a/src/OpenFOAM/primitives/complex/complex.H b/src/OpenFOAM/primitives/complex/complex.H index 1def519a99..ae94a75b66 100644 --- a/src/OpenFOAM/primitives/complex/complex.H +++ b/src/OpenFOAM/primitives/complex/complex.H @@ -51,13 +51,13 @@ namespace Foam class complex; -inline scalar magSqr(const complex& c); -inline complex sqr(const complex& c); -inline scalar mag(const complex& c); -inline const complex& max(const complex& c1, const complex& c2); -inline const complex& min(const complex& c1, const complex& c2); -inline complex limit(const complex& c1, const complex& c2); -inline const complex& sum(const complex& c); +inline scalar magSqr(const complex&); +inline complex sqr(const complex&); +inline scalar mag(const complex&); +inline const complex& max(const complex&, const complex&); +inline const complex& min(const complex&, const complex&); +inline complex limit(const complex&, const complex&); +inline const complex& sum(const complex&); inline complex operator+(const complex&, const complex&); inline complex operator-(const complex&); inline complex operator-(const complex&, const complex&); @@ -67,8 +67,8 @@ inline complex operator*(const scalar, const complex&); inline complex operator*(const complex&, const scalar); inline complex operator/(const complex&, const scalar); inline complex operator/(const scalar, const complex&); -Istream& operator>>(Istream& is, complex&); -Ostream& operator<<(Ostream& os, const complex& C); +Istream& operator>>(Istream&, complex&); +Ostream& operator<<(Ostream&, const complex&); /*---------------------------------------------------------------------------*\ @@ -127,13 +127,13 @@ public: // Member operators - inline void operator=(const complex&); + inline const complex& operator=(const complex&); inline void operator+=(const complex&); inline void operator-=(const complex&); inline void operator*=(const complex&); inline void operator/=(const complex&); - inline void operator=(const scalar); + inline const complex& operator=(const scalar); inline void operator+=(const scalar); inline void operator-=(const scalar); inline void operator*=(const scalar); @@ -150,12 +150,12 @@ public: friend scalar magSqr(const complex& c); friend complex sqr(const complex& c); friend scalar mag(const complex& c); - friend const complex& max(const complex& c1, const complex& c2); - friend const complex& min(const complex& c1, const complex& c2); + friend const complex& max(const complex&, const complex&); + friend const complex& min(const complex&, const complex&); - friend complex limit(const complex& c1, const complex& c2); + friend complex limit(const complex&, const complex&); - friend const complex& sum(const complex& c); + friend const complex& sum(const complex&); // Friend operators diff --git a/src/OpenFOAM/primitives/complex/complexI.H b/src/OpenFOAM/primitives/complex/complexI.H index 8e693eb744..501a11519a 100644 --- a/src/OpenFOAM/primitives/complex/complexI.H +++ b/src/OpenFOAM/primitives/complex/complexI.H @@ -76,10 +76,11 @@ inline complex complex::conjugate() const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline void complex::operator=(const complex& c) +inline const complex& complex::operator=(const complex& c) { re = c.re; im = c.im; + return *this; } @@ -109,10 +110,11 @@ inline void complex::operator/=(const complex& c) } -inline void complex::operator=(const scalar s) +inline const complex& complex::operator=(const scalar s) { re = s; im = 0.0; + return *this; } @@ -234,8 +236,8 @@ inline complex operator+(const complex& c1, const complex& c2) { return complex ( - c1.re+c2.re, - c1.im+c2.im + c1.re + c2.re, + c1.im + c2.im ); } @@ -254,8 +256,8 @@ inline complex operator-(const complex& c1, const complex& c2) { return complex ( - c1.re-c2.re, - c1.im-c2.im + c1.re - c2.re, + c1.im - c2.im ); } diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index c6faa26073..6d930e9fe8 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -196,36 +196,41 @@ Foam::word Foam::fileName::component // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -void Foam::fileName::operator=(const fileName& str) +const Foam::fileName& Foam::fileName::operator=(const fileName& str) { string::operator=(str); + return *this; } -void Foam::fileName::operator=(const word& str) +const Foam::fileName& Foam::fileName::operator=(const word& str) { string::operator=(str); + return *this; } -void Foam::fileName::operator=(const string& str) +const Foam::fileName& Foam::fileName::operator=(const string& str) { string::operator=(str); stripInvalid(); + return *this; } -void Foam::fileName::operator=(const std::string& str) +const Foam::fileName& Foam::fileName::operator=(const std::string& str) { string::operator=(str); stripInvalid(); + return *this; } -void Foam::fileName::operator=(const char* str) +const Foam::fileName& Foam::fileName::operator=(const char* str) { string::operator=(str); stripInvalid(); + return *this; } diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index ccb2d3caa4..a47f53ed80 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -158,11 +158,11 @@ public: // Assignment - void operator=(const fileName&); - void operator=(const word&); - void operator=(const string&); - void operator=(const std::string&); - void operator=(const char*); + const fileName& operator=(const fileName&); + const fileName& operator=(const word&); + const fileName& operator=(const string&); + const fileName& operator=(const std::string&); + const fileName& operator=(const char*); // IOstream operators diff --git a/src/OpenFOAM/primitives/strings/keyType/keyType.H b/src/OpenFOAM/primitives/strings/keyType/keyType.H index 29f851c738..8bfd9b4d09 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyType.H +++ b/src/OpenFOAM/primitives/strings/keyType/keyType.H @@ -106,12 +106,12 @@ public: // Assignment - inline void operator=(const keyType&); - inline void operator=(const word&); + inline const keyType& operator=(const keyType&); + inline const keyType& operator=(const word&); //- Assign from regular expression. - inline void operator=(const string&); - inline void operator=(const char*); + inline const keyType& operator=(const string&); + inline const keyType& operator=(const char*); // IOstream operators diff --git a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H index 391f666aff..61828468a6 100644 --- a/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H +++ b/src/OpenFOAM/primitives/strings/keyType/keyTypeI.H @@ -89,34 +89,38 @@ inline bool Foam::keyType::isPattern() const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline void Foam::keyType::operator=(const keyType& s) +inline const Foam::keyType& Foam::keyType::operator=(const keyType& s) { // Bypass checking string::operator=(s); isPattern_ = s.isPattern_; + return *this; } -inline void Foam::keyType::operator=(const word& s) +inline const Foam::keyType& Foam::keyType::operator=(const word& s) { word::operator=(s); isPattern_ = false; + return *this; } -inline void Foam::keyType::operator=(const string& s) +inline const Foam::keyType& Foam::keyType::operator=(const string& s) { // Bypass checking string::operator=(s); isPattern_ = true; + return *this; } -inline void Foam::keyType::operator=(const char* s) +inline const Foam::keyType& Foam::keyType::operator=(const char* s) { // Bypass checking string::operator=(s); isPattern_ = false; + return *this; } diff --git a/src/OpenFOAM/primitives/strings/string/string.H b/src/OpenFOAM/primitives/strings/string/string.H index 247b031d6c..97c6dd4d4d 100644 --- a/src/OpenFOAM/primitives/strings/string/string.H +++ b/src/OpenFOAM/primitives/strings/string/string.H @@ -144,6 +144,9 @@ public: template static inline string quotemeta(const string&, const char quote='\\'); + //- Avoid masking the normal std::string replace + using std::string::replace; + //- Replace first occurence of sub-string oldStr with newStr // starting at start string& replace diff --git a/src/OpenFOAM/primitives/strings/word/word.H b/src/OpenFOAM/primitives/strings/word/word.H index 1c74119a27..5c910b7891 100644 --- a/src/OpenFOAM/primitives/strings/word/word.H +++ b/src/OpenFOAM/primitives/strings/word/word.H @@ -117,10 +117,10 @@ public: // Assignment - inline void operator=(const word&); - inline void operator=(const string&); - inline void operator=(const std::string&); - inline void operator=(const char*); + inline const word& operator=(const word&); + inline const word& operator=(const string&); + inline const word& operator=(const std::string&); + inline const word& operator=(const char*); // Friend Operators diff --git a/src/OpenFOAM/primitives/strings/word/wordI.H b/src/OpenFOAM/primitives/strings/word/wordI.H index b1daf2752c..c7f9cdb878 100644 --- a/src/OpenFOAM/primitives/strings/word/wordI.H +++ b/src/OpenFOAM/primitives/strings/word/wordI.H @@ -132,30 +132,34 @@ inline bool Foam::word::valid(char c) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline void Foam::word::operator=(const word& q) +inline const Foam::word& Foam::word::operator=(const word& q) { string::operator=(q); + return *this; } -inline void Foam::word::operator=(const string& q) +inline const Foam::word& Foam::word::operator=(const string& q) { string::operator=(q); stripInvalid(); + return *this; } -inline void Foam::word::operator=(const std::string& q) +inline const Foam::word& Foam::word::operator=(const std::string& q) { string::operator=(q); stripInvalid(); + return *this; } -inline void Foam::word::operator=(const char* q) +inline const Foam::word& Foam::word::operator=(const char* q) { string::operator=(q); stripInvalid(); + return *this; } diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H index aee6c3a883..741d76e553 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordRe.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordRe.H @@ -41,7 +41,7 @@ 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 sychronize the regular expression. + recompile() to synchronize the regular expression. SourceFiles wordRe.C @@ -187,22 +187,22 @@ public: //- Assign copy // Always case sensitive - inline void operator=(const wordRe&); + inline const wordRe& operator=(const wordRe&); //- Copy word, never a regular expression - inline void operator=(const word&); + inline const wordRe& operator=(const word&); //- Copy string, auto-test for regular expression // Always case sensitive - inline void operator=(const string&); + inline const wordRe& operator=(const string&); //- Copy string, auto-test for regular expression // Always case sensitive - inline void operator=(const std::string&); + inline const wordRe& operator=(const std::string&); //- Copy string, auto-test for regular expression // Always case sensitive - inline void operator=(const char*); + inline const wordRe& operator=(const char*); // IOstream operators diff --git a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H index b84694ba82..7f242eb2c5 100644 --- a/src/OpenFOAM/primitives/strings/wordRe/wordReI.H +++ b/src/OpenFOAM/primitives/strings/wordRe/wordReI.H @@ -213,7 +213,7 @@ inline void Foam::wordRe::set(const char* str, const compOption opt) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -inline void Foam::wordRe::operator=(const wordRe& str) +inline const Foam::wordRe& Foam::wordRe::operator=(const wordRe& str) { string::operator=(str); @@ -225,34 +225,39 @@ inline void Foam::wordRe::operator=(const wordRe& str) { re_.clear(); } + return *this; } -inline void Foam::wordRe::operator=(const word& str) +inline const Foam::wordRe& Foam::wordRe::operator=(const word& str) { word::operator=(str); re_.clear(); + return *this; } -inline void Foam::wordRe::operator=(const string& str) +inline const Foam::wordRe& Foam::wordRe::operator=(const string& str) { string::operator=(str); compile(DETECT); // auto-detect regex + return *this; } -inline void Foam::wordRe::operator=(const std::string& str) +inline const Foam::wordRe& Foam::wordRe::operator=(const std::string& str) { string::operator=(str); compile(DETECT); // auto-detect regex + return *this; } -inline void Foam::wordRe::operator=(const char* str) +inline const Foam::wordRe& Foam::wordRe::operator=(const char* str) { string::operator=(str); compile(DETECT); // auto-detect regex + return *this; } diff --git a/src/conversion/meshReader/meshReaderAux.C b/src/conversion/meshReader/meshReaderAux.C index a0c179a8be..856d704857 100644 --- a/src/conversion/meshReader/meshReaderAux.C +++ b/src/conversion/meshReader/meshReaderAux.C @@ -97,10 +97,8 @@ void Foam::meshReader::writeInterfaces(const objectRegistry& registry) const OFstream os(ioObj.objectPath()); ioObj.writeHeader(os); - os << interfaces_ - << "// *************************************" - << "************************************ //" - << endl; + os << interfaces_; + ioObj.writeEndDivider(os); } diff --git a/src/sampling/Make/files b/src/sampling/Make/files index c528032519..57306e542b 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -33,6 +33,8 @@ sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C sampledSurface/sampledSurface/sampledSurface.C sampledSurface/sampledSurfaces/sampledSurfaces.C sampledSurface/sampledSurfacesFunctionObject/sampledSurfacesFunctionObject.C +sampledSurface/thresholdCellFaces/thresholdCellFaces.C +sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C surfWriters = sampledSurface/writers @@ -40,8 +42,8 @@ $(surfWriters)/surfaceWriters.C $(surfWriters)/dx/dxSurfaceWriterRunTime.C $(surfWriters)/foamFile/foamFileSurfaceWriterRunTime.C $(surfWriters)/null/nullSurfaceWriterRunTime.C +$(surfWriters)/proxy/proxySurfaceWriterRunTime.C $(surfWriters)/raw/rawSurfaceWriterRunTime.C -$(surfWriters)/stl/stlSurfaceWriterRunTime.C $(surfWriters)/vtk/vtkSurfaceWriterRunTime.C graphField/writePatchGraph.C diff --git a/src/sampling/cuttingPlane/cuttingPlane.H b/src/sampling/cuttingPlane/cuttingPlane.H index b7e31ef906..6804a9ab18 100644 --- a/src/sampling/cuttingPlane/cuttingPlane.H +++ b/src/sampling/cuttingPlane/cuttingPlane.H @@ -62,10 +62,10 @@ class primitiveMesh; class cuttingPlane : public plane, - public BasicMeshedSurface + public MeshedSurface { //- Private typedefs for convenience - typedef BasicMeshedSurface MeshStorage; + typedef MeshedSurface MeshStorage; // Private data diff --git a/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.H b/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.H index 45faa6b907..1096f64519 100644 --- a/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.H +++ b/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriter.H @@ -81,7 +81,7 @@ public: const coordSet&, const wordList&, const List*>&, - Ostream& os + Ostream& ) const; }; diff --git a/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriterRunTime.C b/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriterRunTime.C index 3f019d1203..4cdae12b55 100644 --- a/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriterRunTime.C +++ b/src/sampling/sampledSet/writers/gnuplot/gnuplotSetWriterRunTime.C @@ -32,7 +32,7 @@ License namespace Foam { - makeSetWriters(gnuplotSetWriter) + makeSetWriters(gnuplotSetWriter); } // ************************************************************************* // diff --git a/src/sampling/sampledSet/writers/jplot/jplotSetWriter.H b/src/sampling/sampledSet/writers/jplot/jplotSetWriter.H index 9897520506..940dec2abe 100644 --- a/src/sampling/sampledSet/writers/jplot/jplotSetWriter.H +++ b/src/sampling/sampledSet/writers/jplot/jplotSetWriter.H @@ -54,7 +54,7 @@ class jplotSetWriter // Private Member Functions //- Write header - Ostream& writeHeader(Ostream& os) const; + Ostream& writeHeader(Ostream&) const; public: @@ -85,7 +85,7 @@ public: const coordSet&, const wordList&, const List*>&, - Ostream& os + Ostream& ) const; }; diff --git a/src/sampling/sampledSet/writers/jplot/jplotSetWriterRunTime.C b/src/sampling/sampledSet/writers/jplot/jplotSetWriterRunTime.C index a6a4f48884..8a864712ed 100644 --- a/src/sampling/sampledSet/writers/jplot/jplotSetWriterRunTime.C +++ b/src/sampling/sampledSet/writers/jplot/jplotSetWriterRunTime.C @@ -32,7 +32,7 @@ License namespace Foam { - makeSetWriters(jplotSetWriter) + makeSetWriters(jplotSetWriter); } // ************************************************************************* // diff --git a/src/sampling/sampledSet/writers/raw/rawSetWriter.H b/src/sampling/sampledSet/writers/raw/rawSetWriter.H index af502104a7..346813d941 100644 --- a/src/sampling/sampledSet/writers/raw/rawSetWriter.H +++ b/src/sampling/sampledSet/writers/raw/rawSetWriter.H @@ -81,7 +81,7 @@ public: const coordSet&, const wordList&, const List*>&, - Ostream& os + Ostream& ) const; }; diff --git a/src/sampling/sampledSet/writers/raw/rawSetWriterRunTime.C b/src/sampling/sampledSet/writers/raw/rawSetWriterRunTime.C index 1af20c1dbf..e3acd319a3 100644 --- a/src/sampling/sampledSet/writers/raw/rawSetWriterRunTime.C +++ b/src/sampling/sampledSet/writers/raw/rawSetWriterRunTime.C @@ -32,7 +32,7 @@ License namespace Foam { - makeSetWriters(rawSetWriter) + makeSetWriters(rawSetWriter); } // ************************************************************************* // diff --git a/src/sampling/sampledSet/writers/writer.H b/src/sampling/sampledSet/writers/writer.H index 263d81df5e..e450d07c32 100644 --- a/src/sampling/sampledSet/writers/writer.H +++ b/src/sampling/sampledSet/writers/writer.H @@ -91,22 +91,12 @@ protected: //- Generates filename from coordSet and sampled fields fileName getBaseName(const coordSet&, const wordList&) const; - void writeCoord - ( - const coordSet& samples, - const label sampleI, - Ostream& os - ) const; + void writeCoord(const coordSet&, const label sampleI, Ostream&) const; //- Writes single-column ascii write. Column 1 is coordSet coordinate, // columns 2 is the value. Uses write() function // to write coordinate in correct format. - void writeTable - ( - const coordSet&, - const List&, - Ostream& os - ) const; + void writeTable(const coordSet&, const List&, Ostream&) const; //- Writes multi-column ascii write. Column 1 is coordSet coordinate, // columns 2..n are the values. Uses write() function @@ -139,10 +129,7 @@ public: // Selectors //- Return a reference to the selected writer - static autoPtr New - ( - const word& writeFormat - ); + static autoPtr New(const word& writeFormat); // Constructors @@ -165,8 +152,8 @@ public: ) const = 0; //- General entry point for writing. - // The data is organized in a set of point with one or - // more values per point + // The data is organized in a set of point with one or more values + // per point virtual void write ( const coordSet&, @@ -179,7 +166,7 @@ public: virtual Ostream& write(const scalar, Ostream&) const; template - Ostream& writeVS(const VSType& value, Ostream& os) const; + Ostream& writeVS(const VSType&, Ostream&) const; //- Write vector. Tab separated ascii virtual Ostream& write(const vector&, Ostream&) const; diff --git a/src/sampling/sampledSet/writers/writers.H b/src/sampling/sampledSet/writers/writers.H index ceb47e954e..bf7d033426 100644 --- a/src/sampling/sampledSet/writers/writers.H +++ b/src/sampling/sampledSet/writers/writers.H @@ -40,27 +40,27 @@ SourceFiles // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Only used internally -#define makeTypeSetWritersTypeName(typeWriter, dataType) \ - \ - defineNamedTemplateTypeNameAndDebug(typeWriter, 0); +#define makeTypeSetWritersTypeName(typeWriter, dataType) \ + \ + defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0) // Sometimes used externally -#define makeSetWritersTypeName(typeWriter) \ - \ - makeTypeSetWritersTypeName(typeWriter, scalar); \ - makeTypeSetWritersTypeName(typeWriter, vector); \ - makeTypeSetWritersTypeName(typeWriter, sphericalTensor); \ - makeTypeSetWritersTypeName(typeWriter, symmTensor); \ - makeTypeSetWritersTypeName(typeWriter, tensor); +#define makeSetWritersTypeName(typeWriter) \ + \ + makeTypeSetWritersTypeName(typeWriter, scalar); \ + makeTypeSetWritersTypeName(typeWriter, vector); \ + makeTypeSetWritersTypeName(typeWriter, sphericalTensor); \ + makeTypeSetWritersTypeName(typeWriter, symmTensor); \ + makeTypeSetWritersTypeName(typeWriter, tensor) // Define type info for single dataType template instantiation (eg, vector) -#define makeSetWriterType(typeWriter, dataType) \ - \ - defineNamedTemplateTypeNameAndDebug(typeWriter, 0); \ - addTemplatedToRunTimeSelectionTable \ - ( \ - writer, typeWriter, dataType, word \ - ); +#define makeSetWriterType(typeWriter, dataType) \ + \ + defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0); \ + addTemplatedToRunTimeSelectionTable \ + ( \ + writer, typeWriter, dataType, word \ + ) // Define type info for scalar, vector etc. instantiations @@ -70,7 +70,7 @@ SourceFiles makeSetWriterType(typeWriter, vector); \ makeSetWriterType(typeWriter, sphericalTensor); \ makeSetWriterType(typeWriter, symmTensor); \ - makeSetWriterType(typeWriter, tensor); + makeSetWriterType(typeWriter, tensor) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.H b/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.H index 1da5794a8e..b5abab73b5 100644 --- a/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.H +++ b/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriter.H @@ -81,7 +81,7 @@ public: const coordSet&, const wordList&, const List*>&, - Ostream& os + Ostream& ) const; }; diff --git a/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriterRunTime.C b/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriterRunTime.C index 434c4655fe..e793b6f6f4 100644 --- a/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriterRunTime.C +++ b/src/sampling/sampledSet/writers/xmgrace/xmgraceSetWriterRunTime.C @@ -32,7 +32,7 @@ License namespace Foam { - makeSetWriters(xmgraceSetWriter) + makeSetWriters(xmgraceSetWriter); } // ************************************************************************* // diff --git a/src/sampling/sampledSurface/sampledPatch/sampledPatch.H b/src/sampling/sampledSurface/sampledPatch/sampledPatch.H index fbc0b56ebe..2890a7bd34 100644 --- a/src/sampling/sampledSurface/sampledPatch/sampledPatch.H +++ b/src/sampling/sampledSurface/sampledPatch/sampledPatch.H @@ -50,11 +50,11 @@ namespace Foam class sampledPatch : - public BasicMeshedSurface, + public MeshedSurface, public sampledSurface { //- Private typedefs for convenience - typedef BasicMeshedSurface MeshStorage; + typedef MeshedSurface MeshStorage; // Private data diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 9eb0e73f11..d6b9613f6f 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C @@ -70,18 +70,27 @@ Foam::scalar Foam::sampledSurfaces::mergeTol_(1e-10); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::sampledSurfaces::checkFieldTypes() +Foam::label Foam::sampledSurfaces::classifyFieldTypes() { - wordList fieldTypes(fieldNames_.size()); + label nFields = 0; - // check files for a particular time - if (loadFromFiles_) + scalarFields_.clear(); + vectorFields_.clear(); + sphericalTensorFields_.clear(); + symmTensorFields_.clear(); + tensorFields_.clear(); + + forAll(fieldNames_, fieldI) { - forAll(fieldNames_, fieldI) + const word& fieldName = fieldNames_[fieldI]; + word fieldType = ""; + + // check files for a particular time + if (loadFromFiles_) { IOobject io ( - fieldNames_[fieldI], + fieldName, mesh_.time().timeName(), mesh_, IOobject::MUST_READ, @@ -91,69 +100,96 @@ bool Foam::sampledSurfaces::checkFieldTypes() if (io.headerOk()) { - fieldTypes[fieldI] = io.headerClassName(); + fieldType = io.headerClassName(); } else { - fieldTypes[fieldI] = "(notFound)"; + continue; } } - } - else - { - // check objectRegistry - forAll(fieldNames_, fieldI) + else { - objectRegistry::const_iterator iter = - mesh_.find(fieldNames_[fieldI]); + // check objectRegistry + objectRegistry::const_iterator iter = mesh_.find(fieldName); if (iter != mesh_.objectRegistry::end()) { - fieldTypes[fieldI] = iter()->type(); + fieldType = iter()->type(); } else { - fieldTypes[fieldI] = "(notFound)"; + continue; } } + + + if (fieldType == volScalarField::typeName) + { + scalarFields_.append(fieldName); + nFields++; + } + else if (fieldType == volVectorField::typeName) + { + vectorFields_.append(fieldName); + nFields++; + } + else if (fieldType == volSphericalTensorField::typeName) + { + sphericalTensorFields_.append(fieldName); + nFields++; + } + else if (fieldType == volSymmTensorField::typeName) + { + symmTensorFields_.append(fieldName); + nFields++; + } + else if (fieldType == volTensorField::typeName) + { + tensorFields_.append(fieldName); + nFields++; + } + } + return nFields; +} - label nFields = 0; - // classify fieldTypes - nFields += grep(scalarFields_, fieldTypes); - nFields += grep(vectorFields_, fieldTypes); - nFields += grep(sphericalTensorFields_, fieldTypes); - nFields += grep(symmTensorFields_, fieldTypes); - nFields += grep(tensorFields_, fieldTypes); +void Foam::sampledSurfaces::writeGeometry() const +{ + // Write to time directory under outputPath_ + // skip surface without faces (eg, a failed cut-plane) - if (Pstream::master()) + const fileName outputDir = outputPath_/mesh_.time().timeName(); + + forAll(*this, surfI) { - if (debug) - { - Pout<< "timeName = " << mesh_.time().timeName() << nl - << "scalarFields " << scalarFields_ << nl - << "vectorFields " << vectorFields_ << nl - << "sphTensorFields " << sphericalTensorFields_ << nl - << "symTensorFields " << symmTensorFields_ < 0) + if (Pstream::parRun()) { - if (debug) + if (Pstream::master() && mergeList_[surfI].faces.size()) { - Pout<< "Creating directory " - << outputPath_/mesh_.time().timeName() - << nl << endl; + genericFormatter_->write + ( + outputDir, + s.name(), + mergeList_[surfI].points, + mergeList_[surfI].faces + ); } - - mkDir(outputPath_/mesh_.time().timeName()); + } + else if (s.faces().size()) + { + genericFormatter_->write + ( + outputDir, + s.name(), + s.points(), + s.faces() + ); } } - - return nFields > 0; } @@ -176,6 +212,7 @@ Foam::sampledSurfaces::sampledSurfaces interpolationScheme_(word::null), writeFormat_(word::null), mergeList_(), + genericFormatter_(NULL), scalarFields_(), vectorFields_(), sphericalTensorFields_(), @@ -223,11 +260,39 @@ void Foam::sampledSurfaces::end() void Foam::sampledSurfaces::write() { - if (size() && checkFieldTypes()) + if (size()) { // finalize surfaces, merge points etc. update(); + const label nFields = classifyFieldTypes(); + + if (Pstream::master()) + { + if (debug) + { + Pout<< "timeName = " << mesh_.time().timeName() << nl + << "scalarFields " << scalarFields_ << nl + << "vectorFields " << vectorFields_ << nl + << "sphTensorFields " << sphericalTensorFields_ << nl + << "symTensorFields " << symmTensorFields_ <separateFiles()) + { + writeGeometry(); + } + sampleAndWrite(scalarFields_); sampleAndWrite(vectorFields_); sampleAndWrite(sphericalTensorFields_); @@ -241,6 +306,14 @@ void Foam::sampledSurfaces::read(const dictionary& dict) { fieldNames_ = wordList(dict.lookup("fields")); + const label nFields = fieldNames_.size(); + + scalarFields_.reset(nFields); + vectorFields_.reset(nFields); + sphericalTensorFields_.reset(nFields); + symmTensorFields_.reset(nFields); + tensorFields_.reset(nFields); + interpolationScheme_ = dict.lookupOrDefault ( "interpolationScheme", @@ -252,6 +325,11 @@ void Foam::sampledSurfaces::read(const dictionary& dict) "null" ); + + // define the generic (geometry) writer + genericFormatter_ = surfaceWriter::New(writeFormat_); + + PtrList newList ( dict.lookup("surfaces"), diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 7bf12aaba8..4ad59c486f 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H @@ -64,24 +64,24 @@ class sampledSurfaces template class fieldGroup : - public wordList + public DynamicList { public: //- Surface formatter - autoPtr > formatter; + autoPtr< surfaceWriter > formatter; //- Construct null fieldGroup() : - wordList(0), + DynamicList(0), formatter(NULL) {} //- Construct for a particular surface format fieldGroup(const word& writeFormat) : - wordList(0), + DynamicList(0), formatter(surfaceWriter::New(writeFormat)) {} @@ -93,10 +93,17 @@ class sampledSurfaces const wordList& fieldNames ) : - wordList(fieldNames), + DynamicList(fieldNames), formatter(surfaceWriter::New(writeFormat)) {} + void reset(const label nElem) + { + formatter.clear(); + DynamicList::setCapacity(nElem); + DynamicList::clear(); + } + void operator=(const word& writeFormat) { formatter = surfaceWriter::New(writeFormat); @@ -104,7 +111,7 @@ class sampledSurfaces void operator=(const wordList& fieldNames) { - wordList::operator=(fieldNames); + DynamicList::operator=(fieldNames); } }; @@ -171,6 +178,9 @@ class sampledSurfaces // Calculated + //- Generic surface formatter + autoPtr< surfaceWriter > genericFormatter_; + //- Categorized scalar/vector/tensor fields fieldGroup scalarFields_; fieldGroup vectorFields_; @@ -181,16 +191,11 @@ class sampledSurfaces // Private Member Functions - //- Classify field types, return true if nFields > 0 - bool checkFieldTypes(); + //- Classify field types, returns the number of fields + label classifyFieldTypes(); - //- Find the fields in the list of the given type, return count - template - label grep - ( - fieldGroup& fieldList, - const wordList& fieldTypes - ) const; + //- Write geometry only + void writeGeometry() const; //- Sample and write a particular volume field template diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index e93bb0bde7..6da55cfe87 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -30,35 +30,6 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -Foam::label Foam::sampledSurfaces::grep -( - fieldGroup& fieldList, - const wordList& fieldTypes -) const -{ - fieldList.setSize(fieldNames_.size()); - label nFields = 0; - - forAll(fieldNames_, fieldI) - { - if - ( - fieldTypes[fieldI] - == GeometricField::typeName - ) - { - fieldList[nFields] = fieldNames_[fieldI]; - nFields++; - } - } - - fieldList.setSize(nFields); - - return nFields; -} - - template void Foam::sampledSurfaces::sampleAndWrite ( @@ -67,10 +38,10 @@ void Foam::sampledSurfaces::sampleAndWrite ) { // interpolator for this field - autoPtr > interpolator; + autoPtr< interpolation > interpolator; const word& fieldName = vField.name(); - const fileName& timeDir = vField.time().timeName(); + const fileName outputDir = outputPath_/vField.time().timeName(); forAll(*this, surfI) { @@ -128,8 +99,7 @@ void Foam::sampledSurfaces::sampleAndWrite { formatter.write ( - outputPath_, - timeDir, + outputDir, s.name(), mergeList_[surfI].points, mergeList_[surfI].faces, @@ -147,8 +117,7 @@ void Foam::sampledSurfaces::sampleAndWrite { formatter.write ( - outputPath_, - timeDir, + outputDir, s.name(), s.points(), s.faces(), @@ -217,7 +186,7 @@ void Foam::sampledSurfaces::sampleAndWrite sampleAndWrite ( mesh_.lookupObject - > + > ( fields[fieldI] ), diff --git a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C new file mode 100644 index 0000000000..1dd43b4be3 --- /dev/null +++ b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C @@ -0,0 +1,333 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "sampledThresholdCellFaces.H" + +#include "dictionary.H" +#include "volFields.H" +#include "volPointInterpolation.H" +#include "addToRunTimeSelectionTable.H" +#include "fvMesh.H" +#include "thresholdCellFaces.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(sampledThresholdCellFaces, 0); + addNamedToRunTimeSelectionTable + ( + sampledSurface, + sampledThresholdCellFaces, + word, + thresholdCellFaces + ); +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::sampledThresholdCellFaces::updateGeometry() const +{ + const fvMesh& fvm = static_cast(mesh()); + + // no update needed + if (fvm.time().timeIndex() == prevTimeIndex_) + { + return false; + } + + prevTimeIndex_ = fvm.time().timeIndex(); + + // Optionally read volScalarField + autoPtr readFieldPtr_; + + // 1. see if field in database + // 2. see if field can be read + const volScalarField* cellFldPtr = NULL; + if (fvm.foundObject(fieldName_)) + { + if (debug) + { + Info<< "sampledThresholdCellFaces::updateGeometry() : lookup " + << fieldName_ << endl; + } + + cellFldPtr = &fvm.lookupObject(fieldName_); + } + else + { + // Bit of a hack. Read field and store. + + if (debug) + { + Info<< "sampledThresholdCellFaces::updateGeometry() : reading " + << fieldName_ << " from time " << fvm.time().timeName() + << endl; + } + + readFieldPtr_.reset + ( + new volScalarField + ( + IOobject + ( + fieldName_, + fvm.time().timeName(), + fvm, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + fvm + ) + ); + + cellFldPtr = readFieldPtr_.operator->(); + } + const volScalarField& cellFld = *cellFldPtr; + + + thresholdCellFaces surf + ( + fvm, + cellFld.internalField(), + lowerThreshold_, + upperThreshold_, + triangulate_ + ); + + const_cast + ( + *this + ).MeshedSurface::transfer(surf); + meshCells_.transfer(surf.meshCells()); + + + if (debug) + { + Pout<< "sampledThresholdCellFaces::updateGeometry() : constructed" + << nl + << " field : " << fieldName_ << nl + << " lowerLimit : " << lowerThreshold_ << nl + << " upperLimit : " << upperThreshold_ << nl + << " point : " << points().size() << nl + << " faces : " << faces().size() << nl + << " cut cells : " << meshCells_.size() << endl; + } + + return true; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::sampledThresholdCellFaces::sampledThresholdCellFaces +( + const word& name, + const polyMesh& mesh, + const dictionary& dict +) +: + sampledSurface(name, mesh, dict), + fieldName_(dict.lookup("field")), + lowerThreshold_(dict.lookupOrDefault("lowerLimit", -VGREAT)), + upperThreshold_(dict.lookupOrDefault("upperLimit", VGREAT)), + zoneName_(word::null), + triangulate_(dict.lookupOrDefault("triangulate", false)), + prevTimeIndex_(-1), + meshCells_(0) +{ + if (!dict.found("lowerLimit") && !dict.found("upperLimit")) + { + FatalErrorIn + ( + "sampledThresholdCellFaces::sampledThresholdCellFaces(..)" + ) + << "require at least one of 'lowerLimit' or 'upperLimit'" << endl + << abort(FatalError); + } + + +// dict.readIfPresent("zone", zoneName_); +// +// if (debug && zoneName_.size()) +// { +// if (mesh.cellZones().findZoneID(zoneName_) < 0) +// { +// Info<< "cellZone \"" << zoneName_ +// << "\" not found - using entire mesh" << endl; +// } +// } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::sampledThresholdCellFaces::~sampledThresholdCellFaces() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::sampledThresholdCellFaces::needsUpdate() const +{ + const fvMesh& fvm = static_cast(mesh()); + + return fvm.time().timeIndex() != prevTimeIndex_; +} + + +bool Foam::sampledThresholdCellFaces::expire() +{ + // already marked as expired + if (prevTimeIndex_ == -1) + { + return false; + } + + // force update + prevTimeIndex_ = -1; + return true; +} + + +bool Foam::sampledThresholdCellFaces::update() +{ + return updateGeometry(); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::sample +( + const volScalarField& vField +) const +{ + return sampleField(vField); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::sample +( + const volVectorField& vField +) const +{ + return sampleField(vField); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::sample +( + const volSphericalTensorField& vField +) const +{ + return sampleField(vField); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::sample +( + const volSymmTensorField& vField +) const +{ + return sampleField(vField); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::sample +( + const volTensorField& vField +) const +{ + return sampleField(vField); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::interpolate +( + const interpolation& interpolator +) const +{ + return interpolateField(interpolator); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::interpolate +( + const interpolation& interpolator +) const +{ + return interpolateField(interpolator); +} + +Foam::tmp +Foam::sampledThresholdCellFaces::interpolate +( + const interpolation& interpolator +) const +{ + return interpolateField(interpolator); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::interpolate +( + const interpolation& interpolator +) const +{ + return interpolateField(interpolator); +} + + +Foam::tmp +Foam::sampledThresholdCellFaces::interpolate +( + const interpolation& interpolator +) const +{ + return interpolateField(interpolator); +} + + +void Foam::sampledThresholdCellFaces::print(Ostream& os) const +{ + os << "sampledThresholdCellFaces: " << name() << " :" + << " field:" << fieldName_ + << " lowerLimit:" << lowerThreshold_ + << " upperLimit:" << upperThreshold_; + //<< " faces:" << faces().size() // possibly no geom yet + //<< " points:" << points().size(); +} + + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.H b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.H new file mode 100644 index 0000000000..89b2c21c47 --- /dev/null +++ b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.H @@ -0,0 +1,234 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::sampledThresholdCellFaces + +Description + A sampledSurface defined by the cell faces corresponding to a threshold + value. + +SourceFiles + sampledThresholdCellFaces.C + +\*---------------------------------------------------------------------------*/ + +#ifndef sampledThresholdCellFaces_H +#define sampledThresholdCellFaces_H + +#include "sampledSurface.H" +#include "MeshedSurface.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class sampledThresholdCellFaces Declaration +\*---------------------------------------------------------------------------*/ + +class sampledThresholdCellFaces +: + public sampledSurface, + public MeshedSurface +{ + //- Private typedefs for convenience + typedef MeshedSurface MeshStorage; + + // Private data + + //- Field to get isoSurface of + const word fieldName_; + + //- Threshold value + const scalar lowerThreshold_; + + //- Threshold value + const scalar upperThreshold_; + + //- zone name (if restricted to zones) + word zoneName_; + + //- Triangulated faces or keep faces as is + bool triangulate_; + + // Recreated for every time-step + + //- Time at last call, also track it surface needs an update + mutable label prevTimeIndex_; + + //- For every face the original cell in mesh + mutable labelList meshCells_; + + + // Private Member Functions + + //- Create surface (if time has changed) + // Do nothing (and return false) if no update was needed + bool updateGeometry() const; + + //- sample field on faces + template + tmp > sampleField + ( + const GeometricField& vField + ) const; + + + template + tmp > + interpolateField(const interpolation&) const; + + +public: + + //- Runtime type information + TypeName("sampledThresholdCellFaces"); + + + // Constructors + + //- Construct from dictionary + sampledThresholdCellFaces + ( + const word& name, + const polyMesh&, + const dictionary& + ); + + + // Destructor + + virtual ~sampledThresholdCellFaces(); + + + // Member Functions + + //- Does the surface need an update? + virtual bool needsUpdate() const; + + //- Mark the surface as needing an update. + // May also free up unneeded data. + // Return false if surface was already marked as expired. + virtual bool expire(); + + //- Update the surface as required. + // Do nothing (and return false) if no update was needed + virtual bool update(); + + + //- Points of surface + virtual const pointField& points() const + { + return MeshStorage::points(); + } + + //- Faces of surface + virtual const faceList& faces() const + { + return MeshStorage::faces(); + } + + //- sample field on surface + virtual tmp sample + ( + const volScalarField& + ) const; + + //- sample field on surface + virtual tmp sample + ( + const volVectorField& + ) const; + + //- sample field on surface + virtual tmp sample + ( + const volSphericalTensorField& + ) const; + + //- sample field on surface + virtual tmp sample + ( + const volSymmTensorField& + ) const; + + //- sample field on surface + virtual tmp sample + ( + const volTensorField& + ) const; + + + //- interpolate field on surface + virtual tmp interpolate + ( + const interpolation& + ) const; + + //- interpolate field on surface + virtual tmp interpolate + ( + const interpolation& + ) const; + + //- interpolate field on surface + virtual tmp interpolate + ( + const interpolation& + ) const; + + //- interpolate field on surface + virtual tmp interpolate + ( + const interpolation& + ) const; + + //- interpolate field on surface + virtual tmp interpolate + ( + const interpolation& + ) const; + + //- Write + virtual void print(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "sampledThresholdCellFacesTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFacesTemplates.C b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFacesTemplates.C new file mode 100644 index 0000000000..a1021340c9 --- /dev/null +++ b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFacesTemplates.C @@ -0,0 +1,90 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "sampledThresholdCellFaces.H" + +#include "thresholdCellFaces.H" +#include "volFieldsFwd.H" +#include "pointFields.H" +#include "volPointInterpolation.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +Foam::tmp > +Foam::sampledThresholdCellFaces::sampleField +( + const GeometricField& vField +) const +{ + // Recreate geometry if time has changed + updateGeometry(); + + return tmp >(new Field(vField, meshCells_)); +} + + +template +Foam::tmp > +Foam::sampledThresholdCellFaces::interpolateField +( + const interpolation& interpolator +) const +{ + // Recreate geometry if time has changed + updateGeometry(); + + // One value per point + tmp > tvalues(new Field(points().size())); + Field& values = tvalues(); + + boolList pointDone(points().size(), false); + + forAll(faces(), cutFaceI) + { + const face& f = faces()[cutFaceI]; + + forAll(f, faceVertI) + { + label pointI = f[faceVertI]; + + if (!pointDone[pointI]) + { + values[pointI] = interpolator.interpolate + ( + points()[pointI], + meshCells_[cutFaceI] + ); + pointDone[pointI] = true; + } + } + } + + return tvalues; +} + + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/thresholdCellFaces/thresholdCellFaces.C b/src/sampling/sampledSurface/thresholdCellFaces/thresholdCellFaces.C new file mode 100644 index 0000000000..6caaea0ff0 --- /dev/null +++ b/src/sampling/sampledSurface/thresholdCellFaces/thresholdCellFaces.C @@ -0,0 +1,288 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "thresholdCellFaces.H" + +#include "polyMesh.H" +#include "DynamicList.H" + +#include "emptyPolyPatch.H" +#include "processorPolyPatch.H" + + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::thresholdCellFaces, 0); + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::thresholdCellFaces::calculate +( + const scalarField& field, + const scalar lowerThreshold, + const scalar upperThreshold, + const bool triangulate +) +{ + const labelList& own = mesh_.faceOwner(); + const labelList& nei = mesh_.faceNeighbour(); + + const faceList& origFaces = mesh_.faces(); + const pointField& origPoints = mesh_.points(); + + const polyBoundaryMesh& bMesh = mesh_.boundaryMesh(); + + + surfZoneList surfZones(bMesh.size()+1); + + surfZones[0] = surfZone + ( + "internalMesh", + 0, // size + 0, // start + 0 // index + ); + + forAll(bMesh, patchI) + { + surfZones[patchI+1] = surfZone + ( + bMesh[patchI].name(), + 0, // size + 0, // start + patchI+1 // index + ); + } + + + label nFaces = 0; + label nPoints = 0; + + + meshCells_.clear(); + + DynamicList surfFaces(0.5 * mesh_.nFaces()); + DynamicList