libMesh
transient_system.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 // C++ includes
21 
22 // Local includes
23 #include "libmesh/transient_system.h"
24 #include "libmesh/explicit_system.h"
25 #include "libmesh/linear_implicit_system.h"
26 #include "libmesh/nonlinear_implicit_system.h"
27 #include "libmesh/dof_map.h"
28 #include "libmesh/numeric_vector.h"
29 #include "libmesh/rb_construction.h"
30 #include "libmesh/eigen_system.h"
31 
32 // Nvidia C++ whining about destroying incomplete unique_ptr<T> Base::foo types
33 #include "libmesh/diff_solver.h"
34 #include "libmesh/nonlinear_solver.h"
35 #include "libmesh/shell_matrix.h"
36 #include "libmesh/sparse_matrix.h"
37 
38 namespace libMesh
39 {
40 
41 
42 // ------------------------------------------------------------
43 // TransientSystem implementation
44 template <class Base>
46  const std::string & name_in,
47  const unsigned int number_in) :
48 
49  Base(es, name_in, number_in),
50  old_local_solution(nullptr),
51  older_local_solution(nullptr)
52 {
53  this->add_old_vectors();
54 }
55 
56 
57 
58 template <class Base>
60 
61 
62 
63 template <class Base>
65 {
66  // clear the parent data
67  Base::clear();
68 
69  // Restore us to a "basic" state
70  this->add_old_vectors();
71 }
72 
73 
74 
75 template <class Base>
77 {
78  // re_update the parent system
79  Base::re_update ();
80 
81  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
82 
83  const dof_id_type first_local_dof = Base::get_dof_map().first_dof();
84  const dof_id_type end_local_dof = Base::get_dof_map().end_dof();
85 
86  // Check sizes
87  libmesh_assert_greater_equal (end_local_dof, first_local_dof);
88  libmesh_assert_greater_equal (older_local_solution->size(), send_list.size());
89  libmesh_assert_greater_equal (old_local_solution->size(), send_list.size());
90 
91  // Even if we don't have to do anything ourselves, localize() may
92  // use parallel_only tools
93  // if (first_local_dof == end_local_dof)
94  // return;
95 
96  // Update the old & older solutions with the send_list,
97  // which may have changed since their last update.
98  older_local_solution->localize (first_local_dof,
99  end_local_dof-1,
100  send_list);
101 
102  old_local_solution->localize (first_local_dof,
103  end_local_dof-1,
104  send_list);
105 }
106 
107 
108 
109 
110 template <class Base>
112 {
113  // Check the sizes
114  libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
115  libmesh_assert_less (global_dof_number, old_local_solution->size());
116 
117  return (*old_local_solution)(global_dof_number);
118 }
119 
120 
121 
122 template <class Base>
124 {
125  // Check the sizes
126  libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
127  libmesh_assert_less (global_dof_number, older_local_solution->size());
128 
129  return (*older_local_solution)(global_dof_number);
130 }
131 
132 
133 
134 template <class Base>
136 {
137  ParallelType type =
138 #ifdef LIBMESH_ENABLE_GHOSTED
139  GHOSTED;
140 #else
141  SERIAL;
142 #endif
143 
144  old_local_solution = &(this->add_vector("_transient_old_local_solution", true, type));
145  older_local_solution = &(this->add_vector("_transient_older_local_solution", true, type));
146 }
147 
148 // ------------------------------------------------------------
149 // TransientSystem instantiations
150 template class LIBMESH_EXPORT TransientSystem<LinearImplicitSystem>;
151 template class LIBMESH_EXPORT TransientSystem<NonlinearImplicitSystem>;
152 template class LIBMESH_EXPORT TransientSystem<ExplicitSystem>;
153 template class LIBMESH_EXPORT TransientSystem<System>;
154 template class LIBMESH_EXPORT TransientSystem<RBConstruction>;
155 #ifdef LIBMESH_HAVE_SLEPC
156 template class LIBMESH_EXPORT TransientSystem<EigenSystem>;
157 #endif
158 
159 } // namespace libMesh
This is the EquationSystems class.
Manages storage and variables for transient systems.
The libMesh namespace provides an interface to certain functionality in the library.
TransientSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
uint8_t dof_id_type
Definition: id_types.h:67
ParallelType
Defines an enum for parallel data structure types.