https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
14
17{
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
44void
56
57Real
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}
registerMooseObject("HeatTransferApp", DirectionalFluxBC)
Boundary condition to apply a directional flux multiplied by the surface normal vector.
static InputParameters validParams()
DirectionalFluxBC(const InputParameters &parameters)
virtual Real computeQpResidual() override
unsigned int _illumination
Illumination state (bitmask)
const SelfShadowSideUserObject *const _self_shadow
Self shadow illumination calculation user object.
const RealVectorValue _direction
Flux direction and magnitude vector.
virtual void precalculateResidual() override
static InputParameters validParams()
virtual Real computeQpResidual() override
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
const unsigned int & _current_side
unsigned int _qp
const Elem *const & _current_elem
const MooseArray< Point > & _normals
void paramWarning(const std::string &param, Args... args) const
Given a radiation direction vector this user object computes the illumination state of each side QP o...
unsigned int illumination(const SideIDType &id) const
std::pair< dof_id_type, unsigned int > SideIDType
bool useDisplacedMesh() const
API to chek if the UO runs on the displaced mesh.