libMesh
second_order_unsteady_solver.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 #include "libmesh/second_order_unsteady_solver.h"
19 
20 #include "libmesh/diff_system.h"
21 #include "libmesh/dof_map.h"
22 
23 namespace libMesh
24 {
26  : UnsteadySolver(s),
27  _old_local_solution_rate(NumericVector<Number>::build(s.comm())),
28  _old_local_solution_accel(NumericVector<Number>::build(s.comm()))
29 {}
30 
32 {}
33 
35 {
37 
38  _system.add_vector("_old_solution_rate");
39  _system.add_vector("_old_solution_accel");
40 }
41 
43 {
45 
46 #ifdef LIBMESH_ENABLE_GHOSTED
49  GHOSTED);
50 
53  GHOSTED);
54 #else
57 #endif
58 }
59 
61 {
63 
64 #ifdef LIBMESH_ENABLE_GHOSTED
67  GHOSTED);
68 
71  GHOSTED);
72 #else
75 #endif
76 
77  // localize the old solutions
79  _system.get_vector("_old_solution_rate");
80 
82  _system.get_vector("_old_solution_accel");
83 
84  old_solution_rate.localize
87 
88  old_solution_accel.localize
91 }
92 
94 {
95  libmesh_not_implemented();
96 }
97 
100 {
102  _system.get_vector("_old_solution_rate");
103 
104  _system.project_vector( old_solution_rate, f, g );
105 }
106 
108  const
109 {
110  libmesh_assert_less (global_dof_number, _system.get_dof_map().n_dofs());
111  libmesh_assert_less (global_dof_number, _old_local_solution_rate->size());
112 
113  return (*_old_local_solution_rate)(global_dof_number);
114 }
115 
117  const
118 {
119  libmesh_assert_less (global_dof_number, _system.get_dof_map().n_dofs());
120  libmesh_assert_less (global_dof_number, _old_local_solution_accel->size());
121 
122  return (*_old_local_solution_accel)(global_dof_number);
123 }
124 
125 } // end namespace libMesh
void project_initial_rate(FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr)
Specify non-zero initial velocity.
Numeric vector.
Definition: dof_map.h:66
The libMesh namespace provides an interface to certain functionality in the library.
Number old_solution_accel(const dof_id_type global_dof_number) const
dof_id_type n_dofs() const
Definition: dof_map.h:510
virtual void init() libmesh_override
The initialization function.
SecondOrderUnsteadySolver(sys_type &s)
Constructor.
virtual void init_data() libmesh_override
The data initialization function.
This class provides a specific system class.
Definition: diff_system.h:53
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:257
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:681
const DofMap & get_dof_map() const
Definition: system.h:2030
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:794
UniquePtr< NumericVector< Number > > _old_local_solution_rate
Serial vector of previous time step velocity .
virtual void reinit() libmesh_override
The reinitialization function.
virtual void reinit() libmesh_override
The reinitialization function.
virtual void init() libmesh_override
The initialization function.
dof_id_type n_local_dofs() const
Definition: system.C:185
UniquePtr< NumericVector< Number > > _old_local_solution_accel
Serial vector of previous time step acceleration .
This is a generic class that defines a solver to handle time integration of DifferentiableSystems.
dof_id_type n_dofs() const
Definition: system.C:148
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=libmesh_nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...
Number old_solution_rate(const dof_id_type global_dof_number) const
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:394
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
virtual void init_data() libmesh_override
The data initialization function.
virtual void retrieve_timestep() libmesh_override
This method retrieves all the stored solutions at the current system.time.
uint8_t dof_id_type
Definition: id_types.h:64