Commit 1a741a22 authored by mattijs's avatar mattijs
Browse files

BUG: numbering on lagrangian files was not uptodate with field vtk files

If no particles are in cloud it does not get written. Hence it would also
not output a vtk file. Changed now to always output lagrangian data.
parent 9d216d52
......@@ -376,6 +376,44 @@ int main(int argc, char *argv[])
// mesh wrapper; does subsetting and decomposition
vtkMesh vMesh(mesh, cellSetName);
// Scan for all possible lagrangian clouds
HashSet<fileName> allCloudDirs;
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
fileNameList cloudDirs
(
readDir
(
runTime.timePath()/regionPrefix/cloud::prefix,
fileName::DIRECTORY
)
);
forAll(cloudDirs, i)
{
IOobjectList sprayObjs
(
mesh,
runTime.timeName(),
cloud::prefix/cloudDirs[i]
);
IOobject* positionsPtr = sprayObjs.lookup("positions");
if (positionsPtr)
{
if (allCloudDirs.insert(cloudDirs[i]))
{
Info<< "At time: " << runTime.timeName()
<< " detected cloud directory : " << cloudDirs[i]
<< endl;
}
}
}
}
forAll(timeDirs, timeI)
{
runTime.setTime(timeDirs[timeI], timeI);
......@@ -927,38 +965,33 @@ int main(int argc, char *argv[])
//
//---------------------------------------------------------------------
fileNameList cloudDirs
(
readDir
forAllConstIter(HashSet<fileName>, allCloudDirs, iter)
{
const fileName& cloudName = iter.key();
// Always create the cloud directory.
mkDir(fvPath/cloud::prefix/cloudName);
fileName lagrFileName
(
runTime.timePath()/regionPrefix/cloud::prefix,
fileName::DIRECTORY
)
);
fvPath/cloud::prefix/cloudName/cloudName
+ "_" + timeDesc + ".vtk"
);
Info<< " Lagrangian: " << lagrFileName << endl;
forAll(cloudDirs, i)
{
IOobjectList sprayObjs
(
mesh,
runTime.timeName(),
cloud::prefix/cloudDirs[i]
cloud::prefix/cloudName
);
IOobject* positionsPtr = sprayObjs.lookup("positions");
if (positionsPtr)
{
mkDir(fvPath/cloud::prefix/cloudDirs[i]);
fileName lagrFileName
(
fvPath/cloud::prefix/cloudDirs[i]/cloudDirs[i]
+ "_" + timeDesc + ".vtk"
);
Info<< " Lagrangian: " << lagrFileName << endl;
wordList labelNames(sprayObjs.names(labelIOField::typeName));
Info<< " labels :";
print(Info, labelNames);
......@@ -1000,18 +1033,19 @@ int main(int argc, char *argv[])
vMesh,
binary,
lagrFileName,
cloudDirs[i]
cloudName,
false
);
// Write number of fields
writer.writeParcelHeader
(
labelNames.size()
+ scalarNames.size()
+ vectorNames.size()
+ sphereNames.size()
+ symmNames.size()
+ tensorNames.size()
+ scalarNames.size()
+ vectorNames.size()
+ sphereNames.size()
+ symmNames.size()
+ tensorNames.size()
);
// Fields
......@@ -1022,6 +1056,20 @@ int main(int argc, char *argv[])
writer.writeIOField<symmTensor>(symmNames);
writer.writeIOField<tensor>(tensorNames);
}
else
{
lagrangianWriter writer
(
vMesh,
binary,
lagrFileName,
cloudName,
true
);
// Write number of fields
writer.writeParcelHeader(0);
}
}
}
......
......@@ -37,7 +37,8 @@ Foam::lagrangianWriter::lagrangianWriter
const vtkMesh& vMesh,
const bool binary,
const fileName& fName,
const word& cloudName
const word& cloudName,
const bool dummyCloud
)
:
vMesh_(vMesh),
......@@ -52,19 +53,28 @@ Foam::lagrangianWriter::lagrangianWriter
writeFuns::writeHeader(os_, binary_, mesh.time().caseName());
os_ << "DATASET POLYDATA" << std::endl;
Cloud<passiveParticle> parcels(mesh, cloudName_, false);
if (dummyCloud)
{
nParcels_ = 0;
nParcels_ = parcels.size();
os_ << "POINTS " << nParcels_ << " float" << std::endl;
}
else
{
Cloud<passiveParticle> parcels(mesh, cloudName_, false);
os_ << "POINTS " << parcels.size() << " float" << std::endl;
nParcels_ = parcels.size();
DynamicList<floatScalar> partField(3*parcels.size());
os_ << "POINTS " << nParcels_ << " float" << std::endl;
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
{
writeFuns::insert(elmnt().position(), partField);
DynamicList<floatScalar> partField(3*parcels.size());
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
{
writeFuns::insert(elmnt().position(), partField);
}
writeFuns::write(os_, binary_, partField);
}
writeFuns::write(os_, binary_, partField);
}
......
......@@ -81,7 +81,8 @@ public:
const vtkMesh&,
const bool binary,
const fileName&,
const word&
const word&,
const bool dummyCloud
);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment