ENH: foamToEnsight: add cellZone support

This commit is contained in:
mattijs 2013-09-05 16:25:03 +01:00
parent 1c930f9404
commit 90a8332ffb
5 changed files with 118 additions and 84 deletions

View File

@ -39,6 +39,31 @@ using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> >
volField
(
const fvMeshSubset& meshSubsetter,
const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
if (meshSubsetter.hasSubMesh())
{
tmp<GeometricField<Type, fvPatchField, volMesh> > tfld
(
meshSubsetter.interpolate(vf)
);
tfld().checkOut();
tfld().rename(vf.name());
return tfld;
}
else
{
return vf;
}
}
template<class Type>
Field<Type> map
(
@ -680,7 +705,7 @@ void ensightPointField
template<class Type>
void ensightField
(
const IOobject& fieldObject,
const GeometricField<Type, fvPatchField, volMesh>& vf,
const ensightMesh& eMesh,
const fileName& postProcPath,
const word& prepend,
@ -690,14 +715,11 @@ void ensightField
Ostream& ensightCaseFile
)
{
// Read field
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, eMesh.mesh());
if (nodeValues)
{
tmp<GeometricField<Type, pointPatchField, pointMesh> > pfld
(
volPointInterpolation::New(eMesh.mesh()).interpolate(vf)
volPointInterpolation::New(vf.mesh()).interpolate(vf)
);
pfld().rename(vf.name());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,13 +35,24 @@ SourceFiles
#define ensightField_H
#include "ensightMesh.H"
#include "fvMeshSubset.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Wrapper to get hold of the field or the subsetted field
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
volField
(
const Foam::fvMeshSubset&,
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf
);
template<class Type>
void ensightField
(
const Foam::IOobject& fieldObject,
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf,
const Foam::ensightMesh& eMesh,
const Foam::fileName& postProcPath,
const Foam::word& prepend,

View File

@ -57,14 +57,6 @@ void Foam::ensightMesh::correct()
nFaceZonePrims_ = 0;
boundaryFaceToBeIncluded_.clear();
const cellShapeList& cellShapes = mesh_.cellShapes();
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
const cellModel& prism = *(cellModeller::lookup("prism"));
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
if (!noPatches_)
{
// Patches are output. Check that they're synced.
@ -111,6 +103,16 @@ void Foam::ensightMesh::correct()
}
else
{
const cellShapeList& cellShapes = mesh_.cellShapes();
const cellModel& tet = *(cellModeller::lookup("tet"));
const cellModel& pyr = *(cellModeller::lookup("pyr"));
const cellModel& prism = *(cellModeller::lookup("prism"));
const cellModel& wedge = *(cellModeller::lookup("wedge"));
const cellModel& hex = *(cellModeller::lookup("hex"));
// Count the shapes
labelList& tets = meshCellSets_.tets;
labelList& pyrs = meshCellSets_.pyrs;
@ -926,8 +928,10 @@ void Foam::ensightMesh::writeAllNSided
}
void Foam::ensightMesh::writeAllInternalPoints
void Foam::ensightMesh::writeAllPoints
(
const label ensightPartI,
const word& ensightPartName,
const pointField& uniquePoints,
const label nPoints,
ensightStream& ensightGeometryFile
@ -937,49 +941,8 @@ void Foam::ensightMesh::writeAllInternalPoints
if (Pstream::master())
{
ensightGeometryFile.writePartHeader(1);
ensightGeometryFile.write("internalMesh");
ensightGeometryFile.write("coordinates");
ensightGeometryFile.write(nPoints);
for (direction d=0; d<vector::nComponents; d++)
{
ensightGeometryFile.write(uniquePoints.component(d));
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
scalarField pointsComponent(fromSlave);
ensightGeometryFile.write(pointsComponent);
}
}
}
else
{
for (direction d=0; d<vector::nComponents; d++)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< uniquePoints.component(d);
}
}
}
void Foam::ensightMesh::writeAllPatchPoints
(
const label ensightPatchI,
const word& patchName,
const pointField& uniquePoints,
const label nPoints,
ensightStream& ensightGeometryFile
) const
{
barrier();
if (Pstream::master())
{
ensightGeometryFile.writePartHeader(ensightPatchI);
ensightGeometryFile.write(patchName.c_str());
ensightGeometryFile.writePartHeader(ensightPartI);
ensightGeometryFile.write(ensightPartName.c_str());
ensightGeometryFile.write("coordinates");
ensightGeometryFile.write(nPoints);
@ -998,11 +961,7 @@ void Foam::ensightMesh::writeAllPatchPoints
{
for (direction d=0; d<vector::nComponents; d++)
{
OPstream toMaster
(
Pstream::scheduled,
Pstream::masterNo()
);
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< uniquePoints.component(d);
}
}
@ -1076,8 +1035,10 @@ void Foam::ensightMesh::write
const pointField uniquePoints(mesh_.points(), uniquePointMap_);
writeAllInternalPoints
writeAllPoints
(
1,
"internalMesh",
uniquePoints,
nPoints,
ensightGeometryFile
@ -1166,7 +1127,7 @@ void Foam::ensightMesh::write
inplaceRenumber(pointToGlobal, patchFaces[i]);
}
writeAllPatchPoints
writeAllPoints
(
ensightPatchI++,
patchName,
@ -1271,7 +1232,7 @@ void Foam::ensightMesh::write
inplaceRenumber(pointToGlobal, faceZoneMasterFaces[i]);
}
writeAllPatchPoints
writeAllPoints
(
ensightPatchI++,
faceZoneName,

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -244,17 +244,10 @@ private:
ensightStream& ensightGeometryFile
) const;
void writeAllInternalPoints
void writeAllPoints
(
const pointField& uniquePoints,
const label nPoints,
ensightStream& ensightGeometryFile
) const;
void writeAllPatchPoints
(
label ensightPatchI,
const word& patchName,
const label ensightPartI,
const word& ensightPartName,
const pointField& uniquePoints,
const label nPoints,
ensightStream& ensightGeometryFile

View File

@ -46,6 +46,9 @@ Usage
\param -faceZones zoneList \n
Specify faceZones to write, with wildcards
\param -cellZone zoneName \n
Specify single cellZone to write (not lagrangian)
Note
Parallel support for cloud data is not supported
- writes to \a EnSight directory to avoid collisions with foamToEnsightParts
@ -72,6 +75,9 @@ Note
#include "fvc.H"
#include "cellSet.H"
#include "fvMeshSubset.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -128,6 +134,12 @@ int main(int argc, char *argv[])
"wordReList",
"specify faceZones to write - eg '( slice \"mfp-.*\" )'."
);
argList::addOption
(
"cellZone",
"word",
"specify cellZone to write"
);
#include "setRootCase.H"
@ -212,9 +224,28 @@ int main(int argc, char *argv[])
zonePatterns = wordReList(args.optionLookup("faceZones")());
}
word cellZoneName;
const bool doCellZone = args.optionReadIfPresent("cellZone", cellZoneName);
fvMeshSubset meshSubsetter(mesh);
if (doCellZone)
{
Info<< "Converting cellZone " << cellZoneName
<< " only (puts outside faces into patch "
<< mesh.boundaryMesh()[0].name()
<< ")" << endl;
const cellZone& cz = mesh.cellZones()[cellZoneName];
cellSet c0(mesh, "c0", labelHashSet(cz));
meshSubsetter.setLargeCellSubset(c0, 0);
}
ensightMesh eMesh
(
mesh,
(
meshSubsetter.hasSubMesh()
? meshSubsetter.subMesh()
: meshSubsetter.baseMesh()
),
args.optionFound("noPatches"),
selectedPatches,
patchPatterns,
@ -349,6 +380,17 @@ int main(int argc, char *argv[])
Info<< "Translating time = " << runTime.timeName() << nl;
polyMesh::readUpdateState meshState = mesh.readUpdate();
if (timeIndex != 0 && meshSubsetter.hasSubMesh())
{
Info<< "Converting cellZone " << cellZoneName
<< " only (puts outside faces into patch "
<< mesh.boundaryMesh()[0].name()
<< ")" << endl;
const cellZone& cz = mesh.cellZones()[cellZoneName];
cellSet c0(mesh, "c0", labelHashSet(cz));
meshSubsetter.setLargeCellSubset(c0, 0);
}
if (meshState != polyMesh::UNCHANGED)
{
@ -406,9 +448,10 @@ int main(int argc, char *argv[])
if (volFieldTypes[i] == volScalarField::typeName)
{
volScalarField vf(fieldObject, mesh);
ensightField<scalar>
(
fieldObject,
volField(meshSubsetter, vf),
eMesh,
ensightDir,
prepend,
@ -420,9 +463,10 @@ int main(int argc, char *argv[])
}
else if (volFieldTypes[i] == volVectorField::typeName)
{
volVectorField vf(fieldObject, mesh);
ensightField<vector>
(
fieldObject,
volField(meshSubsetter, vf),
eMesh,
ensightDir,
prepend,
@ -434,9 +478,10 @@ int main(int argc, char *argv[])
}
else if (volFieldTypes[i] == volSphericalTensorField::typeName)
{
volSphericalTensorField vf(fieldObject, mesh);
ensightField<sphericalTensor>
(
fieldObject,
volField(meshSubsetter, vf),
eMesh,
ensightDir,
prepend,
@ -448,9 +493,10 @@ int main(int argc, char *argv[])
}
else if (volFieldTypes[i] == volSymmTensorField::typeName)
{
volSymmTensorField vf(fieldObject, mesh);
ensightField<symmTensor>
(
fieldObject,
volField(meshSubsetter, vf),
eMesh,
ensightDir,
prepend,
@ -462,9 +508,10 @@ int main(int argc, char *argv[])
}
else if (volFieldTypes[i] == volTensorField::typeName)
{
volTensorField vf(fieldObject, mesh);
ensightField<tensor>
(
fieldObject,
volField(meshSubsetter, vf),
eMesh,
ensightDir,
prepend,