mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
foamToEnsight* fixes and tweaks
foamToEnsight:
- add -noPatches option
- had incorrect part# when the internalMesh was not output
- case file is always ascii
foamToEnsightParts:
- fixed field selection bug,
no fields were selected when a single time-step was selected
This commit is contained in:
@ -6,15 +6,13 @@ if (timeDirs.size() > 1)
|
||||
hasMovingMesh = true;
|
||||
for (label i=0; i < timeDirs.size() && hasMovingMesh; ++i)
|
||||
{
|
||||
IOobject io
|
||||
hasMovingMesh = IOobject
|
||||
(
|
||||
"points",
|
||||
timeDirs[i].name(),
|
||||
polyMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
);
|
||||
|
||||
hasMovingMesh = io.headerOk();
|
||||
).headerOk();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,40 +1,40 @@
|
||||
// check the final time directory for
|
||||
// check the final time directory for the following:
|
||||
|
||||
// 1. volume fields
|
||||
HashTable<word> volumeFields;
|
||||
|
||||
// 2. the fields for each cloud:
|
||||
HashTable<HashTable<word> > cloudFields;
|
||||
HashTable< HashTable<word> > cloudFields;
|
||||
|
||||
if (timeDirs.size() > 1)
|
||||
if (timeDirs.size())
|
||||
{
|
||||
IOobjectList objs(mesh, timeDirs[timeDirs.size()-1].name());
|
||||
|
||||
forAllConstIter(IOobjectList, objs, fieldIter)
|
||||
{
|
||||
const IOobject& obj = *fieldIter();
|
||||
const word& fieldName = obj.name();
|
||||
const word& fieldType = obj.headerClassName();
|
||||
|
||||
if
|
||||
(
|
||||
obj.headerClassName() == volScalarField::typeName
|
||||
|| obj.headerClassName() == volVectorField::typeName
|
||||
)
|
||||
if (fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0")
|
||||
{
|
||||
// Add field and field type
|
||||
volumeFields.insert
|
||||
(
|
||||
obj.name(),
|
||||
obj.headerClassName()
|
||||
);
|
||||
// ignore _0 fields
|
||||
}
|
||||
else if (volFieldTypes.found(fieldType))
|
||||
{
|
||||
// simply ignore types that we don't handle
|
||||
volumeFields.insert(fieldName, fieldType);
|
||||
}
|
||||
}
|
||||
|
||||
// now check for lagrangian/<cloudName>
|
||||
|
||||
//
|
||||
// now check for lagrangian/<cloudName>
|
||||
//
|
||||
fileNameList cloudDirs = readDir
|
||||
(
|
||||
runTime.path()
|
||||
/ timeDirs[timeDirs.size() - 1].name()
|
||||
/ timeDirs[timeDirs.size()-1].name()
|
||||
/ regionPrefix
|
||||
/ cloud::prefix,
|
||||
fileName::DIRECTORY
|
||||
@ -47,42 +47,59 @@ if (timeDirs.size() > 1)
|
||||
// Create a new hash table for each cloud
|
||||
cloudFields.insert(cloudName, HashTable<word>());
|
||||
|
||||
// Identify the new cloud in the hash table
|
||||
// Identify the new cloud within the hash table
|
||||
HashTable<HashTable<word> >::iterator cloudIter =
|
||||
cloudFields.find(cloudName);
|
||||
|
||||
IOobjectList cloudObjs
|
||||
IOobjectList objs
|
||||
(
|
||||
mesh,
|
||||
timeDirs[timeDirs.size() - 1].name(),
|
||||
timeDirs[timeDirs.size()-1].name(),
|
||||
cloud::prefix/cloudName
|
||||
);
|
||||
|
||||
bool hasPositions = false;
|
||||
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
|
||||
forAllConstIter(IOobjectList, objs, fieldIter)
|
||||
{
|
||||
const IOobject obj = *fieldIter();
|
||||
const word& fieldName = obj.name();
|
||||
const word& fieldType = obj.headerClassName();
|
||||
|
||||
if (obj.name() == "positions")
|
||||
if (fieldName == "positions")
|
||||
{
|
||||
hasPositions = true;
|
||||
}
|
||||
else
|
||||
else if (cloudFieldTypes.found(fieldType))
|
||||
{
|
||||
// Add field and field type
|
||||
cloudIter().insert
|
||||
(
|
||||
obj.name(),
|
||||
obj.headerClassName()
|
||||
);
|
||||
// simply ignore types that we don't handle
|
||||
cloudIter().insert(fieldName, fieldType);
|
||||
}
|
||||
}
|
||||
|
||||
// drop this cloud if it has no positions
|
||||
if (!hasPositions)
|
||||
// drop this cloud if it has no positions or is otherwise empty
|
||||
if (!hasPositions || cloudIter().empty())
|
||||
{
|
||||
Info<< "removing cloud " << cloudName << endl;
|
||||
cloudFields.erase(cloudIter);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// verify that the variable is present for all times
|
||||
//
|
||||
for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i)
|
||||
{
|
||||
IOobjectList objs(mesh, timeDirs[i].name());
|
||||
|
||||
forAllIter(HashTable<word>, volumeFields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
|
||||
if (!objs.found(fieldName))
|
||||
{
|
||||
volumeFields.erase(fieldIter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -83,23 +83,19 @@ int main(int argc, char *argv[])
|
||||
argList::validOptions.insert("index", "start");
|
||||
argList::validOptions.insert("noMesh", "");
|
||||
|
||||
const word volFieldTypes[] =
|
||||
{
|
||||
volScalarField::typeName,
|
||||
volVectorField::typeName,
|
||||
volSphericalTensorField::typeName,
|
||||
volSymmTensorField::typeName,
|
||||
volTensorField::typeName,
|
||||
word::null
|
||||
};
|
||||
// the volume field types that we handle
|
||||
wordHashSet volFieldTypes;
|
||||
volFieldTypes.insert(volScalarField::typeName);
|
||||
volFieldTypes.insert(volVectorField::typeName);
|
||||
volFieldTypes.insert(volSphericalTensorField::typeName);
|
||||
volFieldTypes.insert(volSymmTensorField::typeName);
|
||||
volFieldTypes.insert(volTensorField::typeName);
|
||||
|
||||
const word sprayFieldTypes[] =
|
||||
{
|
||||
scalarIOField::typeName,
|
||||
vectorIOField::typeName,
|
||||
tensorIOField::typeName,
|
||||
word::null
|
||||
};
|
||||
// the lagrangian field types that we handle
|
||||
wordHashSet cloudFieldTypes;
|
||||
cloudFieldTypes.insert(scalarIOField::typeName);
|
||||
cloudFieldTypes.insert(vectorIOField::typeName);
|
||||
cloudFieldTypes.insert(tensorIOField::typeName);
|
||||
|
||||
const char* geometryName = "geometry";
|
||||
|
||||
@ -168,7 +164,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
# include "checkHasMovingMesh.H"
|
||||
# include "findFields.H"
|
||||
# include "validateFields.H"
|
||||
|
||||
if (hasMovingMesh && optNoMesh)
|
||||
{
|
||||
|
||||
@ -11,8 +11,6 @@
|
||||
{
|
||||
// Read new points
|
||||
io.readOpt() = IOobject::MUST_READ;
|
||||
pointIOField newPoints(io);
|
||||
|
||||
mesh.movePoints(newPoints);
|
||||
mesh.movePoints(pointIOField(io));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,105 +0,0 @@
|
||||
// ignore special fields or fields that we don't handle
|
||||
//
|
||||
forAllIter(HashTable<word>, volumeFields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
const word& fieldType = fieldIter();
|
||||
|
||||
// ignore _0 fields
|
||||
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
|
||||
{
|
||||
volumeFields.erase(fieldIter);
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove types that we don't handle:
|
||||
bool invalid = true;
|
||||
for (label typeI=0; invalid && volFieldTypes[typeI].size(); ++typeI)
|
||||
{
|
||||
if (fieldType == volFieldTypes[typeI])
|
||||
{
|
||||
invalid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (invalid)
|
||||
{
|
||||
Info<< "ignoring " << fieldType << ": " << fieldName << endl;
|
||||
volumeFields.erase(fieldIter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// verify that the variable is present for all times
|
||||
//
|
||||
for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i)
|
||||
{
|
||||
IOobjectList objs(mesh, timeDirs[i].name());
|
||||
|
||||
forAllIter(HashTable<word>, volumeFields, fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
|
||||
if (!objs.found(fieldName))
|
||||
{
|
||||
volumeFields.erase(fieldIter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ignore fields that we don't handle
|
||||
//
|
||||
forAllIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
|
||||
{
|
||||
const word& cloudName = cloudIter.key();
|
||||
|
||||
forAllIter(HashTable<word>, cloudIter(), fieldIter)
|
||||
{
|
||||
const word& fieldName = fieldIter.key();
|
||||
const word& fieldType = fieldIter();
|
||||
|
||||
// remove types that we don't handle:
|
||||
bool invalid = true;
|
||||
for (label typeI=0; invalid && sprayFieldTypes[typeI].size(); ++typeI)
|
||||
{
|
||||
if (fieldType == sprayFieldTypes[typeI])
|
||||
{
|
||||
invalid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (invalid)
|
||||
{
|
||||
Info<< "ignoring " << fieldType << ": " << fieldName << endl;
|
||||
cloudIter().erase(fieldIter);
|
||||
}
|
||||
}
|
||||
|
||||
if (cloudIter().empty())
|
||||
{
|
||||
Info<< "removing cloud " << cloudName << endl;
|
||||
cloudFields.erase(cloudIter);
|
||||
}
|
||||
}
|
||||
|
||||
// DEBUGGING
|
||||
// Info<<"final fields (";
|
||||
// forAllConstIter(HashTable<word>, volumeFields, fieldIter)
|
||||
// {
|
||||
// Info<< " " << fieldIter.key();
|
||||
// }
|
||||
//
|
||||
// Info<< " )\n";
|
||||
//
|
||||
// forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
|
||||
// {
|
||||
// Info<<"final fields for lagrangian/" << cloudIter.key() << " (";
|
||||
// forAllConstIter(HashTable<word>, cloudIter(), fieldIter)
|
||||
// {
|
||||
// Info<< " " << fieldIter.key();
|
||||
// }
|
||||
// Info<< " )\n";
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user