mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: foamToEnsight: add cellZone support
This commit is contained in:
@ -39,6 +39,31 @@ using namespace Foam;
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * 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>
|
template<class Type>
|
||||||
Field<Type> map
|
Field<Type> map
|
||||||
(
|
(
|
||||||
@ -680,7 +705,7 @@ void ensightPointField
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void ensightField
|
void ensightField
|
||||||
(
|
(
|
||||||
const IOobject& fieldObject,
|
const GeometricField<Type, fvPatchField, volMesh>& vf,
|
||||||
const ensightMesh& eMesh,
|
const ensightMesh& eMesh,
|
||||||
const fileName& postProcPath,
|
const fileName& postProcPath,
|
||||||
const word& prepend,
|
const word& prepend,
|
||||||
@ -690,14 +715,11 @@ void ensightField
|
|||||||
Ostream& ensightCaseFile
|
Ostream& ensightCaseFile
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Read field
|
|
||||||
GeometricField<Type, fvPatchField, volMesh> vf(fieldObject, eMesh.mesh());
|
|
||||||
|
|
||||||
if (nodeValues)
|
if (nodeValues)
|
||||||
{
|
{
|
||||||
tmp<GeometricField<Type, pointPatchField, pointMesh> > pfld
|
tmp<GeometricField<Type, pointPatchField, pointMesh> > pfld
|
||||||
(
|
(
|
||||||
volPointInterpolation::New(eMesh.mesh()).interpolate(vf)
|
volPointInterpolation::New(vf.mesh()).interpolate(vf)
|
||||||
);
|
);
|
||||||
pfld().rename(vf.name());
|
pfld().rename(vf.name());
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -35,13 +35,24 @@ SourceFiles
|
|||||||
#define ensightField_H
|
#define ensightField_H
|
||||||
|
|
||||||
#include "ensightMesh.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>
|
template<class Type>
|
||||||
void ensightField
|
void ensightField
|
||||||
(
|
(
|
||||||
const Foam::IOobject& fieldObject,
|
const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& vf,
|
||||||
const Foam::ensightMesh& eMesh,
|
const Foam::ensightMesh& eMesh,
|
||||||
const Foam::fileName& postProcPath,
|
const Foam::fileName& postProcPath,
|
||||||
const Foam::word& prepend,
|
const Foam::word& prepend,
|
||||||
|
|||||||
@ -57,14 +57,6 @@ void Foam::ensightMesh::correct()
|
|||||||
nFaceZonePrims_ = 0;
|
nFaceZonePrims_ = 0;
|
||||||
boundaryFaceToBeIncluded_.clear();
|
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_)
|
if (!noPatches_)
|
||||||
{
|
{
|
||||||
// Patches are output. Check that they're synced.
|
// Patches are output. Check that they're synced.
|
||||||
@ -111,6 +103,16 @@ void Foam::ensightMesh::correct()
|
|||||||
}
|
}
|
||||||
else
|
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
|
// Count the shapes
|
||||||
labelList& tets = meshCellSets_.tets;
|
labelList& tets = meshCellSets_.tets;
|
||||||
labelList& pyrs = meshCellSets_.pyrs;
|
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 pointField& uniquePoints,
|
||||||
const label nPoints,
|
const label nPoints,
|
||||||
ensightStream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
@ -937,49 +941,8 @@ void Foam::ensightMesh::writeAllInternalPoints
|
|||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
ensightGeometryFile.writePartHeader(1);
|
ensightGeometryFile.writePartHeader(ensightPartI);
|
||||||
ensightGeometryFile.write("internalMesh");
|
ensightGeometryFile.write(ensightPartName.c_str());
|
||||||
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.write("coordinates");
|
ensightGeometryFile.write("coordinates");
|
||||||
ensightGeometryFile.write(nPoints);
|
ensightGeometryFile.write(nPoints);
|
||||||
|
|
||||||
@ -998,11 +961,7 @@ void Foam::ensightMesh::writeAllPatchPoints
|
|||||||
{
|
{
|
||||||
for (direction d=0; d<vector::nComponents; d++)
|
for (direction d=0; d<vector::nComponents; d++)
|
||||||
{
|
{
|
||||||
OPstream toMaster
|
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||||
(
|
|
||||||
Pstream::scheduled,
|
|
||||||
Pstream::masterNo()
|
|
||||||
);
|
|
||||||
toMaster<< uniquePoints.component(d);
|
toMaster<< uniquePoints.component(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1076,8 +1035,10 @@ void Foam::ensightMesh::write
|
|||||||
|
|
||||||
const pointField uniquePoints(mesh_.points(), uniquePointMap_);
|
const pointField uniquePoints(mesh_.points(), uniquePointMap_);
|
||||||
|
|
||||||
writeAllInternalPoints
|
writeAllPoints
|
||||||
(
|
(
|
||||||
|
1,
|
||||||
|
"internalMesh",
|
||||||
uniquePoints,
|
uniquePoints,
|
||||||
nPoints,
|
nPoints,
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
@ -1166,7 +1127,7 @@ void Foam::ensightMesh::write
|
|||||||
inplaceRenumber(pointToGlobal, patchFaces[i]);
|
inplaceRenumber(pointToGlobal, patchFaces[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeAllPatchPoints
|
writeAllPoints
|
||||||
(
|
(
|
||||||
ensightPatchI++,
|
ensightPatchI++,
|
||||||
patchName,
|
patchName,
|
||||||
@ -1271,7 +1232,7 @@ void Foam::ensightMesh::write
|
|||||||
inplaceRenumber(pointToGlobal, faceZoneMasterFaces[i]);
|
inplaceRenumber(pointToGlobal, faceZoneMasterFaces[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeAllPatchPoints
|
writeAllPoints
|
||||||
(
|
(
|
||||||
ensightPatchI++,
|
ensightPatchI++,
|
||||||
faceZoneName,
|
faceZoneName,
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -244,17 +244,10 @@ private:
|
|||||||
ensightStream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
void writeAllInternalPoints
|
void writeAllPoints
|
||||||
(
|
(
|
||||||
const pointField& uniquePoints,
|
const label ensightPartI,
|
||||||
const label nPoints,
|
const word& ensightPartName,
|
||||||
ensightStream& ensightGeometryFile
|
|
||||||
) const;
|
|
||||||
|
|
||||||
void writeAllPatchPoints
|
|
||||||
(
|
|
||||||
label ensightPatchI,
|
|
||||||
const word& patchName,
|
|
||||||
const pointField& uniquePoints,
|
const pointField& uniquePoints,
|
||||||
const label nPoints,
|
const label nPoints,
|
||||||
ensightStream& ensightGeometryFile
|
ensightStream& ensightGeometryFile
|
||||||
|
|||||||
@ -46,6 +46,9 @@ Usage
|
|||||||
\param -faceZones zoneList \n
|
\param -faceZones zoneList \n
|
||||||
Specify faceZones to write, with wildcards
|
Specify faceZones to write, with wildcards
|
||||||
|
|
||||||
|
\param -cellZone zoneName \n
|
||||||
|
Specify single cellZone to write (not lagrangian)
|
||||||
|
|
||||||
Note
|
Note
|
||||||
Parallel support for cloud data is not supported
|
Parallel support for cloud data is not supported
|
||||||
- writes to \a EnSight directory to avoid collisions with foamToEnsightParts
|
- writes to \a EnSight directory to avoid collisions with foamToEnsightParts
|
||||||
@ -72,6 +75,9 @@ Note
|
|||||||
|
|
||||||
#include "fvc.H"
|
#include "fvc.H"
|
||||||
|
|
||||||
|
#include "cellSet.H"
|
||||||
|
#include "fvMeshSubset.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -128,6 +134,12 @@ int main(int argc, char *argv[])
|
|||||||
"wordReList",
|
"wordReList",
|
||||||
"specify faceZones to write - eg '( slice \"mfp-.*\" )'."
|
"specify faceZones to write - eg '( slice \"mfp-.*\" )'."
|
||||||
);
|
);
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"cellZone",
|
||||||
|
"word",
|
||||||
|
"specify cellZone to write"
|
||||||
|
);
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
@ -212,9 +224,28 @@ int main(int argc, char *argv[])
|
|||||||
zonePatterns = wordReList(args.optionLookup("faceZones")());
|
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
|
ensightMesh eMesh
|
||||||
(
|
(
|
||||||
mesh,
|
(
|
||||||
|
meshSubsetter.hasSubMesh()
|
||||||
|
? meshSubsetter.subMesh()
|
||||||
|
: meshSubsetter.baseMesh()
|
||||||
|
),
|
||||||
args.optionFound("noPatches"),
|
args.optionFound("noPatches"),
|
||||||
selectedPatches,
|
selectedPatches,
|
||||||
patchPatterns,
|
patchPatterns,
|
||||||
@ -349,6 +380,17 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Translating time = " << runTime.timeName() << nl;
|
Info<< "Translating time = " << runTime.timeName() << nl;
|
||||||
|
|
||||||
polyMesh::readUpdateState meshState = mesh.readUpdate();
|
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)
|
if (meshState != polyMesh::UNCHANGED)
|
||||||
{
|
{
|
||||||
@ -406,9 +448,10 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (volFieldTypes[i] == volScalarField::typeName)
|
if (volFieldTypes[i] == volScalarField::typeName)
|
||||||
{
|
{
|
||||||
|
volScalarField vf(fieldObject, mesh);
|
||||||
ensightField<scalar>
|
ensightField<scalar>
|
||||||
(
|
(
|
||||||
fieldObject,
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
ensightDir,
|
||||||
prepend,
|
prepend,
|
||||||
@ -420,9 +463,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (volFieldTypes[i] == volVectorField::typeName)
|
else if (volFieldTypes[i] == volVectorField::typeName)
|
||||||
{
|
{
|
||||||
|
volVectorField vf(fieldObject, mesh);
|
||||||
ensightField<vector>
|
ensightField<vector>
|
||||||
(
|
(
|
||||||
fieldObject,
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
ensightDir,
|
||||||
prepend,
|
prepend,
|
||||||
@ -434,9 +478,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (volFieldTypes[i] == volSphericalTensorField::typeName)
|
else if (volFieldTypes[i] == volSphericalTensorField::typeName)
|
||||||
{
|
{
|
||||||
|
volSphericalTensorField vf(fieldObject, mesh);
|
||||||
ensightField<sphericalTensor>
|
ensightField<sphericalTensor>
|
||||||
(
|
(
|
||||||
fieldObject,
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
ensightDir,
|
||||||
prepend,
|
prepend,
|
||||||
@ -448,9 +493,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (volFieldTypes[i] == volSymmTensorField::typeName)
|
else if (volFieldTypes[i] == volSymmTensorField::typeName)
|
||||||
{
|
{
|
||||||
|
volSymmTensorField vf(fieldObject, mesh);
|
||||||
ensightField<symmTensor>
|
ensightField<symmTensor>
|
||||||
(
|
(
|
||||||
fieldObject,
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
ensightDir,
|
||||||
prepend,
|
prepend,
|
||||||
@ -462,9 +508,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (volFieldTypes[i] == volTensorField::typeName)
|
else if (volFieldTypes[i] == volTensorField::typeName)
|
||||||
{
|
{
|
||||||
|
volTensorField vf(fieldObject, mesh);
|
||||||
ensightField<tensor>
|
ensightField<tensor>
|
||||||
(
|
(
|
||||||
fieldObject,
|
volField(meshSubsetter, vf),
|
||||||
eMesh,
|
eMesh,
|
||||||
ensightDir,
|
ensightDir,
|
||||||
prepend,
|
prepend,
|
||||||
|
|||||||
Reference in New Issue
Block a user