https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
20registerMooseObject("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
51void
62
63void
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
77void
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}
registerMooseObject("SolidMechanicsApp", GlobalStrain)
This class provides interface for extracting the periodic directions, residual, and jacobian values f...
virtual void computeResidual() override
GlobalStrain(const InputParameters &parameters)
static InputParameters validParams()
virtual void computeJacobian() override
const RankFourTensor & _pst_jacobian
std::vector< std::pair< unsigned int, unsigned int > > _components
virtual void assignComponentIndices(Order var_order)
const VectorValue< bool > & _periodic_dir
const RankTwoTensor & _pst_residual
const unsigned int _dim
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
libMesh::Order order() const
unsigned int number() const
Assembly & _assembly
unsigned int _i
MooseVariableScalar & _var
unsigned int _j
static InputParameters validParams()
DenseMatrix< Number > _local_ke
void accumulateTaggedLocalMatrix()
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
void accumulateTaggedLocalResidual()
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
DenseVector< Number > _local_re
unsigned int m() const
virtual unsigned int size() const override final