https://mooseframework.inl.gov
GlobalStrain.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 "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 using namespace libMesh;
21 
22 registerMooseObject("SolidMechanicsApp", GlobalStrain);
23 
26 {
28  params.addClassDescription("Scalar Kernel to solve for the global strain");
29  params.addRequiredParam<UserObjectName>("global_strain_uo",
30  "The name of the GlobalStrainUserObject");
31 
32  return params;
33 }
34 
36  : ScalarKernel(parameters),
37  _pst(getUserObject<GlobalStrainUserObjectInterface>("global_strain_uo")),
38  _pst_residual(_pst.getResidual()),
39  _pst_jacobian(_pst.getJacobian()),
40  _periodic_dir(_pst.getPeriodicDirections()),
41  _components(_var.order()),
42  _dim(_mesh.dimension())
43 {
44  if ((_dim == 1 && _var.order() != FIRST) || (_dim == 2 && _var.order() != THIRD) ||
45  (_dim == 3 && _var.order() != SIXTH))
46  mooseError("PerdiodicStrain ScalarKernel is only compatible with scalar variables of order "
47  "FIRST in 1D, THIRD in 2D, and SIXTH in 3D. Please change the order of the scalar"
48  "variable according to the mesh dimension.");
49 
51 }
52 
53 void
55 {
57  for (_i = 0; _i < _local_re.size(); ++_i)
58  {
59  if (_periodic_dir(_components[_i].first) || _periodic_dir(_components[_i].second))
60  _local_re(_i) += _pst_residual(_components[_i].first, _components[_i].second);
61  }
63 }
64 
65 void
67 {
69  for (_i = 0; _i < _local_ke.m(); ++_i)
70  for (_j = 0; _j < _local_ke.m(); ++_j)
71  // periodic direction check is not done for jacobian calculations to avoid zero pivot error
73  _components[_i].second,
74  _components[_j].first,
75  _components[_j].second);
77 }
78 
79 void
81 {
82  switch (order)
83  {
84  case 1:
85  _components[0].first = 0;
86  _components[0].second = 0;
87  break;
88 
89  case 3:
90  _components[0].first = 0;
91  _components[0].second = 0;
92  _components[1].first = 1;
93  _components[1].second = 1;
94  _components[2].first = 0;
95  _components[2].second = 1;
96  break;
97 
98  case 6:
99  _components[0].first = 0;
100  _components[0].second = 0;
101  _components[1].first = 1;
102  _components[1].second = 1;
103  _components[2].first = 2;
104  _components[2].second = 2;
105  _components[3].first = 1;
106  _components[3].second = 2;
107  _components[4].first = 0;
108  _components[4].second = 2;
109  _components[5].first = 0;
110  _components[5].second = 1;
111  break;
112 
113  default:
114  mooseError("PerdiodicStrain ScalarKernel is only compatible with FIRST, THIRD, and SIXTH "
115  "order scalar variables.");
116  }
117 }
SIXTH
Order
void accumulateTaggedLocalResidual()
GlobalStrain(const InputParameters &parameters)
Definition: GlobalStrain.C:35
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
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
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
libMesh::Order order() const
virtual void computeJacobian() override
Definition: GlobalStrain.C:66
This class provides interface for extracting the periodic directions, residual, and jacobian values f...
virtual void assignComponentIndices(Order var_order)
Definition: GlobalStrain.C:80
DenseVector< Number > _local_re
void mooseError(Args &&... args) const
virtual unsigned int size() const override final
static InputParameters validParams()
Definition: GlobalStrain.C:25
void addClassDescription(const std::string &doc_string)
virtual void computeResidual() override
Definition: GlobalStrain.C:54
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
static InputParameters validParams()
unsigned int _j
THIRD