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 194 : RayTracingViewFactor::validParams() 18 : { 19 194 : InputParameters params = ViewFactorBase::validParams(); 20 388 : params.addRequiredParam<UserObjectName>("ray_study_name", 21 : "Name of the view factor ray study UO."); 22 194 : params.addClassDescription("Computes view factors for arbitrary geometries using raytracing."); 23 194 : return params; 24 0 : } 25 : 26 103 : RayTracingViewFactor::RayTracingViewFactor(const InputParameters & parameters) 27 103 : : ViewFactorBase(parameters), _ray_study(getUserObject<ViewFactorRayStudy>("ray_study_name")) 28 : { 29 103 : if (_mesh.dimension() == 1) 30 0 : mooseError("View factor calculations do not support 1D"); 31 103 : } 32 : 33 : void 34 12 : RayTracingViewFactor::threadJoinViewFactor(const UserObject & y) 35 : { 36 : const auto & vf = static_cast<const RayTracingViewFactor &>(y); 37 95 : for (unsigned int i = 0; i < _n_sides; ++i) 38 680 : for (unsigned int j = 0; j < _n_sides; ++j) 39 597 : _view_factors[i][j] += vf._view_factors[i][j]; 40 12 : } 41 : 42 : void 43 80 : RayTracingViewFactor::finalizeViewFactor() 44 : { 45 626 : for (unsigned int i = 0; i < _n_sides; ++i) 46 546 : gatherSum(_view_factors[i]); 47 : 48 : // get the _view_factors from ray study 49 626 : for (const auto & from_name : boundaryNames()) 50 4428 : for (const auto & to_name : boundaryNames()) 51 : { 52 3882 : unsigned int from_index = getSideNameIndex(from_name); 53 3882 : unsigned int to_index = getSideNameIndex(to_name); 54 3882 : BoundaryID from_id = _mesh.getBoundaryID(from_name); 55 3882 : BoundaryID to_id = _mesh.getBoundaryID(to_name); 56 3882 : _view_factors[from_index][to_index] = _ray_study.viewFactorInfo(from_id, to_id); 57 : } 58 : 59 : // divide view_factor Fij by Ai and pi 60 80 : const Real divisor = _mesh.dimension() == 2 ? 2 : libMesh::pi; 61 626 : for (unsigned int i = 0; i < _n_sides; ++i) 62 : { 63 546 : const Real factor = 1. / (_areas[i] * divisor); 64 4428 : for (auto & vf : _view_factors[i]) 65 3882 : vf *= factor; 66 : } 67 80 : }