This source file includes following definitions.
- write
- prefix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #include <sstream>
17 #include <config.h>
18 #include <dune/fem/io/file/dataoutput.hh>
19 #include "io_paraview.h"
20 #include "io_parameter.h"
21 #include "grid.h"
22
23 using namespace std;
24
25 using Grid = Esfem::Grid::Grid_and_time::Grid;
26 using FEfun = Esfem::Grid::Scal_FEfun::Dune_FEfun;
27 using Dune_tuple = Dune::tuple<FEfun*, FEfun*>;
28 using DataOutput = Dune::Fem::DataOutput<Grid, Dune_tuple>;
29
30 class DataOutputParameters
31 : public Dune::Fem::LocalParameter<Dune::Fem::DataOutputParameters,
32 DataOutputParameters> {
33 public:
34 explicit DataOutputParameters(const Esfem::Io::Parameter&, const int = 0);
35 DataOutputParameters(const DataOutputParameters&);
36 std::string prefix() const;
37 private:
38 std::string filename;
39 int step;
40 };
41
42
43
44
45 struct Esfem::Io::Paraview::Data{
46 const Dune::Fem::TimeProviderBase& tp;
47 Dune_tuple tuple;
48 DataOutputParameters dop;
49 DataOutput plotter;
50 Data(const Parameter& p, const Grid::Grid_and_time& gt,
51 Grid::Scal_FEfun& fef1, Grid::Scal_FEfun& fef2,
52 const int refinement_label)
53 : tp {gt.time_provider()},
54 tuple {&static_cast<FEfun&>(fef1), &static_cast<FEfun&>(fef2)},
55 dop {p, refinement_label}, plotter {gt.grid(), tuple, dop}
56 {}
57 };
58
59 Esfem::Io::Paraview::Paraview(const Parameter& p , const Grid::Grid_and_time& gt,
60 Grid::Scal_FEfun& fef1, Grid::Scal_FEfun& fef2,
61 const int refinement_label)
62 try : d_ptr {make_unique<Data>(p, gt, fef1, fef2, refinement_label)}
63 {}
64 catch(const std::exception&){
65 std::throw_with_nested(std::logic_error
66 {"Error in constructor of Paraview."});
67 }
68 catch(...){
69 throw std::logic_error{"Unkown error in constructor of Paraview."};
70 }
71 Esfem::Io::Paraview::~Paraview() = default;
72
73
74
75
76
77
78
79 void Esfem::Io::Paraview::write(){
80 d_ptr -> plotter.write( d_ptr -> tp);
81 }
82
83
84
85 DataOutputParameters::DataOutputParameters(const Esfem::Io::Parameter& p, const int i)
86 : filename {p.paraview()}, step {i}
87 {}
88 DataOutputParameters::DataOutputParameters(const DataOutputParameters& other)
89 : step {other.step}
90 {}
91 inline std::string DataOutputParameters::prefix() const {
92 std::ostringstream s;
93 s << filename << step << "-";
94 return s.str();
95 }
96
97
98