https://mooseframework.inl.gov
VolumeJunctionCoupledFlux1Phase.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 "VolumeJunction1Phase.h"
12 
14 
17 {
19 
20  params.addRequiredParam<std::string>("volume_junction",
21  "Name of volume junction component on which to apply flux");
22  params.addRequiredParam<RealVectorValue>("normal_from_junction",
23  "Direction vector pointing from the junction to the "
24  "coupled volume. This vector will be normalized.");
25  params.addRequiredParam<Real>("A_coupled", "Area of the coupled surface [m^2]");
26  params.addParam<MultiAppName>(
27  "multi_app",
28  "If provided, transfers occur with this MultiApp. The following would be transferred: mass "
29  "flow rate, energy flow rate, temperature, and pressure at the junction.");
30  params.addRequiredParam<std::string>("pp_suffix", "Suffix to append to post-processor names");
31 
32  params.addClassDescription(
33  "Applies a flux between a VolumeJunction1Phase component and an external application.");
34 
35  return params;
36 }
37 
39  : Component(params),
40  _volume_junction_name(getParam<std::string>("volume_junction")),
41  _normal_from_junction_unnormalized(getParam<RealVectorValue>("normal_from_junction")),
42  _normal_from_junction(_normal_from_junction_unnormalized.unit()),
43  _pp_suffix(getParam<std::string>("pp_suffix"))
44 {
45 }
46 
47 void
49 {
50  checkComponentOfTypeExistsByName<VolumeJunction1Phase>(_volume_junction_name);
51 }
52 
53 void
55 {
56  const std::vector<NonlinearVariableName> vars = {"rhoV", "rhouV", "rhovV", "rhowV", "rhoEV"};
57  for (const auto i : index_range(vars))
59 
60  const std::vector<std::string> equations = {"mass", "energy"};
61  for (const auto i : index_range(equations))
62  {
63  addFluxPostprocessor(equations[i]);
64  if (isParamValid("multi_app"))
65  addFluxTransfer(equations[i]);
66  }
67 
68  const std::vector<std::string> properties = {"p", "T"};
69  for (const auto i : index_range(properties))
70  {
71  addPropertyPostprocessor(properties[i]);
72  if (isParamValid("multi_app"))
73  addPropertyTransfer(properties[i]);
74  }
75 }
76 
77 void
78 VolumeJunctionCoupledFlux1Phase::addVolumeJunctionKernel(const std::string & var, unsigned int i)
79 {
80  const auto & volume_junction =
82 
83  const std::string class_name = "VolumeJunctionCoupledFlux1PhaseKernel";
84  InputParameters params = _factory.getValidParams(class_name);
85  params.set<NonlinearVariableName>("variable") = var;
86  params.set<std::vector<SubdomainName>>("block") = {_volume_junction_name};
87  params.set<unsigned int>("equation_index") = i;
88  params.set<PostprocessorName>("pressure") = addPostprocessorSuffix("p");
89  params.set<PostprocessorName>("temperature") = addPostprocessorSuffix("T");
90  params.set<Real>("A_coupled") = getParam<Real>("A_coupled");
91  params.set<RealVectorValue>("normal_from_junction") = _normal_from_junction;
92  params.set<UserObjectName>("volume_junction_uo") =
93  volume_junction.getVolumeJunctionUserObjectName();
94  params.set<UserObjectName>("numerical_flux_uo") = volume_junction.getNumericalFluxName(0);
95  params.set<UserObjectName>("fluid_properties") = volume_junction.getFluidPropertiesName();
96  const std::string obj_name = genName(name(), var + "_kernel");
97  getTHMProblem().addKernel(class_name, obj_name, params);
98 }
99 
100 void
102 {
103  const auto & volume_junction =
105 
106  const std::string quantity = equation + "_rate";
107  const std::string class_name = "VolumeJunctionCoupledFlux1PhasePostprocessor";
108  InputParameters params = _factory.getValidParams(class_name);
109  params.set<MooseEnum>("equation") = equation;
110  params.set<PostprocessorName>("pressure") = addPostprocessorSuffix("p");
111  params.set<PostprocessorName>("temperature") = addPostprocessorSuffix("T");
112  params.set<Real>("A_coupled") = getParam<Real>("A_coupled");
113  params.set<RealVectorValue>("normal_from_junction") = _normal_from_junction;
114  params.set<UserObjectName>("volume_junction_uo") =
115  volume_junction.getVolumeJunctionUserObjectName();
116  params.set<UserObjectName>("numerical_flux_uo") = volume_junction.getNumericalFluxName(0);
117  params.set<UserObjectName>("fluid_properties") = volume_junction.getFluidPropertiesName();
118  const std::string obj_name = addPostprocessorSuffix(quantity);
119  getTHMProblem().addPostprocessor(class_name, obj_name, params);
120 }
121 
122 void
124 {
125  const std::string class_name = "Receiver";
126  InputParameters params = _factory.getValidParams(class_name);
127  const PostprocessorName obj_name = addPostprocessorSuffix(property);
128  getTHMProblem().addPostprocessor(class_name, obj_name, params);
129 }
130 
131 void
133 {
134  const std::string quantity = equation + "_rate";
135  const std::string class_name = "MultiAppPostprocessorTransfer";
136  InputParameters params = _factory.getValidParams(class_name);
137  params.set<MultiAppName>("to_multi_app") = getParam<MultiAppName>("multi_app");
138  params.set<PostprocessorName>("from_postprocessor") = addPostprocessorSuffix(quantity);
139  params.set<PostprocessorName>("to_postprocessor") = addPostprocessorSuffix(quantity);
140  params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
141  const PostprocessorName obj_name = genName(name(), quantity + "_transfer");
142  getTHMProblem().addTransfer(class_name, obj_name, params);
143 }
144 
145 void
147 {
148  const std::string class_name = "MultiAppPostprocessorTransfer";
149  InputParameters params = _factory.getValidParams(class_name);
150  params.set<MultiAppName>("from_multi_app") = getParam<MultiAppName>("multi_app");
151  params.set<PostprocessorName>("from_postprocessor") = addPostprocessorSuffix(property);
152  params.set<PostprocessorName>("to_postprocessor") = addPostprocessorSuffix(property);
153  params.set<MooseEnum>("reduction_type") = "average";
154  params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
155  const PostprocessorName obj_name = genName(name(), property + "_transfer");
156  getTHMProblem().addTransfer(class_name, obj_name, params);
157 }
158 
159 PostprocessorName
161 {
162  return base_name + "_" + _pp_suffix;
163 }
virtual void addTransfer(const std::string &transfer_name, const std::string &name, InputParameters &parameters)
void addVolumeJunctionKernel(const std::string &var, unsigned int i)
Adds a VolumeJunctionCoupledFlux1PhaseKernel.
std::string genName(const std::string &prefix, unsigned int id, const std::string &suffix="") const
Build a name from a prefix, number and possible suffix.
void addFluxPostprocessor(const std::string &equation)
Adds a VolumeJunctionCoupledFlux1PhasePostprocessor.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addPropertyTransfer(const std::string &property)
Adds a MultiAppPostprocessorTransfer to get a property.
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition: Component.C:135
char ** vars
void addPropertyPostprocessor(const std::string &property)
Adds a Receiver post-processor.
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
const RealVectorValue _normal_from_junction
Normalized normal vector from junction.
const ExecFlagType EXEC_TIMESTEP_END
virtual void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters)
static InputParameters validParams()
Definition: Component.C:18
void addRequiredParam(const std::string &name, const std::string &doc_string)
VolumeJunctionCoupledFlux1Phase(const InputParameters &params)
virtual void addPostprocessor(const std::string &pp_name, const std::string &name, InputParameters &parameters)
const std::string & name() const
Applies a flux between a VolumeJunction1Phase component and an external application.
virtual void check() const override
Check the component integrity.
const std::string & _volume_junction_name
Volume junction name.
const T & getComponentByName(const std::string &name) const
Get component by its name.
Definition: Simulation.h:504
Base class for THM components.
Definition: Component.h:28
registerMooseObject("ThermalHydraulicsApp", VolumeJunctionCoupledFlux1Phase)
PostprocessorName addPostprocessorSuffix(const std::string &base_name) const
Returns the input with the post-processor suffix.
Junction between 1-phase flow channels that has a non-zero volume.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addFluxTransfer(const std::string &equation)
Adds a MultiAppPostprocessorTransfer for a flux PP.
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:497
void addClassDescription(const std::string &doc_string)
bool isParamValid(const std::string &name) const
auto index_range(const T &sizable)
const std::string & _pp_suffix
Suffix to append to post-processor names.
const ExecFlagType EXEC_INITIAL