Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
amdis-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
amdis
amdis-core
Commits
62155381
Commit
62155381
authored
5 years ago
by
Praetorius, Simon
Browse files
Options
Downloads
Patches
Plain Diff
added vtksequencewriter
parent
be2c0161
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!71
write only rank 0 in parallel
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/amdis/CMakeLists.txt
+1
-0
1 addition, 0 deletions
src/amdis/CMakeLists.txt
src/amdis/io/CMakeLists.txt
+3
-0
3 additions, 0 deletions
src/amdis/io/CMakeLists.txt
src/amdis/io/VtkSequenceWriter.hpp
+137
-0
137 additions, 0 deletions
src/amdis/io/VtkSequenceWriter.hpp
with
141 additions
and
0 deletions
src/amdis/CMakeLists.txt
+
1
−
0
View file @
62155381
...
...
@@ -71,6 +71,7 @@ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis)
add_subdirectory
(
"common"
)
add_subdirectory
(
"functions"
)
add_subdirectory
(
"gridfunctions"
)
add_subdirectory
(
"io"
)
add_subdirectory
(
"linearalgebra"
)
add_subdirectory
(
"localoperators"
)
add_subdirectory
(
"operations"
)
...
...
This diff is collapsed.
Click to expand it.
src/amdis/io/CMakeLists.txt
0 → 100644
+
3
−
0
View file @
62155381
install
(
FILES
VtkSequenceWriter.hpp
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/amdis/io
)
This diff is collapsed.
Click to expand it.
src/amdis/io/VtkSequenceWriter.hpp
0 → 100644
+
137
−
0
View file @
62155381
#pragma once
#include
<vector>
#include
<iostream>
#include
<sstream>
#include
<fstream>
#include
<iomanip>
#include
<memory>
#include
<dune/grid/io/file/vtk/common.hh>
#include
<dune/common/path.hh>
#include
<dune/grid/io/file/vtk/vtkwriter.hh>
namespace
AMDiS
{
/// \brief class to write pvd-files which contains a list of all collected vtk-files
/**
* Write pvd-file suitable for easy visualization with
* <a href="http://www.vtk.org/">The Visualization Toolkit (VTK)</a>.
*
* \tparam GridView Grid view of the grid we are writing
*/
template
<
class
GridView
>
class
VTKSequenceWriter
{
using
VTKWriter
=
Dune
::
VTKWriter
<
GridView
>
;
public:
/// \brief Set up the VTKSequenceWriter class
/**
* \param vtkWriter Writer object used to write the individual time step data files
*/
VTKSequenceWriter
(
std
::
shared_ptr
<
VTKWriter
>
vtkWriter
)
:
vtkWriter_
(
std
::
move
(
vtkWriter
))
{}
/// \brief Set up the VTKSequenceWriter class by creating a timestep writer of type \ref VTKWriter
/**
* \param gridView GridView object passed to the constructor of the VTKWriter
* \param args... Additional arguments forwarded to the VTKWriter constructor.
*/
template
<
class
...
Args
>
VTKSequenceWriter
(
GridView
const
&
gridView
,
Args
&&
...
args
)
:
VTKSequenceWriter
<
GridView
>
(
std
::
make_shared
<
VTKWriter
>
(
gridView
,
FWD
(
args
)...))
{}
/// accessor for the underlying VTKWriter instance
std
::
shared_ptr
<
VTKWriter
>
const
&
vtkWriter
()
const
{
return
vtkWriter_
;
}
/// \brief Adds a field of cell data to the VTK file
template
<
class
...
Args
>
void
addCellData
(
Args
&&
...
args
)
{
vtkWriter_
->
addCellData
(
FWD
(
args
)...);
}
/// \brief Adds a field of vertex data to the VTK file
template
<
class
...
Args
>
void
addVertexData
(
Args
&&
...
args
)
{
vtkWriter_
->
addVertexData
(
FWD
(
args
)...);
}
/// \brief Writes VTK data for the given time,
/**
* \param time The time(step) for the data to be written.
* \param name The basename of the .pvd file (without file extension)
* \param type VTK output type.
*/
virtual
void
write
(
double
time
,
std
::
string
const
&
name
,
Dune
::
VTK
::
OutputType
type
=
Dune
::
VTK
::
ascii
)
{
pwrite
(
time
,
name
,
"."
,
""
,
type
);
}
/// \brief Writes VTK data for the given time,
/**
* \param time The time(step) for the data to be written.
* \param name The basename of the .pvd file (without file extension)
* \param path The directory where to put the .pvd file
* \param extendpath The (relative) subdirectory to path, where to put the timestep files
* \param type VTK output type.
*/
virtual
void
pwrite
(
double
time
,
std
::
string
const
&
name
,
std
::
string
const
&
path
,
std
::
string
const
&
extendpath
,
Dune
::
VTK
::
OutputType
type
=
Dune
::
VTK
::
ascii
)
{
// remember current time step
unsigned
int
count
=
timesteps_
.
size
();
timesteps_
.
push_back
(
time
);
// write VTK file
vtkWriter_
->
pwrite
(
seqName
(
name
,
count
),
concatPaths
(
path
,
extendpath
),
""
,
type
);
// write pvd file ... only on rank 0
if
(
Environment
::
mpiRank
()
==
0
)
{
std
::
ofstream
pvdFile
;
pvdFile
.
exceptions
(
std
::
ios_base
::
badbit
|
std
::
ios_base
::
failbit
|
std
::
ios_base
::
eofbit
);
std
::
string
pvdname
=
path
+
"/"
+
name
+
".pvd"
;
pvdFile
.
open
(
pvdname
.
c_str
());
pvdFile
<<
"<?xml version=
\"
1.0
\"
?>
\n
"
<<
"<VTKFile type=
\"
Collection
\"
version=
\"
0.1
\"
byte_order=
\"
"
<<
VTK
::
getEndiannessString
()
<<
"
\"
>
\n
"
<<
"<Collection>
\n
"
;
for
(
unsigned
int
i
=
0
;
i
<=
count
;
++
i
)
{
std
::
string
piecepath
=
concatPaths
(
path
,
extendpath
);
std
::
string
fullname
=
vtkWriter_
->
getParallelHeaderName
(
seqName
(
name
,
i
),
piecepath
,
Environment
::
mpiSize
());
pvdFile
<<
"<DataSet timestep=
\"
"
<<
timesteps_
[
i
]
<<
"
\"
group=
\"\"
part=
\"
0
\"
name=
\"\"
file=
\"
"
<<
fullname
<<
"
\"
/>
\n
"
;
}
pvdFile
<<
"</Collection>
\n
"
<<
"</VTKFile>
\n
"
<<
std
::
flush
;
pvdFile
.
close
();
}
}
private
:
// create sequence name
std
::
string
seqName
(
std
::
string
const
&
name
,
unsigned
int
count
)
const
{
std
::
stringstream
n
;
n
.
fill
(
'0'
);
n
<<
name
<<
"-"
<<
std
::
setw
(
5
)
<<
count
;
return
n
.
str
();
}
private
:
std
::
shared_ptr
<
VTKWriter
>
vtkWriter_
;
std
::
vector
<
double
>
timesteps_
;
};
}
// end namespace AMDiS
This diff is collapsed.
Click to expand it.
Praetorius, Simon
@spraetor
mentioned in commit
c69738e4
·
5 years ago
mentioned in commit
c69738e4
mentioned in commit c69738e46ade224601426b472e7002f9d61e77e0
Toggle commit list
Praetorius, Simon
@spraetor
mentioned in commit
ee995fd5
·
5 years ago
mentioned in commit
ee995fd5
mentioned in commit ee995fd5355e77f1c7b9bafe218fe3cfbdf30006
Toggle commit list
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment