Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
dune-vtk
Commits
bd80ca32
Commit
bd80ca32
authored
Aug 31, 2018
by
Praetorius, Simon
Browse files
resolved some errors after merge of pvdwriter
parent
69a0e464
Changes
8
Hide whitespace changes
Inline
Side-by-side
dune/vtk/filewriter.hh
View file @
bd80ca32
...
...
@@ -11,7 +11,7 @@ namespace Dune
virtual
~
FileWriter
()
=
default
;
/// Write to file given by `filename`
virtual
void
write
(
std
::
string
const
&
filename
)
=
0
;
virtual
void
write
(
std
::
string
const
&
filename
)
const
=
0
;
};
}
// end namespace Dune
dune/vtk/pvdwriter.hh
View file @
bd80ca32
...
...
@@ -6,7 +6,7 @@
#include
<tuple>
#include
<dune/vtk/vtktypes.hh>
#include
<dune/vtk/vtkwriterinterface.hh>
//
#include <dune/vtk/vtkwriterinterface.hh>
namespace
Dune
{
...
...
@@ -16,26 +16,20 @@ namespace Dune
{
using
Self
=
PvdWriter
;
static_assert
(
IsVtkWriter
<
VtkWriter
>::
value
,
"Writer must implement the VtkWriterInterface."
);
//
static_assert(IsVtkWriter<VtkWriter>::value, "Writer must implement the VtkWriterInterface.");
public:
/// Constructor, creates a VtkWriter with constructor arguments forwarded
template
<
class
...
Args
,
disableCopyMove
<
Self
,
Args
...>
=
0
>
explicit
PvdWriter
(
Args
&&
...
args
)
:
vtkWriter_
{
std
::
forward
<
Args
>
(
args
)...}
{}
/// Write the attached data to the file
void
write
(
double
time
,
std
::
string
const
&
fn
)
{
write
(
time
,
fn
,
Vtk
::
BINARY
);
format_
=
vtkWriter_
.
getFormat
();
datatype_
=
vtkWriter_
.
getDatatype
();
}
/// Write the attached data to the file with \ref Vtk::FormatTypes and \ref Vtk::DataTypes
void
write
(
double
time
,
std
::
string
const
&
fn
,
Vtk
::
FormatTypes
format
,
Vtk
::
DataTypes
datatype
=
Vtk
::
FLOAT32
);
/// Write the attached data to the file
void
write
(
double
time
,
std
::
string
const
&
fn
)
const
;
/// Attach point data to the writer, \see VtkFunction for possible arguments
template
<
class
Function
,
class
...
Args
>
...
...
@@ -59,9 +53,10 @@ namespace Dune
protected:
VtkWriter
vtkWriter_
;
std
::
vector
<
std
::
pair
<
double
,
std
::
string
>>
timeSeries_
;
Vtk
::
FormatTypes
format_
;
Vtk
::
DataTypes
datatype_
;
mutable
std
::
vector
<
std
::
pair
<
double
,
std
::
string
>>
timesteps_
;
};
}
// end namespace Dune
...
...
dune/vtk/pvdwriter.impl.hh
View file @
bd80ca32
...
...
@@ -9,23 +9,15 @@ namespace Dune {
template
<
class
W
>
void
PvdWriter
<
W
>
::
write
(
double
time
,
std
::
string
const
&
fn
,
Vtk
::
FormatTypes
format
,
Vtk
::
DataTypes
datatype
)
::
write
(
double
time
,
std
::
string
const
&
fn
)
const
{
format_
=
format
;
datatype_
=
datatype
;
#ifndef HAVE_ZLIB
if
(
format_
==
Vtk
::
COMPRESSED
)
format_
=
Vtk
::
BINARY
;
#endif
auto
p
=
filesystem
::
path
(
fn
);
auto
name
=
p
.
stem
();
p
.
remove_filename
();
p
/=
name
.
string
();
std
::
string
ext
=
"."
+
vtkWriter_
.
getFileExtension
();
std
::
string
filename
=
p
.
string
()
+
"_t"
+
std
::
to_string
(
time
Serie
s_
.
size
());
std
::
string
filename
=
p
.
string
()
+
"_t"
+
std
::
to_string
(
time
step
s_
.
size
());
int
rank
=
0
;
int
num_ranks
=
1
;
...
...
@@ -36,8 +28,8 @@ void PvdWriter<W>
ext
=
".p"
+
vtkWriter_
.
getFileExtension
();
#endif
time
Serie
s_
.
emplace_back
(
time
,
filename
+
ext
);
vtkWriter_
.
write
(
filename
+
ext
,
format_
,
datatype_
);
time
step
s_
.
emplace_back
(
time
,
filename
+
ext
);
vtkWriter_
.
write
(
filename
+
ext
);
if
(
rank
==
0
)
writeFile
(
time
,
p
.
string
()
+
".pvd"
);
...
...
@@ -67,7 +59,7 @@ void PvdWriter<W>
out
<<
"<Collection>
\n
"
;
// Write all timesteps
for
(
auto
const
&
timestep
:
time
Serie
s_
)
{
for
(
auto
const
&
timestep
:
time
step
s_
)
{
out
<<
"<DataSet"
<<
" timestep=
\"
"
<<
timestep
.
first
<<
"
\"
"
<<
" part=
\"
0
\"
"
...
...
dune/vtk/vtktimeserieswriter.hh
View file @
bd80ca32
...
...
@@ -57,7 +57,7 @@ namespace Dune
/// Writes all timesteps to single timeseries file.
// NOTE: requires an aforging call to \ref writeTimestep
virtual
void
write
(
std
::
string
const
&
fn
)
override
;
virtual
void
write
(
std
::
string
const
&
fn
)
const
override
;
/// Attach point data to the writer, \see VtkFunction for possible arguments
template
<
class
Function
,
class
...
Args
>
...
...
@@ -84,8 +84,8 @@ namespace Dune
// block size of attached data
std
::
vector
<
std
::
uint64_t
>
blocks_
;
std
::
string
filenameMesh_
;
std
::
vector
<
std
::
pair
<
double
,
std
::
string
>>
timesteps_
;
mutable
std
::
string
filenameMesh_
;
mutable
std
::
vector
<
std
::
pair
<
double
,
std
::
string
>>
timesteps_
;
};
}
// end namespace Dune
...
...
dune/vtk/vtktimeserieswriter.impl.hh
View file @
bd80ca32
...
...
@@ -30,7 +30,7 @@ void VtkTimeseriesWriter<W>
auto
tmp
=
tmpDir_
;
tmp
/=
name
.
string
();
vtkWriter_
.
dataCollector_
.
update
();
vtkWriter_
.
update
();
std
::
string
filenameBase
=
tmp
.
string
();
...
...
@@ -60,7 +60,7 @@ void VtkTimeseriesWriter<W>
template
<
class
W
>
void
VtkTimeseriesWriter
<
W
>
::
write
(
std
::
string
const
&
fn
)
::
write
(
std
::
string
const
&
fn
)
const
{
assert
(
initialized_
);
assert
(
timesteps_
.
size
()
<
1000
);
// maximal number of allowed timesteps in timeseries file
...
...
@@ -96,6 +96,7 @@ void VtkTimeseriesWriter<W>
ec
=
std
::
remove
(
timestep
.
second
.
c_str
());
assert
(
ec
==
0
);
}
timesteps_
.
clear
();
}
}
// end namespace Dune
dune/vtk/vtkwriterinterface.hh
View file @
bd80ca32
...
...
@@ -5,15 +5,11 @@
#include
<string>
#include
<vector>
<<<<<<<
HEAD
#ifdef HAVE_ZLIB
#include
<zlib.h>
#endif
#include
<dune/common/std/optional.hh>
=======
>>>>>>>
feature
/
pvdwriter
#include
<dune/vtk/filewriter.hh>
#include
<dune/vtk/vtkfunction.hh>
#include
<dune/vtk/vtktypes.hh>
...
...
@@ -64,7 +60,7 @@ namespace Dune
}
/// Write the attached data to the file
virtual
void
write
(
std
::
string
const
&
fn
)
override
;
virtual
void
write
(
std
::
string
const
&
fn
)
const
override
;
/// Attach point data to the writer, \see VtkFunction for possible arguments
template
<
class
Function
,
class
...
Args
>
...
...
@@ -141,6 +137,21 @@ namespace Dune
return
fileExtension
();
}
Vtk
::
FormatTypes
getFormat
()
const
{
return
format_
;
}
Vtk
::
DataTypes
getDatatype
()
const
{
return
datatype_
;
}
void
update
()
{
dataCollector_
.
update
();
}
protected:
mutable
DataCollector
dataCollector_
;
...
...
dune/vtk/vtkwriterinterface.impl.hh
View file @
bd80ca32
...
...
@@ -19,7 +19,7 @@ namespace Dune {
template
<
class
GV
,
class
DC
>
void
VtkWriterInterface
<
GV
,
DC
>
::
write
(
std
::
string
const
&
fn
)
::
write
(
std
::
string
const
&
fn
)
const
{
dataCollector_
.
update
();
...
...
src/pvdwriter.cc
View file @
bd80ca32
...
...
@@ -18,8 +18,8 @@
#include
<dune/grid/yaspgrid.hh>
#include
<dune/vtk/writers/vtkunstructuredgridwriter.hh>
#include
<dune/vtk/pvdwriter.hh>
#include
<dune/vtk/writers/vtkunstructuredgridwriter.hh>
using
namespace
Dune
;
using
namespace
Dune
::
Functions
;
...
...
@@ -39,13 +39,12 @@ void write (std::string prefix, GridView const& gridView)
auto
p1Analytic
=
makeAnalyticGridViewFunction
([
&
c
](
auto
const
&
x
)
{
return
c
.
dot
(
x
);
},
gridView
);
using
Writer
=
VtkUnstructuredGridWriter
<
GridView
>
;
PvdWriter
<
Writer
>
pvdWriter
(
gridView
);
PvdWriter
<
Writer
>
pvdWriter
(
gridView
,
Vtk
::
ASCII
,
Vtk
::
FLOAT32
);
pvdWriter
.
addPointData
(
p1Analytic
,
"p1"
);
pvdWriter
.
addCellData
(
p1Analytic
,
"p0"
);
for
(
double
t
=
0.0
;
t
<
10.0
;
t
+=
1.0
)
{
pvdWriter
.
write
(
t
,
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
)
+
"d_ascii.vtu"
,
Vtk
::
ASCII
,
Vtk
::
FLOAT32
);
pvdWriter
.
write
(
t
,
prefix
+
"_"
+
std
::
to_string
(
GridView
::
dimension
)
+
"d_ascii.vtu"
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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