libMesh
transient_system.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 namespace libMesh
33 {
34 
35 
36 // ------------------------------------------------------------
37 // TransientSystem implementation
38 template <class Base>
40  const std::string & name_in,
41  const unsigned int number_in) :
42 
43  Base (es, name_in, number_in)
44 {
45  this->add_old_vectors();
46 }
47 
48 
49 
50 template <class Base>
52 {
53  this->clear();
54 
55  // We still have UniquePtrs for API compatibility, but
56  // now that we're System::add_vector()ing these, we can trust
57  // the base class to handle memory management
58  old_local_solution.release();
59  older_local_solution.release();
60 }
61 
62 
63 
64 template <class Base>
66 {
67  // clear the parent data
68  Base::clear();
69 
70  // the old & older local solutions
71  // are now deleted by System!
72  // old_local_solution->clear();
73  // older_local_solution->clear();
74 
75  // FIXME: This preserves maximum backwards compatibility,
76  // but is probably grossly unnecessary:
77  old_local_solution.release();
78  older_local_solution.release();
79 
80  // Restore us to a "basic" state
81  this->add_old_vectors();
82 }
83 
84 
85 
86 template <class Base>
88 {
89  // initialize parent data
90  Base::reinit();
91 
92  // Project the old & older vectors to the new mesh
93  // The System::reinit handles this now
94  // this->project_vector (*old_local_solution);
95  // this->project_vector (*older_local_solution);
96 }
97 
98 
99 
100 template <class Base>
102 {
103  // re_update the parent system
104  Base::re_update ();
105 
106  const std::vector<dof_id_type> & send_list = this->get_dof_map().get_send_list ();
107 
108  const dof_id_type first_local_dof = Base::get_dof_map().first_dof();
109  const dof_id_type end_local_dof = Base::get_dof_map().end_dof();
110 
111  // Check sizes
112  libmesh_assert_greater_equal (end_local_dof, first_local_dof);
113  libmesh_assert_greater_equal (older_local_solution->size(), send_list.size());
114  libmesh_assert_greater_equal (old_local_solution->size(), send_list.size());
115 
116  // Even if we don't have to do anything ourselves, localize() may
117  // use parallel_only tools
118  // if (first_local_dof == end_local_dof)
119  // return;
120 
121  // Update the old & older solutions with the send_list,
122  // which may have changed since their last update.
123  older_local_solution->localize (first_local_dof,
124  end_local_dof-1,
125  send_list);
126 
127  old_local_solution->localize (first_local_dof,
128  end_local_dof-1,
129  send_list);
130 }
131 
132 
133 
134 
135 template <class Base>
137 {
138  // Check the sizes
139  libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
140  libmesh_assert_less (global_dof_number, old_local_solution->size());
141 
142  return (*old_local_solution)(global_dof_number);
143 }
144 
145 
146 
147 template <class Base>
149 {
150  // Check the sizes
151  libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
152  libmesh_assert_less (global_dof_number, older_local_solution->size());
153 
154  return (*older_local_solution)(global_dof_number);
155 }
156 
157 
158 
159 template <class Base>
161 {
162 #ifdef LIBMESH_ENABLE_GHOSTED
165  (&(this->add_vector("_transient_old_local_solution", true, GHOSTED)));
168  (&(this->add_vector("_transient_older_local_solution", true, GHOSTED)));
169 #else
172  (&(this->add_vector("_transient_old_local_solution", true, SERIAL)));
175  (&(this->add_vector("_transient_older_local_solution", true, SERIAL)));
176 #endif
177 }
178 
179 // ------------------------------------------------------------
180 // TransientSystem instantiations
183 template class TransientSystem<ExplicitSystem>;
184 template class TransientSystem<System>;
185 template class TransientSystem<RBConstruction>;
186 #ifdef LIBMESH_HAVE_SLEPC
187 template class TransientSystem<EigenSystem>;
188 #endif
189 
190 } // namespace libMesh
This is the EquationSystems class.
Number older_solution(const dof_id_type global_dof_number) const
UniquePtr< NumericVector< Number > > old_local_solution
All the values I need to compute my contribution to the simulation at hand.
virtual void add_old_vectors()
Helper function for (re-)adding old and older solution vectors.
virtual ~TransientSystem()
Destructor.
virtual void re_update() libmesh_override
Re-update the local values when the mesh has changed.
This class provides a specific system class.
virtual void reinit() libmesh_override
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be use...
The libMesh namespace provides an interface to certain functionality in the library.
TransientSystem(EquationSystems &es, const std::string &name, const unsigned int number)
Constructor.
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
UniquePtr< NumericVector< Number > > older_local_solution
All the values I need to compute my contribution to the simulation at hand.
virtual void clear() libmesh_override
Clear all the data structures associated with the system.
Number old_solution(const dof_id_type global_dof_number) const
sys get_dof_map()
uint8_t dof_id_type
Definition: id_types.h:64