https://mooseframework.inl.gov
MatchedValueBC.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 "MatchedValueBC.h"
11 
14 
15 template <bool is_ad>
18 {
20  params.addRequiredCoupledVar("v", "The variable whose value we are to match.");
21  params.addParam<Real>("u_coeff", 1.0, " A coefficient for primary variable u");
22  params.addParam<Real>("v_coeff", 1.0, " A coefficient for coupled variable v");
23  params.addClassDescription("Implements a NodalBC which equates two different Variables' values "
24  "on a specified boundary.");
25  return params;
26 }
27 
28 template <bool is_ad>
30  : GenericNodalBC<is_ad>(parameters),
31  _v(this->template coupledGenericValue<is_ad>("v")),
32  _v_num(coupled("v")),
33  _u_coeff(this->template getParam<Real>("u_coeff")),
34  _v_coeff(this->template getParam<Real>("v_coeff"))
35 {
36 }
37 
38 template <>
41 {
42  return _u_coeff * _u - _v_coeff * _v[_qp];
43 }
44 
45 template <>
48 {
49  return _u_coeff * _u[_qp] - _v_coeff * _v[_qp];
50 }
51 
52 template <bool is_ad>
53 Real
55 {
56  // For the AD version, we do not need this implementation since AD will
57  // automatically compute derivatives. In other words, this function will
58  // never be called for the AD version. But we can not eliminate this function
59  // for the AD because C++ does not support an optional function declaration based
60  // on a template parameter.
61  if (jvar == _v_num)
62  return -_v_coeff;
63  else
64  return 0.;
65 }
66 
67 template class MatchedValueBCTempl<false>;
68 template class MatchedValueBCTempl<true>;
Moose::GenericType< Real, is_ad > GenericReal
Definition: MooseTypes.h:648
static InputParameters validParams()
registerMooseObject("MooseApp", MatchedValueBC)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
virtual GenericReal< is_ad > computeQpResidual() override
MatchedValueBCTempl(const InputParameters &parameters)
void addRequiredCoupledVar(const std::string &name, const std::string &doc_string)
This method adds a coupled variable name pair.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Implements a simple coupled boundary condition where u=v on the boundary.
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 addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
This is the virtual that derived classes should override for computing an off-diagonal jacobian compo...