libMesh
second_order_unsteady_solver.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 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 #include "libmesh/numeric_vector.h"
23 
24 namespace libMesh
25 {
27  : UnsteadySolver(s),
28  _old_local_solution_rate(NumericVector<Number>::build(s.comm())),
29  _old_local_solution_accel(NumericVector<Number>::build(s.comm()))
30 {}
31 
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 
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
virtual void reinit() override
The reinitialization function.
Number old_solution_accel(const dof_id_type global_dof_number) const
virtual void init_data() override
The data initialization function.
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
Definition: vector_fe_ex5.C:44
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:768
dof_id_type n_dofs(const unsigned int vn) const
Definition: dof_map.h:668
std::unique_ptr< NumericVector< Number > > _old_local_solution_accel
Serial vector of previous time step acceleration .
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type n_local_dofs() const
Definition: system.C:158
virtual void init() override
The initialization function.
SecondOrderUnsteadySolver(sys_type &s)
Constructor.
dof_id_type n_dofs() const
Definition: system.C:121
This class provides a specific system class.
Definition: diff_system.h:54
sys_type & _system
A reference to the system we are solving.
Definition: time_solver.h:312
virtual void reinit() override
The reinitialization function.
virtual void init_data() override
The data initialization function.
virtual ~SecondOrderUnsteadySolver()
Destructor.
virtual void retrieve_timestep() override
This method retrieves all the stored solutions at the current system.time.
Number old_solution_rate(const dof_id_type global_dof_number) const
This is a generic class that defines a solver to handle time integration of DifferentiableSystems.
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system...
void project_initial_rate(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr)
Specify non-zero initial velocity.
std::unique_ptr< NumericVector< Number > > _old_local_solution_rate
Serial vector of previous time step velocity .
virtual void init() override
The initialization function.
const DofMap & get_dof_map() const
Definition: system.h:2374
const std::vector< dof_id_type > & get_send_list() const
Definition: dof_map.h:526
const NumericVector< Number > & get_vector(std::string_view vec_name) const
Definition: system.C:943
uint8_t dof_id_type
Definition: id_types.h:67