www.mooseframework.org
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
UnobstructedPlanarViewFactor Class Reference

Computes the view factors for planar faces in unobstructed radiative heat transfer. More...

#include <UnobstructedPlanarViewFactor.h>

Inheritance diagram for UnobstructedPlanarViewFactor:
[legend]

Public Member Functions

 UnobstructedPlanarViewFactor (const InputParameters &parameters)
 
virtual void execute () override
 
virtual void initialize () override
 
virtual void finalize () override final
 
Real getViewFactor (BoundaryID from_id, BoundaryID to_id) const
 public interface for obtaining view factors More...
 
Real getViewFactor (BoundaryName from_name, BoundaryName to_name) const
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Member Functions

virtual void threadJoinViewFactor (const UserObject &y) override
 a purely virtural function called in finalize, must be overriden by derived class More...
 
virtual void finalizeViewFactor () override
 a purely virtural function called in finalize, must be overriden by derived class More...
 
void reinitFace (dof_id_type elem_id, unsigned int side)
 helper function that reinits an element face More...
 
virtual void threadJoin (const UserObject &y) override final
 
void checkAndNormalizeViewFactor ()
 this function checks & normalizes view factors to sum to one, this is not always More...
 

Protected Attributes

BoundaryInfo * _boundary_info
 
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > _side_list
 
unsigned int _exponent
 
Real _divisor
 
unsigned int _n_sides
 number of boundaries of this side uo More...
 
std::vector< Real > _areas
 area of the sides i More...
 
const Real _view_factor_tol
 view factor tolerance More...
 
const bool _normalize_view_factor
 whether to normalize view factors so vf[from][:] sums to one More...
 
std::vector< std::vector< Real > > _view_factors
 the view factor from side i to side j More...
 
std::unordered_map< std::string, unsigned int > _side_name_index
 boundary name to index map More...
 
std::unique_ptr< const Elem > _current_remote_side
 data of the to_elem side being initialized More...
 
std::unique_ptr< FEBase > _current_remote_fe
 
Real _current_remote_side_volume
 
const std::vector< Real > * _current_remote_JxW
 
const std::vector< Point > * _current_remote_xyz
 
const std::vector< Point > * _current_remote_normals
 
std::vector< Real > _current_remote_coord
 

Detailed Description

Computes the view factors for planar faces in unobstructed radiative heat transfer.

Definition at line 23 of file UnobstructedPlanarViewFactor.h.

Constructor & Destructor Documentation

◆ UnobstructedPlanarViewFactor()

UnobstructedPlanarViewFactor::UnobstructedPlanarViewFactor ( const InputParameters &  parameters)

Definition at line 36 of file UnobstructedPlanarViewFactor.C.

37  : ViewFactorBase(parameters),
38  _boundary_info(nullptr),
39  _current_remote_side(nullptr),
40  _current_remote_fe(nullptr),
41  _current_remote_JxW(nullptr),
42  _current_remote_xyz(nullptr),
44 {
45  _mesh.errorIfDistributedMesh("UnobstructedPlanarViewFactor");
46 
47  if (_mesh.dimension() == 1)
48  mooseError("View factor calculations for 1D geometry makes no sense");
49  else if (_mesh.dimension() == 2)
50  {
51  _exponent = 1;
52  _divisor = 2;
53  }
54  else
55  {
56  _exponent = 2;
57  _divisor = libMesh::pi;
58  }
59 }

Member Function Documentation

◆ checkAndNormalizeViewFactor()

void ViewFactorBase::checkAndNormalizeViewFactor ( )
protectedinherited

this function checks & normalizes view factors to sum to one, this is not always

Definition at line 106 of file ViewFactorBase.C.

107 {
108  for (unsigned int from = 0; from < _n_sides; ++from)
109  {
110  Real s = 0;
111  for (unsigned int to = 0; to < _n_sides; ++to)
112  s += _view_factors[from][to];
113 
114  if (std::abs(1 - s) > _view_factor_tol)
115  mooseError("View factor from boundary ", boundaryNames()[from], " add to ", s);
116 
118  for (unsigned int to = 0; to < _n_sides; ++to)
119  _view_factors[from][to] /= s;
120  }
121 }

