mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: allow cell zone and face zone definition
This commit is contained in:
@ -63,11 +63,16 @@ label maxNodei = 0;
|
|||||||
|
|
||||||
SLPtrList<labelList> slCellLabels;
|
SLPtrList<labelList> slCellLabels;
|
||||||
SLList<label> slCellMap;
|
SLList<label> slCellMap;
|
||||||
|
SLList<label> slCellType;
|
||||||
label maxCelli = 0;
|
label maxCelli = 0;
|
||||||
|
|
||||||
PtrList<SLList<label> > slPatchCells;
|
PtrList<SLList<label> > slPatchCells;
|
||||||
PtrList<SLList<label> > slPatchCellFaces;
|
PtrList<SLList<label> > slPatchCellFaces;
|
||||||
|
|
||||||
|
// Cell types
|
||||||
|
Map<word> cellTypes;
|
||||||
|
label currentTypei = -1;
|
||||||
|
|
||||||
|
|
||||||
// Dummy yywrap to keep yylex happy at compile time.
|
// Dummy yywrap to keep yylex happy at compile time.
|
||||||
// It is called by yylex but is not used as the mechanism to change file.
|
// It is called by yylex but is not used as the mechanism to change file.
|
||||||
@ -108,6 +113,8 @@ value {floatNum}
|
|||||||
node ^{space}"N"{cspace}
|
node ^{space}"N"{cspace}
|
||||||
element ^{space}"EN"{cspace}
|
element ^{space}"EN"{cspace}
|
||||||
bface ^{space}"SFE"{cspace}
|
bface ^{space}"SFE"{cspace}
|
||||||
|
elementTypeName ^{space}"ET"{cspace}
|
||||||
|
elementType ^{space}"TYPE"{cspace}
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@ -160,6 +167,7 @@ bface ^{space}"SFE"{cspace}
|
|||||||
|
|
||||||
slCellMap.append(celli);
|
slCellMap.append(celli);
|
||||||
slCellLabels.append(new labelList(labels));
|
slCellLabels.append(new labelList(labels));
|
||||||
|
slCellType.append(currentTypei);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -210,6 +218,37 @@ bface ^{space}"SFE"{cspace}
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{elementTypeName}{label}{cspace}{identifier}{space}\n {
|
||||||
|
|
||||||
|
IStringStream elementStream(YYText());
|
||||||
|
char tag,c;
|
||||||
|
label cellTypei;
|
||||||
|
word cellTypeName;
|
||||||
|
elementStream
|
||||||
|
>> tag >> tag // skip 'ET'
|
||||||
|
>> c >> cellTypei
|
||||||
|
>> c >> cellTypeName;
|
||||||
|
|
||||||
|
Info<< "Read typeName " << cellTypeName
|
||||||
|
<< " for type " << cellTypei << endl;
|
||||||
|
|
||||||
|
cellTypes.insert(cellTypei, cellTypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{elementType}{label}{space}\n {
|
||||||
|
IStringStream elementStream(YYText());
|
||||||
|
char tag,c;
|
||||||
|
label cellTypei;
|
||||||
|
elementStream
|
||||||
|
>> tag >> tag >> tag >> tag // skip 'TYPE'
|
||||||
|
>> c >> cellTypei;
|
||||||
|
|
||||||
|
currentTypei = cellTypei;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- *\
|
/* ------------------------------------------------------------------------- *\
|
||||||
------ Ignore remaining space and \n s. Any other characters are errors.
|
------ Ignore remaining space and \n s. Any other characters are errors.
|
||||||
\* ------------------------------------------------------------------------- */
|
\* ------------------------------------------------------------------------- */
|
||||||
@ -231,6 +270,29 @@ bface ^{space}"SFE"{cspace}
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
using std::ifstream;
|
using std::ifstream;
|
||||||
|
|
||||||
|
|
||||||
|
label findFace(const polyMesh& mesh, const face& f)
|
||||||
|
{
|
||||||
|
const labelList& pFaces = mesh.pointFaces()[f[0]];
|
||||||
|
|
||||||
|
forAll(pFaces, i)
|
||||||
|
{
|
||||||
|
label faceI = pFaces[i];
|
||||||
|
|
||||||
|
if (mesh.faces()[faceI] == f)
|
||||||
|
{
|
||||||
|
return faceI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FatalErrorIn("findFace(const polyMesh&, const face&)")
|
||||||
|
<< "Cannot find a face matching " << f
|
||||||
|
<< exit(FatalError);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
argList::noParallel();
|
argList::noParallel();
|
||||||
@ -253,7 +315,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
# include "createTime.H"
|
# include "createTime.H"
|
||||||
|
|
||||||
const fileName ansysFile = args[1];
|
fileName ansysFile(args.additionalArgs()[0]);
|
||||||
ifstream ansysStream(ansysFile.c_str());
|
ifstream ansysStream(ansysFile.c_str());
|
||||||
|
|
||||||
if (!ansysStream)
|
if (!ansysStream)
|
||||||
@ -377,6 +439,34 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const word defaultFacesName = "defaultFaces";
|
||||||
|
word defaultFacesType = emptyPolyPatch::typeName;
|
||||||
|
|
||||||
|
// Create dummy mesh just to find out what are internal/external
|
||||||
|
// faces
|
||||||
|
autoPtr<polyMesh> dummyMesh
|
||||||
|
(
|
||||||
|
new polyMesh
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"dummyMesh",
|
||||||
|
runTime.constant(),
|
||||||
|
runTime
|
||||||
|
),
|
||||||
|
xferCopy(points),
|
||||||
|
cellShapes,
|
||||||
|
faceListList(0),
|
||||||
|
wordList(0),
|
||||||
|
wordList(0),
|
||||||
|
defaultFacesName,
|
||||||
|
defaultFacesType,
|
||||||
|
wordList(0)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Warning: tet face order has changed between version 1.9.6 and 2.0
|
// Warning: tet face order has changed between version 1.9.6 and 2.0
|
||||||
//
|
//
|
||||||
label faceIndex[7][6] =
|
label faceIndex[7][6] =
|
||||||
@ -423,10 +513,53 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
boundary[patchI] = patchFaces;
|
boundary[patchI] = patchFaces;
|
||||||
patchNames[patchI] = word("patch") + name(patchI + 1);
|
patchNames[patchI] = word("patch") + name(patchI + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lookup the face labels for all the boundary faces
|
||||||
|
//
|
||||||
|
labelListList boundaryFaceLabels(boundary.size());
|
||||||
|
forAll(boundary, patchI)
|
||||||
|
{
|
||||||
|
const faceList& bFaces = boundary[patchI];
|
||||||
|
labelList& bFaceLabels = boundaryFaceLabels[patchI];
|
||||||
|
bFaceLabels.setSize(bFaces.size());
|
||||||
|
forAll(bFaces, i)
|
||||||
|
{
|
||||||
|
bFaceLabels[i] = findFace(dummyMesh(), bFaces[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Now split the boundary faces into external and internal faces. All
|
||||||
|
// faces go into faceZones and external faces go into patches.
|
||||||
|
List<faceList> patchFaces(slPatchCells.size());
|
||||||
|
labelList patchNFaces(slPatchCells.size(), 0);
|
||||||
|
forAll(boundary, patchI)
|
||||||
|
{
|
||||||
|
const faceList& bFaces = boundary[patchI];
|
||||||
|
const labelList& bFaceLabels = boundaryFaceLabels[patchI];
|
||||||
|
|
||||||
|
patchFaces[patchI].setSize(bFaces.size());
|
||||||
|
|
||||||
|
forAll(bFaces, i)
|
||||||
|
{
|
||||||
|
if (!dummyMesh().isInternalFace(bFaceLabels[i]))
|
||||||
|
{
|
||||||
|
patchFaces[patchI][patchNFaces[patchI]++] = bFaces[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
patchFaces[patchI].setSize(patchNFaces[patchI]);
|
||||||
|
|
||||||
Info<< "Patch " << patchI << " named " << patchNames[patchI]
|
Info<< "Patch " << patchI << " named " << patchNames[patchI]
|
||||||
<< ": " << boundary[patchI].size() << " faces" << endl;
|
<< ": " << boundary[patchI].size() << " faces" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We no longer need the dummyMesh
|
||||||
|
dummyMesh.clear();
|
||||||
|
|
||||||
|
|
||||||
Info<< "ansysToFoam: " << endl
|
Info<< "ansysToFoam: " << endl
|
||||||
<< "Ansys file format does not provide information about the type of "
|
<< "Ansys file format does not provide information about the type of "
|
||||||
<< "the patch (eg. wall, symmetry plane, cyclic etc)." << endl
|
<< "the patch (eg. wall, symmetry plane, cyclic etc)." << endl
|
||||||
@ -434,10 +567,8 @@ int main(int argc, char *argv[])
|
|||||||
<< "as type patch. Please reset after mesh conversion as necessary."
|
<< "as type patch. Please reset after mesh conversion as necessary."
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
wordList patchTypes(boundary.size(), polyPatch::typeName);
|
wordList patchTypes(patchFaces.size(), polyPatch::typeName);
|
||||||
word defaultFacesName = "defaultFaces";
|
wordList patchPhysicalTypes(patchFaces.size());
|
||||||
word defaultFacesType = emptyPolyPatch::typeName;
|
|
||||||
wordList patchPhysicalTypes(boundary.size());
|
|
||||||
|
|
||||||
preservePatchTypes
|
preservePatchTypes
|
||||||
(
|
(
|
||||||
@ -461,7 +592,7 @@ int main(int argc, char *argv[])
|
|||||||
),
|
),
|
||||||
xferMove(points),
|
xferMove(points),
|
||||||
cellShapes,
|
cellShapes,
|
||||||
boundary,
|
patchFaces,
|
||||||
patchNames,
|
patchNames,
|
||||||
patchTypes,
|
patchTypes,
|
||||||
defaultFacesName,
|
defaultFacesName,
|
||||||
@ -469,6 +600,90 @@ int main(int argc, char *argv[])
|
|||||||
patchPhysicalTypes
|
patchPhysicalTypes
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if (cellTypes.size() > 0 || patchNames.size() > 0)
|
||||||
|
{
|
||||||
|
DynamicList<pointZone*> pz;
|
||||||
|
DynamicList<faceZone*> fz;
|
||||||
|
DynamicList<cellZone*> cz;
|
||||||
|
|
||||||
|
// FaceZones
|
||||||
|
forAll(boundaryFaceLabels, patchI)
|
||||||
|
{
|
||||||
|
if (boundaryFaceLabels[patchI].size())
|
||||||
|
{
|
||||||
|
// Re-do the boundaryFaceLabels since the boundary face
|
||||||
|
// labels will be different on the pShapeMesh.
|
||||||
|
const faceList& bFaces = boundary[patchI];
|
||||||
|
labelList& bFaceLabels = boundaryFaceLabels[patchI];
|
||||||
|
forAll(bFaceLabels, i)
|
||||||
|
{
|
||||||
|
bFaceLabels[i] = findFace(pShapeMesh, bFaces[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Creating faceZone " << patchNames[patchI]
|
||||||
|
<< " with " << bFaceLabels.size() << " faces" << endl;
|
||||||
|
|
||||||
|
fz.append
|
||||||
|
(
|
||||||
|
new faceZone
|
||||||
|
(
|
||||||
|
patchNames[patchI],
|
||||||
|
bFaceLabels,
|
||||||
|
boolList(bFaceLabels.size(), false),
|
||||||
|
fz.size(),
|
||||||
|
pShapeMesh.faceZones()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// CellZones
|
||||||
|
labelList types = cellTypes.sortedToc();
|
||||||
|
|
||||||
|
forAll(types, j)
|
||||||
|
{
|
||||||
|
label cellType = types[j];
|
||||||
|
|
||||||
|
// Pick up cells in zone
|
||||||
|
DynamicList<label> addr;
|
||||||
|
|
||||||
|
SLList<label>::iterator cellMapIter = slCellMap.begin();
|
||||||
|
SLList<label>::iterator typeIter = slCellType.begin();
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
;
|
||||||
|
typeIter != slCellType.end();
|
||||||
|
++typeIter, ++cellMapIter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (typeIter() == cellType)
|
||||||
|
{
|
||||||
|
addr.append(cellMap[cellMapIter()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Creating cellZone " << cellTypes[cellType]
|
||||||
|
<< " with " << addr.size() << " cells" << endl;
|
||||||
|
|
||||||
|
cz.append
|
||||||
|
(
|
||||||
|
new cellZone
|
||||||
|
(
|
||||||
|
cellTypes[cellType],
|
||||||
|
addr,
|
||||||
|
j,
|
||||||
|
pShapeMesh.cellZones()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pShapeMesh.addZones(pz, fz, cz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set the precision of the points data to 10
|
// Set the precision of the points data to 10
|
||||||
IOstream::defaultPrecision(10);
|
IOstream::defaultPrecision(10);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user