1 #include <deal.II/grid/tria.h>
2 #include <deal.II/lac/vector.h>
3 #include <deal.II/dofs/dof_handler.h>
4 #include <deal.II/fe/fe_q.h>
9 #include <boost/archive/binary_iarchive.hpp>
10 #include <boost/archive/binary_oarchive.hpp>
12 namespace FEFieldTools
14 using namespace dealii;
18 Triangulation<dim> &field_tria,
19 DoFHandler<dim> &field_dof_handler,
20 Vector<double> &field_solution)
23 std::string file_path =
"field_solution";
24 std::ofstream file_stream(file_path, std::ios::binary);
25 if (!file_stream.good())
27 throw std::runtime_error(
"Error while opening the file: " + file_path);
29 boost::archive::binary_oarchive archive(file_stream);
30 archive << field_solution;
33 std::string file_path =
"field_dof_handler";
34 std::ofstream file_stream(file_path, std::ios::binary);
35 if (!file_stream.good())
37 throw std::runtime_error(
"Error while opening the file: " + file_path);
39 boost::archive::binary_oarchive archive(file_stream);
40 archive << field_dof_handler;
43 std::string file_path =
"field_triangulation";
44 std::ofstream file_stream(file_path, std::ios::binary);
45 if (!file_stream.good())
47 throw std::runtime_error(
"Error while opening the file: " + file_path);
49 boost::archive::binary_oarchive archive(file_stream);
50 archive << field_tria;
56 Triangulation<dim> &field_tria,
57 DoFHandler<dim> &field_dof_handler,
58 Vector<double> &field_solution,
62 std::string file_path =
"field_triangulation";
63 std::ifstream file_stream(file_path, std::ios::binary);
64 if (!file_stream.good())
66 throw std::runtime_error(
"Error while opening the file: " + file_path);
68 boost::archive::binary_iarchive archive(file_stream);
69 archive >> field_tria;
71 field_dof_handler.distribute_dofs(fe);
73 std::string file_path =
"field_dof_handler";
74 std::ifstream file_stream(file_path, std::ios::binary);
75 if (!file_stream.good())
77 throw std::runtime_error(
"Error while opening the file: " + file_path);
79 boost::archive::binary_iarchive archive(file_stream);
80 archive >> field_dof_handler;
83 std::string file_path =
"field_solution";
84 std::ifstream file_stream(file_path, std::ios::binary);
85 if (!file_stream.good())
87 throw std::runtime_error(
"Error while opening the file: " + file_path);
89 boost::archive::binary_iarchive archive(file_stream);
90 archive >> field_solution;
96 Triangulation<dim> &field_tria,
97 DoFHandler<dim> &field_dof_handler,
98 Vector<double> &field_solution,
99 FESystem<dim,dim> &fe)
102 std::string file_path =
"field_triangulation";
103 std::ifstream file_stream(file_path, std::ios::binary);
104 if (!file_stream.good())
106 throw std::runtime_error(
"Error while opening the file: " + file_path);
108 boost::archive::binary_iarchive archive(file_stream);
109 archive >> field_tria;
111 field_dof_handler.distribute_dofs(fe);
113 std::string file_path =
"field_dof_handler";
114 std::ifstream file_stream(file_path, std::ios::binary);
115 if (!file_stream.good())
117 throw std::runtime_error(
"Error while opening the file: " + file_path);
119 boost::archive::binary_iarchive archive(file_stream);
120 archive >> field_dof_handler;
123 std::string file_path =
"field_solution";
124 std::ifstream file_stream(file_path, std::ios::binary);
125 if (!file_stream.good())
127 throw std::runtime_error(
"Error while opening the file: " + file_path);
129 boost::archive::binary_iarchive archive(file_stream);
130 archive >> field_solution;