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/mesh/generation/blockMesh/curvedEdges/arcEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/arcEdge.C index a83154ad56..886281274b 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/arcEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/arcEdge.C @@ -30,8 +30,7 @@ Description #include "arcEdge.H" #include "mathematicalConstants.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -40,8 +39,7 @@ namespace Foam defineTypeNameAndDebug(arcEdge, 0); // Add the curvedEdge constructor functions to the hash tables - curvedEdge::addIstreamConstructorToTable - addArcEdgeIstreamConstructorToTable_; + addToRunTimeSelectionTable(curvedEdge, arcEdge, Istream); } diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.C index c9d31ef6a1..6a2d41a83e 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.C @@ -41,26 +41,7 @@ namespace Foam // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(curvedEdge, 0); - -// Define the constructor function hash tables -HashTable* - curvedEdge::IstreamConstructorTablePtr_; - - -// Hash table Constructor called from the table add functions. - -void curvedEdge::constructTables() -{ - static bool constructed = false; - - if (!constructed) - { - curvedEdge::IstreamConstructorTablePtr_ - = new HashTable; - - constructed = true; - } -} +defineRunTimeSelectionTable(curvedEdge, Istream); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -117,10 +98,11 @@ autoPtr curvedEdge::New(const pointField& points, Istream& is) word curvedEdgeType(is); - HashTable::iterator curvedEdgeConstructorIter = - IstreamConstructorTablePtr_->find(curvedEdgeType); + IstreamConstructorTable::iterator cstrIter = + IstreamConstructorTablePtr_ + ->find(curvedEdgeType); - if (curvedEdgeConstructorIter == IstreamConstructorTablePtr_->end()) + if (cstrIter == IstreamConstructorTablePtr_->end()) { FatalErrorIn("curvedEdge::New(const pointField&, Istream&)") << "Unknown curvedEdge type " << curvedEdgeType << endl << endl @@ -129,7 +111,7 @@ autoPtr curvedEdge::New(const pointField& points, Istream& is) << abort(FatalError); } - return autoPtr(curvedEdgeConstructorIter()(points, is)); + return autoPtr(cstrIter()(points, is)); } @@ -177,7 +159,6 @@ Ostream& operator<<(Ostream& os, const curvedEdge& p) } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.H b/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.H index c568180d73..5ecf489d38 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.H +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/curvedEdge.H @@ -63,51 +63,23 @@ protected: public: - // Constructor Hash tables - - //- Construct from Istream function pointer type - typedef autoPtr (*IstreamConstructorPtr_) - (const pointField&, Istream&); - - //- Construct from Istream function pointer table pointer - static HashTable* - IstreamConstructorTablePtr_; + //- Runtime type information + TypeName("curvedEdge"); - // Hash table constructor classes and functions + // Declare run-time constructor selection tables - //- Hash table Constructor. - // Must be called from the table add functions below. - static void constructTables(); - - - //- Class to add constructor from Istream to Hash table - template - class addIstreamConstructorToTable - { - public: - - static autoPtr New + declareRunTimeSelectionTable + ( + autoPtr, + curvedEdge, + Istream, ( const pointField& points, Istream& is - ) - { - return autoPtr(new curvedEdgeType(points, is)); - } - - addIstreamConstructorToTable() - { - curvedEdge::constructTables(); - - curvedEdge::IstreamConstructorTablePtr_ - ->insert(curvedEdgeType::typeName, New); - } - }; - - - //- Runtime type information - TypeName("curvedEdge"); + ), + (points, is) + ); // Constructors diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.C index f4581ed338..7263f71843 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.C @@ -26,6 +26,7 @@ License #include "polySplineEdge.H" #include "BSpline.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -34,8 +35,7 @@ namespace Foam defineTypeNameAndDebug(polySplineEdge, 0); // Add the curvedEdge constructor functions to the hash tables - curvedEdge::addIstreamConstructorToTable - addPolySplineEdgeIstreamConstructorToTable_; + addToRunTimeSelectionTable(curvedEdge, polySplineEdge, Istream); } diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.H b/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.H index d71685782d..1f59d5bf8e 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.H +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/polySplineEdge.H @@ -92,7 +92,7 @@ public: ); //- Construct from Istream setting pointsList - polySplineEdge(const pointField& points,Istream& is); + polySplineEdge(const pointField& points, Istream& is); // Destructor diff --git a/applications/utilities/mesh/generation/blockMesh/curvedEdges/simpleSplineEdge.C b/applications/utilities/mesh/generation/blockMesh/curvedEdges/simpleSplineEdge.C index 8fe13aefe0..b45f0ea3c2 100644 --- a/applications/utilities/mesh/generation/blockMesh/curvedEdges/simpleSplineEdge.C +++ b/applications/utilities/mesh/generation/blockMesh/curvedEdges/simpleSplineEdge.C @@ -27,9 +27,8 @@ Description \*---------------------------------------------------------------------------*/ -#include "error.H" - #include "simpleSplineEdge.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -39,10 +38,8 @@ namespace Foam // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(simpleSplineEdge, 0); +addToRunTimeSelectionTable(curvedEdge, simpleSplineEdge, Istream); -// Add the curvedEdge constructor functions to the hash tables -curvedEdge::addIstreamConstructorToTable - addSimpleSplineEdgeIstreamConstructorToTable_; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // 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 d581bacd7f..9311c9b4e9 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -282,7 +282,7 @@ int main(int argc, char *argv[]) ( readDir ( - databases[procI].timePath()/regionPrefix/"lagrangian", + databases[procI].timePath()/regionPrefix/cloud::prefix, fileName::DIRECTORY ) ); @@ -300,7 +300,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/probeLocations/probeLocations.C b/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C index 6e9ee2f228..18ba96c4f1 100644 --- a/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C +++ b/applications/utilities/postProcessing/sampling/probeLocations/probeLocations.C @@ -39,10 +39,12 @@ using namespace Foam; int main(int argc, char *argv[]) { timeSelector::addOptions(); +# include "addRegionOption.H" + # include "setRootCase.H" # include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); -# include "createMesh.H" +# include "createNamedMesh.H" IOprobes sniff ( 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/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C index 00091293fa..70eafc70a8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C @@ -143,7 +143,7 @@ void Foam::processorPolyPatch::initGeometry() ( Pstream::blocking, neighbProcNo(), - 3*(sizeof(label) + size()*sizeof(vector) + sizeof(float)) + 3*(sizeof(label) + size()*sizeof(vector) + sizeof(scalar)) ); toNeighbProc @@ -163,7 +163,7 @@ void Foam::processorPolyPatch::calcGeometry() ( Pstream::blocking, neighbProcNo(), - 3*(sizeof(label) + size()*sizeof(vector) + sizeof(float)) + 3*(sizeof(label) + size()*sizeof(vector) + sizeof(scalar)) ); fromNeighbProc >> neighbFaceCentres_ 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/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index a49366e8ad..41f31c0ecc 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -1,5 +1,6 @@ fvMotionSolvers/fvMotionSolver/fvMotionSolver.C fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C +fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C index 68f7280c19..8c53669181 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C @@ -55,25 +55,10 @@ namespace Foam Foam::displacementSBRStressFvMotionSolver::displacementSBRStressFvMotionSolver ( const polyMesh& mesh, - Istream& + Istream& is ) : - fvMotionSolver(mesh), - points0_ - ( - pointIOField - ( - IOobject - ( - "points", - time().constant(), - polyMesh::meshSubDir, - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ) - ), + displacementFvMotionSolver(mesh, is), pointDisplacement_ ( IOobject @@ -132,7 +117,7 @@ Foam::displacementSBRStressFvMotionSolver::curPoints() const tmp tcurPoints ( - points0_ + pointDisplacement_.internalField() + points0() + pointDisplacement_.internalField() ); twoDCorrectPoints(tcurPoints()); @@ -208,63 +193,7 @@ void Foam::displacementSBRStressFvMotionSolver::updateMesh const mapPolyMesh& mpm ) { - fvMotionSolver::updateMesh(mpm); - - // Map points0_ - // Map points0_. Bit special since we somehow have to come up with - // a sensible points0 position for introduced points. - // Find out scaling between points0 and current points - - // Get the new points either from the map or the mesh - const pointField& points = - ( - mpm.hasMotionPoints() - ? mpm.preMotionPoints() - : fvMesh_.points() - ); - - // Note: boundBox does reduce - const vector span0 = boundBox(points0_).span(); - const vector span = boundBox(points).span(); - - vector scaleFactors(cmptDivide(span0, span)); - - pointField newPoints0(mpm.pointMap().size()); - - forAll(newPoints0, pointI) - { - label oldPointI = mpm.pointMap()[pointI]; - - if (oldPointI >= 0) - { - label masterPointI = mpm.reversePointMap()[oldPointI]; - - if (masterPointI == pointI) - { - newPoints0[pointI] = points0_[oldPointI]; - } - else - { - // New point. Assume motion is scaling. - newPoints0[pointI] = points0_[oldPointI] + cmptMultiply - ( - scaleFactors, - points[pointI]-points[masterPointI] - ); - } - } - else - { - FatalErrorIn - ( - "displacementSBRStressFvMotionSolver::updateMesh" - "(const mapPolyMesh& mpm)" - ) << "Cannot work out coordinates of introduced vertices." - << " New vertex " << pointI << " at coordinate " - << points[pointI] << exit(FatalError); - } - } - points0_.transfer(newPoints0); + displacementFvMotionSolver::updateMesh(mpm); // Update diffusivity. Note two stage to make sure old one is de-registered // before creating/registering new one. diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H index 740fed7e7b..766025cf86 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.H @@ -37,7 +37,7 @@ SourceFiles #ifndef displacementSBRStressFvMotionSolver_H #define displacementSBRStressFvMotionSolver_H -#include "fvMotionSolver.H" +#include "displacementFvMotionSolver.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,13 +53,10 @@ class motionDiffusivity; class displacementSBRStressFvMotionSolver : - public fvMotionSolver + public displacementFvMotionSolver { // Private data - //- Reference point field - pointField points0_; - //- Point motion field mutable pointVectorField pointDisplacement_; @@ -105,12 +102,6 @@ public: // Member Functions - //- Return reference to the reference field - const pointField& points0() const - { - return points0_; - } - //- Return reference to the point motion displacement field pointVectorField& pointDisplacement() { diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C new file mode 100644 index 0000000000..aee52c717c --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.C @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "displacementFvMotionSolver.H" +#include "addToRunTimeSelectionTable.H" +#include "mapPolyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +// defineTypeNameAndDebug(displacementFvMotionSolver, 0); +// +// addToRunTimeSelectionTable +// ( +// fvMotionSolver, +// displacementFvMotionSolver, +// dictionary +// ); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::displacementFvMotionSolver:: +displacementFvMotionSolver +( + const polyMesh& mesh, + Istream& +) +: + fvMotionSolver(mesh), + points0_ + ( + pointIOField + ( + IOobject + ( + "points", + mesh.time().constant(), + polyMesh::meshSubDir, + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::displacementFvMotionSolver::~displacementFvMotionSolver() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::displacementFvMotionSolver::updateMesh(const mapPolyMesh& mpm) +{ + fvMotionSolver::updateMesh(mpm); + + // Map points0_. Bit special since we somehow have to come up with + // a sensible points0 position for introduced points. + // Find out scaling between points0 and current points + + // Get the new points either from the map or the mesh + const pointField& points = + ( + mpm.hasMotionPoints() + ? mpm.preMotionPoints() + : fvMesh_.points() + ); + + // Note: boundBox does reduce + const vector span0 = boundBox(points0_).span(); + const vector span = boundBox(points).span(); + + vector scaleFactors(cmptDivide(span0, span)); + + pointField newPoints0(mpm.pointMap().size()); + + forAll(newPoints0, pointI) + { + label oldPointI = mpm.pointMap()[pointI]; + + if (oldPointI >= 0) + { + label masterPointI = mpm.reversePointMap()[oldPointI]; + + if (masterPointI == pointI) + { + newPoints0[pointI] = points0_[oldPointI]; + } + else + { + // New point. Assume motion is scaling. + newPoints0[pointI] = points0_[oldPointI] + cmptMultiply + ( + scaleFactors, + points[pointI]-points[masterPointI] + ); + } + } + else + { + FatalErrorIn + ( + "displacementLaplacianFvMotionSolver::updateMesh" + "(const mapPolyMesh& mpm)" + ) << "Cannot work out coordinates of introduced vertices." + << " New vertex " << pointI << " at coordinate " + << points[pointI] << exit(FatalError); + } + } + points0_.transfer(newPoints0); +} + + +// ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.H new file mode 100644 index 0000000000..aedd15f704 --- /dev/null +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/displacementFvMotionSolver/displacementFvMotionSolver.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::displacementFvMotionSolver.H + +Description + Base class for fvMotionSolvers which calculate displacement. + +SourceFiles + displacementFvMotionSolver.C + +\*---------------------------------------------------------------------------*/ + +#ifndef displacementFvMotionSolver_H +#define displacementFvMotionSolver_H + +#include "fvMotionSolver.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class displacementFvMotionSolver Declaration +\*---------------------------------------------------------------------------*/ + +class displacementFvMotionSolver +: + public fvMotionSolver +{ + // Private data + + //- Reference point field + pointField points0_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + displacementFvMotionSolver + ( + const displacementFvMotionSolver& + ); + + //- Disallow default bitwise assignment + void operator=(const displacementFvMotionSolver&); + + +public: + + //- Runtime type information + TypeName("displacementInterpolation"); + + + // Constructors + + //- Construct from polyMesh and data stream + displacementFvMotionSolver + ( + const polyMesh&, + Istream& msDataUnused + ); + + + // Destructor + + ~displacementFvMotionSolver(); + + + // Member Functions + + //- Return reference to the reference field + const pointField& points0() const + { + return points0_; + } + + //- Update topology + virtual void updateMesh(const mapPolyMesh&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C index 178d1d1b2a..cdd5a999ec 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.C @@ -58,26 +58,10 @@ Foam::displacementInterpolationFvMotionSolver:: displacementInterpolationFvMotionSolver ( const polyMesh& mesh, - Istream& + Istream& is ) : - fvMotionSolver(mesh), - points0_ - ( - pointIOField - ( - IOobject - ( - "points", - mesh.time().constant(), - polyMesh::meshSubDir, - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ) - ), + displacementFvMotionSolver(mesh, is), dynamicMeshCoeffs_ ( IOdictionary @@ -174,7 +158,7 @@ displacementInterpolationFvMotionSolver forAll(fz().meshPoints(), localI) { label pointI = fz().meshPoints()[localI]; - const scalar coord = points0_[pointI][dir]; + const scalar coord = points0()[pointI][dir]; minCoord = min(minCoord, coord); maxCoord = max(maxCoord, coord); } @@ -198,7 +182,7 @@ displacementInterpolationFvMotionSolver zoneCoordinates[zoneCoordinates.size()-1] += SMALL; // Check if we have static min and max mesh bounds - const scalarField meshCoords = points0_.component(dir); + const scalarField meshCoords = points0().component(dir); scalar minCoord = gMin(meshCoords); scalar maxCoord = gMax(meshCoords); @@ -288,7 +272,7 @@ displacementInterpolationFvMotionSolver "displacementInterpolationFvMotionSolver::" "displacementInterpolationFvMotionSolver" "(const polyMesh&, Istream&)" - ) << "Did not find point " << points0_[pointI] + ) << "Did not find point " << points0()[pointI] << " coordinate " << meshCoords[pointI] << " in ranges " << rangeToCoord << abort(FatalError); @@ -344,18 +328,18 @@ Foam::displacementInterpolationFvMotionSolver:: Foam::tmp Foam::displacementInterpolationFvMotionSolver::curPoints() const { - if (mesh().nPoints() != points0_.size()) + if (mesh().nPoints() != points0().size()) { FatalErrorIn ( "displacementInterpolationFvMotionSolver::curPoints() const" ) << "The number of points in the mesh seems to have changed." << endl - << "In constant/polyMesh there are " << points0_.size() + << "In constant/polyMesh there are " << points0().size() << " points; in the current mesh there are " << mesh().nPoints() << " points." << exit(FatalError); } - tmp tcurPoints(new pointField(points0_)); + tmp tcurPoints(new pointField(points0())); pointField& curPoints = tcurPoints(); // Interpolate the diplacement of the face zones. @@ -413,68 +397,4 @@ Foam::displacementInterpolationFvMotionSolver::curPoints() const } -void Foam::displacementInterpolationFvMotionSolver::updateMesh -( - const mapPolyMesh& mpm -) -{ - fvMotionSolver::updateMesh(mpm); - - // Map points0_. Bit special since we somehow have to come up with - // a sensible points0 position for introduced points. - // Find out scaling between points0 and current points - - // Get the new points either from the map or the mesh - const pointField& points = - ( - mpm.hasMotionPoints() - ? mpm.preMotionPoints() - : fvMesh_.points() - ); - - // Note: boundBox does reduce - const vector span0 = boundBox(points0_).span(); - const vector span = boundBox(points).span(); - - vector scaleFactors(cmptDivide(span0, span)); - - pointField newPoints0(mpm.pointMap().size()); - - forAll(newPoints0, pointI) - { - label oldPointI = mpm.pointMap()[pointI]; - - if (oldPointI >= 0) - { - label masterPointI = mpm.reversePointMap()[oldPointI]; - - if (masterPointI == pointI) - { - newPoints0[pointI] = points0_[oldPointI]; - } - else - { - // New point. Assume motion is scaling. - newPoints0[pointI] = points0_[oldPointI] + cmptMultiply - ( - scaleFactors, - points[pointI]-points[masterPointI] - ); - } - } - else - { - FatalErrorIn - ( - "displacementLaplacianFvMotionSolver::updateMesh" - "(const mapPolyMesh& mpm)" - ) << "Cannot work out coordinates of introduced vertices." - << " New vertex " << pointI << " at coordinate " - << points[pointI] << exit(FatalError); - } - } - points0_.transfer(newPoints0); -} - - // ************************************************************************* // diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H index cd7438df06..d67886ac3c 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationFvMotionSolver.H @@ -48,7 +48,7 @@ SourceFiles #ifndef displacementInterpolationFvMotionSolver_H #define displacementInterpolationFvMotionSolver_H -#include "fvMotionSolver.H" +#include "displacementFvMotionSolver.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,13 +61,10 @@ namespace Foam class displacementInterpolationFvMotionSolver : - public fvMotionSolver + public displacementFvMotionSolver { // Private data - //- Reference point field - pointField points0_; - //- Additional settings for motion solver dictionary dynamicMeshCoeffs_; @@ -130,21 +127,12 @@ public: // Member Functions - //- Return reference to the reference field - const pointField& points0() const - { - return points0_; - } - //- Return point location obtained from the current motion field virtual tmp curPoints() const; //- Solve for motion virtual void solve() {} - - //- Update topology - virtual void updateMesh(const mapPolyMesh&); }; diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index a979feebb3..e57a17cce9 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -53,26 +53,10 @@ namespace Foam Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver ( const polyMesh& mesh, - Istream& + Istream& is ) : - fvMotionSolver(mesh), - points0_ - ( - pointIOField - ( - IOobject - ( - "points", - time().constant(), - polyMesh::meshSubDir, - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ) - ) - ), + displacementFvMotionSolver(mesh, is), pointDisplacement_ ( IOobject @@ -186,7 +170,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const } pointLocation_().internalField() = - points0_ + points0() + pointDisplacement_.internalField(); pointLocation_().correctBoundaryConditions(); @@ -198,7 +182,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const forAll(pz, i) { - pointLocation_()[pz[i]] = points0_[pz[i]]; + pointLocation_()[pz[i]] = points0()[pz[i]]; } } @@ -210,7 +194,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const { tmp tcurPoints ( - points0_ + pointDisplacement_.internalField() + points0() + pointDisplacement_.internalField() ); // Implement frozen points @@ -220,7 +204,7 @@ Foam::displacementLaplacianFvMotionSolver::curPoints() const forAll(pz, i) { - tcurPoints()[pz[i]] = points0_[pz[i]]; + tcurPoints()[pz[i]] = points0()[pz[i]]; } } @@ -257,74 +241,7 @@ void Foam::displacementLaplacianFvMotionSolver::updateMesh const mapPolyMesh& mpm ) { - fvMotionSolver::updateMesh(mpm); - - // Map points0_. Bit special since we somehow have to come up with - // a sensible points0 position for introduced points. - // Find out scaling between points0 and current points - - // Get the new points either from the map or the mesh - const pointField& points = - ( - mpm.hasMotionPoints() - ? mpm.preMotionPoints() - : fvMesh_.points() - ); - - // Note: boundBox does reduce - const vector span0 = boundBox(points0_).span(); - const vector span = boundBox(points).span(); - - vector scaleFactors(cmptDivide(span0, span)); - - pointField newPoints0(mpm.pointMap().size()); - - forAll(newPoints0, pointI) - { - label oldPointI = mpm.pointMap()[pointI]; - - if (oldPointI >= 0) - { - label masterPointI = mpm.reversePointMap()[oldPointI]; - - if (masterPointI == pointI) - { - newPoints0[pointI] = points0_[oldPointI]; - } - else - { - // New point. Assume motion is scaling. - newPoints0[pointI] = points0_[oldPointI] + cmptMultiply - ( - scaleFactors, - points[pointI]-points[masterPointI] - ); - } - } - else - { - FatalErrorIn - ( - "displacementLaplacianFvMotionSolver::updateMesh" - "(const mapPolyMesh& mpm)" - ) << "Cannot work out coordinates of introduced vertices." - << " New vertex " << pointI << " at coordinate " - << points[pointI] << exit(FatalError); - } - } - points0_.transfer(newPoints0); - - if (debug & 2) - { - OFstream str(time().timePath()/"points0.obj"); - Pout<< "displacementLaplacianFvMotionSolver :" - << " Writing points0_ to " << str.name() << endl; - - forAll(points0_, pointI) - { - meshTools::writeOBJ(str, points0_[pointI]); - } - } + displacementFvMotionSolver::updateMesh(mpm); // Update diffusivity. Note two stage to make sure old one is de-registered // before creating/registering new one. diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H index 67ed89c40f..6ba0c01e32 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.H @@ -37,7 +37,7 @@ SourceFiles #ifndef displacementLaplacianFvMotionSolver_H #define displacementLaplacianFvMotionSolver_H -#include "fvMotionSolver.H" +#include "displacementFvMotionSolver.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,13 +53,10 @@ class motionDiffusivity; class displacementLaplacianFvMotionSolver : - public fvMotionSolver + public displacementFvMotionSolver { // Private data - //- Reference point field - pointField points0_; - //- Point motion field mutable pointVectorField pointDisplacement_; @@ -113,13 +110,6 @@ public: // Member Functions - - //- Return reference to the reference field - const pointField& points0() const - { - return points0_; - } - //- Return reference to the point motion displacement field pointVectorField& pointDisplacement() { diff --git a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C index 68e0151f85..8c310481d7 100644 --- a/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +++ b/src/fvMotionSolver/pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C @@ -29,7 +29,7 @@ License #include "Time.H" #include "transformField.H" #include "fvMesh.H" -#include "displacementLaplacianFvMotionSolver.H" +#include "displacementFvMotionSolver.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,6 +52,254 @@ const NamedEnum surfaceSlipDisplacementPointPatchVectorField::followModeNames_; +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void surfaceSlipDisplacementPointPatchVectorField::calcProjection +( + vectorField& displacement +) const +{ + const polyMesh& mesh = patch().boundaryMesh().mesh()(); + const pointField& localPoints = patch().localPoints(); + const labelList& meshPoints = patch().meshPoints(); + + //const scalar deltaT = mesh.time().deltaT().value(); + + // Construct large enough vector in direction of projectDir so + // we're guaranteed to hit something. + + //- Per point projection vector: + const scalar projectLen = mag(mesh.bounds().max()-mesh.bounds().min()); + + // For case of fixed projection vector: + vector projectVec; + if (projectMode_ == FIXEDNORMAL) + { + vector n = projectDir_/mag(projectDir_); + projectVec = projectLen*n; + } + + + // Get fixed points (bit of a hack) + const pointZone* zonePtr = NULL; + + if (frozenPointsZone_.size() > 0) + { + const pointZoneMesh& pZones = mesh.pointZones(); + + zonePtr = &pZones[pZones.findZoneID(frozenPointsZone_)]; + + Pout<< "surfaceSlipDisplacementPointPatchVectorField : Fixing all " + << zonePtr->size() << " points in pointZone " << zonePtr->name() + << endl; + } + + // Get the starting locations from the motionSolver + const displacementFvMotionSolver& motionSolver = + mesh.lookupObject + ( + "dynamicMeshDict" + ); + const pointField& points0 = motionSolver.points0(); + + + pointField start(meshPoints.size()); + forAll(start, i) + { + start[i] = points0[meshPoints[i]] + displacement[i]; + } + + label nNotProjected = 0; + + if (projectMode_ == NEAREST) + { + List nearest; + labelList hitSurfaces; + surfaces().findNearest + ( + start, + scalarField(start.size(), sqr(projectLen)), + hitSurfaces, + nearest + ); + + forAll(nearest, i) + { + if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0)) + { + // Fixed point. Reset to point0 location. + displacement[i] = points0[meshPoints[i]] - localPoints[i]; + } + else if (nearest[i].hit()) + { + displacement[i] = + nearest[i].hitPoint() + - points0[meshPoints[i]]; + } + else + { + nNotProjected++; + + if (debug) + { + Pout<< " point:" << meshPoints[i] + << " coord:" << localPoints[i] + << " did not find any surface within " << projectLen + << endl; + } + } + } + } + else + { + // Do tests on all points. Combine later on. + + // 1. Check if already on surface + List nearest; + { + labelList nearestSurface; + surfaces().findNearest + ( + start, + scalarField(start.size(), sqr(SMALL)), + nearestSurface, + nearest + ); + } + + // 2. intersection. (combined later on with information from nearest + // above) + vectorField projectVecs(start.size(), projectVec); + + if (projectMode_ == POINTNORMAL) + { + projectVecs = projectLen*patch().pointNormals(); + } + + // Knock out any wedge component + scalarField offset(start.size(), 0.0); + if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents) + { + forAll(offset, i) + { + offset[i] = start[i][wedgePlane_]; + start[i][wedgePlane_] = 0; + projectVecs[i][wedgePlane_] = 0; + } + } + + List rightHit; + { + labelList rightSurf; + surfaces().findAnyIntersection + ( + start, + start+projectVecs, + rightSurf, + rightHit + ); + } + + List leftHit; + { + labelList leftSurf; + surfaces().findAnyIntersection + ( + start, + start-projectVecs, + leftSurf, + leftHit + ); + } + + // 3. Choose either -fixed, nearest, right, left. + forAll(displacement, i) + { + if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0)) + { + // Fixed point. Reset to point0 location. + displacement[i] = points0[meshPoints[i]] - localPoints[i]; + } + else if (nearest[i].hit()) + { + // Found nearest. + displacement[i] = + nearest[i].hitPoint() + - points0[meshPoints[i]]; + } + else + { + pointIndexHit interPt; + + if (rightHit[i].hit()) + { + if (leftHit[i].hit()) + { + if + ( + magSqr(rightHit[i].hitPoint()-start[i]) + < magSqr(leftHit[i].hitPoint()-start[i]) + ) + { + interPt = rightHit[i]; + } + else + { + interPt = leftHit[i]; + } + } + else + { + interPt = rightHit[i]; + } + } + else + { + if (leftHit[i].hit()) + { + interPt = leftHit[i]; + } + } + + + if (interPt.hit()) + { + if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents) + { + interPt.rawPoint()[wedgePlane_] += offset[i]; + } + displacement[i] = interPt.rawPoint()-points0[meshPoints[i]]; + } + else + { + nNotProjected++; + + if (debug) + { + Pout<< " point:" << meshPoints[i] + << " coord:" << localPoints[i] + << " did not find any intersection between" + << " ray from " << start[i]-projectVecs[i] + << " to " << start[i]+projectVecs[i] << endl; + } + } + } + } + } + + reduce(nNotProjected, sumOp