libMesh
Public Member Functions | Private Attributes | List of all members
LinearElasticity Class Reference
Inheritance diagram for LinearElasticity:
[legend]

Public Member Functions

 LinearElasticity (EquationSystems &es_in)
 
Real kronecker_delta (unsigned int i, unsigned int j)
 Kronecker delta function. More...
 
Real elasticity_tensor (unsigned int i, unsigned int j, unsigned int k, unsigned int l)
 Evaluate the fourth order tensor (C_ijkl) that relates stress to strain. More...
 
void assemble ()
 Assemble the system matrix and right-hand side vector. More...
 
void compute_stresses ()
 
 LinearElasticity (EquationSystems &es_in)
 
Real kronecker_delta (unsigned int i, unsigned int j)
 Kronecker delta function. More...
 
Real elasticity_tensor (unsigned int i, unsigned int j, unsigned int k, unsigned int l)
 Evaluate the fourth order tensor (C_ijkl) that relates stress to strain. More...
 
void assemble ()
 Assemble the system matrix and right-hand side vector. More...
 

Private Attributes

EquationSystemses
 

Detailed Description

Definition at line 117 of file systems_of_equations_ex6.C.

Constructor & Destructor Documentation

◆ LinearElasticity() [1/2]

LinearElasticity::LinearElasticity ( EquationSystems es_in)
inline

Definition at line 124 of file systems_of_equations_ex6.C.

124  :
125  es(es_in)
126  {}

◆ LinearElasticity() [2/2]

LinearElasticity::LinearElasticity ( EquationSystems es_in)
inline

Definition at line 201 of file systems_of_equations_ex9.C.

201  :
202  es(es_in)
203  {}

Member Function Documentation

◆ assemble() [1/2]

void LinearElasticity::assemble ( )
inlinevirtual

Assemble the system matrix and right-hand side vector.

Implements libMesh::System::Assembly.

Definition at line 160 of file systems_of_equations_ex6.C.

