|
| 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 ¶ms) |
| 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 ®ion_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 ®ion_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 | +} |
0 commit comments