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
c5518dd9
Commit
c5518dd9
authored
Jun 15, 2018
by
Mark OLESEN
Browse files
ENH: additional vtk tools for faceNormals, writing file-series
parent
0ec8e3e7
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/conversion/vtk/adaptor/foamVtkTools.H
View file @
c5518dd9
...
...
@@ -197,6 +197,10 @@ public:
//- Convert patch points/faces to vtkPolyData
template
<
class
PatchType
>
static
vtkSmartPointer
<
vtkPolyData
>
mesh
(
const
PatchType
&
p
);
//- Convert patch face normals to vtkFloatArray
template
<
class
PatchType
>
static
vtkSmartPointer
<
vtkFloatArray
>
faceNormals
(
const
PatchType
&
p
);
};
...
...
src/conversion/vtk/adaptor/foamVtkToolsTemplates.C
View file @
c5518dd9
...
...
@@ -109,6 +109,32 @@ Foam::vtk::Tools::Patch::mesh(const PatchType& p)
}
template
<
class
PatchType
>
vtkSmartPointer
<
vtkFloatArray
>
Foam
::
vtk
::
Tools
::
Patch
::
faceNormals
(
const
PatchType
&
p
)
{
auto
array
=
vtkSmartPointer
<
vtkFloatArray
>::
New
();
array
->
SetNumberOfComponents
(
3
);
array
->
SetNumberOfTuples
(
p
.
size
());
// Unit normals for patch faces.
// If not already cached, could be more memory efficient to loop over
// the individual faces instead.
const
vectorField
&
norms
=
p
.
faceNormals
();
vtkIdType
faceId
=
0
;
for
(
const
vector
&
n
:
norms
)
{
array
->
SetTuple
(
faceId
,
n
.
v_
);
++
faceId
;
}
return
array
;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//
// Low-Level conversions
...
...
src/fileFormats/vtk/core/foamVtkCore.C
View file @
c5518dd9
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017
-2018
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -46,6 +46,7 @@ Foam::vtk::fileTagNames
{
fileTag
::
POINT_DATA
,
"PointData"
},
{
fileTag
::
POLY_DATA
,
"PolyData"
},
{
fileTag
::
UNSTRUCTURED_GRID
,
"UnstructuredGrid"
},
{
fileTag
::
MULTI_BLOCK
,
"vtkMultiBlockDataSet"
},
};
...
...
src/fileFormats/vtk/core/foamVtkCore.H
View file @
c5518dd9
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-201
8
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -115,6 +115,7 @@ namespace vtk
POINT_DATA
,
//!< "PointData"
POLY_DATA
,
//!< "PolyData"
UNSTRUCTURED_GRID
,
//!< "UnstructuredGrid"
MULTI_BLOCK
,
//!< "vtkMultiBlockDataSet"
};
//- Strings corresponding to the vtk xml tags
...
...
src/fileFormats/vtk/output/foamVtkOutput.C
View file @
c5518dd9
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-201
8
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -33,6 +33,7 @@ License
#include
"foamVtkLegacyAsciiFormatter.H"
#include
"foamVtkLegacyRawFormatter.H"
#include
"typeInfo.H"
#include
"instant.H"
// * * * * * * * * * * * * * * * Static Data * * * * * * * * * * * * * * * * //
...
...
@@ -101,19 +102,52 @@ Foam::vtk::newFormatter
}
void
Foam
::
vtk
::
writeSeries
(
Ostream
&
os
,
const
word
&
prefix
,
const
word
&
suffix
,
const
UList
<
instant
>&
series
)
{
// Begin file-series (JSON)
os
<<
"{
\n
\"
file-series-version
\"
:
\"
1.0
\"
,
\n
\"
files
\"
: [
\n
"
;
// Track how many entries are remaining
// - trailing commas on all but the final entry (JSON requirement)
label
nremain
=
series
.
size
();
// Each entry
// { "name" : "<prefix>name<suffix>", "time" : value }
for
(
const
instant
&
inst
:
series
)
{
os
<<
" {
\"
name
\"
:
\"
"
<<
prefix
<<
inst
.
name
()
<<
suffix
<<
"
\"
,
\"
time
\"
: "
<<
inst
.
value
()
<<
" }"
;
if
(
--
nremain
)
{
os
<<
','
;
}
os
<<
nl
;
}
os
<<
" ]
\n
}
\n
"
;
}
Foam
::
label
Foam
::
vtk
::
writeVtmFile
(
std
::
ostream
&
os
,
const
UList
<
fileName
>&
files
)
{
const
word
&
content
=
"vtkMultiBlockDataSet"
;
asciiFormatter
vtmFile
(
os
);
vtmFile
.
xmlHeader
()
.
beginVTKFile
(
content
,
"1.0"
);
.
beginVTKFile
(
fileTagNames
[
vtk
::
fileTag
::
MULTI_BLOCK
]
,
"1.0"
);
forAll
(
files
,
i
)
{
...
...
@@ -124,7 +158,7 @@ Foam::label Foam::vtk::writeVtmFile
.
closeTag
(
true
);
}
vtmFile
.
endTag
(
content
).
endVTKFile
();
vtmFile
.
endTag
(
fileTagNames
[
vtk
::
fileTag
::
MULTI_BLOCK
]
).
endVTKFile
();
return
files
.
size
();
}
...
...
src/fileFormats/vtk/output/foamVtkOutput.H
View file @
c5518dd9
...
...
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-201
7
OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-201
8
OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
...
...
@@ -54,6 +54,9 @@ SourceFiles
namespace
Foam
{
// Forward declarations
class
instant
;
namespace
vtk
{
...
...
@@ -73,6 +76,19 @@ namespace vtk
);
//- Write file series (JSON format) for specified time instances
//
// \param prefix before the \c instant.name()
// \param suffix after the \c instant.name()
// \param series the list of name/value entries
void
writeSeries
(
Ostream
&
os
,
const
word
&
prefix
,
const
word
&
suffix
,
const
UList
<
instant
>&
series
);
//- Write vtm datasets for specified files
label
writeVtmFile
(
std
::
ostream
&
os
,
const
UList
<
fileName
>&
files
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment