Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
0be6ba87
Commit
0be6ba87
authored
Jan 28, 2011
by
Mark Olesen
Browse files
ENH: add perNode field writing to ensight/part/ensightPart*
- simplify the ensightSurfaceWriter accordingly
parent
08680b8b
Changes
14
Hide whitespace changes
Inline
Side-by-side
src/conversion/ensight/part/ensightPart.C
View file @
0be6ba87
...
...
@@ -45,11 +45,11 @@ bool Foam::ensightPart::isFieldDefined(const List<scalar>& field) const
{
forAll
(
elemLists_
,
elemI
)
{
const
labelList
&
idList
=
elemLists_
[
elemI
];
const
label
U
List
&
idList
=
elemLists_
[
elemI
];
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
];
const
label
id
=
idList
[
i
];
if
(
id
>=
field
.
size
()
||
isnan
(
field
[
id
]))
{
...
...
@@ -159,7 +159,7 @@ Foam::ensightPart::~ensightPart()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam
::
ensightPart
::
renumber
(
const
labelList
&
origId
)
void
Foam
::
ensightPart
::
renumber
(
const
label
U
List
&
origId
)
{
// transform to global values first
if
(
offset_
)
...
...
src/conversion/ensight/part/ensightPart.H
View file @
0be6ba87
...
...
@@ -134,6 +134,7 @@ protected:
void
writeHeader
(
ensightFile
&
,
bool
withDescription
=
false
)
const
;
//- write a scalar field for idList
// A null reference for idList writes the perNode values
void
writeFieldList
(
ensightFile
&
os
,
...
...
@@ -150,10 +151,10 @@ protected:
//- write connectivities
virtual
void
writeConnectivity
(
ensightGeoFile
&
os
,
ensightGeoFile
&
,
const
word
&
key
,
const
labelList
&
idList
,
const
labelList
&
pointMap
const
label
U
List
&
idList
,
const
label
U
List
&
pointMap
)
const
{}
...
...
@@ -287,7 +288,7 @@ public:
// Edit
//- renumber elements
void
renumber
(
const
labelList
&
);
void
renumber
(
const
label
U
List
&
);
//- write summary information about the object
bool
writeSummary
(
Ostream
&
)
const
;
...
...
@@ -303,28 +304,34 @@ public:
void
writeGeometry
(
ensightGeoFile
&
,
const
pointField
&
)
const
;
//- write scalar field
// optionally write data per node
void
writeScalarField
(
ensightFile
&
,
const
List
<
scalar
>&
field
const
List
<
scalar
>&
field
,
const
bool
perNode
=
false
)
const
;
//- write vector field components
// optionally write data per node
void
writeVectorField
(
ensightFile
&
,
const
List
<
scalar
>&
field0
,
const
List
<
scalar
>&
field1
,
const
List
<
scalar
>&
field2
const
List
<
scalar
>&
field2
,
const
bool
perNode
=
false
)
const
;
//- write generalized field components
// optionally write data per node
template
<
class
Type
>
void
writeField
(
ensightFile
&
,
const
Field
<
Type
>&
const
Field
<
Type
>&
,
const
bool
perNode
=
false
)
const
;
...
...
src/conversion/ensight/part/ensightPartCells.C
View file @
0be6ba87
...
...
@@ -52,7 +52,7 @@ const Foam::List<Foam::word> Foam::ensightPartCells::elemTypes_
void
Foam
::
ensightPartCells
::
classify
(
const
polyMesh
&
mesh
,
const
labelList
&
idList
const
label
U
List
&
idList
)
{
// References to cell shape models
...
...
@@ -203,7 +203,7 @@ Foam::ensightPartCells::ensightPartCells
(
label
partNumber
,
const
polyMesh
&
mesh
,
const
labelList
&
idList
const
label
U
List
&
idList
)
:
ensightPart
(
partNumber
,
"cells"
,
mesh
.
points
()),
...
...
@@ -259,13 +259,13 @@ Foam::ensightPart::localPoints Foam::ensightPartCells::calcLocalPoints() const
forAll
(
elemLists_
,
typeI
)
{
const
labelList
&
idList
=
elemLists_
[
typeI
];
const
label
U
List
&
idList
=
elemLists_
[
typeI
];
// add all points from cells
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
]
+
offset_
;
const
labelList
&
cFaces
=
mesh_
.
cells
()[
id
];
const
label
id
=
idList
[
i
]
+
offset_
;
const
label
U
List
&
cFaces
=
mesh_
.
cells
()[
id
];
forAll
(
cFaces
,
cFaceI
)
{
...
...
@@ -301,8 +301,8 @@ void Foam::ensightPartCells::writeConnectivity
(
ensightGeoFile
&
os
,
const
word
&
key
,
const
labelList
&
idList
,
const
labelList
&
pointMap
const
label
U
List
&
idList
,
const
label
U
List
&
pointMap
)
const
{
os
.
writeKeyword
(
key
);
...
...
@@ -317,8 +317,8 @@ void Foam::ensightPartCells::writeConnectivity
// write the number of faces per element
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
]
+
offset_
;
const
labelList
&
cFace
=
mesh_
.
cells
()[
id
];
const
label
id
=
idList
[
i
]
+
offset_
;
const
label
U
List
&
cFace
=
mesh_
.
cells
()[
id
];
os
.
write
(
cFace
.
size
());
os
.
newline
();
...
...
@@ -327,8 +327,8 @@ void Foam::ensightPartCells::writeConnectivity
// write the number of points per element face
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
]
+
offset_
;
const
labelList
&
cFace
=
mesh_
.
cells
()[
id
];
const
label
id
=
idList
[
i
]
+
offset_
;
const
label
U
List
&
cFace
=
mesh_
.
cells
()[
id
];
forAll
(
cFace
,
faceI
)
{
...
...
@@ -342,8 +342,8 @@ void Foam::ensightPartCells::writeConnectivity
// write the points describing each element face
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
]
+
offset_
;
const
labelList
&
cFace
=
mesh_
.
cells
()[
id
];
const
label
id
=
idList
[
i
]
+
offset_
;
const
label
U
List
&
cFace
=
mesh_
.
cells
()[
id
];
forAll
(
cFace
,
faceI
)
{
...
...
@@ -366,7 +366,7 @@ void Foam::ensightPartCells::writeConnectivity
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
]
+
offset_
;
const
label
id
=
idList
[
i
]
+
offset_
;
const
cellShape
&
cellPoints
=
cellShapes
[
id
];
// convert global -> local index
...
...
src/conversion/ensight/part/ensightPartCells.H
View file @
0be6ba87
...
...
@@ -60,7 +60,7 @@ class ensightPartCells
void
classify
(
const
polyMesh
&
,
const
labelList
&
idLabels
=
labelList
::
null
()
const
label
U
List
&
idLabels
=
label
U
List
::
null
()
);
//- track points used
...
...
@@ -72,10 +72,10 @@ class ensightPartCells
//- element connectivity
virtual
void
writeConnectivity
(
ensightGeoFile
&
os
,
ensightGeoFile
&
,
const
word
&
key
,
const
labelList
&
idList
,
const
labelList
&
pointMap
const
label
U
List
&
idList
,
const
label
U
List
&
pointMap
)
const
;
...
...
@@ -121,7 +121,7 @@ public:
(
label
partNumber
,
const
polyMesh
&
,
const
labelList
&
const
label
U
List
&
);
//- Construct from polyMesh and cellZone
...
...
src/conversion/ensight/part/ensightPartFaces.C
View file @
0be6ba87
...
...
@@ -217,12 +217,12 @@ Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const
forAll
(
elemLists_
,
typeI
)
{
const
labelList
&
idList
=
elemLists_
[
typeI
];
const
label
U
List
&
idList
=
elemLists_
[
typeI
];
// add all points from faces
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
]
+
offset_
;
const
label
id
=
idList
[
i
]
+
offset_
;
const
face
&
f
=
faces_
[
id
];
forAll
(
f
,
fp
)
...
...
@@ -255,8 +255,8 @@ void Foam::ensightPartFaces::writeConnectivity
ensightGeoFile
&
os
,
const
word
&
key
,
const
faceList
&
faces
,
const
labelList
&
idList
,
const
labelList
&
pointMap
const
label
U
List
&
idList
,
const
label
U
List
&
pointMap
)
const
{
os
.
writeKeyword
(
key
);
...
...
@@ -269,7 +269,7 @@ void Foam::ensightPartFaces::writeConnectivity
// write the number of points per face
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
]
+
offset_
;
const
label
id
=
idList
[
i
]
+
offset_
;
const
face
&
f
=
faces
[
id
];
os
.
write
(
f
.
size
());
...
...
@@ -280,7 +280,7 @@ void Foam::ensightPartFaces::writeConnectivity
// write the points describing the face
forAll
(
idList
,
i
)
{
label
id
=
idList
[
i
]
+
offset_
;
const
label
id
=
idList
[
i
]
+
offset_
;
const
face
&
f
=
faces
[
id
];
// convert global -> local index
...
...
@@ -298,8 +298,8 @@ void Foam::ensightPartFaces::writeConnectivity
(
ensightGeoFile
&
os
,
const
word
&
key
,
const
labelList
&
idList
,
const
labelList
&
pointMap
const
label
U
List
&
idList
,
const
label
U
List
&
pointMap
)
const
{
writeConnectivity
...
...
src/conversion/ensight/part/ensightPartFaces.H
View file @
0be6ba87
...
...
@@ -63,8 +63,8 @@ class ensightPartFaces
(
ensightGeoFile
&
,
const
word
&
key
,
const
labelList
&
idList
,
const
labelList
&
pointMap
const
label
U
List
&
idList
,
const
label
U
List
&
pointMap
)
const
;
...
...
@@ -104,8 +104,8 @@ protected:
ensightGeoFile
&
,
const
word
&
key
,
const
faceList
&
,
const
labelList
&
idList
,
const
labelList
&
pointMap
const
label
U
List
&
idList
,
const
label
U
List
&
pointMap
)
const
;
...
...
src/conversion/ensight/part/ensightPartIO.C
View file @
0be6ba87
...
...
@@ -59,22 +59,43 @@ void Foam::ensightPart::writeFieldList
const
labelUList
&
idList
)
const
{
forAll
(
idList
,
i
)
if
(
&
idList
)
{
if
(
idList
[
i
]
>=
field
.
size
()
||
isnan
(
field
[
idList
[
i
]])
)
forAll
(
idList
,
i
)
{
os
.
writeUndef
();
if
(
idList
[
i
]
>=
field
.
size
()
||
isnan
(
field
[
idList
[
i
]]))
{
os
.
writeUndef
();
}
else
{
os
.
write
(
field
[
idList
[
i
]]);
}
os
.
newline
();
}
else
}
else
{
// no idList => perNode
forAll
(
field
,
i
)
{
os
.
write
(
field
[
idList
[
i
]]);
}
if
(
isnan
(
field
[
i
]))
{
os
.
writeUndef
();
}
else
{
os
.
write
(
field
[
i
]);
}
os
.
newline
();
os
.
newline
();
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void
Foam
::
ensightPart
::
reconstruct
(
Istream
&
is
)
...
...
@@ -153,7 +174,7 @@ void Foam::ensightPart::writeGeometry
if
(
size
())
{
const
localPoints
ptList
=
calcLocalPoints
();
const
labelList
&
pointMap
=
ptList
.
list
;
const
label
U
List
&
pointMap
=
ptList
.
list
;
writeHeader
(
os
,
true
);
...
...
@@ -195,21 +216,30 @@ void Foam::ensightPart::writeGeometry
void
Foam
::
ensightPart
::
writeScalarField
(
ensightFile
&
os
,
const
List
<
scalar
>&
field
const
List
<
scalar
>&
field
,
const
bool
perNode
)
const
{
if
(
size
()
&&
field
.
size
()
&&
(
os
.
allowUndef
()
||
isFieldDefined
(
field
)))
{
writeHeader
(
os
);
forAll
(
elementTypes
(),
elemI
)
if
(
perNode
)
{
const
labelList
&
idList
=
elemLists_
[
elemI
];
if
(
idList
.
size
())
os
.
writeKeyword
(
"coordinates"
);
writeFieldList
(
os
,
field
,
labelUList
::
null
());
}
else
{
forAll
(
elementTypes
(),
elemI
)
{
os
.
writeKeyword
(
elementTypes
()[
elemI
]);
writeFieldList
(
os
,
field
,
idList
);
const
labelUList
&
idList
=
elemLists_
[
elemI
];
if
(
idList
.
size
())
{
os
.
writeKeyword
(
elementTypes
()[
elemI
]);
writeFieldList
(
os
,
field
,
idList
);
}
}
}
}
...
...
@@ -221,23 +251,34 @@ void Foam::ensightPart::writeVectorField
ensightFile
&
os
,
const
List
<
scalar
>&
field0
,
const
List
<
scalar
>&
field1
,
const
List
<
scalar
>&
field2
const
List
<
scalar
>&
field2
,
const
bool
perNode
)
const
{
if
(
size
()
&&
field0
.
size
()
&&
(
os
.
allowUndef
()
||
isFieldDefined
(
field0
)))
{
writeHeader
(
os
);
forAll
(
elementTypes
(),
elemI
)
if
(
perNode
)
{
const
labelList
&
idList
=
elemLists_
[
elemI
];
if
(
idList
.
size
())
os
.
writeKeyword
(
"coordinates"
);
writeFieldList
(
os
,
field0
,
labelUList
::
null
());
writeFieldList
(
os
,
field1
,
labelUList
::
null
());
writeFieldList
(
os
,
field2
,
labelUList
::
null
());
}
else
{
forAll
(
elementTypes
(),
elemI
)
{
os
.
writeKeyword
(
elementTypes
()[
elemI
]);
writeFieldList
(
os
,
field0
,
idList
);
writeFieldList
(
os
,
field1
,
idList
);
writeFieldList
(
os
,
field2
,
idList
);
const
labelUList
&
idList
=
elemLists_
[
elemI
];
if
(
idList
.
size
())
{
os
.
writeKeyword
(
elementTypes
()[
elemI
]);
writeFieldList
(
os
,
field0
,
idList
);
writeFieldList
(
os
,
field1
,
idList
);
writeFieldList
(
os
,
field2
,
idList
);
}
}
}
}
...
...
src/conversion/ensight/part/ensightPartTemplates.C
View file @
0be6ba87
...
...
@@ -34,29 +34,46 @@ template<class Type>
void
Foam
::
ensightPart
::
writeField
(
ensightFile
&
os
,
const
Field
<
Type
>&
field
const
Field
<
Type
>&
field
,
const
bool
perNode
)
const
{
if
(
this
->
size
()
&&
field
.
size
())
{
writeHeader
(
os
);
forAll
(
elementTypes
(),
elemI
)
if
(
perNode
)
{
const
labelList
&
idList
=
elemLists_
[
elemI
];
if
(
idList
.
size
())
os
.
writeKeyword
(
"coordinates"
);
for
(
direction
cmpt
=
0
;
cmpt
<
pTraits
<
Type
>::
nComponents
;
++
cmpt
)
{
writeFieldList
(
os
,
field
.
component
(
cmpt
),
labelUList
::
null
());
}
}
else
{
forAll
(
elementTypes
(),
elemI
)
{
os
.
writeKeyword
(
elementTypes
()
[
elemI
]
)
;
const
labelUList
&
idList
=
elemLists_
[
elemI
];
for
(
direction
cmpt
=
0
;
cmpt
<
pTraits
<
Type
>::
nComponents
;
++
cmpt
)
if
(
idList
.
size
())
{
writeFieldList
(
os
,
field
.
component
(
cmpt
),
idList
);
os
.
writeKeyword
(
elementTypes
()[
elemI
]);
for
(
direction
cmpt
=
0
;
cmpt
<
pTraits
<
Type
>::
nComponents
;
++
cmpt
)
{
writeFieldList
(
os
,
field
.
component
(
cmpt
),
idList
);
}
}
}
}
...
...
src/conversion/ensight/part/ensightParts.C
View file @
0be6ba87
...
...
@@ -107,7 +107,7 @@ void Foam::ensightParts::recalculate(const polyMesh& mesh)
forAll
(
mesh
.
cellZones
(),
zoneI
)
{
const
labelList
&
idList
=
mesh
.
cellZones
()[
zoneI
];
const
label
U
List
&
idList
=
mesh
.
cellZones
()[
zoneI
];
forAll
(
idList
,
i
)
{
...
...
@@ -162,8 +162,8 @@ void Foam::ensightParts::recalculate(const polyMesh& mesh)
void
Foam
::
ensightParts
::
renumber
(
const
labelList
&
origCellId
,
const
labelList
&
origFaceId
const
label
U
List
&
origCellId
,
const
label
U
List
&
origFaceId
)
{
forAll
(
partsList_
,
partI
)
...
...
@@ -228,7 +228,8 @@ void Foam::ensightParts::writeScalarField
(
ensightFile
&
os
,
const
List
<
scalar
>&
field
,
bool
useFaceData
const
bool
useFaceData
,
const
bool
perNode
)
const
{
forAll
(
partsList_
,
partI
)
...
...
@@ -240,7 +241,7 @@ void Foam::ensightParts::writeScalarField
:
partsList_
[
partI
].
isCellData
()
)
{
partsList_
[
partI
].
writeScalarField
(
os
,
field
);
partsList_
[
partI
].
writeScalarField
(
os
,
field
,
perNode
);
}
}
}
...
...
@@ -252,7 +253,8 @@ void Foam::ensightParts::writeVectorField
const
List
<
scalar
>&
field0
,
const
List
<
scalar
>&
field1
,
const
List
<
scalar
>&
field2
,
bool
useFaceData
const
bool
useFaceData
,
const
bool
perNode
)
const
{
forAll
(
partsList_
,
partI
)
...
...
@@ -264,7 +266,12 @@ void Foam::ensightParts::writeVectorField
:
partsList_
[
partI
].
isCellData
()
)
{
partsList_
[
partI
].
writeVectorField
(
os
,
field0
,
field1
,
field2
);
partsList_
[
partI
].
writeVectorField
(
os
,
field0
,
field1
,
field2
,
perNode
);
}
}
}
...
...
src/conversion/ensight/part/ensightParts.H
View file @
0be6ba87
...
...
@@ -89,8 +89,8 @@ public:
//- renumber elements
void
renumber
(
const
labelList
&
origCellId
,
const
labelList
&
origFaceId
const
label
U
List
&
origCellId
,
const
label
U
List
&
origFaceId
);
//- number of parts
...
...
@@ -108,26 +108,32 @@ public:
//- write the lists
void
writeData
(
Ostream
&
)
const
;
//- write scalar field
//- write (volume) scalar field
// optionally write data for face parts
// optionally write data per node
void
writeScalarField
(
ensightFile
&
,
const
List
<
scalar
>&
field
,
bool
useFaceData
=
false
const
bool
useFaceData
=
false
,
const
bool
perNode
=
false
)
const
;
//- write vector field components
//- write (volume) vector field components
// optionally write data for face parts
// optionally write data per node
void
writeVectorField
(
ensightFile
&
,
const
List
<
scalar
>&
field0
,
const
List
<
scalar
>&
field1
,
const
List
<
scalar
>&
field2
,
bool
useFaceData
=
false
const
bool
useFaceData
=
false
,
const
bool
perNode
=
false
)
const
;
//- write generalized field components
//- write generalized
volume
field components
template
<
class
Type
>
void
writeField
(
...
...
src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C
View file @
0be6ba87
...
...
@@ -221,10 +221,10 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
dict
.
lookup
(
"interpolationScheme"
)
>>
interpolationScheme_
;
word
write
Format
(
dict
.
lookup
(
"surfaceFormat"
));
word
write
Type
(
dict
.
lookup
(
"surfaceFormat"
));
// define the surface formatter
formatter_
=
surfaceWriter
::
New
(
write
Format
);
formatter_
=
surfaceWriter
::
New
(
write
Type
);
PtrList
<
sampledSurface
>
newList
(
...
...
src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C
View file @
0be6ba87
...
...
@@ -42,44 +42,6 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //