objectRegistry fixes

- objectRegistry gets a rename() that also adjusts the dbDir
- cloud reworked to use static variables subInstance and defaultName.
  This avoids writing "lagrangian" everywhere

string fixes
- avoid masking of std::string::replace in string.H
- avoid old strstream in PV3FoamReader
This commit is contained in:
Mark Olesen
2009-03-06 15:18:00 +01:00
parent 9ce984d1dc
commit b968e62ef9
41 changed files with 171 additions and 104 deletions

View File

@ -70,6 +70,28 @@ int main(int argc, char *argv[])
string test2("~OpenFOAM/controlDict"); string test2("~OpenFOAM/controlDict");
Info<< test2 << " => " << test2.expand() << endl; 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; string s;
Sin.getLine(s); Sin.getLine(s);
@ -78,8 +100,7 @@ int main(int argc, char *argv[])
cout<< "output string with " << s2.length() << " characters\n"; cout<< "output string with " << s2.length() << " characters\n";
cout<< "ostream<< >" << s2 << "<\n"; cout<< "ostream<< >" << s2 << "<\n";
Info<< "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; Info << "End\n" << endl;

View File

@ -312,7 +312,7 @@ int main(int argc, char *argv[])
fileNameList cloudDirs fileNameList cloudDirs
( (
readDir(runTime.timePath()/"lagrangian", fileName::DIRECTORY) readDir(runTime.timePath()/cloud::subInstance, fileName::DIRECTORY)
); );
// Particles // Particles
@ -344,7 +344,7 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
runTime.timeName(), runTime.timeName(),
"lagrangian"/cloudDirs[i] cloud::subInstance/cloudDirs[i]
); );
IOobject* positionsPtr = sprayObjs.lookup("positions"); IOobject* positionsPtr = sprayObjs.lookup("positions");
@ -418,7 +418,7 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
runTime.timeName(), runTime.timeName(),
"lagrangian"/cloudDirs[cloudI] cloud::subInstance/cloudDirs[cloudI]
); );
lagrangianFieldDecomposer::readFields lagrangianFieldDecomposer::readFields

View File

