https://mooseframework.inl.gov
DirectionalFluxBC.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 "DirectionalFluxBC.h"
12 
13 registerMooseObject("HeatTransferApp", DirectionalFluxBC);
14 
17 {
19  params.addClassDescription(
20  "Applies a directional flux multiplied by the surface normal vector. "
21  "Can utilize the self shadowing calculation from a SelfShadowSideUserObject.");
22  params.addRequiredParam<RealVectorValue>("illumination_flux",
23  "Radiation direction and magnitude vector");
24  params.addParam<UserObjectName>(
25  "self_shadow_uo",
26  "SelfShadowSideUserObject that calculates the illumination state of a side set");
27  params.set<FunctionName>("function") = "1";
28  return params;
29 }
30 
32  : FunctionNeumannBC(parameters),
33  _direction(getParam<RealVectorValue>("illumination_flux")),
34  _self_shadow(isParamValid("self_shadow_uo")
35  ? &getUserObject<SelfShadowSideUserObject>("self_shadow_uo")
36  : nullptr)
37 {
38  if (_self_shadow && _self_shadow->useDisplacedMesh() != getParam<bool>("use_displaced_mesh"))
39  paramWarning("use_displaced_mesh",
40  "The SelfShadowSideUserObject should operate on the same mesh (displaced or "
41  "undisplaced) as this BC.");
42 }
43 
44 void
46 {
47  if (_self_shadow)
48  {
51  }
52  else
53  // all bits set
54  _illumination = ~0u;
55 }
56 
57 Real
59 {
60  auto projected_flux = -_direction * _normals[_qp];
61  if (projected_flux > 0)
62  {
63  // tests if the bit at position _qp is set
64  if (_illumination & (1 << _qp))
65  return FunctionNeumannBC::computeQpResidual() * projected_flux;
66  }
67  return 0.0;
68 }
Boundary condition to apply a directional flux multiplied by the surface normal vector.
unsigned int _illumination
Illumination state (bitmask)
static InputParameters validParams()
const MooseArray< Point > & _normals
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
unsigned int illumination(const SideIDType &id) const
const Elem *const & _current_elem
virtual Real computeQpResidual() override
T & set(const std::string &name, bool quiet_mode=false)
bool useDisplacedMesh() const
API to chek if the UO runs on the displaced mesh.
Given a radiation direction vector this user object computes the illumination state of each side QP o...
void addRequiredParam(const std::string &name, const std::string &doc_string)
unsigned int _qp
const SelfShadowSideUserObject *const _self_shadow
Self shadow illumination calculation user object.
std::pair< dof_id_type, unsigned int > SideIDType
registerMooseObject("HeatTransferApp", DirectionalFluxBC)
const unsigned int & _current_side
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)
virtual Real computeQpResidual() override
DirectionalFluxBC(const InputParameters &parameters)
void paramWarning(const std::string &param, Args... args) const
const RealVectorValue _direction
Flux direction and magnitude vector.
virtual void precalculateResidual() override