www.mooseframework.org
CNSFVWENOSlopeLimiting.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
9 
10 template <>
11 InputParameters
13 {
14  InputParameters params = validParams<SlopeLimitingBase>();
15 
16  params.addClassDescription("A user object that performs WENO slope limiting to get the limited "
17  "slopes of cell average variables in multi-dimensions.");
18 
19  params.addParam<Real>("linear_weight", 1, "Linear weight, default = 1");
20 
21  params.addParam<Real>("decay_power", 1, "Decay power, default = 1");
22 
23  return params;
24 }
25 
26 CNSFVWENOSlopeLimiting::CNSFVWENOSlopeLimiting(const InputParameters & parameters)
27  : SlopeLimitingBase(parameters),
28  _lweig(getParam<Real>("linear_weight")),
29  _dpowe(getParam<Real>("decay_power"))
30 {
31 }
32 
33 std::vector<RealGradient>
35 {
36  const Elem * elem = _current_elem;
37 
39  dof_id_type _elementID = elem->id();
40 
42  unsigned int nvars = 5;
43 
45  unsigned int nside = elem->n_sides();
46 
48  std::vector<RealGradient> ugrad(nvars, RealGradient(0., 0., 0.));
49 
51  std::vector<RealGradient> rugrad(nvars, RealGradient(0., 0., 0.));
52 
54  Real eps = 1e-7;
55 
57  std::vector<std::vector<Real>> osci(nside + 1, std::vector<Real>(nvars, 0.));
58 
60  std::vector<std::vector<Real>> weig(nside + 1, std::vector<Real>(nvars, 0.));
61 
63  std::vector<Real> summ(nvars, 0.);
64 
66 
67  rugrad = _rslope.getElementSlope(_elementID);
68 
69  for (unsigned int iv = 0; iv < nvars; iv++)
70  {
71  osci[0][iv] = std::sqrt(rugrad[iv] * rugrad[iv]);
72 
73  weig[0][iv] = _lweig / std::pow(eps + osci[0][iv], _dpowe);
74 
75  summ[iv] = weig[0][iv];
76  }
77 
78  for (unsigned int is = 0; is < nside; is++)
79  {
80  unsigned int in = is + 1;
81  const Elem * neighbor = elem->neighbor_ptr(is);
82 
83  if (neighbor != nullptr && this->hasBlocks(neighbor->subdomain_id()))
84  {
85  dof_id_type _neighborID = neighbor->id();
86  rugrad = _rslope.getElementSlope(_neighborID);
87 
88  for (unsigned int iv = 0; iv < nvars; iv++)
89  {
90  osci[in][iv] = std::sqrt(rugrad[iv] * rugrad[iv]);
91 
92  weig[in][iv] = 1. / std::pow(eps + osci[in][iv], _dpowe);
93 
94  summ[iv] += weig[in][iv];
95  }
96  }
97  }
98 
100 
101  for (unsigned int iv = 0; iv < nvars; iv++)
102  weig[0][iv] = weig[0][iv] / summ[iv];
103 
104  for (unsigned int is = 0; is < nside; is++)
105  {
106  unsigned int in = is + 1;
107  const Elem * neighbor = elem->neighbor_ptr(is);
108 
109  if (neighbor != nullptr && this->hasBlocks(neighbor->subdomain_id()))
110  for (unsigned int iv = 0; iv < nvars; iv++)
111  weig[in][iv] = weig[in][iv] / summ[iv];
112  }
113 
115 
116  rugrad = _rslope.getElementSlope(_elementID);
117 
118  for (unsigned int iv = 0; iv < nvars; iv++)
119  ugrad[iv] = weig[0][iv] * rugrad[iv];
120 
121  for (unsigned int is = 0; is < nside; is++)
122  {
123  unsigned int in = is + 1;
124  const Elem * neighbor = elem->neighbor_ptr(is);
125 
126  if (neighbor != nullptr && this->hasBlocks(neighbor->subdomain_id()))
127  {
128  dof_id_type _neighborID = neighbor->id();
129  rugrad = _rslope.getElementSlope(_neighborID);
130 
131  for (unsigned int iv = 0; iv < nvars; iv++)
132  ugrad[iv] += weig[in][iv] * rugrad[iv];
133  }
134  }
135 
136  return ugrad;
137 }
const SlopeReconstructionBase & _rslope
slope reconstruction user object
virtual const std::vector< RealGradient > & getElementSlope(dof_id_type elementid) const
accessor function call to get element slope values
CNSFVWENOSlopeLimiting(const InputParameters &parameters)
InputParameters validParams< CNSFVWENOSlopeLimiting >()
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Base class for slope limiting to limit the slopes of cell average variables.
InputParameters validParams< SlopeLimitingBase >()
virtual std::vector< RealGradient > limitElementSlope() const
compute the limited slope of the cell