@ -88,7 +88,7 @@ tmp<IOField<Type> > lagrangianFieldDecomposer::decomposeField
( (
field.name(), field.name(),
procMesh_.time().timeName(), procMesh_.time().timeName(),
"lagrangian"/cloudName, cloud::subInstance/cloudName,
procMesh_, procMesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -36,6 +36,7 @@ SourceFiles
#ifndef reconstructLagrangian_H #ifndef reconstructLagrangian_H
#define reconstructLagrangian_H #define reconstructLagrangian_H
#include "cloud.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "IOobjectList.H" #include "IOobjectList.H"
#include "fvMesh.H" #include "fvMesh.H"

View File

@ -47,7 +47,7 @@ Foam::tmp<Foam::IOField<Type> > Foam::reconstructLagrangianField
( (
fieldName, fieldName,
mesh.time().timeName(), mesh.time().timeName(),
"lagrangian"/cloudName, cloud::subInstance/cloudName,
mesh, mesh,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -64,7 +64,7 @@ Foam::tmp<Foam::IOField<Type> > Foam::reconstructLagrangianField
( (
fieldName, fieldName,
meshes[i].time().timeName(), meshes[i].time().timeName(),
"lagrangian"/cloudName, cloud::subInstance/cloudName,
meshes[i], meshes[i],
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -277,7 +277,7 @@ int main(int argc, char *argv[])
( (
readDir readDir
( (
databases[procI].timePath()/regionPrefix/"lagrangian", databases[procI].timePath()/regionPrefix/cloud::subInstance,
fileName::DIRECTORY fileName::DIRECTORY
) )
); );
@ -295,7 +295,7 @@ int main(int argc, char *argv[])
( (
procMeshes.meshes()[procI], procMeshes.meshes()[procI],
databases[procI].timeName(), databases[procI].timeName(),
"lagrangian"/cloudDirs[i] cloud::subInstance/cloudDirs[i]
); );
IOobject* positionsPtr = sprayObjs.lookup("positions"); IOobject* positionsPtr = sprayObjs.lookup("positions");

View File

@ -35,6 +35,7 @@ SourceFiles
#ifndef ensightCloudField_H #ifndef ensightCloudField_H
#define ensightCloudField_H #define ensightCloudField_H
#include "Cloud.H"
#include "IOobject.H" #include "IOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -211,7 +211,7 @@ int main(int argc, char *argv[])
fileNameList cloudDirs = readDir fileNameList cloudDirs = readDir
( (
runTime.timePath()/regionPrefix/"lagrangian", runTime.timePath()/regionPrefix/cloud::subInstance,
fileName::DIRECTORY fileName::DIRECTORY
); );
@ -221,7 +221,7 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
runTime.timeName(), runTime.timeName(),
"lagrangian"/cloudDirs[cloudI] cloud::subInstance/cloudDirs[cloudI]
); );
IOobject* positionsPtr = cloudObjs.lookup("positions"); IOobject* positionsPtr = cloudObjs.lookup("positions");
@ -266,7 +266,7 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
runTime.timeName(), runTime.timeName(),
"lagrangian"/cloudIter.key() cloud::subInstance/cloudIter.key()
); );
forAllConstIter(IOobjectList, cloudObjs, fieldIter) forAllConstIter(IOobjectList, cloudObjs, fieldIter)
@ -426,7 +426,7 @@ int main(int argc, char *argv[])
fileNameList currentCloudDirs = readDir fileNameList currentCloudDirs = readDir
( (
runTime.timePath()/regionPrefix/"lagrangian", runTime.timePath()/regionPrefix/cloud::subInstance,
fileName::DIRECTORY fileName::DIRECTORY
); );
@ -449,7 +449,7 @@ int main(int argc, char *argv[])
( (
fieldName, fieldName,
mesh.time().timeName(), mesh.time().timeName(),
"lagrangian"/cloudName, cloud::subInstance/cloudName,
mesh, mesh,
IOobject::MUST_READ IOobject::MUST_READ
); );

View File

@ -42,7 +42,7 @@ forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
caseFile caseFile
<< setw(16) << "measured: 2" << setw(16) << "measured: 2"
<< fileName(dataMask/"lagrangian"/cloudName/"positions").c_str() << fileName(dataMask/cloud::subInstance/cloudName/"positions").c_str()
<< nl; << nl;
} }
caseFile caseFile
@ -122,7 +122,7 @@ forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
ensightType, ensightType,
fieldName, fieldName,
dataMask, dataMask,
"lagrangian"/cloudName, cloud::subInstance/cloudName,
cloudNo, cloudNo,
2 2
); );

View File

