Skip to content

Commit 4cd1bce

Browse files
committed
Deal with deprecation and add tests
1 parent 6e1564e commit 4cd1bce

File tree

7 files changed

+145
-33
lines changed

7 files changed

+145
-33
lines changed

framework/src/kernels/ConservativeAdvection.C

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ ConservativeAdvectionTempl<false>::validParams()
4040
{
4141
InputParameters params = generalParams();
4242
params.addCoupledVar("velocity", "Velocity vector");
43-
params.renameCoupledVar("velocity",
44-
"velocity_variable",
45-
"Velocity vector given as a variable. 'velocity' is deprecated and will "
46-
"be removed on 12/31/2025. Please use velocity_variable.");
43+
params.deprecateCoupledVar("velocity", "velocity_variable ", "12/31/2025");
4744
return params;
4845
}
4946

@@ -52,18 +49,23 @@ InputParameters
5249
ConservativeAdvectionTempl<is_ad>::validParams()
5350
{
5451
InputParameters params = generalParams();
55-
params.addParam<MaterialPropertyName>("velocity", "Velocity vector");
56-
params.renameParam("velocity",
57-
"velocity_material",
58-
"Velocity vector given as a material. 'velocity' is deprecated and will be "
59-
"removed on 12/31/2025. Please use velocity_material.");
52+
params.addDeprecatedParam<MaterialPropertyName>(
53+
"velocity",
54+
"Velocity vector given as a material",
55+
"The velocity parameter in ADConservativeAdvection will be removed on 12/31/2025. Use "
56+
"velocity_material or velocity_variable instead.");
6057
return params;
6158
}
6259

