https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodalEqualValueConstraint.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
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
34void
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
45void
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}
registerMooseObject("MooseApp", NodalEqualValueConstraint)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
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.
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 ...
Definition MooseBase.h:457
unsigned int number() const
Get variable number coming from libMesh.
Constraint to enforce equal values (in 1D)
const std::vector< unsigned int > _val_number
const std::vector< const VariableValue * > _value
static InputParameters validParams()
virtual void computeResidual() override
Compute this object's contribution to the residual.
virtual void computeJacobian() override
Compute this object's contribution to the diagonal Jacobian entries.
NodalEqualValueConstraint(const InputParameters &parameters)
static InputParameters validParams()
std::vector< dof_id_type > _node_ids
List of node IDs.
Assembly & _assembly
Reference to this Kernel's assembly object.
MooseVariableScalar & _var
Scalar variable.
DenseMatrix< Number > _local_ke
Holds local Jacobian entries as they are accumulated by this Kernel.
void prepareMatrixTag(Assembly &assembly, unsigned int ivar, unsigned int jvar)
Prepare data for computing element jacobian according to the active tags.
void prepareVectorTag(Assembly &assembly, unsigned int ivar)
Prepare data for computing element residual according to active tags.
void assignTaggedLocalResidual()
Local residual blocks will assigned as the current local kernel residual.
DenseVector< Number > _local_re
Holds local residual entries as they are accumulated by this Kernel.
void assignTaggedLocalMatrix()
Local Jacobian blocks will assigned as the current local kernel Jacobian.
unsigned int n() const
unsigned int m() const