https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SubChannelAddVariablesAction.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
11#include "ActionWarehouse.h"
12#include "ActionFactory.h"
14#include "FEProblemBase.h"
15#include "SubChannelApp.h"
17
18registerMooseAction("SubChannelApp", SubChannelAddVariablesAction, "add_aux_variable");
19
22{
24 params.addClassDescription("Adds the variables associated with the subchannel problem");
25 params.addParam<bool>("full_output", false, "Add optional subchannel output variables");
26 return params;
27}
28
30 : Action(parameters),
31 _fe_family(AddAuxVariableAction::getAuxVariableFamilies()),
32 _fe_order(AddAuxVariableAction::getAuxVariableOrders())
33{
34}
35
36void
38 const std::vector<SubdomainName> & blocks)
39{
40 const auto & aux_actions = _awh.getActions<AddAuxVariableAction>();
41
42 for (const auto * aux_action : aux_actions)
43 if (aux_action->name() == var_name)
44 return;
45
46 auto params = _factory.getValidParams("MooseVariable");
47 params.set<MooseEnum>("family") = _fe_family;
48 params.set<MooseEnum>("order") = _fe_order;
49 params.set<std::vector<SubdomainName>>("block") = blocks;
50
51 _problem->addAuxVariable("MooseVariable", var_name, params);
52}
53
54void
56{
57 bool pin_mesh_exist = false;
58 bool duct_mesh_exist = false;
59
60 std::vector<SubdomainName> fluid_blocks;
61 std::vector<SubdomainName> pin_blocks;
62 std::vector<SubdomainName> duct_blocks;
63
64 const auto & mesh_actions = _awh.getActions<AddMeshGeneratorAction>();
65
66 for (const auto * mesh_action : mesh_actions)
67 {
68 if (!mesh_action->parameters().isParamValid("type"))
69 continue;
70
71 const auto & generator_type = mesh_action->getParam<std::string>("type");
72
73 if (generator_type == "SCMQuadAssemblyMeshGenerator")
74 {
75 fluid_blocks = {"subchannel"};
76 const auto & mesh_generator_params = mesh_action->getObjectParams();
77 const auto nx = mesh_generator_params.get<unsigned int>("nx");
78 const auto ny = mesh_generator_params.get<unsigned int>("ny");
79 if (nx > 1 && ny > 1)
80 {
81 pin_mesh_exist = true;
82 pin_blocks = {"fuel_pins"};
83 }
84 }
85 else if (generator_type == "SCMTriAssemblyMeshGenerator")
86 {
87 fluid_blocks = {"subchannel"};
88 pin_mesh_exist = true;
89 pin_blocks = {"fuel_pins"};
90 }
91 else if (generator_type == "SCMQuadSubChannelMeshGenerator" ||
92 generator_type == "SCMTriSubChannelMeshGenerator")
93 {
94 // Use the user-provided mesh generator block name
95 fluid_blocks = {mesh_action->name()};
96 }
97
98 if (generator_type == "SCMTriPinMeshGenerator" || generator_type == "SCMQuadPinMeshGenerator")
99 {
100 pin_mesh_exist = true;
101 // Use the user-provided mesh generator block name
102 pin_blocks = {mesh_action->name()};
103 }
104
105 if (generator_type == "SCMTriDuctMeshGenerator" || generator_type == "SCMQuadDuctMeshGenerator")
106 {
107 duct_mesh_exist = true;
108 // Use the user-provided mesh generator block name
109 duct_blocks = {mesh_action->name()};
110 }
111 }
112
113 // Backward-compatible fallback if no explicit subchannel mesh generator name was found
114 if (fluid_blocks.empty())
115 fluid_blocks = {"subchannel"};
116
117 std::vector<std::pair<std::string, std::vector<SubdomainName>>> vars_to_add;
118
119 // Always-fluid variables
120 vars_to_add.push_back({SubChannelApp::MASS_FLOW_RATE, fluid_blocks});
121 vars_to_add.push_back({SubChannelApp::SURFACE_AREA, fluid_blocks});
122 vars_to_add.push_back({SubChannelApp::SUM_CROSSFLOW, fluid_blocks});
123 vars_to_add.push_back({SubChannelApp::PRESSURE, fluid_blocks});
124 vars_to_add.push_back({SubChannelApp::WETTED_PERIMETER, fluid_blocks});
125 vars_to_add.push_back({SubChannelApp::ENTHALPY, fluid_blocks});
126 vars_to_add.push_back({SubChannelApp::TEMPERATURE, fluid_blocks});
127 vars_to_add.push_back({SubChannelApp::DENSITY, fluid_blocks});
128 vars_to_add.push_back({SubChannelApp::VISCOSITY, fluid_blocks});
129 vars_to_add.push_back({SubChannelApp::DISPLACEMENT, fluid_blocks});
130
131 // q_prime lives on pins if pins exist, otherwise on the fluid mesh
132 if (pin_mesh_exist)
133 vars_to_add.push_back({SubChannelApp::LINEAR_HEAT_RATE, pin_blocks});
134 else
135 vars_to_add.push_back({SubChannelApp::LINEAR_HEAT_RATE, fluid_blocks});
136
137 // Pin-only variables
138 if (pin_mesh_exist)
139 {
140 vars_to_add.push_back({SubChannelApp::PIN_TEMPERATURE, pin_blocks});
141 vars_to_add.push_back({SubChannelApp::PIN_DIAMETER, pin_blocks});
142 // HTC is a subchannel-average output stored on the fluid mesh.
143 vars_to_add.push_back({SubChannelApp::HEAT_TRANSFER_COEFFICIENT, fluid_blocks});
144 }
145
146 // Duct-only variables
147 if (duct_mesh_exist)
148 {
149 vars_to_add.push_back({SubChannelApp::DUCT_HEAT_FLUX, duct_blocks});
150 vars_to_add.push_back({SubChannelApp::DUCT_TEMPERATURE, duct_blocks});
151 }
152
153 if (getParam<bool>("full_output"))
154 {
155 vars_to_add.push_back({SubChannelApp::PRESSURE_DROP, fluid_blocks});
156 vars_to_add.push_back({SubChannelApp::FRICTION_FACTOR, fluid_blocks});
157 }
158
159 for (const auto & var_info : vars_to_add)
160 addAuxVariable(var_info.first, var_info.second);
161}
char ** blocks
registerMooseAction("SubChannelApp", SubChannelAddVariablesAction, "add_aux_variable")
std::vector< const T * > getActions()
static InputParameters validParams()
std::shared_ptr< FEProblemBase > & _problem
ActionWarehouse & _awh
InputParameters getValidParams(const std::string &name) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
const T & getParam(const std::string &name) const
Factory & _factory
Action that adds SubChannel variables needs for the solve.
void addAuxVariable(const std::string &var_name, const std::vector< SubdomainName > &blocks)
Add a block-restricted auxiliary variable unless the user already defined it.
const MooseEnum _fe_order
FE order of the aux variables added by this action.
const MooseEnum _fe_family
FE family of the aux variables added by this action.
SubChannelAddVariablesAction(const InputParameters &parameters)
static const std::string ENTHALPY
static const std::string DISPLACEMENT
static const std::string PRESSURE_DROP
static const std::string WETTED_PERIMETER
static const std::string PRESSURE
static const std::string DUCT_TEMPERATURE
static const std::string FRICTION_FACTOR
static const std::string MASS_FLOW_RATE
static const std::string SURFACE_AREA
static const std::string VISCOSITY
static const std::string DENSITY
static const std::string PIN_DIAMETER
static const std::string HEAT_TRANSFER_COEFFICIENT
static const std::string LINEAR_HEAT_RATE
static const std::string DUCT_HEAT_FLUX
static const std::string SUM_CROSSFLOW
static const std::string PIN_TEMPERATURE
static const std::string TEMPERATURE