Skip to content

Commit fdd57e8

Browse files
authored
Merge pull request #52 from aurora-multiphysics/coaxial-junction
Add coaxial junction to join two coaxial pipes together
2 parents 77e38bb + 3724828 commit fdd57e8

9 files changed

Lines changed: 946 additions & 3 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include "Component.h"
4+
#include "InputParameters.h"
5+
6+
class CoaxialJunction1Phase : public Component {
7+
public:
8+
static InputParameters validParams();
9+
10+
CoaxialJunction1Phase(const InputParameters &params);
11+
12+
protected:
13+
/// Connects the same solid region of two coaxial pipes
14+
void ConnectSolidRegion(const std::string &region_name,
15+
const ComponentName &component1,
16+
const ComponentName &component2);
17+
18+
/// Connects the same flow region of two coaxial pipes
19+
void ConnectFlowRegion(const std::string &region_name,
20+
const ComponentName &component1,
21+
const ComponentName &component2);
22+
};

include/components/CoaxialPipe1Phase.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#include <Component1D.h>
1+
#pragma once
2+
3+
#include <Component.h>
24
#include <FlowChannel1Phase.h>
35
#include <InputParameters.h>
46

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#include "CoaxialJunction1Phase.h"
2+
#include "Component.h"
3+
#include "InputParameters.h"
4+
#include "MooseTypes.h"
5+
#include "Registry.h"
6+
7+
registerMooseObject("ProteusApp", CoaxialJunction1Phase);
8+
9+
namespace {
10+
// Splits component name into component and boundary pair and checks validity
11+
inline std::pair<std::string, std::string>
12+
getComponentAndBoundary(const ComponentName &component) {
13+
auto it = component.rfind(":");
14+
if (it == component.size())
15+
mooseError("No boundary specified. 'coaxial_connections' must be specified "
16+
"as <coaxial>:<boundary>.");
17+
18+
auto comp = component.substr(0, it);
19+
auto boundary = component.substr(it + 1);
20+
21+
if (!(boundary == "in" || boundary == "out"))
22+
mooseError("Boundary must be 'in' or 'out', not '", boundary, "'.");
23+
24+
return {comp, boundary};
25+
}
26+
} // namespace
27+
28+
InputParameters CoaxialJunction1Phase::validParams() {
29+
auto params = Component::validParams();
30+
params.addRequiredParam<std::vector<ComponentName>>(
31+
"coaxial_connections", "Coaxial pipes boundaries to connect. "
32+
"<name>:in indicates start of the pipe, "
33+
"<name>:out indicates the end of the pipe.");
34+
35+
// Passed to 2D coupler
36+
params.addRequiredParam<FunctionName>("tube_htc",
37+
"HTC used for coupling tube regions.");
38+
params.addRequiredParam<FunctionName>("shell_htc",
39+
"HTC used for coupling shell regions.");
40+
41+
// Allows other componenets such as pumps to be inserted instead
42+
params.addParam<bool>("connect_inner", true,
43+
"Whether to connect inner pipe.");
44+
params.addParam<bool>("connect_outer", true,
45+
"Whether to connect the outer annulus.");
46+
47+
params.addParam<bool>("connect_tube", true,
48+
"Whether to connect the solid tube regions.");
49+
params.addParam<bool>("connect_shell", true,
50+
"Whether to connect the solid shell regions.");
51+
52+
return params;
53+
}
54+
55+
CoaxialJunction1Phase::CoaxialJunction1Phase(const InputParameters &params)
56+
: Component(params) {
57+
58+
auto coaxials = params.get<std::vector<ComponentName>>("coaxial_connections");
59+
60+
if (coaxials.size() != 2)
61+
mooseError("'coaxial_connections' must have size 2.");
62+
63+
if (getParam<bool>("connect_tube")) {
64+
ConnectSolidRegion("tube", coaxials[0], coaxials[1]);
65+
}
66+
67+
if (getParam<bool>("connect_shell")) {
68+
ConnectSolidRegion("shell", coaxials[0], coaxials[1]);
69+
}
70+
71+
if (params.get<bool>("connect_inner")) {
72+
ConnectFlowRegion("inner", coaxials[0], coaxials[1]);
73+
}
74+
if (params.get<bool>("connect_outer")) {
75+
ConnectFlowRegion("outer", coaxials[0], coaxials[1]);
76+
}
77+
}
78+
79+
void CoaxialJunction1Phase::ConnectSolidRegion(
80+
const std::string &region_name, const ComponentName &component1,
81+
const ComponentName &component2) {
82+
auto comp_boundary1 = getComponentAndBoundary(component1);
83+
auto comp_boundary2 = getComponentAndBoundary(component2);
84+
85+
const std::string class_name = "HeatStructure2DCoupler";
86+
auto params = _factory.getValidParams(class_name);
87+
params.set<THMProblem *>("_thm_problem") = &getTHMProblem();
88+
89+
// The ends of the solid regions are called start and end rather than in and
90+
// out
91+
auto boundary1 = (comp_boundary1.second == "in") ? "start" : "end";
92+
auto boundary2 = (comp_boundary2.second == "in") ? "start" : "end";
93+
94+
params.set<std::string>("primary_heat_structure") =
95+
comp_boundary1.first + "/" + region_name;
96+
params.set<BoundaryName>("primary_boundary") =
97+
comp_boundary1.first + "/" + region_name + ":" + boundary1;
98+
99+
params.set<std::string>("secondary_heat_structure") =
100+
comp_boundary2.first + "/" + region_name;
101+
params.set<BoundaryName>("secondary_boundary") =
102+
comp_boundary2.first + "/" + region_name + ":" + boundary2;
103+
104+
params.set<FunctionName>("heat_transfer_coefficient") =
105+
parameters().get<FunctionName>(region_name + "_htc");
106+
107+
getTHMProblem().addComponent(class_name,
108+
name() + "/" + region_name + "_coupler", params);
109+
}
110+
111+
void CoaxialJunction1Phase::ConnectFlowRegion(const std::string &region_name,
112+
const ComponentName &component1,
113+
const ComponentName &component2) {
114+
auto comp_boundary1 = getComponentAndBoundary(component1);
115+
auto comp_boundary2 = getComponentAndBoundary(component2);
116+
117+
// In the future, we could create a component to account for form
118+
// loss due to geometry changes
119+
const std::string class_name = "JunctionOneToOne1Phase";
120+
auto params = _factory.getValidParams(class_name);
121+
params.set<THMProblem *>("_thm_problem") = &getTHMProblem();
122+
123+
std::vector<BoundaryName> connections = {
124+
comp_boundary1.first + "/" + region_name + ":" + comp_boundary1.second,
125+
comp_boundary2.first + "/" + region_name + ":" + comp_boundary2.second,
126+
};
127+
params.set<std::vector<BoundaryName>>("connections") = connections;
128+
129+
getTHMProblem().addComponent(
130+
class_name, name() + "/" + region_name + "_junction", params);
131+
}

