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
20using namespace libMesh;
21
22registerMooseObject("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
53void
64
65void
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
79void
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}
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
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...