Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
3963cd95
Commit
3963cd95
authored
Jul 24, 2018
by
Mark OLESEN
Browse files
STYLE: code cleanup in fileFormats, conversion
parent
4a3bb8a9
Changes
34
Hide whitespace changes
Inline
Side-by-side
src/conversion/ensight/mesh/ensightMesh.C
View file @
3963cd95
...
...
@@ -131,11 +131,8 @@ void Foam::ensightMesh::correct()
wordList
patchNames
=
mesh_
.
boundaryMesh
().
names
();
if
(
Pstream
::
parRun
())
{
patchNames
.
setSize
(
mesh_
.
boundary
().
size
()
-
mesh_
.
globalData
().
processorPatches
().
size
()
);
// Do not include processor patches in matching
patchNames
.
setSize
(
mesh_
.
boundaryMesh
().
nNonProcessor
());
}
labelList
matched
;
...
...
@@ -158,9 +155,8 @@ void Foam::ensightMesh::correct()
matched
=
identity
(
patchNames
.
size
());
}
for
All
(
matched
,
match
i
)
for
(
const
label
patchId
:
match
ed
)
{
const
label
patchId
=
matched
[
matchi
];
const
word
&
patchName
=
patchNames
[
patchId
];
// use fvPatch (not polyPatch) to automatically remove empty patches
...
...
@@ -224,9 +220,8 @@ void Foam::ensightMesh::correct()
// Mark boundary faces to be excluded from export
bitSet
excludeFace
(
mesh_
.
nFaces
());
// all false
for
All
(
mesh_
.
boundaryMesh
()
,
patchi
)
for
(
const
polyPatch
&
pp
:
mesh_
.
boundaryMesh
())
{
const
polyPatch
&
pp
=
mesh_
.
boundaryMesh
()[
patchi
];
if
(
isA
<
processorPolyPatch
>
(
pp
)
...
...
@@ -250,9 +245,8 @@ void Foam::ensightMesh::correct()
Foam
::
sort
(
selectZones
);
// Count face types in each selected faceZone
for
All
(
selectZones
,
zonei
)
for
(
const
word
&
zoneName
:
selectZones
)
{
const
word
&
zoneName
=
selectZones
[
zonei
];
const
label
zoneID
=
mesh_
.
faceZones
().
findZoneID
(
zoneName
);
const
faceZone
&
fz
=
mesh_
.
faceZones
()[
zoneID
];
...
...
@@ -318,9 +312,8 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
// use sortedToc for extra safety
//
const
labelList
patchIds
=
patchLookup_
.
sortedToc
();
for
All
(
patchIds
,
listi
)
for
(
const
label
patchId
:
patchIds
)
{
const
label
patchId
=
patchIds
[
listi
];
const
word
&
patchName
=
patchLookup_
[
patchId
];
const
ensightFaces
&
ensFaces
=
boundaryPatchFaces_
[
patchName
];
...
...
@@ -341,9 +334,9 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
// Renumber the patch faces,
// from local patch indexing to unique global index
faceList
patchFaces
(
pp
.
localFaces
());
for
All
(
patchFaces
,
i
)
for
(
face
&
f
:
patchFaces
)
{
inplaceRenumber
(
pointToGlobal
,
patchFaces
[
i
]
);
inplaceRenumber
(
pointToGlobal
,
f
);
}
writeAllPoints
...
...
@@ -363,9 +356,8 @@ void Foam::ensightMesh::write(ensightGeoFile& os) const
// write faceZones, if requested
//
const
wordList
zoneNames
=
faceZoneFaces_
.
sortedToc
();
for
All
(
zoneName
s
,
zone
i
)
for
(
const
word
&
zoneName
:
zone
Names
)
{
const
word
&
zoneName
=
zoneNames
[
zonei
];
const
ensightFaces
&
ensFaces
=
faceZoneFaces_
[
zoneName
];
// Use the properly sorted faceIds (ensightFaces) and do NOT use the
...
...
src/conversion/ensight/mesh/ensightMesh.H
View file @
3963cd95
...
...
@@ -98,14 +98,14 @@ private:
// Parallel merged points
//- Global numbering for merged points
autoPtr
<
globalIndex
>
globalPointsPtr_
;
//- Global numbering for merged points
autoPtr
<
globalIndex
>
globalPointsPtr_
;
//- From mesh point to global merged point
labelList
pointToGlobal_
;
//- From mesh point to global merged point
labelList
pointToGlobal_
;
//- Local points that are unique
labelList
uniquePointMap_
;
//- Local points that are unique
labelList
uniquePointMap_
;
// Private Member Functions
...
...
@@ -117,122 +117,130 @@ private:
//- Inplace renumber of cell-shapes
static
cellShapeList
&
renumberShapes
(
cellShapeList
&
,
cellShapeList
&
shapes
,
const
labelUList
&
pointToGlobal
);
static
cellShapeList
map
(
const
cellShapeList
&
,
const
labelUList
&
prims
,
const
cellShapeList
&
shapes
,
const
labelUList
&
addr
,
const
labelUList
&
pointToGlobal
);
//- Write list of faces
static
void
writeFaceList
(
const
faceList
&
,
ensightGeoFile
&
const
faceList
&
faces
,
ensightGeoFile
&
os
);
//- Write list of faces
static
void
writeFaceList
(
const
UIndirectList
<
face
>&
,
ensightGeoFile
&
const
UIndirectList
<
face
>&
faces
,
ensightGeoFile
&
os
);
//- Write sizes of faces in the list
static
void
writeFaceSizes
(
const
faceList
&
,
ensightGeoFile
&
const
faceList
&
faces
,
ensightGeoFile
&
os
);
//- Write sizes of faces in the list
static
void
writeFaceSizes
(
const
UIndirectList
<
face
>&
,
ensightGeoFile
&
const
UIndirectList
<
face
>&
faces
,
ensightGeoFile
&
os
);
//- Write cell connectivity via
sh
ell shapes
//- Write cell connectivity via
c
ell shapes
static
void
writeCellShapes
(
const
cellShapeList
&
,
ensightGeoFile
&
const
cellShapeList
&
shapes
,
ensightGeoFile
&
os
);
//- Write the number of faces per poly element
void
writePolysNFaces
(
const
labelList
&
polys
,
const
label
U
List
&
polys
,
const
cellList
&
cellFaces
,
ensightGeoFile
&
ensightGeoFile
&
os
)
const
;
//- Write the number of points per poly element
void
writePolysNPointsPerFace
(
const
labelList
&
polys
,
const
label
U
List
&
polys
,
const
cellList
&
cellFaces
,
const
faceList
&
faces
,
ensightGeoFile
&
)
const
;
//- Write the point ids per poly element
void
writePolysPoints
(
const
labelList
&
polys
,
const
label
U
List
&
addr
,
const
cellList
&
cellFaces
,
const
faceList
&
faces
,
const
labelList
&
faceOwner
,
ensightGeoFile
&
)
const
;
//- Write the poly connectivity
void
writePolysConnectivity
(
const
labelList
&
addr
,
const
label
U
List
&
polys
,
const
labelList
&
pointToGlobal
,
ensightGeoFile
&
)
const
;
//- Write the regular cell connectivity for all types
void
writeCellConnectivity
(
const
ensightCells
&
,
const
ensightCells
&
ensCells
,
const
labelList
&
pointToGlobal
,
ensightGeoFile
&
ensightGeoFile
&
os
)
const
;
//- Write the regular cell connectivity for specified type
void
writeCellConnectivity
(
ensightCells
::
elemType
elemType
,
const
ensightCells
&
,
const
ensightCells
&
ensCells
,
const
labelList
&
pointToGlobal
,
ensightGeoFile
&
ensightGeoFile
&
os
)
const
;
//- Write the regular face connectivity for specified type and
//- and specified faces
void
writeFaceConnectivity
(
ensightFaces
::
elemType
elemType
,
const
label
nTotal
,
const
faceList
&
face
Lst
,
const
labelList
&
addr
,
const
faceList
&
face
s
,
const
label
U
List
&
addr
,
ensightGeoFile
&
)
const
;
//- Write the regular face connectivity for specified type
void
writeFaceConnectivity
(
ensightFaces
::
elemType
elemType
,
const
label
nTotal
,
const
faceList
&
face
Lst
,
ensightGeoFile
&
const
faceList
&
face
s
,
ensightGeoFile
&
os
)
const
;
void
writeFaceConnectivity
(
const
ensightFaces
&
,
const
faceList
&
face
Lst
,
ensightGeoFile
&
,
const
ensightFaces
&
ensFaces
,
const
faceList
&
face
s
,
ensightGeoFile
&
os
,
const
bool
raw
=
false
)
const
;
...
...
src/conversion/ensight/mesh/ensightMeshIO.C
View file @
3963cd95
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-201
8
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -42,9 +42,9 @@ Foam::cellShapeList& Foam::ensightMesh::renumberShapes
const
labelUList
&
pointToGlobal
)
{
for
All
(
shapes
,
i
)
for
(
cellShape
&
shape
:
shapes
)
{
inplaceRenumber
(
pointToGlobal
,
shape
s
[
i
]
);
inplaceRenumber
(
pointToGlobal
,
shape
);
}
return
shapes
;
...
...
@@ -58,15 +58,15 @@ Foam::cellShapeList Foam::ensightMesh::map
const
labelUList
&
pointToGlobal
)
{
cellShapeList
lst
(
addr
.
size
());
cellShapeList
l
i
st
(
addr
.
size
());
forAll
(
addr
,
i
)
{
lst
[
i
]
=
shapes
[
addr
[
i
]];
inplaceRenumber
(
pointToGlobal
,
lst
[
i
]);
l
i
st
[
i
]
=
shapes
[
addr
[
i
]];
inplaceRenumber
(
pointToGlobal
,
l
i
st
[
i
]);
}
return
lst
;
return
l
i
st
;
}
...
...
@@ -76,13 +76,11 @@ void Foam::ensightMesh::writeFaceList
ensightGeoFile
&
os
)
{
for
All
(
faceLst
,
i
)
for
(
const
face
&
f
:
faceLst
)
{
const
face
&
f
=
faceLst
[
i
];
forAll
(
f
,
fp
)
for
(
const
label
labi
:
f
)
{
os
.
write
(
f
[
fp
]
+
1
);
os
.
write
(
labi
+
1
);
}
os
.
newline
();
...
...
@@ -96,13 +94,11 @@ void Foam::ensightMesh::writeFaceList
ensightGeoFile
&
os
)
{
for
All
(
faceLst
,
i
)
for
(
const
face
&
f
:
faceLst
)
{
const
face
&
f
=
faceLst
[
i
];
forAll
(
f
,
fp
)
for
(
const
label
labi
:
f
)
{
os
.
write
(
f
[
fp
]
+
1
);
os
.
write
(
labi
+
1
);
}
os
.
newline
();
...
...
@@ -116,10 +112,8 @@ void Foam::ensightMesh::writeFaceSizes
ensightGeoFile
&
os
)
{
for
All
(
faceLst
,
i
)
for
(
const
face
&
f
:
faceLst
)
{
const
face
&
f
=
faceLst
[
i
];
os
.
write
(
f
.
size
());
os
.
newline
();
}
...
...
@@ -132,10 +126,8 @@ void Foam::ensightMesh::writeFaceSizes
ensightGeoFile
&
os
)
{
for
All
(
faceLst
,
i
)
for
(
const
face
&
f
:
faceLst
)
{
const
face
&
f
=
faceLst
[
i
];
os
.
write
(
f
.
size
());
os
.
newline
();
}
...
...
@@ -148,17 +140,15 @@ void Foam::ensightMesh::writeCellShapes
ensightGeoFile
&
os
)
{
for
All
(
shapes
,
i
)
for
(
const
cellShape
&
cellPoints
:
shapes
)
{
const
cellShape
&
cellPoints
=
shapes
[
i
];
// convert global -> local index
// (note: Ensight indices start with 1)
// In ASCII, write one cell per line
for
All
(
cellPoints
,
p
oint
I
)
for
(
const
label
pointi
:
cellP
oint
s
)
{
os
.
write
(
cellPoints
[
point
I
]
+
1
);
os
.
write
(
point
i
+
1
);
}
os
.
newline
();
...
...
@@ -170,15 +160,15 @@ void Foam::ensightMesh::writeCellShapes
void
Foam
::
ensightMesh
::
writePolysNFaces
(
const
labelList
&
addr
,
const
cellList
&
cellFaces
,
const
label
U
List
&
addr
,
const
cellList
&
cellFaces
,
ensightGeoFile
&
os
)
const
{
//
w
rite the number of faces per element (1/line in ASCII)
for
All
(
addr
,
i
)
//
W
rite the number of faces per element (1/line in ASCII)
for
(
const
label
cellId
:
addr
)
{
const
labelUList
&
cf
=
cellFaces
[
addr
[
i
]
];
const
labelUList
&
cf
=
cellFaces
[
cellId
];
os
.
write
(
cf
.
size
());
os
.
newline
();
...
...
@@ -188,20 +178,20 @@ void Foam::ensightMesh::writePolysNFaces
void
Foam
::
ensightMesh
::
writePolysNPointsPerFace
(
const
labelList
&
addr
,
const
label
U
List
&
addr
,
const
cellList
&
cellFaces
,
const
faceList
&
faces
,
ensightGeoFile
&
os
)
const
{
//
w
rite the number of points per element face (1/line in ASCII)
for
All
(
addr
,
i
)
//
W
rite the number of points per element face (1/line in ASCII)
for
(
const
label
cellId
:
addr
)
{
const
labelUList
&
cf
=
cellFaces
[
addr
[
i
]
];
const
labelUList
&
cf
=
cellFaces
[
cellId
];
for
All
(
cf
,
facei
)
for
(
const
label
facei
:
cf
)
{
os
.
write
(
faces
[
cf
[
facei
]
]
.
size
());
os
.
write
(
faces
[
facei
].
size
());
os
.
newline
();
}
}
...
...
@@ -210,21 +200,19 @@ void Foam::ensightMesh::writePolysNPointsPerFace
void
Foam
::
ensightMesh
::
writePolysPoints
(
const
labelList
&
addr
,
const
label
U
List
&
addr
,
const
cellList
&
cellFaces
,
const
faceList
&
faces
,
const
labelList
&
faceOwner
,
ensightGeoFile
&
os
)
const
{
for
All
(
addr
,
i
)
for
(
const
label
cellId
:
addr
)
{
const
label
cellId
=
addr
[
i
];
const
labelUList
&
cf
=
cellFaces
[
cellId
];
for
All
(
cf
,
facei
)
for
(
const
label
faceId
:
cf
)
{
const
label
faceId
=
cf
[
facei
];
const
face
&
f
=
faces
[
faceId
];
// face points (in global points)
if
(
faceId
<
faceOwner
.
size
()
&&
faceOwner
[
faceId
]
!=
cellId
)
...
...
@@ -234,16 +222,16 @@ void Foam::ensightMesh::writePolysPoints
// as per face::reverseFace(), but without copying
os
.
write
(
f
[
0
]
+
1
);
for
(
label
pt
I
=
f
.
size
()
-
1
;
pt
I
>
0
;
--
pt
I
)
for
(
label
pt
i
=
f
.
size
()
-
1
;
pt
i
>
0
;
--
pt
i
)
{
os
.
write
(
f
[
pt
I
]
+
1
);
os
.
write
(
f
[
pt
i
]
+
1
);
}
}
else
{
for
All
(
f
,
ptI
)
for
(
const
label
labi
:
f
)
{
os
.
write
(
f
[
ptI
]
+
1
);
os
.
write
(
labi
+
1
);
}
}
...
...
@@ -255,7 +243,7 @@ void Foam::ensightMesh::writePolysPoints
void
Foam
::
ensightMesh
::
writePolysConnectivity
(
const
labelList
&
addr
,
const
label
U
List
&
addr
,
const
labelList
&
pointToGlobal
,
ensightGeoFile
&
os
)
const
...
...
@@ -329,9 +317,9 @@ void Foam::ensightMesh::writePolysConnectivity
// Renumber faces to use global point numbers
faceList
faces
(
mesh_
.
faces
());
for
All
(
face
s
,
i
)
for
(
face
&
f
:
faces
)
{
inplaceRenumber
(
pointToGlobal
,
f
aces
[
i
]
);
inplaceRenumber
(
pointToGlobal
,
f
);
}
// List of points id for each face of the above list
...
...
@@ -409,11 +397,14 @@ void Foam::ensightMesh::writeCellConnectivity
}
else
{
const
cellShapeList
shapes
=
map
const
cellShapeList
shapes
(
mesh_
.
cellShapes
(),
addr
,
pointToGlobal
map
(
mesh_
.
cellShapes
(),
addr
,
pointToGlobal
)
);
...
...
@@ -454,7 +445,8 @@ void Foam::ensightMesh::writeCellConnectivity
{
for
(
label
typei
=
0
;
typei
<
ensightCells
::
nTypes
;
++
typei
)
{
const
ensightCells
::
elemType
what
=
ensightCells
::
elemType
(
typei
);
const
ensightCells
::
elemType
what
=
ensightCells
::
elemType
(
typei
);
writeCellConnectivity
(
what
,
ensCells
,
pointToGlobal
,
os
);
}
...
...
@@ -489,9 +481,9 @@ void Foam::ensightMesh::writeFaceConnectivity
for
(
int
slave
=
1
;
slave
<
Pstream
::
nProcs
();
++
slave
)
{
IPstream
fromSlave
(
Pstream
::
commsTypes
::
scheduled
,
slave
);
faceList
rec
eived
(
fromSlave
);
faceList
rec
v
(
fromSlave
);
writeFaceSizes
(
rec
eived
,
os
);
writeFaceSizes
(
rec
v
,
os
);
}
}
else
...
...
@@ -516,9 +508,9 @@ void Foam::ensightMesh::writeFaceConnectivity
for
(
int
slave
=
1
;
slave
<
Pstream
::
nProcs
();
++
slave
)
{
IPstream
fromSlave
(
Pstream
::
commsTypes
::
scheduled
,
slave
);
faceList
rec
eived
(
fromSlave
);
faceList
rec
v
(
fromSlave
);
writeFaceList
(
rec
eived
,
os
);
writeFaceList
(
rec
v
,
os
);
}
}
else
...
...
@@ -541,7 +533,7 @@ void Foam::ensightMesh::writeFaceConnectivity
ensightFaces
::
elemType
elemType
,
const
label
nTotal
,
const
faceList
&
faceLst
,
const
labelList
&
addr
,
const
label
U
List
&
addr
,
ensightGeoFile
&
os
)
const
{
...
...
@@ -621,12 +613,13 @@ void Foam::ensightMesh::writeFaceConnectivity
const
bool
raw
)
const
{
if
(
raw
)
for
(
label
typei
=
0
;
typei
<
ensightFaces
::
nTypes
;
++
typei
)
{
for
(
label
typei
=
0
;
typei
<
ensightFaces
::
nTypes
;
++
typei
)
{
const
ensightFaces
::
elemType
what
=
ensightFaces
::
elemType
(
typei
);
const
ensightFaces
::
elemType
what
=
ensightFaces
::
elemType
(
typei
);
if
(
raw
)
{
writeFaceConnectivity
(
what
,
...
...
@@ -640,13 +633,8 @@ void Foam::ensightMesh::writeFaceConnectivity
os
);
}
}
else
{
for
(
label
typei
=
0
;
typei
<
ensightFaces
::
nTypes
;
++
typei
)
else
{
const
ensightFaces
::
elemType
what
=
ensightFaces
::
elemType
(
typei
);
writeFaceConnectivity
(
what
,
...
...
src/conversion/ensight/mesh/ensightMeshOptions.C
View file @
3963cd95
...
...
@@ -25,7 +25,6 @@ License
#include
"ensightMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
ensightMesh
::
options
::
options
(
IOstream
::
streamFormat
format
)
...
...
src/conversion/ensight/output/ensightOutputTemplates.C
View file @
3963cd95
...
...
@@ -144,7 +144,9 @@ bool Foam::ensightOutput::writeFaceSubField
label
start
=
0
;
// start of sublist
for
(
label
typei
=
0
;
typei
<
ensightFaces
::
nTypes
;
++
typei
)
{
const
ensightFaces
::
elemType
what
=
ensightFaces
::
elemType
(
typei
);
const
ensightFaces
::
elemType
what
=
ensightFaces
::
elemType
(
typei
);
const
label
size
=
ensFaces
.
faceIds
(
what
).
size
();
writeFieldContent
...
...
@@ -159,10 +161,8 @@ bool Foam::ensightOutput::writeFaceSubField
return
true
;
}
else
{
return
false
;