Referenced by ViewFactorBase::finalize().

◆ execute()

void UnobstructedPlanarViewFactor::execute ( )
overridevirtual

Definition at line 62 of file UnobstructedPlanarViewFactor.C.

63 {
64  auto current_boundary_name = _mesh.getBoundaryName(_current_boundary_id);
65  if (_side_name_index.find(current_boundary_name) == _side_name_index.end())
66  mooseError("Current boundary name: ",
67  current_boundary_name,
68  " with id ",
69  _current_boundary_id,
70  " not in boundary parameter.");
71  unsigned int index = _side_name_index.find(current_boundary_name)->second;
72 
73  _areas[index] += _current_side_volume;
74 
75  for (auto & side : _side_list)
76  {
77  auto remote_boundary_name = _mesh.getBoundaryName(std::get<2>(side));
78  if (_side_name_index.find(remote_boundary_name) != _side_name_index.end() &&
79  std::get<2>(side) != _current_boundary_id)
80  {
81  // this is the remote side index
82  unsigned int remote_index = _side_name_index.find(remote_boundary_name)->second;
83  Real & vf = _view_factors[index][remote_index];
84 
85  // compute some important quantities on the face
86  reinitFace(std::get<0>(side), std::get<1>(side));
87 
88  // loop over pairs of the qps on the current side
89  for (unsigned int qp = 0; qp < _qrule->n_points(); ++qp)
90  {
91  // loop over the qps on the remote element
92  for (unsigned int r_qp = 0; r_qp < _current_remote_JxW->size(); ++r_qp)
93  {
94  Point r2r = (_q_point[qp] - (*_current_remote_xyz)[r_qp]);
95  Real distance = r2r.norm();
96  Real cos1 = r2r * _normals[qp] / distance;
97  Real cos2 = r2r * (*_current_remote_normals)[r_qp] / distance;
98 
99  vf += _JxW[qp] * _coord[qp] * (*_current_remote_JxW)[r_qp] * _current_remote_coord[r_qp] *
100  std::abs(cos1) * std::abs(cos2) / MathUtils::pow(distance, _exponent);
101  }
102  }
103  }
104  }
105 }

◆ finalize()

void ViewFactorBase::finalize ( )
finaloverridevirtualinherited

Definition at line 83 of file ViewFactorBase.C.

84 {
85  // do some communication before finalizing view_factors
86  for (unsigned int i = 0; i < _n_sides; ++i)
87  gatherSum(_view_factors[i]);
88 
91 }

◆ finalizeViewFactor()

void UnobstructedPlanarViewFactor::finalizeViewFactor ( )
overrideprotectedvirtual

a purely virtural function called in finalize, must be overriden by derived class

Implements ViewFactorBase.

Definition at line 126 of file UnobstructedPlanarViewFactor.C.

127 {
128  gatherSum(_areas);
129 
130  // divide view_factor Fij by Ai and pi
131  for (unsigned int i = 0; i < _n_sides; ++i)
132  for (auto & vf : _view_factors[i])
133  vf /= (_areas[i] * _divisor);
134 }

◆ getViewFactor() [1/2]

Real ViewFactorBase::getViewFactor ( BoundaryID  from_id,
BoundaryID  to_id 
) const
inherited

public interface for obtaining view factors

Definition at line 52 of file ViewFactorBase.C.

53 {
54  auto from_name = _mesh.getBoundaryName(from_id);
55  auto to_name = _mesh.getBoundaryName(to_id);
56 
57  return getViewFactor(from_name, to_name);
58 }

Referenced by ViewFactorPP::getValue(), and ViewFactorObjectSurfaceRadiation::setViewFactors().

◆ getViewFactor() [2/2]

Real ViewFactorBase::getViewFactor ( BoundaryName  from_name,
BoundaryName  to_name 
) const
inherited

Definition at line 61 of file ViewFactorBase.C.

62 {
63  auto from = _side_name_index.find(from_name);
64  auto to = _side_name_index.find(to_name);
65  if (from == _side_name_index.end())
66  mooseError("Boundary id ",
67  _mesh.getBoundaryID(from_name),
68  " with name ",
69  from_name,
70  " not listed in boundary parameter.");
71 
72  if (to == _side_name_index.end())
73  mooseError("Boundary id ",
74  _mesh.getBoundaryID(to_name),
75  " with name ",
76  to_name,
77  " not listed in boundary parameter.");
78 
79  return _view_factors[from->second][to->second];
80 }

