Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2010-10-11 14:17:05 +01:00
10 changed files with 204 additions and 209 deletions

View File

@ -475,7 +475,7 @@ int main(int argc, char *argv[])
{-1, -1, -1, -1, -1, -1}, // 1 {-1, -1, -1, -1, -1, -1}, // 1
{-1, -1, -1, -1, -1, -1}, // 2 {-1, -1, -1, -1, -1, -1}, // 2
{-1, -1, -1, -1, -1, -1}, // 3 {-1, -1, -1, -1, -1, -1}, // 3
{-1, 2, 0, 3, 1, -1}, // tet (version 2.0) { 3, 2, 0, -1, 1, -1}, // tet (version 2.0)
{ 0, 4, 3, -1, 2, 1}, // prism { 0, 4, 3, -1, 2, 1}, // prism
{ 4, 2, 1, 3, 0, 5}, // hex { 4, 2, 1, 3, 0, 5}, // hex
}; };
@ -500,12 +500,14 @@ int main(int argc, char *argv[])
++cellIter, ++faceIter ++cellIter, ++faceIter
) )
{ {
const cellShape& shape = cellShapes[cellMap[cellIter()]];
patchFaces.append patchFaces.append
( (
cellShapes[cellMap[cellIter()] ].faces() shape.faces()
[ [
faceIndex faceIndex
[cellShapes[cellMap[cellIter()] ].nFaces()] [shape.nFaces()]
[faceIter()-1] [faceIter()-1]
] ]
); );

View File

@ -46,10 +46,10 @@ class cellSets
{ {
public: public:
label nHexesWedges;
label nPrisms;
label nPyrs;
label nTets; label nTets;
label nPyrs;
label nPrisms;
label nHexesWedges;
label nPolys; label nPolys;
labelList tets; labelList tets;
@ -57,6 +57,7 @@ public:
labelList prisms; labelList prisms;
labelList wedges; labelList wedges;
labelList hexes; labelList hexes;
labelList hexesWedges;
labelList polys; labelList polys;
@ -65,10 +66,10 @@ public:
//- Construct given the number ov cells //- Construct given the number ov cells
cellSets(const label nCells) cellSets(const label nCells)
: :
nHexesWedges(0),
nPrisms(0),
nPyrs(0),
nTets(0), nTets(0),
nPyrs(0),
nPrisms(0),
nHexesWedges(0),
nPolys(0), nPolys(0),
tets(nCells), tets(nCells),
@ -76,6 +77,7 @@ public:
prisms(nCells), prisms(nCells),
wedges(nCells), wedges(nCells),
hexes(nCells), hexes(nCells),
hexesWedges(nCells),
polys(nCells) polys(nCells)
{} {}
}; };

View File

@ -94,6 +94,11 @@ public:
// Member Functions // Member Functions
virtual bool ascii() const
{
return true;
}
virtual void write(const char* c) virtual void write(const char* c)
{ {
str_ << c << nl; str_ << c << nl;

View File

@ -90,6 +90,11 @@ public:
// Member Functions // Member Functions
virtual bool ascii() const
{
return false;
}
virtual void write(const char* val) virtual void write(const char* val)
{ {
char buffer[80] = {0}; char buffer[80] = {0};

View File

@ -32,68 +32,21 @@ License
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "ensightBinaryStream.H" #include "ensightBinaryStream.H"
#include "ensightAsciiStream.H" #include "ensightAsciiStream.H"
#include "globalIndex.H"
using namespace Foam; using namespace Foam;
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
scalarField map void writeField
(
const Field<Type>& vf,
const labelList& map,
const label cmpt
)
{
scalarField mf(map.size());
forAll(map, i)
{
mf[i] = component(vf[map[i]], cmpt);
}
return mf;
}
template<class Type>
scalarField map
(
const Field<Type>& vf,
const labelList& map1,
const labelList& map2,
const label cmpt
)
{
scalarField mf(map1.size() + map2.size());
forAll(map1, i)
{
mf[i] = component(vf[map1[i]], cmpt);
}
label offset = map1.size();
forAll(map2, i)
{
mf[i + offset] = component(vf[map2[i]], cmpt);
}
return mf;
}
template<class Type>
void writeAllData
( (
const char* key, const char* key,
const Field<Type>& vf, const Field<Type>& vf,
const labelList& prims,
const label nPrims,
ensightStream& ensightFile ensightStream& ensightFile
) )
{ {
if (nPrims) if (returnReduce(vf.size(), sumOp<label>()) > 0)
{ {
if (Pstream::master()) if (Pstream::master())
{ {
@ -101,8 +54,7 @@ void writeAllData
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{ {
scalarField masterData(map(vf, prims, cmpt)); ensightFile.write(vf.component(cmpt));
ensightFile.write(masterData);
for (int slave=1; slave<Pstream::nProcs(); slave++) for (int slave=1; slave<Pstream::nProcs(); slave++)
{ {
@ -117,48 +69,7 @@ void writeAllData
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(vf, prims, cmpt); toMaster<< vf.component(cmpt);
}
}
}
}
template<class Type>
void writeAllFaceData
(
const char* key,
const labelList& prims,
const label nPrims,
const Field<Type>& pf,
ensightStream& ensightFile
)
{
if (nPrims)
{
if (Pstream::master())
{
ensightFile.write(key);
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{
ensightFile.write(map(pf, prims, cmpt));
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
scalarField pf(fromSlave);
ensightFile.write(pf);
}
}
}
else
{
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(pf, prims, cmpt);
} }
} }
} }
@ -183,30 +94,24 @@ bool writePatchField
ensightFile.writePartHeader(ensightPatchI); ensightFile.writePartHeader(ensightPatchI);
} }
writeAllFaceData writeField
( (
"tria3", "tria3",
boundaryFaceSet.tris, Field<Type>(pf, boundaryFaceSet.tris),
nfp.nTris,
pf,
ensightFile ensightFile
); );
writeAllFaceData writeField
( (
"quad4", "quad4",
boundaryFaceSet.quads, Field<Type>(pf, boundaryFaceSet.quads),
nfp.nQuads,
pf,
ensightFile ensightFile
); );
writeAllFaceData writeField
( (
"nsided", "nsided",
boundaryFaceSet.polys, Field<Type>(pf, boundaryFaceSet.polys),
nfp.nPolys,
pf,
ensightFile ensightFile
); );
@ -369,8 +274,7 @@ void ensightField
const labelList& tets = meshCellSets.tets; const labelList& tets = meshCellSets.tets;
const labelList& pyrs = meshCellSets.pyrs; const labelList& pyrs = meshCellSets.pyrs;
const labelList& prisms = meshCellSets.prisms; const labelList& prisms = meshCellSets.prisms;
const labelList& wedges = meshCellSets.wedges; const labelList& hexesWedges = meshCellSets.hexesWedges;
const labelList& hexes = meshCellSets.hexes;
const labelList& polys = meshCellSets.polys; const labelList& polys = meshCellSets.polys;
ensightStream* ensightFilePtr = NULL; ensightStream* ensightFilePtr = NULL;
@ -421,68 +325,38 @@ void ensightField
ensightFile.writePartHeader(1); ensightFile.writePartHeader(1);
} }
if (meshCellSets.nHexesWedges) writeField
{ (
if (Pstream::master()) "hexa8",
{ Field<Type>(vf, hexesWedges),
ensightFile.write("hexa8"); ensightFile
);
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) writeField
{
scalarField masterData(map(vf, hexes, wedges, cmpt));
ensightFile.write(masterData);
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
scalarField data(fromSlave);
ensightFile.write(data);
}
}
}
else
{
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(vf, hexes, wedges, cmpt);
}
}
}
writeAllData
( (
"penta6", "penta6",
vf, Field<Type>(vf, prisms),
prisms,
meshCellSets.nPrisms,
ensightFile ensightFile
); );
writeAllData writeField
( (
"pyramid5", "pyramid5",
vf, Field<Type>(vf, pyrs),
pyrs,
meshCellSets.nPyrs,
ensightFile ensightFile
); );
writeAllData writeField
( (
"tetra4", "tetra4",
vf, Field<Type>(vf, tets),
tets,
meshCellSets.nTets,
ensightFile ensightFile
); );
writeAllData writeField
( (
"nfaced", "nfaced",
vf, Field<Type>(vf, polys),
polys,
meshCellSets.nPolys,
ensightFile ensightFile
); );
} }
@ -611,6 +485,12 @@ void ensightPointField
word timeFile = prepend + itoa(timeIndex); word timeFile = prepend + itoa(timeIndex);
const fvMesh& mesh = eMesh.mesh();
const wordList& allPatchNames = eMesh.allPatchNames();
const wordHashSet& patchNames = eMesh.patchNames();
const wordHashSet& faceZoneNames = eMesh.faceZoneNames();
ensightStream* ensightFilePtr = NULL; ensightStream* ensightFilePtr = NULL;
if (Pstream::master()) if (Pstream::master())
{ {
@ -622,7 +502,7 @@ void ensightPointField
ensightFilePtr = new ensightBinaryStream ensightFilePtr = new ensightBinaryStream
( (
postProcPath/ensightFileName, postProcPath/ensightFileName,
eMesh.mesh().time() mesh.time()
); );
} }
else else
@ -630,7 +510,7 @@ void ensightPointField
ensightFilePtr = new ensightAsciiStream ensightFilePtr = new ensightAsciiStream
( (
postProcPath/ensightFileName, postProcPath/ensightFileName,
eMesh.mesh().time() mesh.time()
); );
} }
} }
@ -656,35 +536,108 @@ void ensightPointField
} }
ensightFile.write(pTraits<Type>::typeName); ensightFile.write(pTraits<Type>::typeName);
ensightFile.write("part"); ensightFile.writePartHeader(1);
ensightFile.write(1);
} }
writeField
(
"coordinates",
Field<Type>(pf.internalField(), eMesh.uniquePointMap()),
ensightFile
);
}
label ensightPatchI = eMesh.patchPartOffset();
forAll(allPatchNames, patchi)
{
const word& patchName = allPatchNames[patchi];
eMesh.barrier();
if (patchNames.empty() || patchNames.found(patchName))
{
const fvPatch& p = mesh.boundary()[patchi];
if
(
returnReduce(p.size(), sumOp<label>())
> 0
)
{
// Renumber the patch points/faces into unique points
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPointsPtr =
mesh.globalData().mergePoints
(
p.patch().meshPoints(),
p.patch().meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels
);
if (Pstream::master()) if (Pstream::master())
{ {
ensightFile.write("coordinates"); ensightFile.writePartHeader(ensightPatchI);
}
Field<Type> uniqueFld(pf.internalField(), eMesh.uniquePointMap()); writeField
(
"coordinates",
Field<Type>(pf.internalField(), uniqueMeshPointLabels),
ensightFile
);
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) ensightPatchI++;
{
ensightFile.write(uniqueFld.component(cmpt));
for (int slave=1; slave<Pstream::nProcs(); slave++)
{
IPstream fromSlave(Pstream::scheduled, slave);
scalarField data(fromSlave);
ensightFile.write(data);
} }
} }
} }
else
// write faceZones, if requested
if (faceZoneNames.size())
{ {
Field<Type> uniqueFld(pf.internalField(), eMesh.uniquePointMap()); forAllConstIter(wordHashSet, faceZoneNames, iter)
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); const word& faceZoneName = iter.key();
toMaster<< uniqueFld.component(cmpt);
eMesh.barrier();
label zoneID = mesh.faceZones().findZoneID(faceZoneName);
const faceZone& fz = mesh.faceZones()[zoneID];
if (returnReduce(fz().nPoints(), sumOp<label>()) > 0)
{
// Renumber the faceZone points/faces into unique points
labelList pointToGlobal;
labelList uniqueMeshPointLabels;
autoPtr<globalIndex> globalPointsPtr =
mesh.globalData().mergePoints
(
fz().meshPoints(),
fz().meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels
);
if (Pstream::master())
{
ensightFile.writePartHeader(ensightPatchI);
}
writeField
(
"coordinates",
Field<Type>
(
pf.internalField(),
uniqueMeshPointLabels
),
ensightFile
);
ensightPatchI++;
} }
} }
} }