@ -27,7 +27,6 @@ License
#include "ensightOutputFunctions.H" #include "ensightOutputFunctions.H"
#include "passiveParticle.H" #include "passiveParticle.H"
#include "Cloud.H"
#include "IOField.H" #include "IOField.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
@ -101,7 +100,7 @@ void ensightParticlePositions
{ {
Cloud<passiveParticle> parcels(mesh, cloudName, false); Cloud<passiveParticle> parcels(mesh, cloudName, false);
fileName cloudDir = subDir/"lagrangian"/cloudName; fileName cloudDir = subDir/cloud::subInstance/cloudName;
fileName postFileName = cloudDir/"positions"; fileName postFileName = cloudDir/"positions";
// the ITER/lagrangian subdirectory must exist // the ITER/lagrangian subdirectory must exist
@ -165,7 +164,7 @@ void ensightLagrangianField
{ {
Info<< " " << fieldObject.name() << flush; Info<< " " << fieldObject.name() << flush;
fileName cloudDir = subDir/"lagrangian"/cloudName; fileName cloudDir = subDir/cloud::subInstance/cloudName;
fileName postFileName = cloudDir/fieldObject.name(); fileName postFileName = cloudDir/fieldObject.name();
string title = string title =

View File

@ -23,9 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description Description
Miscellaneous collection of functions and template related to Ensight data
miscellaneous collection of functions and template related
to Ensight data
SourceFiles SourceFiles
ensightOutputFunctions.C ensightOutputFunctions.C
@ -36,6 +34,7 @@ SourceFiles
#define ensightOutputFunctions_H #define ensightOutputFunctions_H
#include "ensightFile.H" #include "ensightFile.H"
#include "Cloud.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "IOobject.H" #include "IOobject.H"

View File

@ -36,7 +36,7 @@ if (timeDirs.size() > 1)
runTime.path() runTime.path()
/ timeDirs[timeDirs.size() - 1].name() / timeDirs[timeDirs.size() - 1].name()
/ regionPrefix / regionPrefix
/ "lagrangian", / cloud::subInstance,
fileName::DIRECTORY fileName::DIRECTORY
); );
@ -55,7 +55,7 @@ if (timeDirs.size() > 1)
( (
mesh, mesh,
timeDirs[timeDirs.size() - 1].name(), timeDirs[timeDirs.size() - 1].name(),
"lagrangian"/cloudName cloud::subInstance/cloudName
); );
bool hasPositions = false; bool hasPositions = false;

View File

@ -324,7 +324,14 @@ int main(int argc, char *argv[])
{ {
const word& cloudName = cloudIter.key(); const word& cloudName = cloudIter.key();
if (!isDir(runTime.timePath()/regionPrefix/"lagrangian"/cloudName)) if
(
!isDir
(
runTime.timePath()/regionPrefix/
cloud::subInstance/cloudName
)
)
{ {
continue; continue;
} }
@ -333,7 +340,7 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
runTime.timeName(), runTime.timeName(),
"lagrangian"/cloudName cloud::subInstance/cloudName
); );
// check that the positions field is present for this time // check that the positions field is present for this time
@ -365,7 +372,8 @@ int main(int argc, char *argv[])
if (!fieldObject) if (!fieldObject)
{ {
Info<< "missing " Info<< "missing "
<< runTime.timeName()/"lagrangian"/cloudName/fieldName << runTime.timeName()/cloud::subInstance/cloudName
/ fieldName
<< endl; << endl;
continue; continue;
} }

View File

@ -21,7 +21,7 @@ List<IOField<vector>* > sprayVectorFieldPtrs
( (
sprayScalarNames[fieldI], sprayScalarNames[fieldI],
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
mesh, mesh,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -53,7 +53,7 @@ List<IOField<vector>* > sprayVectorFieldPtrs
( (
sprayVectorNames[fieldI], sprayVectorNames[fieldI],
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
mesh, mesh,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -42,7 +42,7 @@ forAll(Times, timeI)
// Same for spray // Same for spray
IOobjectList sprayObjects(mesh, runTime.timeName(), "lagrangian"); IOobjectList sprayObjects(mesh, runTime.timeName(), cloud::subInstance);
{ {
wordList fieldNames(sprayObjects.names(scalarIOField::typeName)); wordList fieldNames(sprayObjects.names(scalarIOField::typeName));
forAll(fieldNames, fieldI) forAll(fieldNames, fieldI)

View File

@ -49,7 +49,7 @@ int main(int argc, char *argv[])
"volScalarField", "volScalarField",
"volVectorField", "volVectorField",
"surfaceScalarField", "surfaceScalarField",
"lagrangian" cloud::subInstance
}; };
# include "setRootCase.H" # include "setRootCase.H"

View File

@ -60,13 +60,13 @@ for(label i=0; i < nTypes; i++)
} }
if ( fieldTypes[i] == "lagrangian") if ( fieldTypes[i] == cloud::subInstance )
{ {
IOobject lagrangianHeader IOobject lagrangianHeader
( (
"positions", "positions",
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
mesh, mesh,
IOobject::NO_READ IOobject::NO_READ
); );
@ -75,7 +75,7 @@ for(label i=0; i < nTypes; i++)
{ {
Cloud<passiveParticle> particles(mesh); Cloud<passiveParticle> particles(mesh);
IOobjectList objects(mesh, runTime.timeName(), "lagrangian"); IOobjectList objects(mesh, runTime.timeName(), cloud::subInstance);
wordList lagrangianScalarNames = objects.names("scalarField"); wordList lagrangianScalarNames = objects.names("scalarField");
wordList lagrangianVectorNames = objects.names("vectorField"); wordList lagrangianVectorNames = objects.names("vectorField");

View File

@ -42,7 +42,7 @@ forAll(lagrangianScalarNames, i)
( (
name, name,
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
mesh, mesh,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
@ -73,7 +73,7 @@ forAll(lagrangianVectorNames, i)
( (
name, name,
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
mesh, mesh,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -40,7 +40,7 @@ forAll(lagrangianScalarNames, i)
( (
name, name,
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
mesh, mesh,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -914,7 +914,7 @@ int main(int argc, char *argv[])
( (
readDir readDir
( (
runTime.timePath()/regionPrefix/"lagrangian", runTime.timePath()/regionPrefix/cloud::subInstance,
fileName::DIRECTORY fileName::DIRECTORY
) )
); );
@ -925,18 +925,18 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
runTime.timeName(), runTime.timeName(),
"lagrangian"/cloudDirs[i] cloud::subInstance/cloudDirs[i]
); );
IOobject* positionsPtr = sprayObjs.lookup("positions"); IOobject* positionsPtr = sprayObjs.lookup("positions");
if (positionsPtr) if (positionsPtr)
{ {
mkDir(fvPath/"lagrangian"/cloudDirs[i]); mkDir(fvPath/cloud::subInstance/cloudDirs[i]);
fileName lagrFileName fileName lagrFileName
( (
fvPath/"lagrangian"/cloudDirs[i]/cloudDirs[i] fvPath/cloud::subInstance/cloudDirs[i]/cloudDirs[i]
+ "_" + name(timeI) + ".vtk" + "_" + name(timeI) + ".vtk"
); );

View File

@ -39,6 +39,7 @@ SourceFiles
#include "globalPointPatch.H" #include "globalPointPatch.H"
#include "OFstream.H" #include "OFstream.H"
#include "Cloud.H"
#include "volFields.H" #include "volFields.H"
#include "pointFields.H" #include "pointFields.H"
#include "vtkMesh.H" #include "vtkMesh.H"

View File

@ -41,7 +41,7 @@ void Foam::lagrangianWriter::writeIOField(const wordList& objects)
( (
object, object,
vMesh_.mesh().time().timeName(), vMesh_.mesh().time().timeName(),
"lagrangian"/cloudName_, cloud::subInstance/cloudName_,
vMesh_.mesh(), vMesh_.mesh(),
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,

View File

@ -58,6 +58,11 @@ SourceFiles
#ifndef vtkPV3Foam_H #ifndef vtkPV3Foam_H
#define 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 "className.H"
#include "fileName.H" #include "fileName.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"

View File

@ -268,7 +268,7 @@ void Foam::vtkPV3Foam::convertLagrangianFields
( (
mesh, mesh,
dbPtr_().timeName(), dbPtr_().timeName(),
"lagrangian"/cloudName cloud::subInstance/cloudName
); );
pruneObjectList(objects, selectedFields); pruneObjectList(objects, selectedFields);

View File

@ -30,6 +30,8 @@ InClass
#ifndef vtkPV3FoamLagrangianFields_H #ifndef vtkPV3FoamLagrangianFields_H
#define vtkPV3FoamLagrangianFields_H #define vtkPV3FoamLagrangianFields_H
#include "Cloud.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type> template<class Type>

View File

@ -53,7 +53,7 @@ vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::lagrangianVTKMesh - timePath " Info<< "<beg> Foam::vtkPV3Foam::lagrangianVTKMesh - timePath "
<< mesh.time().timePath()/"lagrangian"/cloudName << endl; << mesh.time().timePath()/cloud::subInstance/cloudName << endl;
printMemory(); printMemory();
} }
@ -63,7 +63,7 @@ vtkPolyData* Foam::vtkPV3Foam::lagrangianVTKMesh
( (
mesh, mesh,
mesh.time().timeName(), mesh.time().timeName(),
"lagrangian"/cloudName cloud::subInstance/cloudName
); );
IOobject* positionsPtr = sprayObjs.lookup("positions"); IOobject* positionsPtr = sprayObjs.lookup("positions");

View File

@ -34,6 +34,7 @@ License
#include "IOPtrList.H" #include "IOPtrList.H"
#include "polyBoundaryMeshEntries.H" #include "polyBoundaryMeshEntries.H"
#include "entry.H" #include "entry.H"
#include "Cloud.H"
#include "vtkPV3FoamReader.h" #include "vtkPV3FoamReader.h"
// local headers // local headers
@ -148,16 +149,16 @@ void Foam::vtkPV3Foam::updateInfoLagrangian()
if (debug) if (debug)
{ {
Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangian" << nl Info<< "<beg> Foam::vtkPV3Foam::updateInfoLagrangian" << nl
<< " " << dbPtr_->timePath()/"lagrangian" << endl; << " " << dbPtr_->timePath()/cloud::subInstance << endl;
} }
// use the db directly since this might be called without a mesh, // use the db directly since this might be called without a mesh,
// but the region must get added back in // but the region must get added back in
fileName lagrangianPrefix("lagrangian"); fileName lagrangianPrefix(cloud::subInstance);
if (meshRegion_ != polyMesh::defaultRegion) if (meshRegion_ != polyMesh::defaultRegion)
{ {
lagrangianPrefix = meshRegion_/"lagrangian"; lagrangianPrefix = meshRegion_/cloud::subInstance;
} }
// Search for list of lagrangian objects for this time // 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, // use the db directly since this might be called without a mesh,
// but the region must get added back in // but the region must get added back in
fileName lagrangianPrefix("lagrangian"); fileName lagrangianPrefix(cloud::subInstance);
if (meshRegion_ != polyMesh::defaultRegion) if (meshRegion_ != polyMesh::defaultRegion)
{ {
lagrangianPrefix = meshRegion_/"lagrangian"; lagrangianPrefix = meshRegion_/cloud::subInstance;
} }
IOobjectList objects IOobjectList objects

View File

@ -137,7 +137,12 @@ int USERD_get_gold_part_build_info
if (Numparts_available > nPatches+1) if (Numparts_available > nPatches+1)
{ {
strncpy(part_descriptions[nPatches+1], sprayName.c_str(), Z_BUFL); strncpy
(
part_descriptions[nPatches+1],
cloud::subInstance.c_str(),
Z_BUFL
);
number_of_elements[nPatches+1][Z_POINT] = sprayPtr->size(); number_of_elements[nPatches+1][Z_POINT] = sprayPtr->size();
number_of_nodes[nPatches+1] = sprayPtr->size(); number_of_nodes[nPatches+1] = sprayPtr->size();
} }

View File

@ -164,7 +164,7 @@ int USERD_set_filenames
( (
"positions", "positions",
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
runTime, runTime,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
@ -179,7 +179,7 @@ int USERD_set_filenames
sprayPtr = new Cloud<passiveParticle>(*meshPtr); sprayPtr = new Cloud<passiveParticle>(*meshPtr);
IOobjectList objects(*meshPtr, runTime.timeName(), "lagrangian"); IOobjectList objects(*meshPtr, runTime.timeName(), cloud::subInstance);
lagrangianScalarNames = lagrangianScalarNames =
(const wordList&)objects.names(sprayScalarFieldName); (const wordList&)objects.names(sprayScalarFieldName);

View File

@ -12,7 +12,7 @@ if (nVar >= 0)
( (
name, name,
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
mesh, mesh,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -14,7 +14,7 @@ if (nVar >= 0)
( (
name, name,
runTime.timeName(), runTime.timeName(),
"lagrangian", cloud::subInstance,
mesh, mesh,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE

View File

@ -32,7 +32,6 @@ static bool isSpray[maxNames];
static word scalarName = "volScalarField"; static word scalarName = "volScalarField";
static word vectorName = "volVectorField"; static word vectorName = "volVectorField";
static word tensorName = "volTensorField"; static word tensorName = "volTensorField";
static word sprayName = "lagrangian";
static word sprayScalarFieldName = "scalarField"; static word sprayScalarFieldName = "scalarField";
static word sprayVectorFieldName = "vectorField"; static word sprayVectorFieldName = "vectorField";
static word sprayTensorFieldName = "tensorField"; static word sprayTensorFieldName = "tensorField";

View File

@ -34,6 +34,7 @@ Description
#ifndef MapLagrangianFields_H #ifndef MapLagrangianFields_H
#define MapLagrangianFields_H #define MapLagrangianFields_H
#include "cloud.H"
#include "GeometricField.H" #include "GeometricField.H"
#include "meshToMesh.H" #include "meshToMesh.H"
#include "IOobjectList.H" #include "IOobjectList.H"
@ -60,8 +61,7 @@ void MapLagrangianFields
forAllIter(IOobjectList, fields, fieldIter) forAllIter(IOobjectList, fields, fieldIter)
{ {
Info<< " mapping lagrangian field " Info<< " mapping lagrangian field " << fieldIter()->name() << endl;
<< fieldIter()->name() << endl;
// Read field (does not need mesh) // Read field (does not need mesh)
IOField<Type> fieldSource(*fieldIter()); IOField<Type> fieldSource(*fieldIter());
@ -73,7 +73,7 @@ void MapLagrangianFields
( (
fieldIter()->name(), fieldIter()->name(),
meshTarget.time().timeName(), meshTarget.time().timeName(),
"lagrangian"/cloudName, cloud::subInstance/cloudName,
meshTarget, meshTarget,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,

View File

@ -94,7 +94,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
( (
readDir readDir
( (
meshSource.time().timePath()/"lagrangian", meshSource.time().timePath()/cloud::subInstance,
fileName::DIRECTORY fileName::DIRECTORY
) )
); );
@ -106,7 +106,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
( (
meshSource, meshSource,
meshSource.time().timeName(), meshSource.time().timeName(),
"lagrangian"/cloudDirs[cloudI] cloud::subInstance/cloudDirs[cloudI]
); );
IOobject* positionsPtr = objects.lookup("positions"); IOobject* positionsPtr = objects.lookup("positions");

View File

@ -45,7 +45,7 @@ namespace Foam
{ {
//- Read a hex label from an input stream //- Read a hex label from an input stream
label readHexLabel(ISstream& is); label readHexLabel(ISstream&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -98,7 +98,7 @@ Foam::wordList Foam::objectRegistry::names() const
wordList objectNames(size()); wordList objectNames(size());
label count=0; label count=0;
for (const_iterator iter = begin(); iter != end(); ++iter) for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{ {
objectNames[count++] = iter()->name(); objectNames[count++] = iter()->name();
} }
@ -112,7 +112,7 @@ Foam::wordList Foam::objectRegistry::names(const word& ClassName) const
wordList objectNames(size()); wordList objectNames(size());
label count=0; label count=0;
for (const_iterator iter = begin(); iter != end(); ++iter) for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{ {
if (iter()->type() == ClassName) if (iter()->type() == ClassName)
{ {
@ -195,15 +195,33 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
<< " in registry " << name() << " in registry " << name()
<< endl; << 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 bool Foam::objectRegistry::modified() const
{ {
for (const_iterator iter = begin(); iter != end(); ++iter) for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{ {
if (iter()->modified()) if (iter()->modified())
{ {
@ -248,7 +266,7 @@ bool Foam::objectRegistry::writeObject
{ {
bool ok = true; bool ok = true;
for (const_iterator iter = begin(); iter != end(); ++iter) for (const_iterator iter = cbegin(); iter != cend(); ++iter)
{ {
if (objectRegistry::debug) if (objectRegistry::debug)
{ {

View File

@ -154,6 +154,9 @@ public:
// Edit // Edit
//- Rename
virtual void rename(const word& newName);
//- Add an regIOobject to registry //- Add an regIOobject to registry
bool checkIn(regIOobject&) const; bool checkIn(regIOobject&) const;

View File

@ -29,10 +29,10 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam defineTypeNameAndDebug(Foam::cloud, 0);
{
defineTypeNameAndDebug(cloud, 0); const Foam::word Foam::cloud::subInstance("lagrangian");
} Foam::word Foam::cloud::defaultName("defaultCloud");
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -42,9 +42,9 @@ Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
( (
IOobject IOobject
( (
cloudName, ( cloudName.size() ? cloudName : defaultName ),
obr.time().timeName(), obr.time().timeName(),
"lagrangian", subInstance,
obr, obr,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE IOobject::AUTO_WRITE

View File

@ -69,15 +69,16 @@ public:
//- Runtime type information //- Runtime type information
TypeName("cloud"); TypeName("cloud");
//- The subInstance (local) to prefix: %lagrangian
static const word subInstance;
//- The default cloud name: %defaultCloud
static word defaultName;
// Constructors // Constructors
//- Construct for the given objectRegistry and named cloud instance //- Construct for the given objectRegistry and named cloud instance
cloud cloud(const objectRegistry&, const word& cloudName = "");
(
const objectRegistry& obr,
const word& cloudName = "defaultCloud"
);
// Destructor // Destructor

View File

@ -144,6 +144,9 @@ public:
template<class String> template<class String>
static inline string quotemeta(const string&, const char quote='\\'); 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 //- Replace first occurence of sub-string oldStr with newStr
// starting at start // starting at start
string& replace string& replace

View File

@ -41,7 +41,7 @@ Description
Note Note
If the string contents are changed - eg, by the operator+=() or by If the string contents are changed - eg, by the operator+=() or by
string::replace(), etc - it will be necessary to use compile() or string::replace(), etc - it will be necessary to use compile() or
recompile() to sychronize the regular expression. recompile() to synchronize the regular expression.
SourceFiles SourceFiles
wordRe.C wordRe.C