Commit 1323f83e authored by mark's avatar mark
Browse files

BUG: foamToEnsight -faceZones fails (issue #317)

- was using direct face ids instead of appropriate sub-lists
- also removed typo that wasn't helping much either
parent 1ceacc9c
......@@ -258,9 +258,9 @@ void Foam::ensightMesh::correct()
Foam::sort(selectZones);
// Count face types in each selected faceZone
forAll(selectZones, zoneI)
forAll(selectZones, zonei)
{
const word& zoneName = selectZones[zoneI];
const word& zoneName = selectZones[zonei];
const label zoneID = mesh_.faceZones().findZoneID(zoneName);
const faceZone& fz = mesh_.faceZones()[zoneID];
......@@ -342,12 +342,12 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
(
pp.meshPoints(),
pp.meshPointMap(),
pointToGlobal,
uniqueMeshPointLabels
pointToGlobal, // local patch point to unique global index
uniqueMeshPointLabels // unique global points
);
pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
// Renumber the patch faces
// Renumber the patch faces,
// from local patch indexing to unique global index
faceList patchFaces(pp.localFaces());
forAll(patchFaces, i)
{
......@@ -359,7 +359,7 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
ensFaces.index(),
patchName,
globalPointsPtr().size(),
uniquePoints,
pointField(mesh_.points(), uniqueMeshPointLabels),
os
);
......@@ -391,30 +391,28 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
uniqueMeshPointLabels
);
pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
primitiveFacePatch facePatch
// Make a copy in the proper order
primitiveFacePatch pp
(
faceList(mesh_.faces(), ensFaces.faceIds()),
mesh_.points()
);
const boolList& flip = ensFaces.flipMap();
forAll(facePatch[faceI], faceI)
forAll(pp, facei)
{
if (flip[faceI])
if (flip[facei])
{
facePatch[faceI].flip();
pp[facei].flip();
}
}
// Faces belonging to the faceZone, in local numbering
faceList localFaces(facePatch.localFaces());
// Renumber the faceZone master faces
forAll(localFaces, i)
// Renumber the faces belonging to the faceZone,
// from local numbering to unique global index
faceList patchFaces(pp.localFaces());
forAll(patchFaces, i)
{
inplaceRenumber(pointToGlobal, localFaces[i]);
inplaceRenumber(pointToGlobal, patchFaces[i]);
}
writeAllPoints
......@@ -422,11 +420,11 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
ensFaces.index(),
zoneName,
globalPointsPtr().size(),
uniquePoints,
pointField(mesh_.points(), uniqueMeshPointLabels),
os
);
writeFaceConnectivity(ensFaces, localFaces, os, true);
writeFaceConnectivity(ensFaces, patchFaces, os, true);
}
}
......
......@@ -55,27 +55,42 @@ class ensightOutput
{
// Private Methods
template<class Type>
static void writeField
//- Write field content (component-wise) for the given ensight element type
template<template<typename> class FieldContainer, class Type>
static void writeFieldContent
(
const char* key,
const FieldContainer<Type>& fld,
ensightFile& os
);
//- Write a field of faces values as an indirect list,
// using the face ids from ensightFaces
template<class Type>
static bool writeFaceField
(
const Field<Type>& fld,
const ensightFaces&,
ensightFile& os
);
//- Write a field of faces values as a sublist,
// using the sublist sizes ensightFaces
template<class Type>
static bool writePatchField
static bool writeFaceSubField
(
const Field<Type>& pf,
const ensightFaces& ensFaces,
const Field<Type>& fld,
const ensightFaces&,
ensightFile& os
);
//- Write a field of cell values as an indirect list,
// using the cell ids from ensightCells
template<class Type>
static bool writeVolField
static bool writeCellField
(
const Field<Type>& vf,
const ensightCells& ensCells,
const Field<Type>& fld,
const ensightCells&,
ensightFile& os,
const bool deprecatedOrder = false
);
......
......@@ -41,11 +41,11 @@ License
// * * * * * * * * * * Static Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::ensightOutput::writeField
template<template<typename> class FieldContainer, class Type>
void Foam::ensightOutput::writeFieldContent
(
const char* key,
const Field<Type>& fld,
const FieldContainer<Type>& fld,
ensightFile& os
)
{
......@@ -85,7 +85,7 @@ void Foam::ensightOutput::writeField
template<class Type>
bool Foam::ensightOutput::writePatchField
bool Foam::ensightOutput::writeFaceField
(
const Field<Type>& pf,
const ensightFaces& ensFaces,
......@@ -99,14 +99,11 @@ bool Foam::ensightOutput::writePatchField
os.beginPart(ensFaces.index());
}
const List<ensightFaces::elemType> enums =
ensightFaces::elemEnum.enums();
forAllConstIter(List<ensightFaces::elemType>, enums, iter)
for (label typei=0; typei < ensightFaces::nTypes; ++typei)
{
const ensightFaces::elemType& what = *iter;
const ensightFaces::elemType what = ensightFaces::elemType(typei);
writeField
writeFieldContent
(
ensightFaces::key(what),
Field<Type>(pf, ensFaces.faceIds(what)),
......@@ -124,7 +121,47 @@ bool Foam::ensightOutput::writePatchField
template<class Type>
bool Foam::ensightOutput::writeVolField
bool Foam::ensightOutput::writeFaceSubField
(
const Field<Type>& pf,
const ensightFaces& ensFaces,
Foam::ensightFile& os
)
{
if (ensFaces.total())
{
if (Pstream::master())
{
os.beginPart(ensFaces.index());
}
label start = 0; // start of sublist
for (label typei = 0; typei < ensightFaces::nTypes; ++typei)
{
const ensightFaces::elemType what = ensightFaces::elemType(typei);
const label size = ensFaces.faceIds(what).size();
writeFieldContent
(
ensightFaces::key(what),
SubField<Type>(pf, size, start),
os
);
start += size; // start of next sublist
}
return true;
}
else
{
return false;
}
}
template<class Type>
bool Foam::ensightOutput::writeCellField
(
const Field<Type>& vf,
const ensightCells& ensCells,
......@@ -151,34 +188,30 @@ bool Foam::ensightOutput::writeVolField
ensightCells::NFACED
};
for (int i=0; i < 5; ++i)
for (label typei=0; typei < ensightCells::nTypes; ++typei)
{
const ensightCells::elemType& what = oldOrder[i];
const ensightCells::elemType& what = oldOrder[typei];
writeField
writeFieldContent
(
ensightCells::key(what),
Field<Type>(vf, ensCells.cellIds(what)),
os
);
}
return true;
}
else
{
const List<ensightCells::elemType> enums =
ensightCells::elemEnum.enums();
forAllConstIter(List<ensightCells::elemType>, enums, iter)
{
const ensightCells::elemType& what = *iter;
for (label typei=0; typei < ensightCells::nTypes; ++typei)
{
const ensightCells::elemType what = ensightCells::elemType(typei);
writeField
(
ensightCells::key(what),
Field<Type>(vf, ensCells.cellIds(what)),
os
);
}
writeFieldContent
(
ensightCells::key(what),
Field<Type>(vf, ensCells.cellIds(what)),
os
);
}
return true;
......@@ -209,7 +242,7 @@ bool Foam::ensightOutput::writeField
//
if (ensMesh.useInternalMesh())
{
writeVolField(vf, meshCells, os, ensMesh.deprecatedOrder());
writeCellField(vf, meshCells, os, ensMesh.deprecatedOrder());
}
//
......@@ -223,7 +256,7 @@ bool Foam::ensightOutput::writeField
const word& patchName = patchLookup[listi];
const ensightFaces& ensFaces = patchFaces[patchName];
writePatchField
writeFaceField
(
vf.boundaryField()[patchId],
ensFaces,
......@@ -303,7 +336,9 @@ bool Foam::ensightOutput::writeField
);
}
writePatchField(values, ensFaces, os);
// The field is already copied in the proper order
// - just need its corresponding sub-fields
writeFaceSubField(values, ensFaces, os);
}
}
......@@ -335,7 +370,7 @@ bool Foam::ensightOutput::ensightPointField
os.beginPart(0); // 0 = internalMesh
}
writeField
writeFieldContent
(
"coordinates",
Field<Type>(pf.internalField(), ensMesh.uniquePointMap()),
......@@ -373,7 +408,7 @@ bool Foam::ensightOutput::ensightPointField
os.beginPart(ensFaces.index());
}
writeField
writeFieldContent
(
"coordinates",
Field<Type>(pf.internalField(), uniqueMeshPointLabels),
......@@ -417,7 +452,7 @@ bool Foam::ensightOutput::ensightPointField
os.beginPart(ensFaces.index());
}
writeField
writeFieldContent
(
"coordinates",
Field<Type>(pf.internalField(), uniqueMeshPointLabels),
......
......@@ -55,12 +55,12 @@ class ensightSerialOutput
{
// Private Methods
//- Write field component-wise
template<class Type>
static void writeField
//- Write field content (component-wise) for the given ensight element type
template<template<typename> class FieldContainer, class Type>
static void writeFieldContent
(
const word& key,
const Field<Type>& field,
const FieldContainer<Type>& fld,
ensightFile& os
);
......
......@@ -31,11 +31,11 @@ License
// * * * * * * * * * * Static Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::ensightSerialOutput::writeField
template<template<typename> class FieldContainer, class Type>
void Foam::ensightSerialOutput::writeFieldContent
(
const word& key,
const Field<Type>& fld,
const FieldContainer<Type>& fld,
ensightFile& os
)
{
......@@ -82,14 +82,11 @@ bool Foam::ensightSerialOutput::writeField
{
os.beginPart(part.index());
const List<ensightFaces::elemType> enums =
ensightFaces::elemEnum.enums();
forAllConstIter(List<ensightFaces::elemType>, enums, iter)
for (label typei=0; typei < ensightFaces::nTypes; ++typei)
{
const ensightFaces::elemType what = *iter;
const ensightFaces::elemType what = ensightFaces::elemType(typei);
writeField
writeFieldContent
(
ensightFaces::key(what),
Field<Type>(fld, part.faceIds(what)),
......@@ -115,14 +112,11 @@ bool Foam::ensightSerialOutput::writeField
{
os.beginPart(part.index());
const List<ensightCells::elemType> enums =
ensightCells::elemEnum.enums();
forAllConstIter(List<ensightCells::elemType>, enums, iter)
for (label typei=0; typei < ensightCells::nTypes; ++typei)
{
const ensightCells::elemType what = *iter;
const ensightCells::elemType what = ensightCells::elemType(typei);
writeField
writeFieldContent
(
ensightCells::key(what),
Field<Type>(fld, part.cellIds(what)),
......
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