19 #include "elasticity_system.h" 22 #include "libmesh/dof_map.h" 23 #include "libmesh/elem.h" 24 #include "libmesh/fe_base.h" 25 #include "libmesh/fem_context.h" 26 #include "libmesh/zero_function.h" 27 #include "libmesh/dirichlet_boundaries.h" 28 #include "libmesh/quadrature.h" 29 #include "libmesh/unsteady_solver.h" 30 #include "libmesh/parallel_implementation.h" 31 #include "libmesh/boundary_info.h" 49 _u_var = this->add_variable (
"Ux", _fe_type);
51 _v_var = this->add_variable (
"Uy", _fe_type);
55 _w_var = this->add_variable (
"Uz", _fe_type);
59 this->time_evolving(_u_var,2);
60 this->time_evolving(_v_var,2);
61 this->time_evolving(_w_var,2);
63 #ifdef LIBMESH_ENABLE_DIRICHLET 65 std::set<boundary_id_type> all_boundary_ids, dirichlet_boundary_ids,
66 dirichlet_u_boundary_ids, dirichlet_v_boundary_ids;
67 all_boundary_ids = this->get_mesh().get_boundary_info().get_boundary_ids();
68 this->comm().set_union(all_boundary_ids);
81 std::vector<unsigned int> variables {_u_var};
83 variables.push_back(_v_var);
85 variables.push_back(_w_var);
93 this->get_dof_map().add_dirichlet_boundary(dirichlet_bc);
95 if (!dirichlet_u_boundary_ids.empty())
100 this->get_dof_map().add_dirichlet_boundary(dirichlet_u_bc);
103 if (!dirichlet_v_boundary_ids.empty())
108 this->get_dof_map().add_dirichlet_boundary(dirichlet_v_bc);
111 #endif // LIBMESH_ENABLE_DIRICHLET 119 FEMContext & c = cast_ref<FEMContext &>(context);
129 u_elem_fe->get_JxW();
130 u_elem_fe->get_phi();
131 u_elem_fe->get_dphi();
157 FEMContext & c = cast_ref<FEMContext &>(context);
168 unsigned int u_dot_var = this->get_second_order_dot_var(_u_var);
169 unsigned int v_dot_var = this->get_second_order_dot_var(_v_var);
170 unsigned int w_dot_var = this->get_second_order_dot_var(_w_var);
179 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
181 const std::vector<std::vector<Real>> & phi = u_elem_fe->
get_phi();
182 const std::vector<std::vector<RealGradient>> & grad_phi = u_elem_fe->
get_dphi();
188 std::reference_wrapper<DenseSubVector<Number>> F[3] =
199 std::reference_wrapper<DenseSubMatrix<Number>> K[3][3] =
208 Gradient body_force(0.0, 0.0, -1.0);
210 for (
unsigned int qp=0; qp != n_qpoints; qp++)
220 Tensor grad_U (grad_u, grad_v, grad_w);
223 for (
unsigned int i = 0; i < _dim; i++)
224 for (
unsigned int j = 0; j < _dim; j++)
225 for (
unsigned int k = 0; k < _dim; k++)
226 for (
unsigned int l = 0; l < _dim; l++)
229 for (
unsigned int i=0; i != n_u_dofs; i++)
231 for (
unsigned int alpha = 0; alpha < _dim; alpha++)
233 for (
unsigned int d = 0; d < _dim; ++d)
234 F[d](i) += (tau(d,alpha)*grad_phi[i][qp](alpha) - body_force(d)*phi[i][qp])*JxW[qp];
236 if (request_jacobian)
238 for (
unsigned int j=0; j != n_u_dofs; j++)
240 for (
unsigned int beta = 0; beta < _dim; beta++)
245 for (
unsigned int k = 0; k < _dim; ++k)
246 for (
unsigned int l = 0; l < _dim; ++l)
248 c0*grad_phi[i][qp](alpha)*JxW[qp];
258 return request_jacobian;
264 FEMContext & c = cast_ref<FEMContext &>(context);
280 unsigned int u_dot_var = this->get_second_order_dot_var(_u_var);
281 unsigned int v_dot_var = this->get_second_order_dot_var(_v_var);
282 unsigned int w_dot_var = this->get_second_order_dot_var(_w_var);
291 std::reference_wrapper<DenseSubVector<Number>> F[3] =
299 const std::vector<Real> & JxW = u_side_fe->
get_JxW();
301 const std::vector<std::vector<Real>> & phi = u_side_fe->
get_phi();
303 const std::vector<Point> & normals = u_side_fe->
get_normals();
309 traction(_dim-1) = -1;
311 const bool pressureforce =
314 for (
unsigned int qp=0; qp != n_qpoints; qp++)
317 traction = pressure * normals[qp];
319 for (
unsigned int i=0; i != n_u_dofs; i++)
320 for (
unsigned int d = 0; d < _dim; ++d)
321 F[d](i) -= traction(d)*phi[i][qp]*JxW[qp];
327 return request_jacobian;
333 FEMContext & c = cast_ref<FEMContext &>(context);
345 unsigned int u_dot_var = this->get_second_order_dot_var(_u_var);
346 unsigned int v_dot_var = this->get_second_order_dot_var(_v_var);
347 unsigned int w_dot_var = this->get_second_order_dot_var(_w_var);
356 const std::vector<Real> & JxW = u_elem_fe->
get_JxW();
358 const std::vector<std::vector<Real>> & phi = u_elem_fe->
get_phi();
361 std::reference_wrapper<DenseSubVector<Number>> F[3] =
369 std::reference_wrapper<DenseSubMatrix<Number>> Kdiag[3] =
378 for (
unsigned int qp=0; qp != n_qpoints; qp++)
384 std::vector<Number> accel(3);
391 for (
unsigned int i=0; i != n_u_dofs; i++)
393 for (
unsigned int d = 0; d < _dim; ++d)
394 F[d](i) += _rho*accel[d]*phi[i][qp]*JxW[qp];
396 if (request_jacobian)
398 for (
unsigned int j=0; j != n_u_dofs; j++)
402 _rho*phi[i][qp]*phi[j][qp]*JxW[qp];
404 for (
unsigned int d = 0; d < _dim; ++d)
405 Kdiag[d](i,j) += jac_term;
412 return request_jacobian;
414 #endif // LIBMESH_DIM > 2 419 const Real poisson_ratio = 0.3;
420 const Real young_modulus = 1.0e2;
423 const Real lambda_1 = (young_modulus*poisson_ratio)/((1.+poisson_ratio)*(1.-2.*poisson_ratio));
424 const Real lambda_2 = young_modulus/(2.*(1.+poisson_ratio));
boundary_id_type boundary_id_min_x
Real get_elem_solution_derivative() const
The derivative of the current elem_solution w.r.t.
const boundary_id_type edge_boundary_id
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
This class provides all data required for a physics package (e.g.
void get_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge/face (2D/3D) finite element object for variable var for the largest dimension in th...
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
ConstFunction that simply returns 0.
virtual void init_context(DiffContext &context)
Real kronecker_delta(unsigned int i, unsigned int j)
void interior_accel(unsigned int var, unsigned int qp, OutputType &u) const
unsigned int n_dof_indices() const
Total number of dof indices on the element.
virtual bool mass_residual(bool request_jacobian, DiffContext &context)
Subtracts a mass vector contribution on elem from elem_residual.
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
bool has_side_boundary_id(boundary_id_type id) const
Reports if the boundary id is found on the current side.
boundary_id_type boundary_id_max_x
const std::vector< std::vector< OutputGradient > > & get_dphi() const
Gradient interior_gradient(unsigned int var, unsigned int qp) const
boundary_id_type boundary_id_max_z
const boundary_id_type node_boundary_id
virtual void init_data() override
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used...
virtual_for_inffe const std::vector< Real > & get_JxW() const
This class provides all data required for a physics package (e.g.
boundary_id_type boundary_id_max_y
unsigned int n_points() const
virtual bool side_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on side of elem to elem_residual.
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
const boundary_id_type pressure_boundary_id
Real get_elem_solution_accel_derivative() const
The derivative of the current elem_solution_accel w.r.t.
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used...
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual_for_inffe const std::vector< Point > & get_normals() const
const boundary_id_type fixed_u_boundary_id
static const boundary_id_type & traction_boundary_id
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh...
boundary_id_type boundary_id_min_y
virtual bool element_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on elem to elem_residual.
This class forms the foundation from which generic finite elements may be derived.
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
const std::set< unsigned char > & elem_dimensions() const
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem. ...
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
const std::vector< std::vector< OutputShape > > & get_phi() const
boundary_id_type boundary_id_min_z
const boundary_id_type fixed_v_boundary_id