www.mooseframework.org
GlobalStrain.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "GlobalStrain.h"
12 
13 // MOOSE includes
14 #include "Assembly.h"
15 #include "MooseVariableScalar.h"
16 #include "SystemBase.h"
17 #include "RankTwoTensor.h"
18 #include "RankFourTensor.h"
19 
20 registerMooseObject("SolidMechanicsApp", GlobalStrain);
21 
24 {
26  params.addClassDescription("Scalar Kernel to solve for the global strain");
27  params.addRequiredParam<UserObjectName>("global_strain_uo",
28  "The name of the GlobalStrainUserObject");
29 
30  return params;
31 }
32 
34  : ScalarKernel(parameters),
35  _pst(getUserObject<GlobalStrainUserObjectInterface>("global_strain_uo")),
36  _pst_residual(_pst.getResidual()),
37  _pst_jacobian(_pst.getJacobian()),
38  _periodic_dir(_pst.getPeriodicDirections()),
39  _components(_var.order()),
40  _dim(_mesh.dimension())
41 {
42  if ((_dim == 1 && _var.order() != FIRST) || (_dim == 2 && _var.order() != THIRD) ||
43  (_dim == 3 && _var.order() != SIXTH))
44  mooseError("PerdiodicStrain ScalarKernel is only compatible with scalar variables of order "
45  "FIRST in 1D, THIRD in 2D, and SIXTH in 3D. Please change the order of the scalar"
46  "variable according to the mesh dimension.");
47 
49 }
50 
51 void
53 {
55  for (_i = 0; _i < _local_re.size(); ++_i)
56  {
57  if (_periodic_dir(_components[_i].first) || _periodic_dir(_components[_i].second))
58  _local_re(_i) += _pst_residual(_components[_i].first, _components[_i].second);
59  }
61 }
62 
63 void
65 {
67  for (_i = 0; _i < _local_ke.m(); ++_i)
68  for (_j = 0; _j < _local_ke.m(); ++_j)
69  // periodic direction check is not done for jacobian calculations to avoid zero pivot error
71  _components[_i].second,
72  _components[_j].first,
73  _components[_j].second);
75 }
76 
77 void
79 {
80  switch (order)
81  {
82  case 1:
83  _components[0].first = 0;
84  _components[0].second = 0;
85  break;
86 
87  case 3:
88  _components[0].first = 0;
89  _components[0].second = 0;
90  _components[1].first = 1;
91  _components[1].second = 1;
92  _components[2].first = 0;
93  _components[2].second = 1;
94  break;
95 
96  case 6:
97  _components[0].first = 0;
98  _components[0].second = 0;
99  _components[1].first = 1;
100  _components[1].second = 1;
101  _components[2].first = 2;
102  _components[2].second = 2;
103  _components[3].first = 1;
104  _components[3].second = 2;
105  _components[4].first = 0;
106  _components[4].second = 2;
107  _components[5].first = 0;
108  _components[5].second = 1;
109  break;
110 
111  default:
112  mooseError("PerdiodicStrain ScalarKernel is only compatible with FIRST, THIRD, and SIXTH "
113  "order scalar variables.");
114  }
115 }
SIXTH
Order
void accumulateTaggedLocalResidual()
GlobalStrain(const InputParameters &parameters)
Definition: GlobalStrain.C:33
unsigned int _i
unsigned int number() const
const RankTwoTensor & _pst_residual
Definition: GlobalStrain.h:37
FIRST
const RankFourTensor & _pst_jacobian
Definition: GlobalStrain.h:38
MooseVariableScalar & _var
unsigned int m() const
const unsigned int _dim
Definition: GlobalStrain.h:42
DenseMatrix< Number > _local_ke
void addRequiredParam(const std::string &name, const std::string &doc_string)
std::vector< std::pair< unsigned int, unsigned int > > _components
Definition: GlobalStrain.h:41
const VectorValue< bool > & _periodic_dir
Definition: GlobalStrain.h:39
registerMooseObject("SolidMechanicsApp", GlobalStrain)
void accumulateTaggedLocalMatrix()
Assembly & _assembly
Order order() const
virtual void computeJacobian() override
Definition: GlobalStrain.C:64
This class provides interface for extracting the periodic directions, residual, and jacobian values f...
virtual void assignComponentIndices(Order var_order)
Definition: GlobalStrain.C:78
DenseVector< Number > _local_re
void mooseError(Args &&... args) const
virtual unsigned int size() const override final
static InputParameters validParams()
Definition: GlobalStrain.C:23
void addClassDescription(const std::string &doc_string)
virtual void computeResidual() override
Definition: GlobalStrain.C:52
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
static InputParameters validParams()
unsigned int _j
THIRD