-
Notifications
You must be signed in to change notification settings - Fork 0
/
Output.h
66 lines (51 loc) · 1.67 KB
/
Output.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Output.h
*
* Created on: Dec 22, 2014
* Author: viktor
*/
#ifndef OUTPUT_H_
#define OUTPUT_H_
#include <deal.II/numerics/data_out.h>
//#include "DiscretizationData.h"
#include "DataTypes.h"
#include <string>
using namespace MonteCarlo;
using namespace dealii;
template<int dim>
class Output
{
public:
Output() {};
virtual ~Output() {};
void print( const solution_type<dim> &solution , const std::string filename );
void print_exact_function( const int level, Function<dim> &function_to_plot, const std::string filename );
};
template<int dim>
void Output<dim>::print( const solution_type<dim> &solution, const std::string filename )
{
DataOut<dim> data_out;
data_out.attach_dof_handler ( *(DiscretizationData<dim>::dof_handlers_ptr[solution.level]) );
data_out.add_data_vector ( solution.vector, "solution" );
data_out.build_patches ();
//
// std::ofstream output (filename+".gpl");
// data_out.write_gnuplot (output);
std::ofstream output (filename+".vtk");
data_out.write_vtk (output);
}
template<int dim>
void Output<dim>::print_exact_function( const int level, Function<dim> &function_to_plot, const std::string filename )
{
solution_type<dim> function(level);
VectorTools::interpolate ( *(DiscretizationData<dim>::dof_handlers_ptr[level]), function_to_plot, function.vector );
DataOut<dim> data_out;
data_out.attach_dof_handler ( *(DiscretizationData<dim>::dof_handlers_ptr[level]) );
data_out.add_data_vector ( function.vector, "function" );
data_out.build_patches ();
// std::ofstream output (filename+".gpl");
// data_out.write_gnuplot (output);
std::ofstream output (filename+".vtk");
data_out.write_vtk (output);
}
#endif /* OUTPUT_H_ */