https://mooseframework.inl.gov
HomogenizationConstraintScalarKernel.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 //* This file is part of the MOOSE framework
11 //* https://mooseframework.inl.gov
12 //*
13 //* All rights reserved, see COPYRIGHT for full restrictions
14 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
15 //*
16 //* Licensed under LGPL 2.1, please see LICENSE for details
17 //* https://www.gnu.org/licenses/lgpl-2.1.html
18 
20 
21 // MOOSE includes
22 #include "Assembly.h"
23 #include "MooseVariableScalar.h"
24 #include "Function.h"
25 
27 
30 {
32  params.addClassDescription("Calculate the scalar equation residual and Jacobian associated with "
33  "the homogenization constraint.");
34  params.addRequiredParam<UserObjectName>("homogenization_constraint",
35  "The UserObject defining the homogenization constraint");
36 
37  return params;
38 }
39 
41  const InputParameters & parameters)
42  : ScalarKernel(parameters),
43  _constraint(getUserObject<HomogenizationConstraint>("homogenization_constraint")),
44  _residual(_constraint.getResidual()),
45  _jacobian(_constraint.getJacobian()),
46  _cmap(_constraint.getConstraintMap())
47 {
48  if (_var.order() != _cmap.size())
49  mooseError("Homogenization kernel requires a variable of order ", _cmap.size());
50 }
51 
52 void
54 {
55 }
56 
57 void
59 {
61  _i = 0;
62  for (auto && indices : _cmap)
63  {
64  auto && [i, j] = indices.first;
65  _local_re(_i++) += _residual(i, j);
66  }
68 }
69 
70 void
72 {
74  _i = 0;
75  for (auto && indices1 : _cmap)
76  {
77  auto && [i, j] = indices1.first;
78  _j = 0;
79  for (auto && indices2 : _cmap)
80  {
81  auto && [a, b] = indices2.first;
82  _local_ke(_i, _j++) += _jacobian(i, j, a, b);
83  }
84  _i++;
85  }
87 }
const RankFourTensor & _jacobian
The actual tensor jacobian, from the user object.
const RankTwoTensor & _residual
The actual tensor residual, from the user object.
const Homogenization::ConstraintMap & _cmap
The constraint map.
void accumulateTaggedLocalResidual()
unsigned int _i
unsigned int number() const
MooseVariableScalar & _var
DenseMatrix< Number > _local_ke
void addRequiredParam(const std::string &name, const std::string &doc_string)
Computes ${V}(X_{ij}-{X}_{ij})dV$.
virtual void computeJacobian()
Copies the on-diagonal Jacobian from the user object.
void accumulateTaggedLocalMatrix()
Assembly & _assembly
libMesh::Order order() const
registerMooseObject("SolidMechanicsApp", HomogenizationConstraintScalarKernel)
HomogenizationConstraintScalarKernel(const InputParameters &parameters)
DenseVector< Number > _local_re
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
static InputParameters validParams()
virtual void computeResidual()
Copies the residual from the user object.
unsigned int _j