-
Notifications
You must be signed in to change notification settings - Fork 41
/
InScatter.C
104 lines (95 loc) · 3.26 KB
/
InScatter.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "InScatter.h"
registerMooseObject("MoltresApp", InScatter);
InputParameters
InScatter::validParams()
{
InputParameters params = Kernel::validParams();
params += ScalarTransportBase::validParams();
params.addRequiredParam<unsigned int>("group_number", "The current energy group");
params.addRequiredParam<unsigned int>("num_groups", "The total numer of energy groups");
params.addCoupledVar("temperature", "The temperature used to interpolate material properties");
params.addRequiredCoupledVar("group_fluxes", "All the variables that hold the group fluxes. "
"These MUST be listed by decreasing "
"energy/increasing group number.");
params.addParam<bool>(
"sss2_input", true, "Whether serpent 2 was used to generate the input files.");
return params;
}
InScatter::InScatter(const InputParameters & parameters)
: Kernel(parameters),
ScalarTransportBase(parameters),
_gtransfxs(getMaterialProperty<std::vector<Real>>("gtransfxs")),
_d_gtransfxs_d_temp(getMaterialProperty<std::vector<Real>>("d_gtransfxs_d_temp")),
_group(getParam<unsigned int>("group_number") - 1),
_num_groups(getParam<unsigned int>("num_groups")),
_temp_id(coupled("temperature")),
_sss2_input(getParam<bool>("sss2_input"))
{
unsigned int n = coupledComponents("group_fluxes");
if (!(n == _num_groups))
{
mooseError("The number of coupled variables doesn't match the number of groups.");
}
_group_fluxes.resize(n);
_flux_ids.resize(n);
for (unsigned int i = 0; i < _group_fluxes.size(); ++i)
{
_group_fluxes[i] = &coupledValue("group_fluxes", i);
_flux_ids[i] = coupled("group_fluxes", i);
}
}
Real
InScatter::computeQpResidual()
{
Real r = 0;
for (unsigned int i = 0; i < _num_groups; ++i)
{
if (i == _group)
continue;
if (_sss2_input)
r += -_test[_i][_qp] * _gtransfxs[_qp][i * _num_groups + _group] *
computeConcentration((*_group_fluxes[i]), _qp);
else
r += -_test[_i][_qp] * _gtransfxs[_qp][i + _group * _num_groups] *
computeConcentration((*_group_fluxes[i]), _qp);
}
return r;
}
Real
InScatter::computeQpJacobian()
{
return 0.;
}
Real
InScatter::computeQpOffDiagJacobian(unsigned int jvar)
{
Real jac = 0;
for (unsigned int i = 0; i < _num_groups; ++i)
{
if (jvar == _flux_ids[i] && jvar != _group)
{
if (_sss2_input)
jac += -_test[_i][_qp] * _gtransfxs[_qp][i * _num_groups + _group] *
computeConcentrationDerivative((*_group_fluxes[i]), _phi, _j, _qp);
else
jac += -_test[_i][_qp] * _gtransfxs[_qp][i + _group * _num_groups] *
computeConcentrationDerivative((*_group_fluxes[i]), _phi, _j, _qp);
break;
}
}
if (jvar == _temp_id)
{
for (unsigned int i = 0; i < _num_groups; ++i)
{
if (i == _group)
continue;
if (_sss2_input)
jac += -_test[_i][_qp] * _d_gtransfxs_d_temp[_qp][i * _num_groups + _group] * _phi[_j][_qp] *
computeConcentration((*_group_fluxes[i]), _qp);
else
jac += -_test[_i][_qp] * _d_gtransfxs_d_temp[_qp][i + _group * _num_groups] * _phi[_j][_qp] *
computeConcentration((*_group_fluxes[i]), _qp);
}
}
return jac;
}