https://mooseframework.inl.gov
DirichletBCBase.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 "DirichletBCBase.h"
11 
14 {
16  params.addParam<bool>(
17  "preset", true, "Whether or not to preset the BC (apply the value before the solve begins).");
18  return params;
19 }
20 
22  : NodalBC(parameters), _preset(getParam<bool>("preset"))
23 {
24 }
25 
26 void
28 {
29  mooseAssert(_preset, "BC is not preset");
30 
31  if (_var.isNodalDefined())
32  {
33  const dof_id_type & dof_idx = _var.nodalDofIndex();
34  current_solution.set(dof_idx, computeQpValue());
35  }
36 }
37 
38 Real
40 {
41  return _u[_qp] - computeQpValue();
42 }
void computeValue(NumericVector< Number > &current_solution)
Method to preset the nodal value if applicable.
virtual Real computeQpResidual() override
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Base class for deriving any boundary condition that works at nodes.
Definition: NodalBC.h:20
const unsigned int _qp
Pseudo-"quadrature point" index (Always zero for the current node)
Definition: NodalBC.h:44
DirichletBCBase(const InputParameters &parameters)
MooseVariable & _var
Definition: NodalBC.h:38
static InputParameters validParams()
const bool _preset
Whether or not the value is to be preset.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual bool isNodalDefined() const override
Is this variable defined at nodes.
const dof_id_type & nodalDofIndex() const override
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 void set(const numeric_index_type i, const Number value)=0
virtual Real computeQpValue()=0
Compute the value of the DirichletBC at the current quadrature point.
static InputParameters validParams()
Definition: NodalBC.C:19
const VariableValue & _u
Value of the unknown variable this BC is acting on.
Definition: NodalBC.h:47
uint8_t dof_id_type