View File

@ -35,7 +35,6 @@ SourceFiles
#define ensightField_H #define ensightField_H
#include "ensightMesh.H" #include "ensightMesh.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -48,6 +47,7 @@ void ensightField
const Foam::word& prepend, const Foam::word& prepend,
const Foam::label timeIndex, const Foam::label timeIndex,
const bool binary, const bool binary,
const bool nodeValues,
Foam::Ostream& ensightCaseFile Foam::Ostream& ensightCaseFile
); );

View File

@ -114,6 +114,7 @@ void Foam::ensightMesh::correct()
labelList& prisms = meshCellSets_.prisms; labelList& prisms = meshCellSets_.prisms;
labelList& wedges = meshCellSets_.wedges; labelList& wedges = meshCellSets_.wedges;
labelList& hexes = meshCellSets_.hexes; labelList& hexes = meshCellSets_.hexes;
labelList& hexesWedges = meshCellSets_.hexesWedges;
labelList& polys = meshCellSets_.polys; labelList& polys = meshCellSets_.polys;
label nTets = 0; label nTets = 0;
@ -121,6 +122,7 @@ void Foam::ensightMesh::correct()
label nPrisms = 0; label nPrisms = 0;
label nWedges = 0; label nWedges = 0;
label nHexes = 0; label nHexes = 0;
label nHexesWedges = 0;
label nPolys = 0; label nPolys = 0;
forAll(cellShapes, cellI) forAll(cellShapes, cellI)
@ -143,10 +145,12 @@ void Foam::ensightMesh::correct()
else if (cellModel == wedge) else if (cellModel == wedge)
{ {
wedges[nWedges++] = cellI; wedges[nWedges++] = cellI;
hexesWedges[nHexesWedges++] = cellI;
} }
else if (cellModel == hex) else if (cellModel == hex)
{ {
hexes[nHexes++] = cellI; hexes[nHexes++] = cellI;
hexesWedges[nHexesWedges++] = cellI;
} }
else else
{ {
@ -170,7 +174,7 @@ void Foam::ensightMesh::correct()
meshCellSets_.nPrisms = nPrisms; meshCellSets_.nPrisms = nPrisms;
reduce(meshCellSets_.nPrisms, sumOp<label>()); reduce(meshCellSets_.nPrisms, sumOp<label>());
meshCellSets_.nHexesWedges = nHexes + nWedges; meshCellSets_.nHexesWedges = nHexesWedges;
reduce(meshCellSets_.nHexesWedges, sumOp<label>()); reduce(meshCellSets_.nHexesWedges, sumOp<label>());
meshCellSets_.nPolys = nPolys; meshCellSets_.nPolys = nPolys;
@ -507,6 +511,25 @@ void Foam::ensightMesh::writePrims
{ {
// Create a temp int array // Create a temp int array
if (cellShapes.size()) if (cellShapes.size())
{
if (ensightGeometryFile.ascii())
{
// Workaround for paraview issue : write one cell per line
forAll(cellShapes, i)
{
const cellShape& cellPoints = cellShapes[i];
List<int> temp(cellPoints.size());
forAll(cellPoints, pointI)
{
temp[pointI] = cellPoints[pointI] + 1;
}
ensightGeometryFile.write(temp);
}
}
else
{ {
// All the cellShapes have the same number of elements! // All the cellShapes have the same number of elements!
int numIntElem = cellShapes.size()*cellShapes[0].size(); int numIntElem = cellShapes.size()*cellShapes[0].size();
@ -527,6 +550,7 @@ void Foam::ensightMesh::writePrims
ensightGeometryFile.write(temp); ensightGeometryFile.write(temp);
} }
} }
}
void Foam::ensightMesh::writePolysNFaces void Foam::ensightMesh::writePolysNFaces

View File

@ -86,6 +86,8 @@ public:
return name_; return name_;
} }
virtual bool ascii() const = 0;
virtual void write(const char*) = 0; virtual void write(const char*) = 0;
virtual void write(const int) = 0; virtual void write(const int) = 0;

View File

@ -82,9 +82,8 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
} }
else else
{ {
if (!loadedLibraries.found(functionLibPtr)) if (loadedLibraries.insert(functionLibPtr, functionLibName))
{ {
loadedLibraries.insert(functionLibPtr, functionLibName);
return true; return true;
} }
else else

View File

@ -27,7 +27,10 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::scalar Foam::polyMeshTetDecomposition::minTetQuality = 1e-12; // Note: the use of this tolerance is ad-hoc, there may be extreme
// cases where the resulting tetrahedra still have particle tracking
// problems.
const Foam::scalar Foam::polyMeshTetDecomposition::minTetQuality = SMALL;
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //