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 "SubChannelMesh.h" 11 : 12 : InputParameters 13 1114 : SubChannelMesh::validParams() 14 : { 15 1114 : InputParameters params = MooseMesh::validParams(); 16 1114 : params.addClassDescription("Base class for all mesh containers"); 17 1114 : return params; 18 0 : } 19 : 20 557 : SubChannelMesh::SubChannelMesh(const InputParameters & params) : MooseMesh(params), _kij(0.0) {} 21 : 22 0 : SubChannelMesh::SubChannelMesh(const SubChannelMesh & other_mesh) 23 : : MooseMesh(other_mesh), 24 0 : _unheated_length_entry(other_mesh._unheated_length_entry), 25 0 : _heated_length(other_mesh._heated_length), 26 0 : _unheated_length_exit(other_mesh._unheated_length_exit), 27 0 : _z_grid(other_mesh._z_grid), 28 0 : _k_grid(other_mesh._k_grid), 29 0 : _spacer_z(other_mesh._spacer_z), 30 0 : _spacer_k(other_mesh._spacer_k), 31 0 : _kij(other_mesh._kij), 32 0 : _pitch(other_mesh._pitch), 33 0 : _pin_diameter(other_mesh._pin_diameter), 34 0 : _n_cells(other_mesh._n_cells) 35 : { 36 0 : } 37 : 38 : void 39 597 : SubChannelMesh::generateZGrid(Real unheated_length_entry, 40 : Real heated_length, 41 : Real unheated_length_exit, 42 : unsigned int n_cells, 43 : std::vector<Real> & z_grid) 44 : { 45 597 : Real L = unheated_length_entry + heated_length + unheated_length_exit; 46 597 : Real dz = L / n_cells; 47 14054 : for (unsigned int i = 0; i < n_cells + 1; i++) 48 13457 : z_grid.push_back(dz * i); 49 597 : } 50 : 51 : unsigned int 52 1486203 : SubChannelMesh::getZIndex(const Point & point) const 53 : { 54 1486203 : if (_z_grid.size() == 0) 55 0 : mooseError("_z_grid is empty."); 56 : 57 1486203 : if (point(2) <= _z_grid[0]) 58 : return 0; 59 1449326 : if (point(2) >= _z_grid[_z_grid.size() - 1]) 60 22788 : return _z_grid.size() - 1; 61 : 62 : unsigned int lo = 0; 63 1426538 : unsigned int hi = _z_grid.size(); 64 8261497 : while (lo < hi) 65 : { 66 6834959 : unsigned int mid = (lo + hi) / 2; 67 6834959 : if (std::abs(_z_grid[mid] - point(2)) < 1e-5) 68 1426538 : return mid; 69 5408421 : else if (_z_grid[mid] < point(2)) 70 : lo = mid; 71 : else 72 : hi = mid; 73 : } 74 : return lo; 75 : }