www.mooseframework.org
NodalEqualValueConstraint.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 
11 
12 // MOOSE includes
13 #include "Assembly.h"
14 #include "MooseVariableScalar.h"
15 
17 
20 {
22  params.addClassDescription("Constrain two nodes to have identical values.");
23  params.addRequiredCoupledVar("var", "Variable(s) to put the constraint on");
24  return params;
25 }
26 
28  : NodalScalarKernel(parameters), _val_number(coupledIndices("var")), _value(coupledValues("var"))
29 {
30  if (_node_ids.size() != 2)
31  paramError("boundary", "invalid number of nodes: want 2, got ", _node_ids.size());
32 }
33 
34 void
36 {
38 
39  for (unsigned int k = 0; k < _value.size(); k++)
40  _local_re(k) = (*_value[k])[0] - (*_value[k])[1];
41 
43 }
44 
45 void
47 {
49 
50  // put zeroes on the diagonal (we have to do it, otherwise PETSc will complain!)
51  for (unsigned int i = 0; i < _local_ke.m(); i++)
52  for (unsigned int j = 0; j < _local_ke.n(); j++)
53  _local_ke(i, j) = 0.;
54 
56 
57  for (unsigned int k = 0; k < _value.size(); k++)
58  {
60 
61  _local_ke(k, 0) = 1.;
62  _local_ke(k, 1) = -1.;
63 
65  }
66 }
virtual void computeJacobian() override
Compute this object&#39;s contribution to the diagonal Jacobian entries.
unsigned int number() const
Get variable number coming from libMesh.
void assignTaggedLocalMatrix()
Local Jacobian blocks will assigned as the current local kernel Jacobian.
static InputParameters validParams()
void assignTaggedLocalResidual()
Local residual blocks will assigned as the current local kernel residual.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const std::vector< unsigned int > _val_number
MooseVariableScalar & _var
Scalar variable.
unsigned int m() const
registerMooseObject("MooseApp", NodalEqualValueConstraint)
DenseMatrix< Number > _local_ke
Holds local Jacobian entries as they are accumulated by this Kernel.
static InputParameters validParams()
NodalEqualValueConstraint(const InputParameters &parameters)
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
virtual void computeResidual() override
Compute this object&#39;s contribution to the residual.
Assembly & _assembly
Reference to this Kernel&#39;s assembly object.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
Constraint to enforce equal values (in 1D)
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
std::vector< dof_id_type > _node_ids
List of node IDs.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
unsigned int n() const
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
Prepare data for computing element jacobian according to the active tags.
const std::vector< const VariableValue * > _value