Skip to content

Commit 391abd9

Browse files
committed
(a) make active block to be default block (b) add regression test (modules/heat_transfer/test/tests/default_block_check) (c) material_coverage_check fixing
1 parent 1261730 commit 391abd9

15 files changed

+767
-16
lines changed

framework/include/problems/FEProblemBase.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2398,7 +2398,7 @@ class FEProblemBase : public SubProblem, public Restartable
23982398
/**
23992399
* @returns the active blocks
24002400
*/
2401-
const std::vector<SubdomainName> getActiveBlockLists() const { return _active_blocks; };
2401+
const std::vector<SubdomainName> getDefaultBlockLists() const { return _default_blocks; };
24022402

24032403
protected:
24042404
/// Create extra tagged vectors and matrices
@@ -2738,7 +2738,7 @@ class FEProblemBase : public SubProblem, public Restartable
27382738
std::vector<SolverParams> _solver_params;
27392739

27402740
/// blocks that help user to set easier for both kernel and material coverage check
2741-
std::vector<SubdomainName> _active_blocks;
2741+
std::vector<SubdomainName> _default_blocks;
27422742

27432743
/// Determines whether and which subdomains are to be checked to ensure that they have an active kernel
27442744
CoverageCheckMode _kernel_coverage_check;

framework/src/actions/AddVariableAction.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ AddVariableAction::getSubdomainIDs()
314314
std::vector<SubdomainName> block_param =
315315
_moose_object_pars.get<std::vector<SubdomainName>>("block");
316316
if (block_param.empty() && _problem->isParamValid("default_block"))
317-
block_param = _problem->getActiveBlockLists();
317+
block_param = _problem->getDefaultBlockLists();
318318

319319
for (const auto & subdomain_name : block_param)
320320
{

framework/src/interfaces/BlockRestrictable.C

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ BlockRestrictable::initializeBlockRestrictable(const MooseObject * moose_object)
102102
_blk_ids.insert(_vec_ids.begin(), _vec_ids.end());
103103
}
104104

105-
if (_blk_feproblem->isParamValid("default_block"))
105+
if (_blk_feproblem->isParamSetByUser("default_block"))
106106
{
107107
// Get the default block list from the FEProblem
108-
std::vector<SubdomainName> default_blocks = _blk_feproblem->getActiveBlockLists();
108+
std::vector<SubdomainName> default_blocks = _blk_feproblem->getDefaultBlockLists();
109109
// Check that the supplied blocks are a subset of the default blocks
110110
if (!std::includes(
111111
default_blocks.begin(), default_blocks.end(), _blocks.begin(), _blocks.end()))
@@ -114,9 +114,9 @@ BlockRestrictable::initializeBlockRestrictable(const MooseObject * moose_object)
114114
}
115115
}
116116
// when 'default_block' is set at the [Problem] -> 'block' input should come first before this
117-
else if (_blk_feproblem->isParamValid("default_block"))
117+
else if (_blk_feproblem->isParamSetByUser("default_block"))
118118
{
119-
_blocks = _blk_feproblem->getActiveBlockLists();
119+
_blocks = _blk_feproblem->getDefaultBlockLists();
120120
// Get the IDs from the supplied names
121121
_vec_ids = _blk_mesh->getSubdomainIDs(_blocks);
122122

framework/src/problems/FEProblemBase.C

+8-7
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ FEProblemBase::validParams()
360360
"boundary_restricted_elem_integrity_check material_coverage_check "
361361
"material_coverage_block_list fv_bcs_integrity_check "
362362
"material_dependency_check check_uo_aux_state error_on_jacobian_nonzero_reallocation",
363-
"Simulation checks active_blocks");
363+
"Simulation checks default_blocks");
364364
params.addParamNamesToGroup("use_nonlinear previous_nl_solution_required nl_sys_names "
365365
"ignore_zeros_in_jacobian identify_variable_groups_in_nl",
366366
"Nonlinear system(s)");
@@ -450,26 +450,27 @@ FEProblemBase::FEProblemBase(const InputParameters & parameters)
450450
_previous_nl_solution_required(getParam<bool>("previous_nl_solution_required")),
451451
_has_nonlocal_coupling(false),
452452
_calculate_jacobian_in_uo(false),
453-
_active_blocks(getParam<std::vector<SubdomainName>>("default_block")),
453+
_default_blocks(getParam<std::vector<SubdomainName>>("default_block")),
454454
_kernel_coverage_check(
455455
isParamSetByUser("kernel_coverage_check") || !isParamSetByUser("default_block")
456456
? getParam<MooseEnum>("kernel_coverage_check").getEnum<CoverageCheckMode>()
457457
: CoverageCheckMode::ONLY_LIST),
458458
_kernel_coverage_blocks(isParamSetByUser("kernel_coverage_check") ||
459459
!isParamSetByUser("default_block")
460460
? getParam<std::vector<SubdomainName>>("kernel_coverage_block_list")
461-
: _active_blocks),
461+
: _default_blocks),
462462
_boundary_restricted_node_integrity_check(
463463
getParam<bool>("boundary_restricted_node_integrity_check")),
464464
_boundary_restricted_elem_integrity_check(
465465
getParam<bool>("boundary_restricted_elem_integrity_check")),
466466
_material_coverage_check(
467-
_active_blocks.empty()
467+
isParamSetByUser("material_coverage_check") || !isParamSetByUser("default_block")
468468
? getParam<MooseEnum>("material_coverage_check").getEnum<CoverageCheckMode>()
469469
: CoverageCheckMode::ONLY_LIST),
470-
_material_coverage_blocks(_active_blocks.empty() ? getParam<std::vector<SubdomainName>>(
471-
"material_coverage_block_list")
472-
: _active_blocks),
470+
_material_coverage_blocks(
471+
isParamSetByUser("material_coverage_check") || !isParamSetByUser("default_block")
472+
? getParam<std::vector<SubdomainName>>("material_coverage_block_list")
473+
: _default_blocks),
473474
_fv_bcs_integrity_check(getParam<bool>("fv_bcs_integrity_check")),
474475
_material_dependency_check(getParam<bool>("material_dependency_check")),
475476
_uo_aux_state_check(getParam<bool>("check_uo_aux_state")),