◆ initialize()

void UnobstructedPlanarViewFactor::initialize ( )
overridevirtual

Definition at line 108 of file UnobstructedPlanarViewFactor.C.

109 {
110  // get boundary info from the mesh
111  _boundary_info = &_mesh.getMesh().get_boundary_info();
112 
113  // get a list of all sides
114  _side_list = _boundary_info->build_active_side_list();
115 
116  // set view_factors to zero
117  for (unsigned int j = 0; j < _n_sides; ++j)
118  {
119  _areas[j] = 0;
120  for (auto & vf : _view_factors[j])
121  vf = 0;
122  }
123 }

◆ reinitFace()

void UnobstructedPlanarViewFactor::reinitFace ( dof_id_type  elem_id,
unsigned int  side 
)
protected

helper function that reinits an element face

Definition at line 145 of file UnobstructedPlanarViewFactor.C.

146 {
147  const Elem * current_remote_elem = _mesh.getMesh().elem_ptr(elem_id);
148  _current_remote_side = current_remote_elem->build_side_ptr(side);
150 
151  Order order = current_remote_elem->default_order();
152  unsigned int dim = _mesh.getMesh().mesh_dimension();
153  _current_remote_fe = FEBase::build(dim, FEType(order));
154  QGauss qface(dim - 1, FEType(order).default_quadrature_order());
155  _current_remote_fe->attach_quadrature_rule(&qface);
156 
160 
161  _current_remote_fe->reinit(current_remote_elem, side);
162 
163  // set _coord
164  unsigned int n_points = _current_remote_xyz->size();
165  unsigned int rz_radial_coord = _subproblem.getAxisymmetricRadialCoord();
166  _current_remote_coord.resize(n_points);
167  switch (_assembly.coordSystem())
168  {
169  case Moose::COORD_XYZ:
170  for (unsigned int qp = 0; qp < n_points; qp++)
171  _current_remote_coord[qp] = 1.;
172  break;
173 
174  case Moose::COORD_RZ:
175  for (unsigned int qp = 0; qp < n_points; qp++)
176  _current_remote_coord[qp] = 2 * M_PI * (*_current_remote_xyz)[qp](rz_radial_coord);
177  break;
178 
179  case Moose::COORD_RSPHERICAL:
180  for (unsigned int qp = 0; qp < n_points; qp++)
182  4 * M_PI * (*_current_remote_xyz)[qp](0) * (*_current_remote_xyz)[qp](0);
183  break;
184 
185  default:
186  mooseError("Unknown coordinate system");
187  break;
188  }
189 }

Referenced by execute().

◆ threadJoin()

void ViewFactorBase::threadJoin ( const UserObject &  y)
finaloverrideprotectedvirtualinherited

Definition at line 94 of file ViewFactorBase.C.

95 {
96  const ViewFactorBase & pps = static_cast<const ViewFactorBase &>(y);
97  for (unsigned int i = 0; i < _n_sides; ++i)
98  {
99  for (unsigned int j = 0; j < _n_sides; ++j)
100  _view_factors[i][j] += pps._view_factors[i][j];
101  }
103 }

◆ threadJoinViewFactor()

void UnobstructedPlanarViewFactor::threadJoinViewFactor ( const UserObject &  y)
overrideprotectedvirtual

a purely virtural function called in finalize, must be overriden by derived class

Implements ViewFactorBase.

Definition at line 137 of file UnobstructedPlanarViewFactor.C.

138 {
139  const UnobstructedPlanarViewFactor & pps = static_cast<const UnobstructedPlanarViewFactor &>(y);
140  for (unsigned int i = 0; i < _n_sides; ++i)
141  _areas[i] += pps._areas[i];
142 }

◆ validParams()

InputParameters UnobstructedPlanarViewFactor::validParams ( )
static

Definition at line 28 of file UnobstructedPlanarViewFactor.C.

