https://mooseframework.inl.gov
MassFreeConstraint.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 "MassFreeConstraint.h"
11 #include "Assembly.h"
12 #include "SystemBase.h"
13 #include "MooseVariable.h"
14 
15 registerMooseObject("ThermalHydraulicsApp", MassFreeConstraint);
16 
19 {
21  params.addRequiredParam<std::vector<Real>>("normals", "node normals");
22  params.addRequiredParam<std::vector<dof_id_type>>("nodes", "node IDs");
23  params.addRequiredCoupledVar("rhouA", "Momentum");
24  params.addClassDescription(
25  "Constrains the momentum at the user-specified nodes along the user-specified normals");
26  return params;
27 }
28 
30  : NodalConstraint(parameters),
31  _normals(getParam<std::vector<Real>>("normals")),
32  _rhouA(coupledValue("rhouA")),
33  _rhouA_var_number(coupled("rhouA"))
34 {
35  _primary_node_vector = getParam<std::vector<dof_id_type>>("nodes");
36  // just a dummy value that is never used
37  _connected_nodes.push_back(*_primary_node_vector.begin());
38 }
39 
40 void
42 {
43  const auto & dofs = _var.dofIndices();
44  std::vector<Number> re(dofs.size());
45 
46  for (unsigned int i = 0; i < dofs.size(); i++)
47  re[i] = _rhouA[i] * _normals[i];
48 
50 }
51 
53 
54 void
56 {
57  const auto & dofs = _var.dofIndices();
58 
59  // off-diag
60  {
62  auto && dofs_rhouA = var_rhouA.dofIndices();
63  DenseMatrix<Number> Kee(dofs.size(), dofs_rhouA.size());
64 
65  Kee.zero();
66  for (unsigned int i = 0; i < dofs.size(); i++)
67  Kee(i, i) = _normals[i];
68  addJacobian(_assembly, Kee, dofs, dofs_rhouA, _var.scalingFactor());
69  }
70 }
71 
ConstraintType
virtual void zero() override final
void addResiduals(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
unsigned int _rhouA_var_number
Free BC for the mass equation.
virtual void computeResidual() override final
registerMooseObject("ThermalHydraulicsApp", MassFreeConstraint)
THREAD_ID _tid
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
SystemBase & _sys
std::vector< dof_id_type > _primary_node_vector
void addJacobian(Assembly &assembly, const Residuals &residuals, const Indices &dof_indices, Real scaling_factor)
virtual Real computeQpResidual(Moose::ConstraintType type) override
const std::vector< dof_id_type > & dofIndices() const final
std::vector< dof_id_type > _connected_nodes
virtual Real computeQpJacobian(Moose::ConstraintJacobianType type) override
Assembly & _assembly
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
const VariableValue & _rhouA
virtual void computeJacobian() override final
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseVariableFE< T > & getFieldVariable(THREAD_ID tid, const std::string &var_name)
ConstraintJacobianType
MassFreeConstraint(const InputParameters &parameters)
void addClassDescription(const std::string &doc_string)
std::vector< Real > _normals
static InputParameters validParams()
void scalingFactor(const std::vector< Real > &factor)
MooseVariable & _var