VertexCFD  0.0-dev
VertexCFD_Mesh_Restart.hpp
1 #ifndef VERTEXCFD_MESH_RESTART_HPP
2 #define VERTEXCFD_MESH_RESTART_HPP
3 
4 #include <Panzer_GlobalIndexer.hpp>
5 #include <Panzer_STK_Interface.hpp>
6 
7 #include <Thyra_VectorBase.hpp>
8 
9 #include <Teuchos_Comm.hpp>
10 #include <Teuchos_ParameterList.hpp>
11 #include <Teuchos_RCP.hpp>
12 
13 #include <cstdint>
14 #include <string>
15 #include <vector>
16 
17 namespace VertexCFD
18 {
19 namespace Mesh
20 {
21 //---------------------------------------------------------------------------//
22 class Restart
23 {
24  public:
25  ~Restart() = default;
26 
27  MPI_Datatype
28  setupDofMapData(const Teuchos::RCP<const panzer_stk::STK_Interface>& mesh,
29  const Teuchos::RCP<const panzer::GlobalIndexer>& dof_manager,
30  int& dofmap_offset,
31  int& local_num_own_elem,
32  std::vector<int>& owned_element_lids);
33 };
34 
35 //---------------------------------------------------------------------------//
36 class RestartWriter : public Restart
37 {
38  public:
39  // NOTE: allow_dofmap_overwrite is false by default and should be provided
40  // only in unit tests.
41  RestartWriter(const Teuchos::RCP<const panzer_stk::STK_Interface>& mesh,
42  const Teuchos::RCP<const panzer::GlobalIndexer>& dof_manager,
43  const Teuchos::ParameterList& output_params,
44  const bool allow_dofmap_overwrite = false);
45 
46  ~RestartWriter();
47 
48  void
49  writeSolution(const Teuchos::RCP<const Thyra::VectorBase<double>>& x,
50  const Teuchos::RCP<const Thyra::VectorBase<double>>& x_dot,
51  const int index,
52  const double time = 0.0);
53 
54  private:
55  Teuchos::RCP<const panzer::GlobalIndexer> _dof_manager;
56  std::string _file_prefix;
57  std::vector<int> _displacements;
58  std::unordered_map<panzer::GlobalOrdinal, int> _global_to_local;
59  MPI_Datatype _dof_type;
60 };
61 
62 //---------------------------------------------------------------------------//
63 class RestartReader : public Restart
64 {
65  public:
66  RestartReader(const Teuchos::RCP<const Teuchos::Comm<int>>& comm,
67  const Teuchos::ParameterList& input_params);
68 
69  void
70  readSolution(const Teuchos::RCP<const panzer_stk::STK_Interface>& mesh,
71  const Teuchos::RCP<const panzer::GlobalIndexer>& dof_manager,
72  const Teuchos::RCP<Thyra::VectorBase<double>>& x,
73  const Teuchos::RCP<Thyra::VectorBase<double>>& x_dot);
74 
75  double initialStateTime() const { return _t_init; }
76 
77  private:
78  std::string _restart_file_name;
79  std::string _dofmap_file_name;
80  double _t_init;
81 
82  void update_vector(const Teuchos::RCP<Thyra::VectorBase<double>>& vec,
83  const std::vector<double>& data) const;
84 };
85 
86 //---------------------------------------------------------------------------//
87 
88 } // end namespace Mesh
89 } // end namespace VertexCFD
90 
91 #endif // end VERTEXCFD_MESH_RESTART_HPP
VertexCFD
Definition: tstMethodManufacturedSolutionBC.cpp:23
VertexCFD::Mesh::Restart
Definition: VertexCFD_Mesh_Restart.hpp:23
VertexCFD::Mesh::RestartWriter
Definition: VertexCFD_Mesh_Restart.hpp:37
VertexCFD::Mesh::RestartReader
Definition: VertexCFD_Mesh_Restart.hpp:64