Skip to content

Commit d06848b

Browse files
committed
Added vpp_vars to FlowChannelBase
Closes #31891
1 parent 3f5bdaa commit d06848b

File tree

8 files changed

+136
-0
lines changed

8 files changed

+136
-0
lines changed

modules/thermal_hydraulics/doc/content/source/components/FlowChannel1Phase.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ the following parameters:
2424
- [!param](/Components/FlowChannel1Phase/initial_T)
2525
- [!param](/Components/FlowChannel1Phase/initial_vel)
2626

27+
This component offers options to output quantities via vector post-processors:
28+
29+
- [!param](/Components/FlowChannel1Phase/vpp_vars): Creates an [ElementValueSampler.md] with a vector for each of the listed variables (see below for a list of variables).
30+
- [!param](/Components/FlowChannel1Phase/create_flux_vpp): Creates a [NumericalFlux3EqnInternalValues.md], which creates a vector for each numerical flux component (mass, momentum, energy) at the internal sides.
31+
2732
!syntax parameters /Components/FlowChannel1Phase
2833

2934
## Mesh id=mesh

modules/thermal_hydraulics/include/components/Component1D.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Component1D : public GeneratedMeshComponent
7373

7474
protected:
7575
virtual bool usingSecondOrderMesh() const override;
76+
std::string sortBy() const;
7677

7778
/// Map of end type to a list of connections
7879
std::map<Component1DConnection::EEndType, std::vector<Connection>> _connections;

modules/thermal_hydraulics/src/components/Component1D.C

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,25 @@ Component1D::getConnections(Component1DConnection::EEndType end_type) const
164164
else
165165
mooseError(name(), ": Invalid end type (", end_type, ").");
166166
}
167+
168+
std::string
169+
Component1D::sortBy() const
170+
{
171+
// choose the dominant direction
172+
std::string dominant_direction = "x";
173+
const Real x_abs = std::abs(_dir(0));
174+
const Real y_abs = std::abs(_dir(1));
175+
const Real z_abs = std::abs(_dir(2));
176+
Real max_value = x_abs;
177+
if (y_abs > max_value)
178+
{
179+
dominant_direction = "y";
180+
max_value = y_abs;
181+
}
182+
if (z_abs > max_value)
183+
{
184+
dominant_direction = "z";
185+
max_value = z_abs;
186+
}
187+
return dominant_direction;
188+
}

modules/thermal_hydraulics/src/components/FlowChannelBase.C

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ FlowChannelBase::validParams()
9898
"If true, when there are multiple heat transfer components connected to "
9999
"this flow channel, use their index for naming related quantities; "
100100
"otherwise, use the name of the heat transfer component.");
101+
params.addParam<std::vector<VariableName>>(
102+
"vpp_vars", {}, "Variables to add in an ElementValueSampler");
101103

102104
params.setDocString(
103105
"orientation",
@@ -321,6 +323,18 @@ FlowChannelBase::addMooseObjects()
321323
}
322324
}
323325

326+
const auto & vpp_vars = getParam<std::vector<VariableName>>("vpp_vars");
327+
if (vpp_vars.size() > 0)
328+
{
329+
const std::string class_name = "ElementValueSampler";
330+
InputParameters params = _factory.getValidParams(class_name);
331+
params.set<std::vector<SubdomainName>>("block") = getSubdomainNames();
332+
params.set<std::vector<VariableName>>("variable") = vpp_vars;
333+
params.set<MooseEnum>("sort_by") = sortBy();
334+
params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_TIMESTEP_END};
335+
getTHMProblem().addVectorPostprocessor(class_name, name() + "_vars_vpp", params);
336+
}
337+
324338
_flow_model->addMooseObjects();
325339

326340
for (const auto & closures : _closures_objects)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
energy_flux,id,mass_flux,momentum_flux,x,y,z
2+
42923519.842431,0,142.59242584674,109018.77462793,0.2,0,1.2246467991474e-17
3+
42926546.468124,1,142.60899170696,108990.26418095,0.4,0,2.4492935982947e-17
4+
42929591.848237,2,142.62563642346,108961.75041735,0.6,0,3.6739403974421e-17
5+
42932655.998424,3,142.64236005822,108933.23332136,0.8,0,4.8985871965894e-17
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
T,id,p,x,y,z
2+
291.32385895141,0,90222.60983281,0.1,0,6.1232339957368e-18
3+
291.30184724105,1,90182.891036046,0.3,0,1.836970198721e-17
4+
291.27977673955,2,90143.131282025,0.5,0,3.0616169978684e-17
5+
291.25764992243,3,90103.333225525,0.7,0,4.2862637970157e-17
6+
291.23546671384,4,90063.496755943,0.9,0,5.5109105961631e-17
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[GlobalParams]
2+
gravity_vector = '0 0 0'
3+
scaling_factor_1phase = '1 1 1e-5'
4+
[]
5+
6+
[FluidProperties]
7+
[fp]
8+
type = IdealGasFluidProperties
9+
[]
10+
[]
11+
12+
[Closures]
13+
[simple_closures]
14+
type = Closures1PhaseSimple
15+
[]
16+
[]
17+
18+
[Components]
19+
[inlet]
20+
type = InletStagnationPressureTemperature1Phase
21+
input = 'pipe:in'
22+
p0 = 1e5
23+
T0 = 300
24+
[]
25+
[pipe]
26+
type = FlowChannel1Phase
27+
position = '0 0 0'
28+
orientation = '1 0 0'
29+
length = 1.0
30+
n_elems = 5
31+
A = 1.0
32+
initial_T = 300
33+
initial_p = 1e5
34+
initial_vel = 0
35+
fp = fp
36+
closures = simple_closures
37+
f = 0
38+
vpp_vars = 'p T'
39+
create_flux_vpp = true
40+
[]
41+
[outlet]
42+
type = Outlet1Phase
43+
input = 'pipe:out'
44+
p = 0.9e5
45+
[]
46+
[]
47+
48+
[Preconditioning]
49+
[pc]
50+
type = SMP
51+
full = true
52+
[]
53+
[]
54+
55+
[Executioner]
56+
type = Transient
57+
scheme = bdf2
58+
59+
start_time = 0
60+
dt = 1
61+
num_steps = 1
62+
63+
solve_type = NEWTON
64+
nl_rel_tol = 1e-8
65+
nl_abs_tol = 1e-8
66+
nl_max_its = 10
67+
68+
l_tol = 1e-3
69+
l_max_its = 10
70+
[]
71+
72+
[Outputs]
73+
csv = true
74+
execute_on = 'FINAL'
75+
[]

modules/thermal_hydraulics/test/tests/components/flow_channel_1phase/tests

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
[]
3939
[]
4040

41+
[output_vpps]
42+
type = CSVDiff
43+
input = 'output_vpps.i'
44+
csvdiff = 'output_vpps_out_pipe_vars_vpp_0002.csv output_vpps_out_pipe_flux_vpp_0002.csv'
45+
rel_err = 1e-6
46+
requirement = 'The system shall be able to simulate a single-phase flow channel and output quantities to a CSV file.'
47+
[]
48+
4149
# error checking
4250
[err:wrong_fp]
4351
type = 'RunException'

0 commit comments

Comments
 (0)