Line data Source code
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 : 16 : InputParameters 17 352 : RayTracingViewFactor::validParams() 18 : { 19 352 : InputParameters params = ViewFactorBase::validParams(); 20 704 : params.addRequiredParam<UserObjectName>("ray_study_name", 21 : "Name of the view factor ray study UO."); 22 352 : params.addClassDescription("Computes view factors for arbitrary geometries using raytracing."); 23 352 : return params; 24 0 : } 25 : 26 187 : RayTracingViewFactor::RayTracingViewFactor(const InputParameters & parameters) 27 187 : : ViewFactorBase(parameters), _ray_study(getUserObject<ViewFactorRayStudy>("ray_study_name")) 28 : { 29 187 : if (_mesh.dimension() == 1) 30 0 : mooseError("View factor calculations do not support 1D"); 31 187 : } 32 : 33 : void 34 3048 : RayTracingViewFactor::execute() 35 : { 36 : // compute areas 37 3048 : auto current_boundary_name = _mesh.getBoundaryName(_current_boundary_id); 38 : auto it = _side_name_index.find(current_boundary_name); 39 3048 : if (it == _side_name_index.end()) 40 0 : mooseError("Current boundary name: ", 41 : current_boundary_name, 42 : " with id ", 43 0 : _current_boundary_id, 44 : " not in boundary parameter."); 45 : 46 3048 : _areas[it->second] += _current_side_volume; 47 3048 : } 48 : 49 : void 50 144 : RayTracingViewFactor::initialize() 51 : { 52 : // set view_factors to zero 53 : std::fill(_areas.begin(), _areas.end(), 0); 54 144 : } 55 : 56 : void 57 122 : RayTracingViewFactor::finalizeViewFactor() 58 : { 59 122 : gatherSum(_areas); 60 : 61 : // get the _view_factors from ray study 62 942 : for (const auto & from_name : boundaryNames()) 63 6568 : for (const auto & to_name : boundaryNames()) 64 : { 65 5748 : unsigned int from_index = getSideNameIndex(from_name); 66 5748 : unsigned int to_index = getSideNameIndex(to_name); 67 5748 : BoundaryID from_id = _mesh.getBoundaryID(from_name); 68 5748 : BoundaryID to_id = _mesh.getBoundaryID(to_name); 69 5748 : _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 122 : const Real divisor = _mesh.dimension() == 2 ? 2 : libMesh::pi; 74 942 : for (unsigned int i = 0; i < _n_sides; ++i) 75 : { 76 820 : const Real factor = 1. / (_areas[i] * divisor); 77 6568 : for (auto & vf : _view_factors[i]) 78 5748 : vf *= factor; 79 : } 80 122 : } 81 : 82 : void 83 22 : RayTracingViewFactor::threadJoinViewFactor(const UserObject & y) 84 : { 85 : const auto & pps = static_cast<const RayTracingViewFactor &>(y); 86 165 : for (unsigned int i = 0; i < _n_sides; ++i) 87 143 : _areas[i] += pps._areas[i]; 88 22 : }