https://mooseframework.inl.gov
MomentBalancing.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "MomentBalancing.h"
11 
12 // MOOSE includes
13 #include "ElasticityTensorTools.h"
14 #include "Material.h"
15 #include "MooseVariable.h"
16 #include "PermutationTensor.h"
17 #include "RankFourTensor.h"
18 #include "RankTwoTensor.h"
19 
20 registerMooseObject("SolidMechanicsApp", MomentBalancing);
21 
24 {
26  params.addClassDescription("Balance of momentum for three-dimensional Cosserat media, notably in "
27  "a Cosserat layered elasticity model.");
28  params.addRequiredRangeCheckedParam<unsigned int>(
29  "component",
30  "component<3",
31  "An integer corresponding to the direction the variable this "
32  "kernel acts in. (0 for x, 1 for y, 2 for z)");
33  params.addParam<std::string>(
34  "appended_property_name", "", "Name appended to material properties to make them unique");
35  params.addRequiredCoupledVar("Cosserat_rotations", "The 3 Cosserat rotation variables");
36  params.addRequiredCoupledVar("displacements", "The 3 displacement variables");
37  params.set<bool>("use_displaced_mesh") = false;
38 
39  return params;
40 }
41 
43  : Kernel(parameters),
44  _stress(getMaterialProperty<RankTwoTensor>("stress" +
45  getParam<std::string>("appended_property_name"))),
46  _Jacobian_mult(getMaterialProperty<RankFourTensor>(
47  "Jacobian_mult" + getParam<std::string>("appended_property_name"))),
48  _component(getParam<unsigned int>("component")),
49  _nrots(coupledComponents("Cosserat_rotations")),
50  _wc_var(_nrots),
51  _ndisp(coupledComponents("displacements")),
52  _disp_var(_ndisp)
53 {
54  if (_nrots != 3)
55  mooseError("MomentBalancing: This Kernel is only defined for 3-dimensional simulations so 3 "
56  "Cosserat rotation variables are needed");
57  for (unsigned i = 0; i < _nrots; ++i)
58  _wc_var[i] = coupled("Cosserat_rotations", i);
59 
60  if (_ndisp != 3)
61  mooseError("MomentBalancing: This Kernel is only defined for 3-dimensional simulations so 3 "
62  "displacement variables are needed");
63  for (unsigned i = 0; i < _ndisp; ++i)
64  _disp_var[i] = coupled("displacements", i);
65 
66  // Following check is necessary to ensure the correct Jacobian is calculated
67  if (_wc_var[_component] != _var.number())
68  mooseError("MomentBalancing: The variable for this Kernel must be equal to the Cosserat "
69  "rotation variable defined by the \"component\" and the \"Cosserat_rotations\" "
70  "parameters");
71 }
72 
73 Real
75 {
76  Real the_sum = 0.0;
77  for (const auto j : make_range(Moose::dim))
78  for (const auto k : make_range(Moose::dim))
79  the_sum += PermutationTensor::eps(_component, j, k) * _stress[_qp](j, k);
80  return _test[_i][_qp] * the_sum;
81 }
82 
83 Real
85 {
88 }
89 
90 Real
92 {
93  // What does 2D look like here?
94  for (unsigned v = 0; v < _ndisp; ++v)
95  if (jvar == _disp_var[v])
98 
99  // What does 2D look like here?
100  for (unsigned v = 0; v < _nrots; ++v)
101  if (jvar == _wc_var[v])
104 
105  return 0.0;
106 }
int eps(unsigned int i, unsigned int j)
virtual unsigned int coupled(const std::string &var_name, unsigned int comp=0) const
void addRequiredRangeCheckedParam(const std::string &name, const std::string &parsed_function, const std::string &doc_string)
static InputParameters validParams()
std::vector< unsigned int > _disp_var
the moose variable numbers for the displacements
std::vector< unsigned int > _wc_var
the moose variable numbers for the Cosserat rotation degrees of freedom
MooseVariable & _var
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
Real momentJacobianWC(const RankFourTensor &r4t, unsigned int i, unsigned int k, Real test, Real phi)
This is used for the moment-balancing kernel eps_ijk*stress_jk*test, when varied wrt w_k (the cossera...
unsigned int number() const
const MaterialProperty< RankTwoTensor > & _stress
the stress tensor (not the moment stress) at the quad-point.
const VariablePhiGradient & _grad_phi
const unsigned int _nrots
T & set(const std::string &name, bool quiet_mode=false)
static constexpr std::size_t dim
This Kernel computes epsilon_ijk * stress_jk (sum over j and k) "i" is called _component in this clas...
const VariableTestValue & _test
const MaterialProperty< RankFourTensor > & _Jacobian_mult
d(stress tensor)/(d strain tensor) Here strain_ij = grad_j disp_i + epsilon_ijk * wc_k ...
virtual Real computeQpResidual()
unsigned int _i
Real momentJacobian(const RankFourTensor &r4t, unsigned int i, unsigned int k, Real test, const RealGradient &grad_phi)
This is used for the moment-balancing kernel eps_ijk*stress_jk*test, when varied wrt u_k Jacobian ent...
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _j
const unsigned int _ndisp
virtual Real computeQpJacobian()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const VariablePhiValue & _phi
MomentBalancing(const InputParameters &parameters)
const unsigned int _component
The Kernel computes epsilon_{component j k}*stress_{j k}.
static const std::string k
Definition: NS.h:130
void ErrorVector unsigned int
virtual Real computeQpOffDiagJacobian(unsigned int jvar)
unsigned int _qp
registerMooseObject("SolidMechanicsApp", MomentBalancing)