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);
159 vec.add(-1., prev_sol);
160 vec.scale(1./beta/dt);
162 vec.add(-(1.-beta)/beta, prev_vel);
170 MAST::FirstOrderNewmarkTransientSolver::
171 update_sensitivity_velocity(libMesh::NumericVector<Real>& vec,
172 const libMesh::NumericVector<Real>& sol) {
174 const libMesh::NumericVector<Real>
175 &prev_sol = this->solution_sensitivity(1),
176 &prev_vel = this->velocity_sensitivity(1);
180 vec.add(-1., prev_sol);
181 vec.scale(1./beta/dt);
183 vec.add(-(1.-beta)/beta, prev_vel);
191 MAST::FirstOrderNewmarkTransientSolver::
192 update_delta_velocity(libMesh::NumericVector<Real>& vec,
193 const libMesh::NumericVector<Real>& sol) {
196 vec.add( 1./beta/dt, sol);
205 MAST::FirstOrderNewmarkTransientSolver::
206 elem_calculations(
bool if_jac,
210 libmesh_assert(_assembly_ops);
211 unsigned int n_dofs = (
unsigned int)vec.size();
214 f_x = RealVectorX::Zero(n_dofs),
215 f_m = RealVectorX::Zero(n_dofs);
218 f_m_jac_xdot = RealMatrixX::Zero(n_dofs, n_dofs),
219 f_m_jac = RealMatrixX::Zero(n_dofs, n_dofs),
220 f_x_jac = RealMatrixX::Zero(n_dofs, n_dofs);
223 _assembly_ops->elem_calculations(if_jac,
230 if (_if_highest_derivative_solution) {
279 mat = (1./beta/dt)*f_m_jac_xdot + (f_m_jac + f_x_jac);
290 libmesh_assert(_assembly_ops);
293 _assembly_ops->linearized_jacobian_solution_product(vec);
305 libmesh_assert(_assembly_ops);
306 unsigned int n_dofs = (
unsigned int)vec.size();
309 f_x = RealVectorX::Zero(n_dofs),
310 f_m = RealVectorX::Zero(n_dofs);
313 _assembly_ops->elem_sensitivity_calculations(f,
329 libmesh_assert(_assembly_ops);
330 libmesh_assert_equal_to(prev_sols.size(), 2);
332 unsigned int n_dofs = (
unsigned int)vec.size();
338 dummy_vec = RealVectorX::Zero(n_dofs);
341 f_m_jac_xdot = RealMatrixX::Zero(n_dofs, n_dofs),
342 dummy_mat = RealMatrixX::Zero(n_dofs, n_dofs);
345 _assembly_ops->elem_calculations(
true,
352 vec = -1.*(f_m_jac_xdot * ( (1./beta/dt)*sol + (1.-beta)/beta * vel));
362 libmesh_assert(
false);
372 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_topology_sensitivity_calculations(const MAST::FunctionBase &f, const MAST::FieldFunction< RealVectorX > &vel, RealVectorX &vec)
performs the element topology sensitivity calculations over elem, and returns the element residual se...
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
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...