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"
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;
81 std::vector<unsigned int> variables {
_u_var};
83 variables.push_back(
_v_var);
85 variables.push_back(
_w_var);
95 if (!dirichlet_u_boundary_ids.empty())
103 if (!dirichlet_v_boundary_ids.empty())
114 FEMSystem::init_data();
119 FEMContext & c = cast_ref<FEMContext &>(context);
157 FEMContext & c = cast_ref<FEMContext &>(context);
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);
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);
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;
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));
virtual bool mass_residual(bool request_jacobian, DiffContext &context)
Subtracts a mass vector contribution on elem from elem_residual.
virtual void init_data()
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
virtual bool element_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on elem to elem_residual.
virtual bool side_time_derivative(bool request_jacobian, DiffContext &context)
Adds the time derivative contribution on side of elem to elem_residual.
Real kronecker_delta(unsigned int i, unsigned int j)
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
virtual void init_context(DiffContext &context)
void set_union(T &data, const unsigned int root_id) const
const std::set< boundary_id_type > & get_boundary_ids() const
This class provides all data required for a physics package (e.g.
Real get_elem_solution_derivative() const
The derivative of the current elem_solution w.r.t.
Real get_elem_solution_accel_derivative() const
The derivative of the current elem_solution_accel w.r.t.
unsigned int n_dof_indices() const
Total number of dof indices on the element.
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
virtual void time_evolving(unsigned int var, unsigned int order)
Tells the DiffSystem that variable var is evolving with respect to time.
unsigned int get_second_order_dot_var(unsigned int var) const
For a given second order (in time) variable var, this method will return the index to the correspondi...
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
virtual_for_inffe const std::vector< Point > & get_normals() const
virtual_for_inffe const std::vector< Real > & get_JxW() const
This class forms the foundation from which generic finite elements may be derived.
const std::vector< std::vector< OutputShape > > & get_phi() const
const std::vector< std::vector< OutputGradient > > & get_dphi() const
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...
Gradient interior_gradient(unsigned int var, unsigned int qp) const
const std::set< unsigned char > & elem_dimensions() const
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
void interior_accel(unsigned int var, unsigned int qp, OutputType &u) const
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.
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem.
bool has_side_boundary_id(boundary_id_type id) const
Reports if the boundary id is found on the current side.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
const Parallel::Communicator & comm() const
unsigned int n_points() const
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
const DofMap & get_dof_map() const
const MeshBase & get_mesh() const
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
ConstFunction that simply returns 0.
boundary_id_type boundary_id_max_x
boundary_id_type boundary_id_min_y
boundary_id_type boundary_id_max_z
boundary_id_type boundary_id_max_y
boundary_id_type boundary_id_min_z
boundary_id_type boundary_id_min_x
const boundary_id_type fixed_v_boundary_id
static const boundary_id_type & traction_boundary_id
const boundary_id_type edge_boundary_id
const boundary_id_type pressure_boundary_id
const boundary_id_type node_boundary_id
const boundary_id_type fixed_u_boundary_id
boundary_id_type boundary_id_min_x
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real