Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/components/CoaxialJunction1Phase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "Component.h"
#include "InputParameters.h"

class CoaxialJunction1Phase : public Component {
public:
static InputParameters validParams();

CoaxialJunction1Phase(const InputParameters &params);

protected:
/// Connects the same solid region of two coaxial pipes
void ConnectSolidRegion(const std::string &region_name,
const ComponentName &component1,
const ComponentName &component2);

/// Connects the same flow region of two coaxial pipes
void ConnectFlowRegion(const std::string &region_name,
const ComponentName &component1,
const ComponentName &component2);
};
4 changes: 3 additions & 1 deletion include/components/CoaxialPipe1Phase.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <Component1D.h>
#pragma once

#include <Component.h>
#include <FlowChannel1Phase.h>
#include <InputParameters.h>

Expand Down
131 changes: 131 additions & 0 deletions src/components/CoaxialJunction1Phase.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
#include "CoaxialJunction1Phase.h"
#include "Component.h"
#include "InputParameters.h"
#include "MooseTypes.h"
#include "Registry.h"

registerMooseObject("ProteusApp", CoaxialJunction1Phase);

namespace {
// Splits component name into component and boundary pair and checks validity
inline std::pair<std::string, std::string>
getComponentAndBoundary(const ComponentName &component) {
auto it = component.rfind(":");
if (it == component.size())
mooseError("No boundary specified. 'coaxial_connections' must be specified "
"as <coaxial>:<boundary>.");

auto comp = component.substr(0, it);
auto boundary = component.substr(it + 1);

if (!(boundary == "in" || boundary == "out"))
mooseError("Boundary must be 'in' or 'out', not '", boundary, "'.");

return {comp, boundary};
}
} // namespace

InputParameters CoaxialJunction1Phase::validParams() {
auto params = Component::validParams();
params.addRequiredParam<std::vector<ComponentName>>(
"coaxial_connections", "Coaxial pipes boundaries to connect. "
"<name>:in indicates start of the pipe, "
"<name>:out indicates the end of the pipe.");

// Passed to 2D coupler
params.addRequiredParam<FunctionName>("tube_htc",
"HTC used for coupling tube regions.");
params.addRequiredParam<FunctionName>("shell_htc",
"HTC used for coupling shell regions.");

// Allows other componenets such as pumps to be inserted instead
params.addParam<bool>("connect_inner", true,
"Whether to connect inner pipe.");
params.addParam<bool>("connect_outer", true,
"Whether to connect the outer annulus.");

params.addParam<bool>("connect_tube", true,
"Whether to connect the solid tube regions.");
params.addParam<bool>("connect_shell", true,
"Whether to connect the solid shell regions.");

return params;
}

CoaxialJunction1Phase::CoaxialJunction1Phase(const InputParameters &params)
: Component(params) {

auto coaxials = params.get<std::vector<ComponentName>>("coaxial_connections");

if (coaxials.size() != 2)
mooseError("'coaxial_connections' must have size 2.");

if (getParam<bool>("connect_tube")) {
ConnectSolidRegion("tube", coaxials[0], coaxials[1]);
}

if (getParam<bool>("connect_shell")) {
ConnectSolidRegion("shell", coaxials[0], coaxials[1]);
}

if (params.get<bool>("connect_inner")) {
ConnectFlowRegion("inner", coaxials[0], coaxials[1]);
}
if (params.get<bool>("connect_outer")) {
ConnectFlowRegion("outer", coaxials[0], coaxials[1]);
}
}

void CoaxialJunction1Phase::ConnectSolidRegion(
const std::string &region_name, const ComponentName &component1,
const ComponentName &component2) {
auto comp_boundary1 = getComponentAndBoundary(component1);
auto comp_boundary2 = getComponentAndBoundary(component2);

const std::string class_name = "HeatStructure2DCoupler";
auto params = _factory.getValidParams(class_name);
params.set<THMProblem *>("_thm_problem") = &getTHMProblem();

// The ends of the solid regions are called start and end rather than in and
// out
auto boundary1 = (comp_boundary1.second == "in") ? "start" : "end";
auto boundary2 = (comp_boundary2.second == "in") ? "start" : "end";

params.set<std::string>("primary_heat_structure") =
comp_boundary1.first + "/" + region_name;
params.set<BoundaryName>("primary_boundary") =
comp_boundary1.first + "/" + region_name + ":" + boundary1;

params.set<std::string>("secondary_heat_structure") =
comp_boundary2.first + "/" + region_name;
params.set<BoundaryName>("secondary_boundary") =
comp_boundary2.first + "/" + region_name + ":" + boundary2;

params.set<FunctionName>("heat_transfer_coefficient") =
parameters().get<FunctionName>(region_name + "_htc");

getTHMProblem().addComponent(class_name,
name() + "/" + region_name + "_coupler", params);
}