src/components/CoaxialPipe1Phase.C

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,10 @@ InputParameters CoaxialPipe1Phase::validParams() {
130130
params.addParam<FunctionName>("initial_p", "Global pressure initialisation");
131131
params.addParam<FunctionName>("initial_vel",
132132
"Global velocity initialisation");
133-
params.addParamNamesToGroup("fp closures initial_T initial_p initial_vel",
134-
"global");
133+
params.addParam<RealVectorValue>(
134+
"gravity_vector", RealVectorValue{0, 0, -9.81}, "Gravity vector");
135+
params.addParamNamesToGroup(
136+
"fp closures initial_T initial_p initial_vel gravity_vector", "global");
135137

136138
return params;
137139
}
@@ -175,6 +177,10 @@ void CoaxialPipe1Phase::AddInnerPipe(const InputParameters &params) {
175177
params.get<RealVectorValue>("orientation");
176178
pipe_params.set<std::vector<Real>>("length") =
177179
params.get<std::vector<Real>>("length");
180+
pipe_params.set<std::vector<std::string>>("axial_region_names") =
181+
params.get<std::vector<std::string>>("axial_region_names");
182+
pipe_params.set<RealVectorValue>("gravity_vector") =
183+
params.get<RealVectorValue>("gravity_vector");
178184

179185
Real radius = params.get<Real>("tube_inner_radius");
180186

@@ -214,6 +220,10 @@ void CoaxialPipe1Phase::AddOuterAnnulus(const InputParameters &params) {
214220
params.get<RealVectorValue>("orientation");
215221
pipe_params.set<std::vector<Real>>("length") =
216222
params.get<std::vector<Real>>("length");
223+
pipe_params.set<std::vector<std::string>>("axial_region_names") =
224+
params.get<std::vector<std::string>>("axial_region_names");
225+
pipe_params.set<RealVectorValue>("gravity_vector") =
226+
params.get<RealVectorValue>("gravity_vector");
217227

218228
Real tube_radius = params.get<Real>("tube_inner_radius");
219229
auto tube_widths = params.get<std::vector<Real>>("tube_widths");
@@ -264,6 +274,8 @@ void CoaxialPipe1Phase::AddSolidTube(const InputParameters &params) {
264274
params.get<RealVectorValue>("orientation");
265275
tube_params.set<std::vector<Real>>("length") =
266276
params.get<std::vector<Real>>("length");
277+
tube_params.set<std::vector<std::string>>("axial_region_names") =
278+
params.get<std::vector<std::string>>("axial_region_names");
267279

268280
copyParamFromParamWithGlobal<FunctionName>("initial_T", "tube_initial_T",
269281
"initial_T", tube_params, params);
@@ -297,6 +309,8 @@ void CoaxialPipe1Phase::AddSolidShell(const InputParameters &params) {
297309
params.get<RealVectorValue>("orientation");
298310
tube_params.set<std::vector<Real>>("length") =
299311
params.get<std::vector<Real>>("length");
312+
tube_params.set<std::vector<std::string>>("axial_region_names") =
313+
params.get<std::vector<std::string>>("axial_region_names");
300314

301315
copyParamFromParamWithGlobal<FunctionName>("initial_T", "shell_initial_T",
302316
"initial_T", tube_params, params);

0 commit comments

Comments
 (0)