https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WellBase.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 "WellBase.h"
11#include "PhysicalConstants.h"
12
15{
17
18 params.addRequiredParam<Point>("surface_point", "Surface point [m]");
19 params.addRequiredParam<std::vector<Point>>("junction_points", "Junction points [m]");
20 params.addParam<Point>(
21 "end_point", "End point [m]. If not provided, the well ends at the final volume junction");
22 params.addRequiredParam<std::vector<unsigned int>>("section_n_elems",
23 "Number of elements in each well section");
24 params.addRequiredParam<FunctionName>("area",
25 "Cross-sectional flow area function of the well [m^2]");
26 params.addRequiredParam<std::vector<Real>>("junction_coupling_areas",
27 "Flow surface area for each junction point [m^2]");
28 params.addRequiredParam<RealVectorValue>("fracture_direction", "Direction to fracture");
29 params.addRequiredParam<Real>("junction_volume", "Volume of each junction [m^3]");
30
31 params.addRequiredParam<FunctionName>("initial_pressure", "Initial pressure function [Pa]");
32 params.addRequiredParam<FunctionName>("initial_temperature", "Initial temperature function [K]");
33
34 params.addRequiredParam<UserObjectName>("fluid_properties", "Fluid properties object");
35 params.addParam<FunctionName>("friction_factor", "0.0", "Darcy friction factor function");
36
37 params.addParam<MultiAppName>(
38 "multi_app",
39 "If provided, transfers occur with this MultiApp. The following would be transferred: mass "
40 "flow rate, energy flow rate, temperature, and pressure at each junction.");
41
42 return params;
43}
44
46 : THMActionComponent(params),
47 _surface_point(getParam<Point>("surface_point")),
48 _junction_points(getParam<std::vector<Point>>("junction_points")),
49 _section_n_elems(getParam<std::vector<unsigned int>>("section_n_elems")),
50 _n_sections(_section_n_elems.size()),
51 _junction_coupling_areas(getParam<std::vector<Real>>("junction_coupling_areas")),
52 _closures_name(name() + "_closures")
53{
54 _all_points.push_back(_surface_point);
55 for (const auto i : index_range(_junction_points))
56 _all_points.push_back(_junction_points[i]);
57 if (isParamValid("end_point"))
58 _all_points.push_back(getParam<Point>("end_point"));
59
60 checkVectorParamsSameLength<Point, unsigned int>("junction_points", "section_n_elems");
61 checkVectorParamsSameLength<Point, Real>("junction_points", "junction_coupling_areas");
62}
63
64void
66{
67 const std::string class_name = "Closures1PhaseSimple";
68 auto params = _factory.getValidParams(class_name);
69 addClosuresObject(class_name, _closures_name, params);
70}
71
72void
74{
75 for (const auto i : index_range(_all_points))
76 if (i != 0)
77 addFlowChannel(i - 1, is_production);
78
79 if (isParamValid("end_point"))
80 addWall(is_production);
81
82 for (const auto i : index_range(_junction_points))
83 {
84 addJunction(i, is_production);
86 }
87}
88
89void
90WellBase::addFlowChannel(unsigned int i, bool is_production)
91{
92 Point start_position, end_position;
93 if (is_production)
94 {
95 start_position = _all_points[i + 1];
96 end_position = _all_points[i];
97 }
98 else
99 {
100 start_position = _all_points[i];
101 end_position = _all_points[i + 1];
102 }
103
104 const RealVectorValue translation = end_position - start_position;
105
106 const std::string class_name = "FlowChannel1Phase";
107 auto params = _factory.getValidParams(class_name);
108 params.set<Point>("position") = start_position;
109 params.set<RealVectorValue>("orientation") = translation;
110 params.set<std::vector<Real>>("length") = {translation.norm()};
111 params.set<std::vector<unsigned int>>("n_elems") = {_section_n_elems[i]};
112 params.set<FunctionName>("A") = getParam<FunctionName>("area");
113 params.set<FunctionName>("initial_p") = getParam<FunctionName>("initial_pressure");
114 params.set<FunctionName>("initial_T") = getParam<FunctionName>("initial_temperature");
115 params.set<FunctionName>("initial_vel") = "0.0";
116 params.set<RealVectorValue>("gravity_vector") = {
118 params.set<UserObjectName>("fp") = getParam<UserObjectName>("fluid_properties");
119 params.set<std::vector<std::string>>("closures") = {_closures_name};
120 params.set<FunctionName>("f") = getParam<FunctionName>("friction_factor");
121 params.set<MooseEnum>("rdg_slope_reconstruction") = "full";
122 params.set<std::vector<Real>>("scaling_factor_1phase") = {1.0, 1.0, 1e-5};
123 params.set<std::vector<VariableName>>("vpp_vars") = {"p"};
124 params.set<bool>("create_flux_vpp") = true;
125 addTHMComponent(class_name, flowChannelName(i), params);
126}
127
128void
129WellBase::addWall(bool is_production)
130{
131 const std::string in_or_out = is_production ? ":in" : ":out";
132
133 const std::string class_name = "SolidWall1Phase";
134 auto params = _factory.getValidParams(class_name);
135 params.set<BoundaryName>("input") = flowChannelName(_n_sections - 1) + in_or_out;
136 addTHMComponent(class_name, name() + "_wall", params);
137}
138
139void
140WellBase::addJunction(unsigned int i, bool is_production)
141{
142 const std::string first_end = is_production ? ":in" : ":out";
143 const std::string second_end = is_production ? ":out" : ":in";
144 std::vector<BoundaryName> connections;
145 connections.push_back(flowChannelName(i) + first_end);
146 if (i + 1 <= _n_sections - 1)
147 connections.push_back(flowChannelName(i + 1) + second_end);
148
149 const std::string class_name = "VolumeJunction1Phase";
150 auto params = _factory.getValidParams(class_name);
151 params.set<Point>("position") = _junction_points[i];
152 params.set<std::vector<BoundaryName>>("connections") = connections;
153 params.set<FunctionName>("initial_p") = getParam<FunctionName>("initial_pressure");
154 params.set<FunctionName>("initial_T") = getParam<FunctionName>("initial_temperature");
155 params.set<FunctionName>("initial_vel_x") = "0.0";
156 params.set<FunctionName>("initial_vel_y") = "0.0";
157 params.set<FunctionName>("initial_vel_z") = "0.0";
158 params.set<Real>("volume") = getParam<Real>("junction_volume");
159 params.set<Real>("scaling_factor_rhoEV") = 1e-5;
160 addTHMComponent(class_name, volumeJunctionName(i), params);
161}
162
163void
165{
166 const std::string class_name = "VolumeJunctionCoupledFlux1Phase";
167 auto params = _factory.getValidParams(class_name);
168 params.set<Real>("A_coupled") = _junction_coupling_areas[i];
169 params.set<RealVectorValue>("normal_from_junction") =
170 getParam<RealVectorValue>("fracture_direction");
171 params.set<std::string>("volume_junction") = volumeJunctionName(i);
172 params.set<std::string>("pp_suffix") = name() + std::to_string(i + 1);
173 if (isParamValid("multi_app"))
174 params.set<MultiAppName>("multi_app") = getParam<MultiAppName>("multi_app");
175 addTHMComponent(class_name, volumeJunctionName(i) + "_flux", params);
176}
177
178std::string
179WellBase::flowChannelName(unsigned int i) const
180{
181 return name() + std::to_string(i + 1);
182}
183
184std::string
185WellBase::volumeJunctionName(unsigned int i) const
186{
187 return name() + "_junc" + std::to_string(i + 1);
188}
const std::string name
Definition Setup.h:21
void ErrorVector unsigned int
InputParameters getValidParams(const std::string &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
const std::string & name() const
bool isParamValid(const std::string &name) const
Factory & _factory
Base class for ActionComponents that build THM components.
static InputParameters validParams()
void addClosuresObject(const std::string &class_name, const std::string &obj_name, InputParameters &params)
Adds a Closures object.
void addTHMComponent(const std::string &class_name, const std::string &obj_name, InputParameters &params)
Adds a THM component.
const std::vector< Point > & _junction_points
Junction points.
Definition WellBase.h:45
void addJunctionFlux(unsigned int i)
Adds a junction coupling.
Definition WellBase.C:164
void addJunction(unsigned int i, bool is_production)
Adds a junction.
Definition WellBase.C:140
void addWall(bool is_production)
Adds a wall at the end of a well.
Definition WellBase.C:129
std::string flowChannelName(unsigned int i) const
Name of a flow channel.
Definition WellBase.C:179
const unsigned int _n_sections
Number of flow channels.
Definition WellBase.h:49
static InputParameters validParams()
Definition WellBase.C:14
virtual void addClosures() override
Definition WellBase.C:65
const std::string _closures_name
Closures name.
Definition WellBase.h:53
const std::vector< Real > & _junction_coupling_areas
Coupled flow area of each junction.
Definition WellBase.h:51
WellBase(const InputParameters &params)
Definition WellBase.C:45
std::vector< Point > _all_points
Surface point, junction points, and optional end point.
Definition WellBase.h:56
void addFlowChannel(unsigned int i, bool is_production)
Adds a flow channel.
Definition WellBase.C:90
std::string volumeJunctionName(unsigned int i) const
Name of a volume junction.
Definition WellBase.C:185
const std::vector< unsigned int > & _section_n_elems
Number of elements in each flow channel.
Definition WellBase.h:47
const Point & _surface_point
Surface point.
Definition WellBase.h:43
void addWellBaseComponents(bool is_production)
Adds the components common to both injection and production.
Definition WellBase.C:73
const auto acceleration_of_gravity