6360
template <bool is_ad>
6461
ConservativeAdvectionTempl<is_ad>::ConservativeAdvectionTempl(const InputParameters & parameters)
6562
: GenericKernel<is_ad>(parameters),
66-
_velocity(isParamValid("velocity_material")
63+
_velocity(this->isParamValid("velocity")
64+
? (is_ad ? &this->template getGenericMaterialProperty<RealVectorValue, is_ad>(
65+
"velocity")
66+
.get()
67+
: &this->template coupledGenericVectorValue<is_ad>("velocity"))
68+
: this->isParamValid("velocity_material")
6769
? &this->template getGenericMaterialProperty<RealVectorValue, is_ad>(
6870
"velocity_material")
6971
.get()
@@ -84,10 +86,13 @@ ConservativeAdvectionTempl<is_ad>::ConservativeAdvectionTempl(const InputParamet
8486
paramError(
8587
"advected_quantity",
8688
"Upwinding is not compatable with an advected quantity that is not the primary variable.");
87-
if ((!this->isParamValid("velocity_variable") && !isParamValid("velocity_material")) ||
88-
(this->isParamValid("velocity_variable") && isParamValid("velocity_material")))
89+
90+
if (!_velocity || (this->isParamValid("velocity") && this->isParamValid("velocity_material")) ||
91+
(this->isParamValid("velocity_variable") && this->isParamValid("velocity_material")) ||
92+
(this->isParamValid("velocity") && this->isParamValid("velocity_variable")))
8993
paramError("velocity_variable",
90-
"Either velocity_variable or velocity_material must be specificied, not both.");
94+
"Either velocity_variable or velocity_material must be specificied, not both, nor "
95+
"velocity.");
9196
}
9297

9398
template <bool is_ad>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# ADConservativeAdvection with upwinding_type = None
2+
# Apply a velocity = (1, 0, 0) and see a pulse advect to the right
3+
# Note there are overshoots and undershoots
4+
[Mesh]
5+
type = GeneratedMesh
6+
dim = 1
7+
nx = 10
8+
[]
9+
10+
[Variables]
11+
[u]
12+
[]
13+
[]
14+
15+
[BCs]
16+
[u_injection_left]
17+
type = InflowBC
18+
boundary = left
19+
variable = u
20+
velocity = '1 0 0'
21+
inlet_conc = 1
22+
[]
23+
[]
24+
25+
[Materials]
26+
[v]
27+
type = ADGenericConstantVectorMaterial
28+
prop_names = v
29+
prop_values = '1 0 0'
30+
[]
31+
[]
32+
33+
[Kernels]
34+
[udot]
35+
type = ADTimeDerivative
36+
variable = u
37+
[]
38+
[advection]
39+
type = ADConservativeAdvection
40+
variable = u
41+
[]
42+
[]
43+
44+
[Executioner]
45+
type = Transient
46+
solve_type = LINEAR
47+
dt = 0.1
48+
end_time = 1
49+
l_tol = 1E-14
50+
[]
51+
52+
[Outputs]
53+
exodus = true
54+
[]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
no_upwinding_1D_out.e
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
no_upwinding_1D_out.e
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
no_upwinding_1D_out.e

test/tests/kernels/conservative_advection/no_upwinding_1D.i

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,29 @@
88
[]
99

1010
[Variables]
11-
[./u]
12-
[../]
11+
[u]
12+
[]
1313
[]
1414

1515
[BCs]
16-
[./u_injection_left]
16+
[u_injection_left]
1717
type = InflowBC
1818
boundary = left
1919
variable = u
2020
velocity = '1 0 0'
2121
inlet_conc = 1
22-
[../]
22+
[]
2323
[]
2424

2525
[Kernels]
26-
[./udot]
26+
[udot]
2727
type = TimeDerivative
2828
variable = u
29-
[../]
30-
[./advection]
29+
[]
30+
[advection]
3131
type = ConservativeAdvection
3232
variable = u
33-
velocity = '1 0 0'
34-
[../]
33+
[]
3534
[]
3635

3736
[Executioner]

test/tests/kernels/conservative_advection/tests

Lines changed: 62 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,38 @@
22
design = 'ConservativeAdvection.md'
33
issues = '#11852'
44

5+
[error]
6+
requirement = 'The system shall handle unique cases when trying to compute conservative advection '
7+
[no_velocity]
8+
type = RunException
9+
input = no_upwinding_1D.i
10+
detail = 'by throwing an error when no velocity is given,'
11+
expect_err = "Either velocity_variable or velocity_material must be specificied, not both, nor velocity."
12+
[]
13+
[ad_no_velocity]
14+
type = RunException
15+
input = ad_no_upwinding_1D.i
16+
detail = 'by throwing an error when no velocity is given when using AD,'
17+
expect_err = "Either velocity_variable or velocity_material must be specificied, not both, nor velocity."
18+
[]
19+
[deprecated_velocity]
20+
type = RunException
21+
input = no_upwinding_1D.i
22+
detail = 'by throwing a deprecation warning when no velocity is given when using AD,'
23+
cli_args = "Kernels/advection/velocity='1 0 0'"
24+
allow_deprecated = False
25+
expect_err = "'velocity' has been deprecated and will be removed on 12/31/2025. Please use 'velocity_variable ' instead."
26+
[]
27+
[ad_deprecated_velocity]
28+
type = RunException
29+
input = ad_no_upwinding_1D.i
30+
detail = 'by throwing a deprecation warning when velocity is given when using AD,'
31+
cli_args = "Kernels/advection/velocity=v Materials/v/type=ADGenericConstantVectorMaterial Materials/v/prop_names=v Materials/v/prop_values='1 0 0'"
32+
allow_deprecated = False
33+
expect_err = "The velocity parameter in ADConservativeAdvection will be removed on 12/31/2025. Use velocity_material or velocity_variable instead."
34+
[]
35+
[]
36+
537
[upwinding]
638
requirement = 'The system shall include the ability to compute the residual contribution from '
739
'the conservative form of the advection operator'
@@ -11,63 +43,82 @@
1143
input = no_upwinding_jacobian.i
1244
ratio_tol = 1E-7
1345
difference_tol = 1E-7
14-
15-
detail = 'without upwinding in 3D,'
46+
detail = 'and compute a perfect jacobian without upwinding in 3D,'
1647
[]
1748
[full_upwinding_jacobian]
1849
type = PetscJacobianTester
1950
input = full_upwinding_jacobian.i
2051
ratio_tol = 1E-7
2152
difference_tol = 1E-7
22-
23-
detail = 'with upwinding in 3D,'
53+
detail = 'and compute a perfect jacobian with upwinding in 3D,'
2454
[]
2555
[no_upwinding_1D]
2656
type = Exodiff
2757
input = no_upwinding_1D.i
2858
exodiff = no_upwinding_1D_out.e
2959
abs_zero = 1E-7
30-
31-
detail = 'without upwinding in 1D,'
60+
cli_args = "Kernels/advection/velocity_variable='1 0 0'"
61+
detail = 'without upwinding in 1D, with velocity given as a variable,'
62+
[]
63+
[no_upwinding_1D_mat]
64+
type = Exodiff
65+
input = no_upwinding_1D.i
66+
prereq = upwinding/no_upwinding_1D
67+
exodiff = no_upwinding_1D_mat_out.e
68+
abs_zero = 1E-7
69+
cli_args = "Outputs/file_base=no_upwinding_1D_mat_out Kernels/advection/velocity_material=v Materials/v/type=GenericConstantVectorMaterial Materials/v/prop_names=v Materials/v/prop_values='1 0 0'"
70+
detail = 'without upwinding in 1D, with velocity given as a material,'
71+
[]
72+
[ad_no_upwinding_1D]
73+
type = Exodiff
74+
input = ad_no_upwinding_1D.i
75+
exodiff = ad_no_upwinding_1D_out.e
76+
abs_zero = 1E-7
77+
cli_args = "Kernels/advection/velocity_variable='1 0 0'"
78+
detail = 'without upwinding in 1D, with velocity given as a variable, using AD,'
79+
[]
80+
[ad_no_upwinding_1D_mat]
81+
type = Exodiff
82+
input = ad_no_upwinding_1D.i
83+
prereq = upwinding/ad_no_upwinding_1D
84+
exodiff = ad_no_upwinding_1D_mat_out.e
85+
abs_zero = 1E-7
86+
cli_args = "Outputs/file_base=ad_no_upwinding_1D_mat_out Kernels/advection/velocity_material=v Materials/v/type=ADGenericConstantVectorMaterial Materials/v/prop_names=v Materials/v/prop_values='1 0 0'"
87+
detail = 'without upwinding in 1D, with velocity given as a material, using AD,'
3288
[]
3389
[full_upwinding_1D]
3490
type = Exodiff
3591
input = full_upwinding_1D.i
3692
exodiff = full_upwinding_1D_out.e
3793
abs_zero = 1E-7
38-
3994
detail = 'with upwinding in 1D,'
4095
[]
4196
[no_upwinding_2D]
4297
type = Exodiff
4398
input = no_upwinding_2D.i
4499
exodiff = no_upwinding_2D_out.e
45100
abs_zero = 1E-7
46-
47101
detail = 'without upwinding in 2D,'
48102
[]
49103
[full_upwinding_2D]
50104
type = Exodiff
51105
input = full_upwinding_2D.i
52106
exodiff = full_upwinding_2D_out.e
53107
abs_zero = 1E-7
54-
55108
detail = 'with upwinding in 2D,'
56109
[]
57110
[none_in_all_out]
58111
type = Exodiff
59112
input = none_in_all_out.i
60113
exodiff = none_in_all_out_out.e
61114
abs_zero = 1E-7
62-
63115
detail = 'with upwinding and an outflow boundary condition, and'
64116
[]
65117
[none_in_none_out]
66118
type = CSVDiff
67119
input = none_in_none_out.i
68120
csvdiff = none_in_none_out_out.csv
69121
abs_zero = 1E-7
70-
71122
detail = 'without any outflow boundary conditions.'
72123
[]
73124
[]

0 commit comments

Comments
 (0)