References libMesh::SparseMatrix< T >::add_matrix(), libMesh::NumericVector< T >::add_vector(), libMesh::FEGenericBase< OutputType >::build(), libMesh::DofMap::constrain_element_matrix_and_vector(), libMesh::FEType::default_quadrature_order(), dim, libMesh::DofMap::dof_indices(), elasticity_tensor(), libMesh::MeshBase::get_boundary_info(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::ImplicitSystem::get_system_matrix(), libMesh::BoundaryInfo::has_boundary_id(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), libMesh::ExplicitSystem::rhs, libMesh::System::variable_number(), and libMesh::DofMap::variable_type().

161  {
162  const MeshBase & mesh = es.get_mesh();
163 
164  const unsigned int dim = mesh.mesh_dimension();
165 
166  LinearImplicitSystem & system = es.get_system<LinearImplicitSystem>("Elasticity");
167 
168  const unsigned int u_var = system.variable_number ("u");
169 
170  const DofMap & dof_map = system.get_dof_map();
171  FEType fe_type = dof_map.variable_type(u_var);
172  std::unique_ptr<FEBase> fe (FEBase::build(dim, fe_type));
173  QGauss qrule (dim, fe_type.default_quadrature_order());
174  fe->attach_quadrature_rule (&qrule);
175 
176  std::unique_ptr<FEBase> fe_face (FEBase::build(dim, fe_type));
177  QGauss qface(dim-1, fe_type.default_quadrature_order());
178  fe_face->attach_quadrature_rule (&qface);
179 
180  const std::vector<Real> & JxW = fe->get_JxW();
181  const std::vector<std::vector<Real>> & phi = fe->get_phi();
182  const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
183 
185  DenseSubMatrix<Number> Ke_var[3][3] =
186  {
190  };
191 
193 
194  DenseSubVector<Number> Fe_var[3] =
198 
199  std::vector<dof_id_type> dof_indices;
200  std::vector<std::vector<dof_id_type>> dof_indices_var(3);
201 
202  SparseMatrix<Number> & matrix = system.get_system_matrix();
203 
204  for (const auto & elem : mesh.active_local_element_ptr_range())
205  {
206  dof_map.dof_indices (elem, dof_indices);
207  for (unsigned int var=0; var<3; var++)
208  dof_map.dof_indices (elem, dof_indices_var[var], var);
209 
210  const unsigned int n_dofs = dof_indices.size();
211  const unsigned int n_var_dofs = dof_indices_var[0].size();
212 
213  fe->reinit (elem);
214 
215  Ke.resize (n_dofs, n_dofs);
216  for (unsigned int var_i=0; var_i<3; var_i++)
217  for (unsigned int var_j=0; var_j<3; var_j++)
218  Ke_var[var_i][var_j].reposition (var_i*n_var_dofs, var_j*n_var_dofs, n_var_dofs, n_var_dofs);
219 
220  Fe.resize (n_dofs);
221  for (unsigned int var=0; var<3; var++)
222  Fe_var[var].reposition (var*n_var_dofs, n_var_dofs);
223 
224  for (unsigned int qp=0; qp<qrule.n_points(); qp++)
225  {
226  // assemble \int_Omega C_ijkl u_k,l v_i,j \dx
227  for (unsigned int dof_i=0; dof_i<n_var_dofs; dof_i++)
228  for (unsigned int dof_j=0; dof_j<n_var_dofs; dof_j++)
229  for (unsigned int i=0; i<3; i++)
230  for (unsigned int j=0; j<3; j++)
231  for (unsigned int k=0; k<3; k++)
232  for (unsigned int l=0; l<3; l++)
233  Ke_var[i][k](dof_i,dof_j) +=
234  JxW[qp] * elasticity_tensor(i,j,k,l) * dphi[dof_j][qp](l) * dphi[dof_i][qp](j);
235 
236  // assemble \int_Omega f_i v_i \dx
237  VectorValue<Number> f_vec(0., 0., -1.);
238  for (unsigned int dof_i=0; dof_i<n_var_dofs; dof_i++)
239  for (unsigned int i=0; i<3; i++)
240  Fe_var[i](dof_i) += JxW[qp] * (f_vec(i) * phi[dof_i][qp]);
241  }
242 
243  // assemble \int_\Gamma g_i v_i \ds
244  VectorValue<Number> g_vec(0., 0., -1.);
245  {
246  for (auto side : elem->side_index_range())
247  if (elem->neighbor_ptr(side) == nullptr)
248  {
249  const std::vector<std::vector<Real>> & phi_face = fe_face->get_phi();
250  const std::vector<Real> & JxW_face = fe_face->get_JxW();
251 
252  fe_face->reinit(elem, side);
253 
254  // Apply a traction
255  for (unsigned int qp=0; qp<qface.n_points(); qp++)
256  if (mesh.get_boundary_info().has_boundary_id(elem, side, BOUNDARY_ID_MAX_X))
257  for (unsigned int dof_i=0; dof_i<n_var_dofs; dof_i++)
258  for (unsigned int i=0; i<3; i++)
259  Fe_var[i](dof_i) += JxW_face[qp] * (g_vec(i) * phi_face[dof_i][qp]);
260  }
261  }
262 
263  dof_map.constrain_element_matrix_and_vector (Ke, Fe, dof_indices);
264 
265  matrix.add_matrix (Ke, dof_indices);
266  system.rhs->add_vector (Fe, dof_indices);
267  }
268  }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:182
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
void constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix and vector.
Definition: dof_map.h:2254
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1992
unsigned int dim
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
void resize(const unsigned int n)
Resize the vector.
Definition: dense_vector.h:374
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:2144
MeshBase & mesh
NumericVector< Number > * rhs
The system matrix.
Order default_quadrature_order() const
Definition: fe_type.h:357
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition: mesh_base.h:159
const T_sys & get_system(std::string_view name) const
This is the MeshBase class.
Definition: mesh_base.h:74
unsigned int variable_number(std::string_view var) const
Definition: system.C:1557
Defines a dense subvector for use in finite element computations.
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:169
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
Defines a dense submatrix for use in Finite Element-type computations.
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
Evaluate the fourth order tensor (C_ijkl) that relates stress to strain.
const MeshBase & get_mesh() const
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Definition: dense_matrix.h:895
This class implements specific orders of Gauss quadrature.
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
const DofMap & get_dof_map() const
Definition: system.h:2293
const SparseMatrix< Number > & get_system_matrix() const

◆ assemble() [2/2]

void LinearElasticity::assemble ( )
inlinevirtual

Assemble the system matrix and right-hand side vector.

Implements libMesh::System::Assembly.

Definition at line 237 of file systems_of_equations_ex9.C.

References libMesh::SparseMatrix< T >::add_matrix(), libMesh::NumericVector< T >::add_vector(), libMesh::FEGenericBase< OutputType >::build(), libMesh::DofMap::constrain_element_matrix_and_vector(), libMesh::FEType::default_quadrature_order(), dim, libMesh::DofMap::dof_indices(), elasticity_tensor(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), libMesh::ImplicitSystem::get_system_matrix(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::DenseVector< T >::resize(), libMesh::DenseMatrix< T >::resize(), libMesh::ExplicitSystem::rhs, libMesh::System::variable_number(), and libMesh::DofMap::variable_type().

238  {
239  const MeshBase & mesh = es.get_mesh();
240 
241  const unsigned int dim = mesh.mesh_dimension();
242 
243  LinearImplicitSystem & system = es.get_system<LinearImplicitSystem>("Elasticity");
244 
245  const unsigned int u_var = system.variable_number ("u");
246 
247  const DofMap & dof_map = system.get_dof_map();
248  FEType fe_type = dof_map.variable_type(u_var);
249  std::unique_ptr<FEBase> fe (FEBase::build(dim, fe_type));
250  QGauss qrule (dim, fe_type.default_quadrature_order());
251  fe->attach_quadrature_rule (&qrule);
252 
253  std::unique_ptr<FEBase> fe_face (FEBase::build(dim, fe_type));
254  QGauss qface(dim-1, fe_type.default_quadrature_order());
255  fe_face->attach_quadrature_rule (&qface);
256 
257  const std::vector<Real> & JxW = fe->get_JxW();
258  const std::vector<std::vector<Real>> & phi = fe->get_phi();
259  const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
260 
262  DenseSubMatrix<Number> Ke_var[3][3] =
263  {
267  };
268 
270 
271  DenseSubVector<Number> Fe_var[3] =
275 
276  std::vector<dof_id_type> dof_indices;
277  std::vector<std::vector<dof_id_type>> dof_indices_var(3);
278 
279  SparseMatrix<Number> & matrix = system.get_system_matrix();
280 
281  for (const auto & elem : mesh.active_local_element_ptr_range())
282  {
283  dof_map.dof_indices (elem, dof_indices);
284  for (unsigned int var=0; var<3; var++)
285  dof_map.dof_indices (elem, dof_indices_var[var], var);
286 
287  const unsigned int n_dofs = dof_indices.size();
288  const unsigned int n_var_dofs = dof_indices_var[0].size();
289 
290  fe->reinit (elem);
291 
292  Ke.resize (n_dofs, n_dofs);
293  for (unsigned int var_i=0; var_i<3; var_i++)
294  for (unsigned int var_j=0; var_j<3; var_j++)
295  Ke_var[var_i][var_j].reposition (var_i*n_var_dofs, var_j*n_var_dofs, n_var_dofs, n_var_dofs);
296 
297  Fe.resize (n_dofs);
298  for (unsigned int var=0; var<3; var++)
299  Fe_var[var].reposition (var*n_var_dofs, n_var_dofs);
300 
301  for (unsigned int qp=0; qp<qrule.n_points(); qp++)
302  {
303  // assemble \int_Omega C_ijkl u_k,l v_i,j \dx
304  for (unsigned int dof_i=0; dof_i<n_var_dofs; dof_i++)
305  for (unsigned int dof_j=0; dof_j<n_var_dofs; dof_j++)
306  for (unsigned int i=0; i<3; i++)
307  for (unsigned int j=0; j<3; j++)
308  for (unsigned int k=0; k<3; k++)
309  for (unsigned int l=0; l<3; l++)
310  Ke_var[i][k](dof_i,dof_j) +=
311  JxW[qp] * elasticity_tensor(i,j,k,l) * dphi[dof_j][qp](l) * dphi[dof_i][qp](j);
312 
313  // assemble \int_Omega f_i v_i \dx
314  // The mesh for this example has two subdomains with ids 1
315  // and 101, and the forcing function is different on each.
316  auto f_vec = (elem->subdomain_id() == 101 ?
317  VectorValue<Number>(1., 1., 0.) :
318  VectorValue<Number>(0.36603, 1.36603, 0.));
319 
320  for (unsigned int dof_i=0; dof_i<n_var_dofs; dof_i++)
321  for (unsigned int i=0; i<3; i++)
322  Fe_var[i](dof_i) += JxW[qp] * (f_vec(i) * phi[dof_i][qp]);
323  }
324 
325  dof_map.constrain_element_matrix_and_vector (Ke, Fe, dof_indices);
326 
327  matrix.add_matrix (Ke, dof_indices);
328  system.rhs->add_vector (Fe, dof_indices);
329  }
330  }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:182
void constrain_element_matrix_and_vector(DenseMatrix< Number > &matrix, DenseVector< Number > &rhs, std::vector< dof_id_type > &elem_dofs, bool asymmetric_constraint_rows=true) const
Constrains the element matrix and vector.
Definition: dof_map.h:2254
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1992
unsigned int dim
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
void resize(const unsigned int n)
Resize the vector.
Definition: dense_vector.h:374
virtual void add_vector(const T *v, const std::vector< numeric_index_type > &dof_indices)
Computes , where v is a pointer and each dof_indices[i] specifies where to add value v[i]...
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:2144
MeshBase & mesh
NumericVector< Number > * rhs
The system matrix.
Order default_quadrature_order() const
Definition: fe_type.h:357
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
const T_sys & get_system(std::string_view name) const
This is the MeshBase class.
Definition: mesh_base.h:74
unsigned int variable_number(std::string_view var) const
Definition: system.C:1557
Defines a dense subvector for use in finite element computations.
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:169
virtual void add_matrix(const DenseMatrix< T > &dm, const std::vector< numeric_index_type > &rows, const std::vector< numeric_index_type > &cols)=0
Add the full matrix dm to the SparseMatrix.
Defines a dense submatrix for use in Finite Element-type computations.
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
Evaluate the fourth order tensor (C_ijkl) that relates stress to strain.
const MeshBase & get_mesh() const
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
Definition: dense_matrix.h:895
This class implements specific orders of Gauss quadrature.
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
const DofMap & get_dof_map() const
Definition: system.h:2293
const SparseMatrix< Number > & get_system_matrix() const

◆ compute_stresses()

void LinearElasticity::compute_stresses ( )
inline

Definition at line 271 of file systems_of_equations_ex6.C.

References libMesh::FEGenericBase< OutputType >::build(), libMesh::DenseMatrix< T >::cholesky_solve(), libMesh::System::current_solution(), libMesh::FEType::default_quadrature_order(), dim, libMesh::DofMap::dof_indices(), elasticity_tensor(), libMesh::System::get_dof_map(), libMesh::EquationSystems::get_mesh(), libMesh::EquationSystems::get_system(), mesh, libMesh::MeshBase::mesh_dimension(), libMesh::System::n_vars(), libMesh::System::solution, std::sqrt(), libMesh::System::update(), libMesh::System::variable_number(), and libMesh::DofMap::variable_type().

Referenced by main().

272  {
273  const MeshBase & mesh = es.get_mesh();
274  const unsigned int dim = mesh.mesh_dimension();
275 
276  LinearImplicitSystem & system = es.get_system<LinearImplicitSystem>("Elasticity");
277 
278  unsigned int displacement_vars[3];
279  displacement_vars[0] = system.variable_number ("u");
280  displacement_vars[1] = system.variable_number ("v");
281  displacement_vars[2] = system.variable_number ("w");
282  const unsigned int u_var = system.variable_number ("u");
283 
284  const DofMap & dof_map = system.get_dof_map();
285  FEType fe_type = dof_map.variable_type(u_var);
286  std::unique_ptr<FEBase> fe (FEBase::build(dim, fe_type));
287  QGauss qrule (dim, fe_type.default_quadrature_order());
288  fe->attach_quadrature_rule (&qrule);
289 
290  const std::vector<Real> & JxW = fe->get_JxW();
291  const std::vector<std::vector<Real>> & phi = fe->get_phi();
292  const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
293 
294  // Also, get a reference to the ExplicitSystem
295  ExplicitSystem & stress_system = es.get_system<ExplicitSystem>("StressSystem");
296  const DofMap & stress_dof_map = stress_system.get_dof_map();
297  unsigned int sigma_vars[6];
298  sigma_vars[0] = stress_system.variable_number ("sigma_00");
299  sigma_vars[1] = stress_system.variable_number ("sigma_01");
300  sigma_vars[2] = stress_system.variable_number ("sigma_02");
301  sigma_vars[3] = stress_system.variable_number ("sigma_11");
302  sigma_vars[4] = stress_system.variable_number ("sigma_12");
303  sigma_vars[5] = stress_system.variable_number ("sigma_22");
304  unsigned int vonMises_var = stress_system.variable_number ("vonMises");
305 
306  // Storage for the stress dof indices on each element
307  std::vector<std::vector<dof_id_type>> dof_indices_var(system.n_vars());
308  std::vector<dof_id_type> stress_dof_indices_var;
309  std::vector<dof_id_type> vonmises_dof_indices_var;
310 
311  for (const auto & elem : mesh.active_local_element_ptr_range())
312  {
313  for (unsigned int var=0; var<3; var++)
314  dof_map.dof_indices (elem, dof_indices_var[var], displacement_vars[var]);
315 
316  const unsigned int n_var_dofs = dof_indices_var[0].size();
317 
318  fe->reinit (elem);
319 
320  std::vector<TensorValue<Number>> stress_tensor_qp(qrule.n_points());
321  for (unsigned int qp=0; qp<qrule.n_points(); qp++)
322  {
323  // Row is variable u1, u2, or u3, column is x, y, or z
324  TensorValue<Number> grad_u;
325  for (unsigned int var_i=0; var_i<3; var_i++)
326  for (unsigned int var_j=0; var_j<3; var_j++)
327  for (unsigned int j=0; j<n_var_dofs; j++)
328  grad_u(var_i,var_j) += dphi[j][qp](var_j) * system.current_solution(dof_indices_var[var_i][j]);
329 
330  for (unsigned int var_i=0; var_i<3; var_i++)
331  for (unsigned int var_j=0; var_j<3; var_j++)
332  for (unsigned int k=0; k<3; k++)
333  for (unsigned int l=0; l<3; l++)
334  stress_tensor_qp[qp](var_i,var_j) += elasticity_tensor(var_i,var_j,k,l) * grad_u(k,l);
335  }
336 
337  stress_dof_map.dof_indices (elem, vonmises_dof_indices_var, vonMises_var);
338  std::vector<TensorValue<Number>> elem_sigma_vec(vonmises_dof_indices_var.size());
339 
340  // Below we project each component of the stress tensor onto a L2_LAGRANGE discretization.
341  // Note that this gives a discontinuous stress plot on element boundaries, which is
342  // appropriate. We then also get the von Mises stress from the projected stress tensor.
343  unsigned int stress_var_index = 0;
344  for (unsigned int var_i=0; var_i<3; var_i++)
345  for (unsigned int var_j=var_i; var_j<3; var_j++)
346  {
347  stress_dof_map.dof_indices (elem, stress_dof_indices_var, sigma_vars[stress_var_index]);
348 
349  const unsigned int n_proj_dofs = stress_dof_indices_var.size();
350 
351  DenseMatrix<Real> Me(n_proj_dofs, n_proj_dofs);
352  for (unsigned int qp=0; qp<qrule.n_points(); qp++)
353  {
354  for(unsigned int i=0; i<n_proj_dofs; i++)
355  for(unsigned int j=0; j<n_proj_dofs; j++)
356  {
357  Me(i,j) += JxW[qp]*(phi[i][qp]*phi[j][qp]);
358  }
359  }
360 
361  DenseVector<Number> Fe(n_proj_dofs);
362  for (unsigned int qp=0; qp<qrule.n_points(); qp++)
363  for(unsigned int i=0; i<n_proj_dofs; i++)
364  {
365  Fe(i) += JxW[qp] * stress_tensor_qp[qp](var_i,var_j) * phi[i][qp];
366  }
367 
368  DenseVector<Number> projected_data;
369  Me.cholesky_solve(Fe, projected_data);
370 
371  for(unsigned int index=0; index<n_proj_dofs; index++)
372  {
373  dof_id_type dof_index = stress_dof_indices_var[index];
374  if ((stress_system.solution->first_local_index() <= dof_index) &&
375  (dof_index < stress_system.solution->last_local_index()))
376  stress_system.solution->set(dof_index, projected_data(index));
377 
378  elem_sigma_vec[index](var_i,var_j) = projected_data(index);
379  }
380 
381  stress_var_index++;
382  }
383 
384  for (std::size_t index=0; index<elem_sigma_vec.size(); index++)
385  {
386  elem_sigma_vec[index](1,0) = elem_sigma_vec[index](0,1);
387  elem_sigma_vec[index](2,0) = elem_sigma_vec[index](0,2);
388  elem_sigma_vec[index](2,1) = elem_sigma_vec[index](1,2);
389 
390  // Get the von Mises stress from the projected stress tensor
391  Number vonMises_value = std::sqrt(0.5*(Utility::pow<2>(elem_sigma_vec[index](0,0) - elem_sigma_vec[index](1,1)) +
392  Utility::pow<2>(elem_sigma_vec[index](1,1) - elem_sigma_vec[index](2,2)) +
393  Utility::pow<2>(elem_sigma_vec[index](2,2) - elem_sigma_vec[index](0,0)) +
394  6.*(Utility::pow<2>(elem_sigma_vec[index](0,1)) +
395  Utility::pow<2>(elem_sigma_vec[index](1,2)) +
396  Utility::pow<2>(elem_sigma_vec[index](2,0)))));
397 
398  dof_id_type dof_index = vonmises_dof_indices_var[index];
399 
400  if ((stress_system.solution->first_local_index() <= dof_index) &&
401  (dof_index < stress_system.solution->last_local_index()))
402  stress_system.solution->set(dof_index, vonMises_value);
403  }
404  }
405 
406  // Should call close and update when we set vector entries directly
407  stress_system.solution->close();
408  stress_system.update();
409  }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:182
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1992
unsigned int dim
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
const FEType & variable_type(const unsigned int c) const
Definition: dof_map.h:2144
MeshBase & mesh
Order default_quadrature_order() const
Definition: fe_type.h:357
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
Definition: type_vector.h:53
const T_sys & get_system(std::string_view name) const
This is the MeshBase class.
Definition: mesh_base.h:74
Number current_solution(const dof_id_type global_dof_number) const
Definition: system.C:157
unsigned int variable_number(std::string_view var) const
Definition: system.C:1557
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:169
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1573
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
Evaluate the fourth order tensor (C_ijkl) that relates stress to strain.
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition: system.C:493
const MeshBase & get_mesh() const
This class implements specific orders of Gauss quadrature.
unsigned int mesh_dimension() const
Definition: mesh_base.C:324
unsigned int n_vars() const
Definition: system.h:2349
const DofMap & get_dof_map() const
Definition: system.h:2293
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems...
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
uint8_t dof_id_type
Definition: id_types.h:67

◆ elasticity_tensor() [1/2]

Real LinearElasticity::elasticity_tensor ( unsigned int  i,
unsigned int  j,
unsigned int  k,
unsigned int  l 
)
inline

Evaluate the fourth order tensor (C_ijkl) that relates stress to strain.

Definition at line 140 of file systems_of_equations_ex6.C.

References kronecker_delta(), and libMesh::Real.

144  {
145  // Hard code material parameters for the sake of simplicity
146  const Real poisson_ratio = 0.3;
147  const Real young_modulus = 1.;
148 
149  // Define the Lame constants
150  const Real lambda_1 = (young_modulus*poisson_ratio)/((1.+poisson_ratio)*(1.-2.*poisson_ratio));
151  const Real lambda_2 = young_modulus/(2.*(1.+poisson_ratio));
152 
153  return lambda_1 * kronecker_delta(i, j) * kronecker_delta(k, l) +
154  lambda_2 * (kronecker_delta(i, k) * kronecker_delta(j, l) + kronecker_delta(i, l) * kronecker_delta(j, k));
155  }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real kronecker_delta(unsigned int i, unsigned int j)
Kronecker delta function.

◆ elasticity_tensor() [2/2]

Real LinearElasticity::elasticity_tensor ( unsigned int  i,
unsigned int  j,
unsigned int  k,
unsigned int  l 
)
inline

Evaluate the fourth order tensor (C_ijkl) that relates stress to strain.

Definition at line 217 of file systems_of_equations_ex9.C.

References kronecker_delta(), and libMesh::Real.

221  {
222  // Hard code material parameters for the sake of simplicity
223  const Real poisson_ratio = 0.3;
224  const Real young_modulus = 1.;
225 
226  // Define the Lame constants
227  const Real lambda_1 = (young_modulus*poisson_ratio)/((1.+poisson_ratio)*(1.-2.*poisson_ratio));
228  const Real lambda_2 = young_modulus/(2.*(1.+poisson_ratio));
229 
230  return lambda_1 * kronecker_delta(i, j) * kronecker_delta(k, l) +
231  lambda_2 * (kronecker_delta(i, k) * kronecker_delta(j, l) + kronecker_delta(i, l) * kronecker_delta(j, k));
232  }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real kronecker_delta(unsigned int i, unsigned int j)
Kronecker delta function.

◆ kronecker_delta() [1/2]

Real LinearElasticity::kronecker_delta ( unsigned int  i,
unsigned int  j 
)
inline

Kronecker delta function.

Definition at line 131 of file systems_of_equations_ex6.C.

133  {
134  return i == j ? 1. : 0.;
135  }

◆ kronecker_delta() [2/2]

Real LinearElasticity::kronecker_delta ( unsigned int  i,
unsigned int  j 
)
inline

Kronecker delta function.

Definition at line 208 of file systems_of_equations_ex9.C.

210  {
211  return i == j ? 1. : 0.;
212  }

Member Data Documentation

◆ es

EquationSystems & LinearElasticity::es
private

Definition at line 120 of file systems_of_equations_ex6.C.


The documentation for this class was generated from the following files: