www.mooseframework.org
CNSFVMinmaxSlopeLimiting.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  params.addClassDescription("A user object that performs the min-max slope limiting to get the "
16  "limited slopes of cell average variables.");
17  return params;
18 }
19 
20 CNSFVMinmaxSlopeLimiting::CNSFVMinmaxSlopeLimiting(const InputParameters & parameters)
21  : SlopeLimitingBase(parameters)
22 {
23 }
24 
25 std::vector<RealGradient>
27 {
28  const Elem * elem = _current_elem;
29 
31  dof_id_type _elementID = elem->id();
32 
34  Point ecent = elem->centroid();
35 
37  unsigned int nside = elem->n_sides();
38 
40  unsigned int nvars = 5;
41 
43  std::vector<Point> scent(nside, Point(0., 0., 0.));
44 
46  std::vector<RealGradient> ugrad(nvars, RealGradient(0., 0., 0.));
47 
49  bool bflag = false;
50 
52  std::vector<Real> umin(nvars, 0.);
54  std::vector<Real> umax(nvars, 0.);
56  std::vector<Real> uelem(nvars, 0.);
58  std::vector<RealGradient> rugrad(nvars, RealGradient(0., 0., 0.));
60  std::vector<std::vector<Real>> limit(nside + 1, std::vector<Real>(nvars, 1.));
61 
62  Real dij = 0.;
63 
64  uelem = _rslope.getElementAverageValue(_elementID);
65 
66  for (unsigned int iv = 0; iv < nvars; iv++)
67  {
68  umin[iv] = uelem[iv];
69  umax[iv] = uelem[iv];
70  }
71 
73 
74  for (unsigned int is = 0; is < nside; is++)
75  {
76  const Elem * neighbor = elem->neighbor_ptr(is);
77 
78  if (neighbor != nullptr && this->hasBlocks(neighbor->subdomain_id()))
79  {
80  dof_id_type _neighborID = neighbor->id();
81  uelem = _rslope.getElementAverageValue(_neighborID);
82  scent[is] = _rslope.getSideCentroid(_elementID, _neighborID);
83  }
84  else
85  {
86  uelem = _rslope.getBoundaryAverageValue(_elementID, is);
87  scent[is] = _rslope.getBoundarySideCentroid(_elementID, is);
88  }
89 
90  for (unsigned int iv = 0; iv < nvars; iv++)
91  {
92  if (uelem[iv] < umin[iv])
93  umin[iv] = uelem[iv];
94  if (uelem[iv] > umax[iv])
95  umax[iv] = uelem[iv];
96  }
97  }
98 
100 
101  rugrad = _rslope.getElementSlope(_elementID);
102  uelem = _rslope.getElementAverageValue(_elementID);
103 
104  for (unsigned int is = 0; is < nside; is++)
105  {
106  for (unsigned int iv = 0; iv < nvars; iv++)
107  {
108  dij = (scent[is] - ecent) * rugrad[iv];
109 
110  if (dij > 0.)
111  limit[is + 1][iv] = std::min(1., (umax[iv] - uelem[iv]) / dij);
112  else if (dij < 0.)
113  limit[is + 1][iv] = std::min(1., (umin[iv] - uelem[iv]) / dij);
114  }
115  }
116 
118 
119  for (unsigned int is = 0; is < nside; is++)
120  {
121  for (unsigned int iv = 0; iv < nvars; iv++)
122  {
123  if (limit[0][iv] > limit[is + 1][iv])
124  limit[0][iv] = limit[is + 1][iv];
125  }
126  }
127 
129 
130  if (!_include_bc && bflag)
131  {
132  for (unsigned int iv = 0; iv < nvars; iv++)
133  ugrad[iv] = RealGradient(0., 0., 0.);
134  }
135  else
136  {
137  for (unsigned int iv = 0; iv < nvars; iv++)
138  ugrad[iv] = rugrad[iv] * limit[0][iv];
139  }
140 
141  return ugrad;
142 }
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
virtual const Point & getSideCentroid(dof_id_type elementid, dof_id_type neighborid) const
accessor function call to get cached internal side centroid
InputParameters validParams< CNSFVMinmaxSlopeLimiting >()
Base class for slope limiting to limit the slopes of cell average variables.
virtual std::vector< RealGradient > limitElementSlope() const
compute the limited slope of the cell
InputParameters validParams< SlopeLimitingBase >()
virtual const Point & getBoundarySideCentroid(dof_id_type elementid, unsigned int side) const
accessor function call to get cached boundary side centroid
virtual const std::vector< Real > & getElementAverageValue(dof_id_type elementid) const
accessor function call to get element average variable values
bool _include_bc
option whether to include BCs
CNSFVMinmaxSlopeLimiting(const InputParameters &parameters)
virtual const std::vector< Real > & getBoundaryAverageValue(dof_id_type elementid, unsigned int side) const
accessor function call to get boundary average variable values