https://mooseframework.inl.gov
GateValve1Phase.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 
10 #include "GateValve1Phase.h"
11 #include "FlowChannel1Phase.h"
12 #include "FlowModelSinglePhase.h"
13 
14 registerMooseObject("ThermalHydraulicsApp", GateValve1Phase);
15 
18 {
20 
21  params.addRequiredParam<Real>("open_area_fraction", "Fraction of flow area that is open [-]");
22 
23  params.declareControllable("open_area_fraction");
24 
25  params.addClassDescription("Gate valve component for 1-phase flow");
26 
27  return params;
28 }
29 
31 
32 void
34 {
36 
37  const auto & connected_elems = getConnectedElementIDs();
38  if (connected_elems.size() == 2)
39  getTHMProblem().augmentSparsity(connected_elems[0], connected_elems[1]);
40 }
41 
42 void
44 {
46 
47  // Check that there are exactly 2 connections
49 
50  // Log warning if slope reconstruction is used on one or more of the adjacent flow channels
51  bool slope_reconstruction_used = false;
52  for (const auto & connection : getConnections())
53  {
54  const std::string & comp_name = connection._component_name;
55  if (hasComponentByName<FlowChannel1Phase>(comp_name))
56  {
57  const FlowChannel1Phase & comp = getComponentByName<FlowChannel1Phase>(comp_name);
58  slope_reconstruction_used =
59  slope_reconstruction_used || (comp.getSlopeReconstruction() != "none");
60  }
61  }
62  if (slope_reconstruction_used)
63  logWarning("Currently GateValve1Phase cannot perform slope reconstruction across the "
64  "junction, so the slopes on the adjacent elements will be zero.");
65 }
66 
67 void
69 {
71  execute_on = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
72 
73  // Add user object for computing and storing the fluxes
74  {
75  const std::string class_name = "ADGateValve1PhaseUserObject";
76  InputParameters params = _factory.getValidParams(class_name);
77  params.set<std::vector<BoundaryName>>("boundary") = _boundary_names;
78  params.set<std::vector<Real>>("normals") = _normals;
79  params.set<std::vector<processor_id_type>>("processor_ids") = getConnectedProcessorIDs();
80  // It is assumed that each channel should have the same numerical flux, so
81  // just use the first one.
82  params.set<UserObjectName>("numerical_flux") = _numerical_flux_names[0];
83  params.set<Real>("open_area_fraction") = getParam<Real>("open_area_fraction");
84  params.set<std::vector<VariableName>>("A") = {FlowModel::AREA};
85  params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
86  params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
87  params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
88  params.set<std::string>("component_name") = name();
89  params.set<ExecFlagEnum>("execute_on") = execute_on;
90  getTHMProblem().addUserObject(class_name, _junction_uo_name, params);
91 
92  connectObject(params, _junction_uo_name, "open_area_fraction");
93  }
94 
95  const std::vector<NonlinearVariableName> var_names = {
97 
98  // Add BC to each of the connected flow channels
99  for (std::size_t i = 0; i < _boundary_names.size(); i++)
100  for (std::size_t j = 0; j < var_names.size(); j++)
101  {
102  const std::string class_name = "ADGateValve1PhaseBC";
103  InputParameters params = _factory.getValidParams(class_name);
104  params.set<std::vector<BoundaryName>>("boundary") = {_boundary_names[i]};
105  params.set<Real>("normal") = _normals[i];
106  params.set<NonlinearVariableName>("variable") = var_names[j];
107  params.set<UserObjectName>("gate_valve_uo") = _junction_uo_name;
108  params.set<unsigned int>("connection_index") = i;
109  params.set<std::vector<VariableName>>("A_elem") = {FlowModel::AREA};
110  params.set<std::vector<VariableName>>("A_linear") = {FlowModel::AREA_LINEAR};
111  params.set<std::vector<VariableName>>("rhoA") = {FlowModelSinglePhase::RHOA};
112  params.set<std::vector<VariableName>>("rhouA") = {FlowModelSinglePhase::RHOUA};
113  params.set<std::vector<VariableName>>("rhoEA") = {FlowModelSinglePhase::RHOEA};
114  params.set<bool>("implicit") = getTHMProblem().getImplicitTimeIntegrationFlag();
116  class_name, genName(name(), i, var_names[j] + ":" + class_name), params);
117  }
118 }
static const std::string AREA_LINEAR
Definition: FlowModel.h:103
GateValve1Phase(const InputParameters &params)
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.
const std::vector< processor_id_type > & getConnectedProcessorIDs()
Gets the processor IDs of the connected 1D components.
static const std::string AREA
Definition: FlowModel.h:102
THMProblem & getTHMProblem() const
Gets the THM problem.
Definition: Component.C:135
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
T & set(const std::string &name, bool quiet_mode=false)
const MooseEnum & getSlopeReconstruction() const
Gets the slope reconstruction option used.
InputParameters getValidParams(const std::string &name) const
void logWarning(Args &&... args) const
Logs a warning.
Definition: Component.h:224
virtual void setupMesh() override
Performs mesh setup such as creating mesh or naming mesh sets.
Gate valve component for 1-phase flow.
std::vector< BoundaryName > _boundary_names
Boundary names of connected components.
static InputParameters validParams()
virtual const std::string & name() const
void addRequiredParam(const std::string &name, const std::string &doc_string)
virtual void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters &parameters)
registerMooseObject("ThermalHydraulicsApp", GateValve1Phase)
ExecFlagEnum getDefaultExecFlagEnum()
virtual void check() const override
Check the component integrity.
Single-component, single-phase flow channel.
const std::vector< dof_id_type > & getConnectedElementIDs()
Gets the element IDs of the connected 1D components.
static const std::string RHOUA
std::vector< UserObjectName > _numerical_flux_names
static const std::string RHOA
void checkNumberOfConnections(const unsigned int &n_connections) const
Checks that the number of connections is equal to the supplied value.
const ExecFlagType EXEC_LINEAR
const ExecFlagType EXEC_NONLINEAR
static InputParameters validParams()
virtual void check() const override
Check the component integrity.
const std::string _junction_uo_name
Name of junction user object name, if any.
Definition: FlowJunction.h:40
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Base class for 1-phase flow junctions.
Factory & _factory
The Factory associated with the MooseApp.
Definition: Component.h:446
void connectObject(const InputParameters &params, const std::string &mooseName, const std::string &name) const
Connect with control logic.
Definition: Component.C:98
virtual std::vector< std::shared_ptr< UserObject > > addUserObject(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
const std::vector< Connection > & getConnections() const
Returns the vector of connections of this component.
const bool & getImplicitTimeIntegrationFlag()
Gets the flag indicating whether an implicit time integration scheme is being used.
Definition: Simulation.h:329
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
static const std::string RHOEA
std::vector< Real > _normals
Outward normals associated with connected components.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
virtual void augmentSparsity(const dof_id_type &elem_id1, const dof_id_type &elem_id2)
Hint how to augment sparsity pattern between two elements.
Definition: Simulation.C:71
virtual void addMooseObjects() override
const ExecFlagType EXEC_INITIAL