framework/src/systems/SystemBase.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ SystemBase::addVariable(const std::string & var_type,
721721
std::set<SubdomainID> blocks;
722722
std::vector<SubdomainName> block_param = parameters.get<std::vector<SubdomainName>>("block");
723723
if (block_param.empty() and _fe_problem.isParamValid("default_block"))
724-
block_param = _fe_problem.getActiveBlockLists();
724+
block_param = _fe_problem.getDefaultBlockLists();
725725

726726
for (const auto & subdomain_name : block_param)
727727
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
[Problem]
2+
default_block = '0 1 3'
3+
[]
4+
5+
[Mesh]
6+
[gmg]
7+
type = GeneratedMeshGenerator
8+
dim = 2
9+
nx = 48
10+
ny = 32
11+
xmin = 0
12+
xmax = 3
13+
ymin = 0
14+
ymax = 2
15+
[]
16+
[block_left]
17+
type = SubdomainBoundingBoxGenerator
18+
input = gmg
19+
block_id = 0
20+
block_name = material_left
21+
bottom_left = '0 0 0'
22+
top_right = '1.25 2.0 0'
23+
[]
24+
[block_right]
25+
type = SubdomainBoundingBoxGenerator
26+
input = block_left
27+
block_id = 1
28+
block_name = material_right
29+
bottom_left = '1.75 0 0'
30+
top_right = '3.0 2.0 0'
31+
[]
32+
[block_middle]
33+
type = SubdomainBoundingBoxGenerator
34+
input = block_right
35+
block_id = 2
36+
block_name = material_null
37+
bottom_left = '1.25 0 0'
38+
top_right = '1.75 2.0 0'
39+
[]
40+
[block_middle_new]
41+
type = SubdomainBoundingBoxGenerator
42+
input = block_middle
43+
block_id = 3
44+
block_name = material_middle
45+
bottom_left = '1.25 1.0 0'
46+
top_right = '1.75 2.0 0'
47+
[]
48+
use_displaced_mesh = false
49+
[]
50+
51+
[Variables]
52+
[cond]
53+
order = FIRST
54+
[]
55+
[]
56+
57+
[Kernels]
58+
[diff]
59+
type = HeatConduction
60+
variable = cond
61+
block = '0 1'
62+
[]
63+
64+
[heat_ie]
65+
type = HeatConductionTimeDerivative
66+
variable = cond
67+
block = '3'
68+
[]
69+
[]
70+
71+
[Materials]
72+
[material_left_cond]
73+
type = HeatConductionMaterial
74+
block = 0
75+
specific_heat = 30
76+
thermal_conductivity = 20
77+
[]
78+
[material_right_cond]
79+
type = HeatConductionMaterial
80+
block = 1
81+
specific_heat = 75
82+
thermal_conductivity = 50
83+
[]
84+
[material_middle_cond]
85+
type = HeatConductionMaterial
86+
block = 3
87+
specific_heat = 150
88+
thermal_conductivity = 100
89+
[]
90+
[density_left]
91+
type = GenericConstantMaterial
92+
prop_names = 'density'
93+
block = 0
94+
prop_values = 10
95+
[]
96+
[density_right]
97+
type = GenericConstantMaterial
98+
prop_names = 'density'
99+
block = 1
100+
prop_values = 20
101+
[]
102+
[density_middle]
103+
type = GenericConstantMaterial
104+
prop_names = 'density'
105+
block = 3
106+
prop_values = 50
107+
[]
108+
[]
109+
110+
[BCs]
111+
[left]
112+
type = DirichletBC
113+
variable = cond
114+
boundary = left
115+
value = 10
116+
[]
117+
118+
[right]
119+
type = DirichletBC
120+
variable = cond
121+
boundary = right
122+
value = 0
123+
[]
124+
[]
125+
126+
[Executioner]
127+
type = Transient
128+
solve_type = NEWTON
129+
petsc_options_iname = '-pc_type'
130+
petsc_options_value = 'lu'
131+
dt = 1
132+
end_time = 1
133+
[]
134+
135+
[Postprocessors]
136+
[T3]
137+
type = ElementAverageValue
138+
variable = cond
139+
block = '3'
140+
execute_on = 'INITIAL TIMESTEP_END'
141+
[]
142+
[]
143+
144+
[Outputs]
145+
exodus = true
146+
csv = true
147+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
[Problem]
2+
default_block = '0 1 3'
3+
kernel_coverage_check = ONLY_LIST
4+
kernel_coverage_block_list = '0 1'
5+
[]
6+
7+
[Mesh]
8+
[gmg]
9+
type = GeneratedMeshGenerator
10+
dim = 2
11+
nx = 48
12+
ny = 32
13+
xmin = 0
14+
xmax = 3
15+
ymin = 0
16+
ymax = 2
17+
[]
18+
[block_left]
19+
type = SubdomainBoundingBoxGenerator
20+
input = gmg
21+
block_id = 0
22+
block_name = material_left
23+
bottom_left = '0 0 0'
24+
top_right = '1.25 2.0 0'
25+
[]
26+
[block_right]
27+
type = SubdomainBoundingBoxGenerator
28+
input = block_left
29+
block_id = 1
30+
block_name = material_right
31+
bottom_left = '1.75 0 0'
32+
top_right = '3.0 2.0 0'
33+
[]
34+
[block_middle]
35+
type = SubdomainBoundingBoxGenerator
36+
input = block_right
37+
block_id = 2
38+
block_name = material_null
39+
bottom_left = '1.25 0 0'
40+
top_right = '1.75 2.0 0'
41+
[]
42+
[block_middle_new]
43+
type = SubdomainBoundingBoxGenerator
44+
input = block_middle
45+
block_id = 3
46+
block_name = material_middle
47+
bottom_left = '1.25 1.0 0'
48+
top_right = '1.75 2.0 0'
49+
[]
50+
use_displaced_mesh = false
51+
[]
52+
53+
[Variables]
54+
[cond]
55+
order = FIRST
56+
[]
57+
[]
58+
59+
[Kernels]
60+
[diff]
61+
type = HeatConduction
62+
variable = cond
63+
[]
64+
[]
65+
66+
[Materials]
67+
[material_left_cond]
68+
type = HeatConductionMaterial
69+
block = 0
70+
specific_heat = 30
71+
thermal_conductivity = 20
72+
[]
73+
[material_right_cond]
74+
type = HeatConductionMaterial
75+
block = 1
76+
specific_heat = 75
77+
thermal_conductivity = 50
78+
[]
79+
[material_middle_cond]
80+
type = HeatConductionMaterial
81+
block = 3
82+
specific_heat = 150
83+
thermal_conductivity = 100
84+
[]
85+
[density_left]
86+
type = GenericConstantMaterial
87+
prop_names = 'density'
88+
block = 0
89+
prop_values = 10
90+
[]
91+
[density_right]
92+
type = GenericConstantMaterial
93+
prop_names = 'density'
94+
block = 1
95+
prop_values = 20
96+
[]
97+
[density_middle]
98+
type = GenericConstantMaterial
99+
prop_names = 'density'
100+
block = 3
101+
prop_values = 50
102+
[]
103+
[]
104+
105+
[BCs]
106+
[left]
107+
type = DirichletBC
108+
variable = cond
109+
boundary = left
110+
value = 10
111+
[]
112+
113+
[right]
114+
type = DirichletBC
115+
variable = cond
116+
boundary = right
117+
value = 0
118+
[]
119+
[]
120+
121+
[Executioner]
122+
type = Transient
123+
solve_type = NEWTON
124+
petsc_options_iname = '-pc_type'
125+
petsc_options_value = 'lu'
126+
dt = 1
127+
end_time = 1
128+
[]
129+
130+
[Postprocessors]
131+
[T3]
132+
type = ElementAverageValue
133+
variable = cond
134+
block = '3'
135+
execute_on = 'INITIAL TIMESTEP_END'
136+
[]
137+
[]
138+
139+
[Outputs]
140+
exodus = true
141+
csv = true
142+
[]

0 commit comments

Comments
 (0)