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 "SCMPlanarMean.h" 11 : #include "SolutionHandle.h" 12 : #include "FEProblemBase.h" 13 : #include "Function.h" 14 : #include "MooseMesh.h" 15 : #include "MooseVariable.h" 16 : #include "SubProblem.h" 17 : #include "libmesh/system.h" 18 : #include "SCM.h" 19 : 20 : registerMooseObject("SubChannelApp", SCMPlanarMean); 21 : 22 : InputParameters 23 106 : SCMPlanarMean::validParams() 24 : { 25 106 : InputParameters params = GeneralPostprocessor::validParams(); 26 106 : params.addClassDescription("Calculates an mass-flow-rate averaged mean of the chosen " 27 : "variable on a z-plane at a user defined height over all subchannels"); 28 212 : params.addRequiredParam<AuxVariableName>("variable", "Variable you want the mean of"); 29 212 : params.addRequiredParam<Real>("height", "Axial location of plane [m]"); 30 106 : return params; 31 0 : } 32 : 33 53 : SCMPlanarMean::SCMPlanarMean(const InputParameters & parameters) 34 : : GeneralPostprocessor(parameters), 35 53 : _mesh(SCM::getConstMesh<SubChannelMesh>(_fe_problem.mesh())), 36 106 : _variable(getParam<AuxVariableName>("variable")), 37 106 : _height(getParam<Real>("height")), 38 53 : _mean_value(0) 39 : { 40 53 : } 41 : 42 : void 43 53 : SCMPlanarMean::execute() 44 : { 45 53 : auto nz = _mesh.getNumOfAxialCells(); 46 53 : auto n_channels = _mesh.getNumOfChannels(); 47 53 : auto Soln = SolutionHandle(_fe_problem.getVariable(0, _variable)); 48 53 : auto mdot_soln = SolutionHandle(_fe_problem.getVariable(0, "mdot")); 49 53 : auto z_grid = _mesh.getZGrid(); 50 : auto total_length = 51 53 : _mesh.getHeatedLength() + _mesh.getHeatedLengthEntry() + _mesh.getHeatedLengthExit(); 52 : 53 : auto mass_flow = 0.0; 54 : auto sum_sol_mass_flow = 0.0; 55 : 56 : // Use outlet mass flow rate for weighting. Print value at the exit of the assembly. 57 53 : if (_height >= total_length) 58 : { 59 2087 : for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++) 60 : { 61 2034 : auto * node_out = _mesh.getChannelNode(i_ch, nz); 62 2034 : mass_flow += mdot_soln(node_out); 63 2034 : sum_sol_mass_flow += Soln(node_out) * mdot_soln(node_out); 64 : } 65 53 : _mean_value = sum_sol_mass_flow / mass_flow; 66 : } 67 : else 68 : { 69 : // Locally average over each axial location in each channel 70 0 : for (unsigned int iz = 0; iz < nz; iz++) 71 : { 72 0 : if (_height >= z_grid[iz] && _height < z_grid[iz + 1]) 73 : { 74 0 : for (unsigned int i_ch = 0; i_ch < n_channels; i_ch++) 75 : { 76 0 : auto * node_out = _mesh.getChannelNode(i_ch, iz + 1); 77 0 : auto * node_in = _mesh.getChannelNode(i_ch, iz); 78 0 : auto average_solution = Soln(node_in) + (Soln(node_out) - Soln(node_in)) * 79 0 : (_height - z_grid[iz]) / 80 0 : (z_grid[iz + 1] - z_grid[iz]); 81 0 : auto average_mass_flow = mdot_soln(node_in) + (mdot_soln(node_out) - mdot_soln(node_in)) * 82 0 : (_height - z_grid[iz]) / 83 0 : (z_grid[iz + 1] - z_grid[iz]); 84 0 : mass_flow += average_mass_flow; 85 0 : sum_sol_mass_flow += average_solution * average_mass_flow; 86 : } 87 0 : _mean_value = sum_sol_mass_flow / mass_flow; 88 0 : break; 89 : } 90 : } 91 : } 92 53 : } 93 : 94 : Real 95 53 : SCMPlanarMean::getValue() const 96 : { 97 53 : return _mean_value; 98 : }