transient_system.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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
27 #include "libmesh/dof_map.h"
28 #include "libmesh/numeric_vector.h"
30 
31 namespace libMesh
32 {
33 
34 
35 // ------------------------------------------------------------
36 // TransientSystem implementation
37 template <class Base>
39  const std::string& name_in,
40  const unsigned int number_in) :
41 
42  Base (es, name_in, number_in)
43 {
44 #ifdef LIBMESH_ENABLE_GHOSTED
47  (&(this->add_vector("_transient_old_local_solution", true, GHOSTED)));
50  (&(this->add_vector("_transient_older_local_solution", true, GHOSTED)));
51 #else
54  (&(this->add_vector("_transient_old_local_solution", true, SERIAL)));
57  (&(this->add_vector("_transient_older_local_solution", true, SERIAL)));
58 #endif
59 }
60 
61 
62 
63 template <class Base>
65 {
66  this->clear();
67 
68  // We still have AutoPtrs for API compatibility, but
69  // now that we're System::add_vector()ing these, we can trust
70  // the base class to handle memory management
71  old_local_solution.release();
72  older_local_solution.release();
73 }
74 
75 
76 
77 template <class Base>
79 {
80  // clear the parent data
81  Base::clear();
82 
83  // the old & older local solutions
84  // are now deleted by System!
85  // old_local_solution->clear();
86  // older_local_solution->clear();
87 
88  // FIXME: This preserves maximum backwards compatibility,
89  // but is probably grossly unnecessary:
90  old_local_solution.release();
91  older_local_solution.release();
92 
93  old_local_solution =
95  (&(this->add_vector("_transient_old_local_solution")));
96  older_local_solution =
98  (&(this->add_vector("_transient_older_local_solution")));
99 }
100 
101 
102 
103 
104 template <class Base>
106 {
107  // initialize parent data
108  Base::init_data();
109 
110  // Initialize the old & older solutions
111  // Using new ghosted vectors if enabled
112 #ifdef LIBMESH_ENABLE_GHOSTED
113  old_local_solution->init (this->n_dofs(), this->n_local_dofs(),
114  this->get_dof_map().get_send_list(), false,
115  GHOSTED);
116  older_local_solution->init (this->n_dofs(), this->n_local_dofs(),
117  this->get_dof_map().get_send_list(), false,
118  GHOSTED);
119 #else
120  old_local_solution->init (this->n_dofs(), false, SERIAL);
121  older_local_solution->init (this->n_dofs(), false, SERIAL);
122 #endif
123 }
124 
125 
126 
127 template <class Base>
129 {
130  // initialize parent data
131  Base::reinit();
132 
133  // Project the old & older vectors to the new mesh
134  // The System::reinit handles this now
135  // this->project_vector (*old_local_solution);
136  // this->project_vector (*older_local_solution);
137 }
138 
139 
140 
141 template <class Base>
143 {
144  // re_update the parent system
145  Base::re_update ();
146 
147  const std::vector<dof_id_type>& send_list = this->get_dof_map().get_send_list ();
148 
149  const dof_id_type first_local_dof = Base::get_dof_map().first_dof();
150  const dof_id_type end_local_dof = Base::get_dof_map().end_dof();
151 
152  // Check sizes
153  libmesh_assert_greater_equal (end_local_dof, first_local_dof);
154  libmesh_assert_greater_equal (older_local_solution->size(), send_list.size());
155  libmesh_assert_greater_equal (old_local_solution->size(), send_list.size());
156 
157  // Even if we don't have to do anything ourselves, localize() may
158  // use parallel_only tools
159  // if (first_local_dof == end_local_dof)
160  // return;
161 
162  // Update the old & older solutions with the send_list,
163  // which may have changed since their last update.
164  older_local_solution->localize (first_local_dof,
165  end_local_dof-1,
166  send_list);
167 
168  old_local_solution->localize (first_local_dof,
169  end_local_dof-1,
170  send_list);
171 }
172 
173 
174 
175 
176 template <class Base>
178 {
179  // Check the sizes
180  libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
181  libmesh_assert_less (global_dof_number, old_local_solution->size());
182 
183  return (*old_local_solution)(global_dof_number);
184 }
185 
186 
187 
188 template <class Base>
190 {
191  // Check the sizes
192  libmesh_assert_less (global_dof_number, this->get_dof_map().n_dofs());
193  libmesh_assert_less (global_dof_number, older_local_solution->size());
194 
195  return (*older_local_solution)(global_dof_number);
196 }
197 
198 
199 
200 
201 // ------------------------------------------------------------
202 // TransientSystem instantiations
205 template class TransientSystem<ExplicitSystem>;
206 template class TransientSystem<System>;
207 template class TransientSystem<RBConstruction>;
208 
209 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:07 UTC

Hosted By:
SourceForge.net Logo