void CoaxialJunction1Phase::ConnectFlowRegion(const std::string &region_name,
const ComponentName &component1,
const ComponentName &component2) {
auto comp_boundary1 = getComponentAndBoundary(component1);
auto comp_boundary2 = getComponentAndBoundary(component2);

// In the future, we could create a component to account for form
// loss due to geometry changes
const std::string class_name = "JunctionOneToOne1Phase";
auto params = _factory.getValidParams(class_name);
params.set<THMProblem *>("_thm_problem") = &getTHMProblem();

std::vector<BoundaryName> connections = {
comp_boundary1.first + "/" + region_name + ":" + comp_boundary1.second,
comp_boundary2.first + "/" + region_name + ":" + comp_boundary2.second,
};
params.set<std::vector<BoundaryName>>("connections") = connections;

getTHMProblem().addComponent(
class_name, name() + "/" + region_name + "_junction", params);
}
18 changes: 16 additions & 2 deletions src/components/CoaxialPipe1Phase.C
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ InputParameters CoaxialPipe1Phase::validParams() {
params.addParam<FunctionName>("initial_p", "Global pressure initialisation");
params.addParam<FunctionName>("initial_vel",
"Global velocity initialisation");
params.addParamNamesToGroup("fp closures initial_T initial_p initial_vel",
"global");
params.addParam<RealVectorValue>(
"gravity_vector", RealVectorValue{0, 0, -9.81}, "Gravity vector");
params.addParamNamesToGroup(
"fp closures initial_T initial_p initial_vel gravity_vector", "global");

return params;
}
Expand Down Expand Up @@ -175,6 +177,10 @@ void CoaxialPipe1Phase::AddInnerPipe(const InputParameters &params) {
params.get<RealVectorValue>("orientation");
pipe_params.set<std::vector<Real>>("length") =
params.get<std::vector<Real>>("length");
pipe_params.set<std::vector<std::string>>("axial_region_names") =
params.get<std::vector<std::string>>("axial_region_names");
pipe_params.set<RealVectorValue>("gravity_vector") =
params.get<RealVectorValue>("gravity_vector");

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

Expand Down Expand Up @@ -214,6 +220,10 @@ void CoaxialPipe1Phase::AddOuterAnnulus(const InputParameters &params) {
params.get<RealVectorValue>("orientation");
pipe_params.set<std::vector<Real>>("length") =
params.get<std::vector<Real>>("length");
pipe_params.set<std::vector<std::string>>("axial_region_names") =
params.get<std::vector<std::string>>("axial_region_names");
pipe_params.set<RealVectorValue>("gravity_vector") =
params.get<RealVectorValue>("gravity_vector");

Real tube_radius = params.get<Real>("tube_inner_radius");
auto tube_widths = params.get<std::vector<Real>>("tube_widths");
Expand Down Expand Up @@ -264,6 +274,8 @@ void CoaxialPipe1Phase::AddSolidTube(const InputParameters &params) {
params.get<RealVectorValue>("orientation");
tube_params.set<std::vector<Real>>("length") =
params.get<std::vector<Real>>("length");
tube_params.set<std::vector<std::string>>("axial_region_names") =
params.get<std::vector<std::string>>("axial_region_names");

copyParamFromParamWithGlobal<FunctionName>("initial_T", "tube_initial_T",
"initial_T", tube_params, params);
Expand Down Expand Up @@ -297,6 +309,8 @@ void CoaxialPipe1Phase::AddSolidShell(const InputParameters &params) {
params.get<RealVectorValue>("orientation");
tube_params.set<std::vector<Real>>("length") =
params.get<std::vector<Real>>("length");
tube_params.set<std::vector<std::string>>("axial_region_names") =
params.get<std::vector<std::string>>("axial_region_names");

copyParamFromParamWithGlobal<FunctionName>("initial_T", "shell_initial_T",
"initial_T", tube_params, params);
Expand Down
Loading
Loading