https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
15template <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
28template <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
38template <>
41{
42 return _u_coeff * _u - _v_coeff * _v[_qp];
43}
44
45template <>
48{
49 return _u_coeff * _u[_qp] - _v_coeff * _v[_qp];
50}
51
52template <bool is_ad>
53Real
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
67template class MatchedValueBCTempl<false>;
68template class MatchedValueBCTempl<true>;
registerMooseObject("MooseApp", MatchedValueBC)
Moose::GenericType< Real, is_ad > GenericReal
Definition MooseTypes.h:698
static InputParameters validParams()
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 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.
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.
Implements a simple coupled boundary condition where u=v on the boundary.
static InputParameters validParams()
MatchedValueBCTempl(const InputParameters &parameters)
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
This is the virtual that derived classes should override for computing an off-diagonal jacobian compo...
virtual GenericReal< is_ad > computeQpResidual() override