20 #include "libmesh/dof_map.h"
21 #include "libmesh/fe_base.h"
22 #include "libmesh/fem_context.h"
23 #include "libmesh/zero_function.h"
24 #include "libmesh/dirichlet_boundaries.h"
25 #include "libmesh/quadrature.h"
26 #include "libmesh/unsteady_solver.h"
39 this->time_evolving(_u_var,2);
40 this->time_evolving(_v_var,2);
41 this->time_evolving(_w_var,2);
43 #ifdef LIBMESH_ENABLE_DIRICHLET
44 std::set<boundary_id_type> boundary_ids;
45 boundary_ids.insert(BOUNDARY_ID_MIN_X);
46 boundary_ids.insert(NODE_BOUNDARY_ID);
47 boundary_ids.insert(EDGE_BOUNDARY_ID);
49 std::vector<unsigned int> variables;
50 variables.push_back(_u_var);
51 variables.push_back(_v_var);
52 variables.push_back(_w_var);
61 this->get_dof_map().add_dirichlet_boundary(dirichlet_bc);
63 #endif // LIBMESH_ENABLE_DIRICHLET
71 FEMContext & c = cast_ref<FEMContext &>(context);
92 FEMContext & c = cast_ref<FEMContext &>(context);
103 unsigned int u_dot_var = this->get_second_order_dot_var(_u_var);
104 unsigned int v_dot_var = this->get_second_order_dot_var(_v_var);
105 unsigned int w_dot_var = this->get_second_order_dot_var(_w_var);
114 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
116 const std::vector<std::vector<Real>> & phi = u_elem_fe->
get_phi();
117 const std::vector<std::vector<RealGradient>> & grad_phi = u_elem_fe->
get_dphi();
135 Gradient body_force(0.0, 0.0, -1.0);
137 for (
unsigned int qp=0; qp != n_qpoints; qp++)
145 Tensor grad_U (grad_u, grad_v, grad_w);
148 for (
unsigned int i = 0; i < 3; i++)
149 for (
unsigned int j = 0; j < 3; j++)
150 for (
unsigned int k = 0; k < 3; k++)
151 for (
unsigned int l = 0; l < 3; l++)
154 for (
unsigned int i=0; i != n_u_dofs; i++)
156 for (
unsigned int alpha = 0; alpha < 3; alpha++)
158 Fu(i) += (tau(0,alpha)*grad_phi[i][qp](alpha) - body_force(0)*phi[i][qp])*JxW[qp];
159 Fv(i) += (tau(1,alpha)*grad_phi[i][qp](alpha) - body_force(1)*phi[i][qp])*JxW[qp];
160 Fw(i) += (tau(2,alpha)*grad_phi[i][qp](alpha) - body_force(2)*phi[i][qp])*JxW[qp];
162 if (request_jacobian)
164 for (
unsigned int j=0; j != n_u_dofs; j++)
166 for (
unsigned int beta = 0; beta < 3; beta++)
181 Kuu(i,j) += dtau_uu*grad_phi[i][qp](alpha)*JxW[qp];
182 Kuv(i,j) += dtau_uv*grad_phi[i][qp](alpha)*JxW[qp];
183 Kuw(i,j) += dtau_uw*grad_phi[i][qp](alpha)*JxW[qp];
184 Kvu(i,j) += dtau_vu*grad_phi[i][qp](alpha)*JxW[qp];
185 Kvv(i,j) += dtau_vv*grad_phi[i][qp](alpha)*JxW[qp];
186 Kvw(i,j) += dtau_vw*grad_phi[i][qp](alpha)*JxW[qp];
187 Kwu(i,j) += dtau_wu*grad_phi[i][qp](alpha)*JxW[qp];
188 Kwv(i,j) += dtau_wv*grad_phi[i][qp](alpha)*JxW[qp];
189 Kww(i,j) += dtau_ww*grad_phi[i][qp](alpha)*JxW[qp];
199 return request_jacobian;
205 FEMContext & c = cast_ref<FEMContext &>(context);
219 unsigned int u_dot_var = this->get_second_order_dot_var(_u_var);
220 unsigned int v_dot_var = this->get_second_order_dot_var(_v_var);
221 unsigned int w_dot_var = this->get_second_order_dot_var(_w_var);
234 const std::vector<Real> & JxW = u_side_fe->
get_JxW();
236 const std::vector<std::vector<Real>> & phi = u_side_fe->
get_phi();
242 for (
unsigned int qp=0; qp != n_qpoints; qp++)
244 for (
unsigned int i=0; i != n_u_dofs; i++)
246 Fu(i) -= traction(0)*phi[i][qp]*JxW[qp];
247 Fv(i) -= traction(1)*phi[i][qp]*JxW[qp];
248 Fw(i) -= traction(2)*phi[i][qp]*JxW[qp];
255 return request_jacobian;
261 FEMContext & c = cast_ref<FEMContext &>(context);
272 unsigned int u_dot_var = this->get_second_order_dot_var(_u_var);
273 unsigned int v_dot_var = this->get_second_order_dot_var(_v_var);
274 unsigned int w_dot_var = this->get_second_order_dot_var(_w_var);
283 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
285 const std::vector<std::vector<Real>> & phi = u_elem_fe->
get_phi();
298 for (
unsigned int qp=0; qp != n_qpoints; qp++)
309 for (
unsigned int i=0; i != n_u_dofs; i++)
311 Fu(i) += _rho*u_ddot*phi[i][qp]*JxW[qp];
312 Fv(i) += _rho*v_ddot*phi[i][qp]*JxW[qp];
313 Fw(i) += _rho*w_ddot*phi[i][qp]*JxW[qp];
315 if (request_jacobian)
317 for (
unsigned int j=0; j != n_u_dofs; j++)
322 Kuu(i,j) += jac_term;
323 Kvv(i,j) += jac_term;
324 Kww(i,j) += jac_term;
331 return request_jacobian;
333 #endif // LIBMESH_DIM > 2
338 const Real poisson_ratio = 0.3;
339 const Real young_modulus = 1.0e2;
342 const Real lambda_1 = (young_modulus*poisson_ratio)/((1.+poisson_ratio)*(1.-2.*poisson_ratio));
343 const Real lambda_2 = young_modulus/(2.*(1.+poisson_ratio));