phaseflow
FEM solver for the Navier-Stokes-Boussinesq equations coupled with enthalpy-based phase change
 All Classes Namespaces Files Functions Variables Macros Pages
fe_field_tools.h
Go to the documentation of this file.
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>
5 
6 #include <iostream>
7 #include <fstream>
8 
9 #include <boost/archive/binary_iarchive.hpp>
10 #include <boost/archive/binary_oarchive.hpp>
11 
12 namespace FEFieldTools
13 {
14  using namespace dealii;
15 
16  template<int dim>
18  Triangulation<dim> &field_tria,
19  DoFHandler<dim> &field_dof_handler,
20  Vector<double> &field_solution)
21  {
22  {
23  std::string file_path = "field_solution";
24  std::ofstream file_stream(file_path, std::ios::binary);
25  if (!file_stream.good())
26  {
27  throw std::runtime_error("Error while opening the file: " + file_path);
28  }
29  boost::archive::binary_oarchive archive(file_stream);
30  archive << field_solution;
31  }
32  {
33  std::string file_path = "field_dof_handler";
34  std::ofstream file_stream(file_path, std::ios::binary);
35  if (!file_stream.good())
36  {
37  throw std::runtime_error("Error while opening the file: " + file_path);
38  }
39  boost::archive::binary_oarchive archive(file_stream);
40  archive << field_dof_handler;
41  }
42  {
43  std::string file_path = "field_triangulation";
44  std::ofstream file_stream(file_path, std::ios::binary);
45  if (!file_stream.good())
46  {
47  throw std::runtime_error("Error while opening the file: " + file_path);
48  }
49  boost::archive::binary_oarchive archive(file_stream);
50  archive << field_tria;
51  }
52  }
53 
54  template<int dim>
56  Triangulation<dim> &field_tria,
57  DoFHandler<dim> &field_dof_handler,
58  Vector<double> &field_solution,
59  FE_Q<dim> &fe)
60  {
61  {
62  std::string file_path = "field_triangulation";
63  std::ifstream file_stream(file_path, std::ios::binary);
64  if (!file_stream.good())
65  {
66  throw std::runtime_error("Error while opening the file: " + file_path);
67  }
68  boost::archive::binary_iarchive archive(file_stream);
69  archive >> field_tria;
70  }
71  field_dof_handler.distribute_dofs(fe);
72  {
73  std::string file_path = "field_dof_handler";
74  std::ifstream file_stream(file_path, std::ios::binary);
75  if (!file_stream.good())
76  {
77  throw std::runtime_error("Error while opening the file: " + file_path);
78  }
79  boost::archive::binary_iarchive archive(file_stream);
80  archive >> field_dof_handler;
81  }
82  {
83  std::string file_path = "field_solution";
84  std::ifstream file_stream(file_path, std::ios::binary);
85  if (!file_stream.good())
86  {
87  throw std::runtime_error("Error while opening the file: " + file_path);
88  }
89  boost::archive::binary_iarchive archive(file_stream);
90  archive >> field_solution;
91  }
92  }
93 
94  template<int dim>
96  Triangulation<dim> &field_tria,
97  DoFHandler<dim> &field_dof_handler,
98  Vector<double> &field_solution,
99  FESystem<dim,dim> &fe)
100  {
101  {
102  std::string file_path = "field_triangulation";
103  std::ifstream file_stream(file_path, std::ios::binary);
104  if (!file_stream.good())
105  {
106  throw std::runtime_error("Error while opening the file: " + file_path);
107  }
108  boost::archive::binary_iarchive archive(file_stream);
109  archive >> field_tria;
110  }
111  field_dof_handler.distribute_dofs(fe);
112  {
113  std::string file_path = "field_dof_handler";
114  std::ifstream file_stream(file_path, std::ios::binary);
115  if (!file_stream.good())
116  {
117  throw std::runtime_error("Error while opening the file: " + file_path);
118  }
119  boost::archive::binary_iarchive archive(file_stream);
120  archive >> field_dof_handler;
121  }
122  {
123  std::string file_path = "field_solution";
124  std::ifstream file_stream(file_path, std::ios::binary);
125  if (!file_stream.good())
126  {
127  throw std::runtime_error("Error while opening the file: " + file_path);
128  }
129  boost::archive::binary_iarchive archive(file_stream);
130  archive >> field_solution;
131  }
132  }
133 }
134 
void load_field_parts(Triangulation< dim > &field_tria, DoFHandler< dim > &field_dof_handler, Vector< double > &field_solution, FE_Q< dim > &fe)
Definition: fe_field_tools.h:55
void save_field_parts(Triangulation< dim > &field_tria, DoFHandler< dim > &field_dof_handler, Vector< double > &field_solution)
Definition: fe_field_tools.h:17