Line data Source code
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 : #pragma once 11 : 12 : // MOOSE includes 13 : #include "Constraint.h" 14 : #include "NeighborCoupleableMooseVariableDependencyIntermediateInterface.h" 15 : 16 : class NodalConstraint : public Constraint, 17 : public NeighborCoupleableMooseVariableDependencyIntermediateInterface, 18 : public NeighborMooseVariableInterface<Real> 19 : { 20 : public: 21 : static InputParameters validParams(); 22 : 23 : NodalConstraint(const InputParameters & parameters); 24 : 25 : /** 26 : * Get the list of primary nodes 27 : * @return list of primary nodes IDs 28 : */ 29 796 : std::vector<dof_id_type> & getPrimaryNodeId() { return _primary_node_vector; } 30 : 31 : /** 32 : * Get the list of connected secondary nodes 33 : * @return list of secondary node IDs 34 : */ 35 796 : std::vector<dof_id_type> & getSecondaryNodeId() { return _connected_nodes; } 36 : 37 : /** 38 : * Built the connectivity for this constraint 39 : */ 40 : virtual void updateConnectivity(); 41 : 42 : /** 43 : * Computes the nodal residual. 44 : */ 45 0 : virtual void computeResidual() override final 46 : { 47 0 : mooseError("NodalConstraint do not need computeResidual()"); 48 : } 49 : virtual void computeResidual(NumericVector<Number> & residual); 50 : 51 : /** 52 : * Computes the jacobian for the current element. 53 : */ 54 0 : virtual void computeJacobian() override final 55 : { 56 0 : mooseError("NodalConstraint do not need computeJacobian()"); 57 : } 58 : virtual void computeJacobian(SparseMatrix<Number> & jacobian); 59 : 60 : /** 61 : * The variable number that this object operates on. 62 : */ 63 0 : const MooseVariable & variable() const override { return _var; } 64 : 65 : protected: 66 : /** 67 : * This is the virtual that derived classes should override for computing the residual on 68 : * neighboring element. 69 : */ 70 : virtual Real computeQpResidual(Moose::ConstraintType type) = 0; 71 : 72 : /** 73 : * This is the virtual that derived classes should override for computing the Jacobian on 74 : * neighboring element. 75 : */ 76 : virtual Real computeQpJacobian(Moose::ConstraintJacobianType type) = 0; 77 : 78 : MooseVariable & _var; 79 : 80 : MooseVariable & _var_secondary; 81 : 82 : /// Value of the unknown variable this BC is action on 83 : const VariableValue & _u_secondary; 84 : /// node IDs connected to the primary node (secondary nodes) 85 : std::vector<dof_id_type> _connected_nodes; 86 : /// node IDs of the primary node 87 : std::vector<dof_id_type> _primary_node_vector; 88 : /// Holds the current solution at the current quadrature point 89 : const VariableValue & _u_primary; 90 : /// Specifies formulation type used to apply constraints 91 : Moose::ConstraintFormulationType _formulation; 92 : /** 93 : * When the secondary node is constrained to move as a linear combination of the primary nodes, 94 : * the coefficients associated with each primary node is stored in _weights. 95 : */ 96 : std::vector<Real> _weights; 97 : /// Counter for primary and secondary nodes 98 : unsigned int _i; 99 : unsigned int _j; 100 : };