29 {
30  InputParameters params = ViewFactorBase::validParams();
31  params.addClassDescription(
32  "Computes the view factors for planar faces in unubstructed radiative heat transfer.");
33  return params;
34 }

Member Data Documentation

◆ _areas

std::vector<Real> ViewFactorBase::_areas
protectedinherited

area of the sides i

Definition at line 53 of file ViewFactorBase.h.

Referenced by execute(), finalizeViewFactor(), initialize(), and threadJoinViewFactor().

◆ _boundary_info

BoundaryInfo* UnobstructedPlanarViewFactor::_boundary_info
protected

Definition at line 40 of file UnobstructedPlanarViewFactor.h.

Referenced by initialize().

◆ _current_remote_coord

std::vector<Real> UnobstructedPlanarViewFactor::_current_remote_coord
protected

Definition at line 50 of file UnobstructedPlanarViewFactor.h.

Referenced by execute(), and reinitFace().

◆ _current_remote_fe

std::unique_ptr<FEBase> UnobstructedPlanarViewFactor::_current_remote_fe
protected

Definition at line 45 of file UnobstructedPlanarViewFactor.h.

Referenced by reinitFace().

◆ _current_remote_JxW

const std::vector<Real>* UnobstructedPlanarViewFactor::_current_remote_JxW
protected

Definition at line 47 of file UnobstructedPlanarViewFactor.h.

Referenced by execute(), and reinitFace().

◆ _current_remote_normals

const std::vector<Point>* UnobstructedPlanarViewFactor::_current_remote_normals
protected

Definition at line 49 of file UnobstructedPlanarViewFactor.h.

Referenced by reinitFace().

◆ _current_remote_side

std::unique_ptr<const Elem> UnobstructedPlanarViewFactor::_current_remote_side
protected

data of the to_elem side being initialized

Definition at line 44 of file UnobstructedPlanarViewFactor.h.

Referenced by reinitFace().

◆ _current_remote_side_volume

Real UnobstructedPlanarViewFactor::_current_remote_side_volume
protected

Definition at line 46 of file UnobstructedPlanarViewFactor.h.

Referenced by reinitFace().

◆ _current_remote_xyz

const std::vector<Point>* UnobstructedPlanarViewFactor::_current_remote_xyz
protected

Definition at line 48 of file UnobstructedPlanarViewFactor.h.

Referenced by reinitFace().

◆ _divisor

Real UnobstructedPlanarViewFactor::_divisor
protected

◆ _exponent

unsigned int UnobstructedPlanarViewFactor::_exponent
protected

Definition at line 53 of file UnobstructedPlanarViewFactor.h.

Referenced by execute(), and UnobstructedPlanarViewFactor().

◆ _n_sides

unsigned int ViewFactorBase::_n_sides
protectedinherited

◆ _normalize_view_factor

const bool ViewFactorBase::_normalize_view_factor
protectedinherited

whether to normalize view factors so vf[from][:] sums to one

Definition at line 59 of file ViewFactorBase.h.

Referenced by ViewFactorBase::checkAndNormalizeViewFactor().

◆ _side_list

std::vector<std::tuple<dof_id_type, unsigned short int, boundary_id_type> > UnobstructedPlanarViewFactor::_side_list
protected

Definition at line 41 of file UnobstructedPlanarViewFactor.h.

Referenced by execute(), and initialize().

◆ _side_name_index

std::unordered_map<std::string, unsigned int> ViewFactorBase::_side_name_index
protectedinherited

boundary name to index map

Definition at line 65 of file ViewFactorBase.h.

Referenced by execute(), ViewFactorBase::getViewFactor(), and ViewFactorBase::ViewFactorBase().

◆ _view_factor_tol

const Real ViewFactorBase::_view_factor_tol
protectedinherited

view factor tolerance

Definition at line 56 of file ViewFactorBase.h.

Referenced by ViewFactorBase::checkAndNormalizeViewFactor().

◆ _view_factors

std::vector<std::vector<Real> > ViewFactorBase::_view_factors
protectedinherited

