https://mooseframework.inl.gov
RayTracingViewFactor.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 "RayTracingViewFactor.h"
11 
12 #include "ViewFactorRayStudy.h"
13 
14 registerMooseObject("HeatTransferApp", RayTracingViewFactor);
15 
18 {
20  params.addRequiredParam<UserObjectName>("ray_study_name",
21  "Name of the view factor ray study UO.");
22  params.addClassDescription("Computes view factors for arbitrary geometries using raytracing.");
23  return params;
24 }
25 
27  : ViewFactorBase(parameters), _ray_study(getUserObject<ViewFactorRayStudy>("ray_study_name"))
28 {
29  if (_mesh.dimension() == 1)
30  mooseError("View factor calculations do not support 1D");
31 }
32 
33 void
35 {
36  // compute areas
37  auto current_boundary_name = _mesh.getBoundaryName(_current_boundary_id);
38  auto it = _side_name_index.find(current_boundary_name);
39  if (it == _side_name_index.end())
40  mooseError("Current boundary name: ",
41  current_boundary_name,
42  " with id ",
44  " not in boundary parameter.");
45 
46  _areas[it->second] += _current_side_volume;
47 }
48 
49 void
51 {
52  // set view_factors to zero
53  std::fill(_areas.begin(), _areas.end(), 0);
54 }
55 
56 void
58 {
60 
61  // get the _view_factors from ray study
62  for (const auto & from_name : boundaryNames())
63  for (const auto & to_name : boundaryNames())
64  {
65  unsigned int from_index = getSideNameIndex(from_name);
66  unsigned int to_index = getSideNameIndex(to_name);
67  BoundaryID from_id = _mesh.getBoundaryID(from_name);
68  BoundaryID to_id = _mesh.getBoundaryID(to_name);
69  _view_factors[from_index][to_index] = _ray_study.viewFactorInfo(from_id, to_id);
70  }
71 
72  // divide view_factor Fij by Ai and pi
73  const Real divisor = _mesh.dimension() == 2 ? 2 : libMesh::pi;
74  for (unsigned int i = 0; i < _n_sides; ++i)
75  {
76  const Real factor = 1. / (_areas[i] * divisor);
77  for (auto & vf : _view_factors[i])
78  vf *= factor;
79  }
80 }
81 
82 void
84 {
85  const auto & pps = static_cast<const RayTracingViewFactor &>(y);
86  for (unsigned int i = 0; i < _n_sides; ++i)
87  _areas[i] += pps._areas[i];
88 }
static InputParameters validParams()
std::vector< Real > _areas
area of the sides i
std::unordered_map< std::string, unsigned int > _side_name_index
boundary name to index map
unsigned int _n_sides
number of boundaries of this side uo
const std::string & getBoundaryName(BoundaryID boundary_id)
virtual void threadJoinViewFactor(const UserObject &y) override
a purely virtual function called in finalize, must be overriden by derived class
const std::vector< double > y
Computes the view factors for planar faces in unobstructed radiative heat transfer.
virtual void initialize() override
void addRequiredParam(const std::string &name, const std::string &doc_string)
A base class for automatic computation of view factors between sidesets.
registerMooseObject("HeatTransferApp", RayTracingViewFactor)
RayTracingStudy used to generate Rays for view factor computation using the angular quadrature method...
const Real & _current_side_volume
const BoundaryID & _current_boundary_id
RayTracingViewFactor(const InputParameters &parameters)
void gatherSum(T &value)
std::vector< std::vector< Real > > _view_factors
the view factor from side i to side j
virtual unsigned int dimension() const
boundary_id_type BoundaryID
virtual void execute() override
unsigned int getSideNameIndex(std::string name) const
helper function to get the index from the boundary name
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MooseMesh & _mesh
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
Real viewFactorInfo(const BoundaryID from_id, const BoundaryID to_id) const
Accessor for the finalized view factor info.
const ViewFactorRayStudy & _ray_study
const std::vector< BoundaryName > & boundaryNames() const
virtual void finalizeViewFactor() override
a purely virtural function called in finalize, must be overriden by derived class ...
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
const Real pi