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

A base class for automatic computation of view factors between sidesets. More...

#include <ViewFactorBase.h>

Inheritance diagram for ViewFactorBase:
[legend]

Public Member Functions

 ViewFactorBase (const InputParameters &parameters)
 
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 threadJoin (const UserObject &y) override final
 
void checkAndNormalizeViewFactor ()
 this function checks & normalizes view factors to sum to one, this is not always More...
 
virtual void finalizeViewFactor ()=0
 a purely virtural function called in finalize, must be overriden by derived class More...
 
virtual void threadJoinViewFactor (const UserObject &y)=0
 a purely virtural function called in finalize, must be overriden by derived class More...
 

Protected Attributes

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...
 

Detailed Description

A base class for automatic computation of view factors between sidesets.

Definition at line 23 of file ViewFactorBase.h.

Constructor & Destructor Documentation

◆ ViewFactorBase()

ViewFactorBase::ViewFactorBase ( const InputParameters &  parameters)

Definition at line 33 of file ViewFactorBase.C.

34  : SideUserObject(parameters),
35  _n_sides(boundaryIDs().size()),
37  _view_factor_tol(getParam<Real>("view_factor_tol")),
38  _normalize_view_factor(getParam<bool>("normalize_view_factor"))
39 {
40  // sizing the view factor array
41  _view_factors.resize(_n_sides);
42  for (auto & v : _view_factors)
43  v.resize(_n_sides);
44 
45  // set up the map from the side id to the local index & side name to local index
46  std::vector<BoundaryName> boundary_names = getParam<std::vector<BoundaryName>>("boundary");
47  for (unsigned int j = 0; j < boundary_names.size(); ++j)
48  _side_name_index[boundary_names[j]] = j;
49 }

Member Function Documentation

◆ checkAndNormalizeViewFactor()

void ViewFactorBase::checkAndNormalizeViewFactor ( )
protected

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 finalize().

◆ finalize()

void ViewFactorBase::finalize ( )
finaloverridevirtual

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()

virtual void ViewFactorBase::finalizeViewFactor ( )
protectedpure virtual

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

Implemented in UnobstructedPlanarViewFactor.

Referenced by finalize().

◆ getViewFactor() [1/2]

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

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

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 }

◆ threadJoin()

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

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()

virtual void ViewFactorBase::threadJoinViewFactor ( const UserObject &  y)
protectedpure virtual

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

Implemented in UnobstructedPlanarViewFactor.

Referenced by threadJoin().

◆ validParams()

InputParameters ViewFactorBase::validParams ( )
static

Definition at line 18 of file ViewFactorBase.C.

19 {
20  InputParameters params = SideUserObject::validParams();
21  params.addParam<Real>("view_factor_tol",
22  std::numeric_limits<Real>::max(),
23  "Tolerance for checking view factors. Default is to allow everything.");
24  params.addParam<bool>("normalize_view_factor",
25  true,
26  "Determines if view factors are normalized to sum to one (consistent with "
27  "their definition).");
28  params.addClassDescription(
29  "A base class for automatic computation of view factors between sidesets.");
30  return params;
31 }

Referenced by UnobstructedPlanarViewFactor::validParams().

Member Data Documentation

◆ _areas

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

◆ _n_sides

unsigned int ViewFactorBase::_n_sides
protected

◆ _normalize_view_factor

const bool ViewFactorBase::_normalize_view_factor
protected

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

Definition at line 59 of file ViewFactorBase.h.

Referenced by checkAndNormalizeViewFactor().

◆ _side_name_index

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

boundary name to index map

Definition at line 65 of file ViewFactorBase.h.

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

◆ _view_factor_tol

const Real ViewFactorBase::_view_factor_tol
protected

view factor tolerance

Definition at line 56 of file ViewFactorBase.h.

Referenced by checkAndNormalizeViewFactor().

◆ _view_factors

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

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
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
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
ViewFactorBase::getViewFactor
Real getViewFactor(BoundaryID from_id, BoundaryID to_id) const
public interface for obtaining view factors
Definition: ViewFactorBase.C:52
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
validParams
InputParameters validParams()