https://mooseframework.inl.gov
IntegratedBCBase.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 "IntegratedBCBase.h"
11 #include "Assembly.h"
12 
15 {
18 
19  params.addParam<std::vector<AuxVariableName>>(
20  "save_in",
21  {},
22  "The name of auxiliary variables to save this BC's residual contributions to. "
23  "Everything about that variable must match everything about this variable (the "
24  "type, what blocks it's on, etc.)");
25  params.addParam<std::vector<AuxVariableName>>(
26  "diag_save_in",
27  {},
28  "The name of auxiliary variables to save this BC's diagonal jacobian "
29  "contributions to. Everything about that variable must match everything "
30  "about this variable (the type, what blocks it's on, etc.)");
31 
32  params.addParamNamesToGroup("diag_save_in save_in", "Advanced");
33 
34  params.addParam<bool>(
35  "skip_execution_outside_variable_domain",
36  false,
37  "Whether to skip execution of this boundary condition when the variable it "
38  "applies to is not defined on the boundary. This can facilitate setups with "
39  "moving variable domains and fixed boundaries. Note that the FEProblem boundary-restricted "
40  "integrity checks will also need to be turned off if using this option");
41  params.addParamNamesToGroup("skip_execution_outside_variable_domain", "Advanced");
42 
43  // Integrated BCs always rely on Boundary MaterialData
44  params.set<Moose::MaterialDataType>("_material_data_type") = Moose::BOUNDARY_MATERIAL_DATA;
45 
46  return params;
47 }
48 
50  : BoundaryCondition(parameters, false), // False is because this is NOT nodal
52  MaterialPropertyInterface(this, Moose::EMPTY_BLOCK_IDS, boundaryIDs()),
53  _current_elem(_assembly.elem()),
54  _current_elem_volume(_assembly.elemVolume()),
55  _current_side(_assembly.side()),
56  _current_side_elem(_assembly.sideElem()),
57  _current_side_volume(_assembly.sideElemVolume()),
58  _current_boundary_id(_assembly.currentBoundaryID()),
59  _qrule(_assembly.qRuleFace()),
60  _q_point(_assembly.qPointsFace()),
61  _JxW(_assembly.JxWFace()),
62  _coord(_assembly.coordTransformation()),
63  _save_in_strings(parameters.get<std::vector<AuxVariableName>>("save_in")),
64  _diag_save_in_strings(parameters.get<std::vector<AuxVariableName>>("diag_save_in")),
65  _skip_execution_outside_variable_domain(
66  getParam<bool>("skip_execution_outside_variable_domain"))
67 {
68 }
69 
70 void
71 IntegratedBCBase::prepareShapes(const unsigned int var_num)
72 {
74 }
75 
76 bool
78 {
79 #ifdef DEBUG
80  const bool check_subdomain = true;
81 #else
82  const bool check_subdomain = false;
83 #endif
84  if (_skip_execution_outside_variable_domain || check_subdomain)
85  {
86  mooseAssert(_current_elem, "Should have a current element");
87  const auto block_id = _current_elem->subdomain_id();
88 #ifdef DEBUG
89  if (!_skip_execution_outside_variable_domain && !variable().hasBlocks(block_id))
90  mooseError("This boundary condition is being executed outside the domain of "
91  "definition of its variable, on subdomain: ",
92  block_id);
93 #endif
94  if (!variable().hasBlocks(block_id))
95  return false;
96  }
97  return true;
98 }
const Elem *const & _current_elem
current element
T * get(const std::unique_ptr< T > &u)
The MooseUtils::get() specializations are used to support making forwards-compatible code changes fro...
Definition: MooseUtils.h:1155
MaterialDataType
MaterialData types.
Definition: MooseTypes.h:692
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
IntegratedBCBase(const InputParameters &parameters)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
THREAD_ID _tid
The thread ID for this kernel.
const bool _skip_execution_outside_variable_domain
Whether to allow skipping the execution of the boundary condition outside of its domain of definition...
SubProblem & _subproblem
Reference to this kernel&#39;s SubProblem.
void prepareShapes(unsigned int var_num) override final
Prepare shape functions.
virtual bool shouldApply() const override
Hook for turning the boundary condition on and off.
Base class for creating new types of boundary conditions.
const std::set< SubdomainID > EMPTY_BLOCK_IDS
Definition: MooseTypes.h:684
An interface for accessing Materials.
Intermediate base class that ties together all the interfaces for getting MooseVariableFEBases with t...
static InputParameters validParams()
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:267
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 const MooseVariableBase & variable() const =0
Returns the variable that this object operates on.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
static InputParameters validParams()
virtual void prepareFaceShapes(unsigned int var, const THREAD_ID tid)=0
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...