The documentation for this class was generated from the following files:
ViewFactorBase
A base class for automatic computation of view factors between sidesets.
Definition: ViewFactorBase.h:23
ViewFactorBase::_side_name_index
std::unordered_map< std::string, unsigned int > _side_name_index
boundary name to index map
Definition: ViewFactorBase.h:65
ViewFactorBase::_areas
std::vector< Real > _areas
area of the sides i
Definition: ViewFactorBase.h:53
ViewFactorBase::_normalize_view_factor
const bool _normalize_view_factor
whether to normalize view factors so vf[from][:] sums to one
Definition: ViewFactorBase.h:59
pow
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Definition: ExpressionBuilder.h:673
ViewFactorBase::finalizeViewFactor
virtual void finalizeViewFactor()=0
a purely virtural function called in finalize, must be overriden by derived class
ViewFactorBase::_n_sides
unsigned int _n_sides
number of boundaries of this side uo
Definition: ViewFactorBase.h:50
UnobstructedPlanarViewFactor::_current_remote_fe
std::unique_ptr< FEBase > _current_remote_fe
Definition: UnobstructedPlanarViewFactor.h:45
UnobstructedPlanarViewFactor::_exponent
unsigned int _exponent
Definition: UnobstructedPlanarViewFactor.h:53
ViewFactorBase::_view_factors
std::vector< std::vector< Real > > _view_factors
the view factor from side i to side j
Definition: ViewFactorBase.h:62
ViewFactorBase::_view_factor_tol
const Real _view_factor_tol
view factor tolerance
Definition: ViewFactorBase.h:56
UnobstructedPlanarViewFactor::_current_remote_side
std::unique_ptr< const Elem > _current_remote_side
data of the to_elem side being initialized
Definition: UnobstructedPlanarViewFactor.h:44
ViewFactorBase::getViewFactor
Real getViewFactor(BoundaryID from_id, BoundaryID to_id) const
public interface for obtaining view factors
Definition: ViewFactorBase.C:52
ViewFactorBase::ViewFactorBase
ViewFactorBase(const InputParameters &parameters)
Definition: ViewFactorBase.C:33
ViewFactorBase::threadJoinViewFactor
virtual void threadJoinViewFactor(const UserObject &y)=0
a purely virtural function called in finalize, must be overriden by derived class
ViewFactorBase::checkAndNormalizeViewFactor
void checkAndNormalizeViewFactor()
this function checks & normalizes view factors to sum to one, this is not always
Definition: ViewFactorBase.C:106
UnobstructedPlanarViewFactor::_current_remote_side_volume
Real _current_remote_side_volume
Definition: UnobstructedPlanarViewFactor.h:46
UnobstructedPlanarViewFactor::_current_remote_JxW
const std::vector< Real > * _current_remote_JxW
Definition: UnobstructedPlanarViewFactor.h:47
UnobstructedPlanarViewFactor::_side_list
std::vector< std::tuple< dof_id_type, unsigned short int, boundary_id_type > > _side_list
Definition: UnobstructedPlanarViewFactor.h:41
UnobstructedPlanarViewFactor::_current_remote_normals
const std::vector< Point > * _current_remote_normals
Definition: UnobstructedPlanarViewFactor.h:49
UnobstructedPlanarViewFactor::_current_remote_xyz
const std::vector< Point > * _current_remote_xyz
Definition: UnobstructedPlanarViewFactor.h:48
UnobstructedPlanarViewFactor
Computes the view factors for planar faces in unobstructed radiative heat transfer.
Definition: UnobstructedPlanarViewFactor.h:23
UnobstructedPlanarViewFactor::reinitFace
void reinitFace(dof_id_type elem_id, unsigned int side)
helper function that reinits an element face
Definition: UnobstructedPlanarViewFactor.C:145
ViewFactorBase::validParams
static InputParameters validParams()
Definition: ViewFactorBase.C:18
UnobstructedPlanarViewFactor::_current_remote_coord
std::vector< Real > _current_remote_coord
Definition: UnobstructedPlanarViewFactor.h:50
UnobstructedPlanarViewFactor::_divisor
Real _divisor
Definition: UnobstructedPlanarViewFactor.h:54
UnobstructedPlanarViewFactor::_boundary_info
BoundaryInfo * _boundary_info
Definition: UnobstructedPlanarViewFactor.h:40