29 #include "libmesh/numeric_vector.h" 32 MAST::FirstOrderNewmarkTransientSolver::FirstOrderNewmarkTransientSolver():
33 MAST::TransientSolverBase(1, 2),
38 MAST::FirstOrderNewmarkTransientSolver::~FirstOrderNewmarkTransientSolver()
44 MAST::FirstOrderNewmarkTransientSolver::
45 set_element_data(
const std::vector<libMesh::dof_id_type>& dof_indices,
46 const std::vector<libMesh::NumericVector<Real>*>& sols) {
48 libmesh_assert_equal_to(sols.size(), 2);
50 const unsigned int n_dofs = (
unsigned int)dof_indices.size();
55 sol = RealVectorX::Zero(n_dofs),
56 vel = RealVectorX::Zero(n_dofs);
59 const libMesh::NumericVector<Real>
60 &sol_global = *sols[0],
61 &vel_global = *sols[1];
65 for (
unsigned int i=0; i<n_dofs; i++) {
67 sol(i) = sol_global(dof_indices[i]);
68 vel(i) = vel_global(dof_indices[i]);
71 _assembly_ops->set_elem_solution(sol);
72 _assembly_ops->set_elem_velocity(vel);
78 MAST::FirstOrderNewmarkTransientSolver::
79 extract_element_sensitivity_data(
const std::vector<libMesh::dof_id_type>& dof_indices,
80 const std::vector<libMesh::NumericVector<Real>*>& sols,
81 std::vector<RealVectorX>& local_sols) {
83 libmesh_assert_equal_to(sols.size(), 2);
85 const unsigned int n_dofs = (
unsigned int)dof_indices.size();
93 sol = RealVectorX::Zero(n_dofs);
94 vel = RealVectorX::Zero(n_dofs);
96 const libMesh::NumericVector<Real>
97 &sol_global = *sols[0],
98 &vel_global = *sols[1];
102 for (
unsigned int i=0; i<n_dofs; i++) {
104 sol(i) = sol_global(dof_indices[i]);
105 vel(i) = vel_global(dof_indices[i]);
113 MAST::FirstOrderNewmarkTransientSolver::
114 set_element_perturbed_data(
const std::vector<libMesh::dof_id_type>& dof_indices,
115 const std::vector<libMesh::NumericVector<Real>*>& sols){
117 libmesh_assert_equal_to(sols.size(), 2);
119 const unsigned int n_dofs = (
unsigned int)dof_indices.size();
124 sol = RealVectorX::Zero(n_dofs),
125 vel = RealVectorX::Zero(n_dofs);
128 const libMesh::NumericVector<Real>
129 &sol_global = *sols[0],
130 &vel_global = *sols[1];
134 for (
unsigned int i=0; i<n_dofs; i++) {
136 sol(i) = sol_global(dof_indices[i]);
137 vel(i) = vel_global(dof_indices[i]);
140 _assembly_ops->set_elem_perturbed_solution(sol);
141 _assembly_ops->set_elem_perturbed_velocity(vel);
149 MAST::FirstOrderNewmarkTransientSolver::
150 update_velocity(libMesh::NumericVector<Real>& vec,
151 const libMesh::NumericVector<Real>& sol) {
153 const libMesh::NumericVector<Real>
154 &prev_sol = this->solution(1),
155 &prev_vel = this->velocity(1);
158 vec.add(-1., prev_sol);
159 vec.scale(1./beta/dt);
161 vec.add(-(1.-beta)/beta, prev_vel);
169 MAST::FirstOrderNewmarkTransientSolver::
170 update_sensitivity_velocity(libMesh::NumericVector<Real>& vec,
171 const libMesh::NumericVector<Real>& sol) {
173 const libMesh::NumericVector<Real>
174 &prev_sol = this->solution_sensitivity(1),
175 &prev_vel = this->velocity_sensitivity(1);
178 vec.add(-1., prev_sol);
179 vec.scale(1./beta/dt);
181 vec.add(-(1.-beta)/beta, prev_vel);
189 MAST::FirstOrderNewmarkTransientSolver::
190 update_delta_velocity(libMesh::NumericVector<Real>& vec,
191 const libMesh::NumericVector<Real>& sol) {
194 vec.scale( 1./beta/dt);
203 MAST::FirstOrderNewmarkTransientSolver::
204 elem_calculations(
bool if_jac,
208 libmesh_assert(_assembly_ops);
209 unsigned int n_dofs = (
unsigned int)vec.size();
212 f_x = RealVectorX::Zero(n_dofs),
213 f_m = RealVectorX::Zero(n_dofs);
216 f_m_jac_xdot = RealMatrixX::Zero(n_dofs, n_dofs),
217 f_m_jac = RealMatrixX::Zero(n_dofs, n_dofs),
218 f_x_jac = RealMatrixX::Zero(n_dofs, n_dofs);
221 _assembly_ops->elem_calculations(if_jac,
228 if (_if_highest_derivative_solution) {
277 mat = (1./beta/dt)*f_m_jac_xdot + (f_m_jac + f_x_jac);
288 libmesh_assert(_assembly_ops);
291 _assembly_ops->linearized_jacobian_solution_product(vec);
303 libmesh_assert(_assembly_ops);
304 unsigned int n_dofs = (
unsigned int)vec.size();
307 f_x = RealVectorX::Zero(n_dofs),
308 f_m = RealVectorX::Zero(n_dofs);
311 _assembly_ops->elem_sensitivity_calculations(f,
327 if (_if_highest_derivative_solution)
return;
330 libmesh_assert(_assembly_ops);
331 libmesh_assert_equal_to(prev_sols.size(), 2);
333 unsigned int n_dofs = (
unsigned int)vec.size();
339 dummy_vec = RealVectorX::Zero(n_dofs);
342 f_m_jac_xdot = RealMatrixX::Zero(n_dofs, n_dofs),
343 dummy_mat = RealMatrixX::Zero(n_dofs, n_dofs);
346 _assembly_ops->elem_calculations(
true,
353 vec = -1.*(f_m_jac_xdot * ( (1./beta/dt)*sol + (1.-beta)/beta * vel));
363 libmesh_assert(
false);
372 libmesh_assert(
false);
382 libmesh_assert(
false);
virtual void elem_sensitivity_calculations(const MAST::FunctionBase &f, RealVectorX &vec)
performs the element sensitivity calculations over elem, and returns the element residual sensitivity...
virtual void elem_sensitivity_contribution_previous_timestep(const std::vector< RealVectorX > &prev_sols, RealVectorX &vec)
computes the contribution for this element from previous time step
virtual void elem_topology_sensitivity_calculations(const MAST::FunctionBase &f, RealVectorX &vec)
performs the element topology sensitivity calculations over elem, and returns the element residual se...
Matrix< Real, Dynamic, Dynamic > RealMatrixX
Matrix< Real, Dynamic, 1 > RealVectorX
virtual void elem_linearized_jacobian_solution_product(RealVectorX &vec)
This class implements the Newmark solver for solution of a first-order ODE.
virtual void elem_shape_sensitivity_calculations(const MAST::FunctionBase &f, RealVectorX &vec)
performs the element shape sensitivity calculations over elem, and returns the element residual sensi...