https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
SlopeReconstruction1DInterface< is_ad > Class Template Referenceabstract

Interface class for 1-D slope reconstruction. More...

#include <SlopeReconstruction1DInterface.h>

Public Types

enum  ESlopeReconstructionType {
  None, Full, Minmod, MC,
  Superbee
}
 Slope reconstruction type. More...
 

Public Member Functions

 SlopeReconstruction1DInterface (const MooseObject *moose_object)
 

Static Public Member Functions

static MooseEnum getSlopeReconstructionMooseEnum (const std::string &name="")
 Gets a MooseEnum for slope reconstruction type. More...
 
static InputParameters validParams ()
 

Static Public Attributes

static const std::map< std::string, ESlopeReconstructionType_slope_reconstruction_type_to_enum
 Map of slope reconstruction type string to enum. More...
 

Protected Member Functions

virtual void getNeighborPrimitiveVariables (const Elem *elem, std::vector< std::vector< GenericReal< is_ad >>> &W_neighbor, std::vector< Point > &x_neighbor) const
 Gets the primitive solution vector and position of neighbor(s) More...
 
std::vector< GenericReal< is_ad > > getElementSlopes (const Elem *elem) const
 Gets limited slopes for the primitive variables in the 1-D direction. More...
 
std::vector< GenericReal< is_ad > > getBoundaryElementSlopes (const std::vector< GenericReal< is_ad >> &W_elem, const Point &x_elem, const RealVectorValue &dir, std::vector< std::vector< GenericReal< is_ad >>> W_neighbor, std::vector< Point > x_neighbor, const std::vector< GenericReal< is_ad >> &W_boundary) const
 Gets limited slopes for the primitive variables in the 1-D direction for boundary element. More...
 
std::vector< GenericReal< is_ad > > getElementSlopes (const std::vector< GenericReal< is_ad >> &W_elem, const Point &x_elem, const RealVectorValue &dir, const std::vector< std::vector< GenericReal< is_ad >>> &W_neighbor, const std::vector< Point > &x_neighbor) const
 Gets limited slopes for the primitive variables in the 1-D direction. More...
 
virtual std::vector< GenericReal< is_ad > > computeElementPrimitiveVariables (const Elem *elem) const =0
 Computes the cell-average primitive variable values for an element. More...
 

Protected Attributes

const MooseObject *const _moose_object
 MooseObject this interface is extending. More...
 
const ESlopeReconstructionType _scheme
 Slope reconstruction scheme. More...
 

Static Protected Attributes

static const unsigned int _n_side = 2
 Number of sides. More...
 
static const unsigned int _n_sten = 3
 Number of elemental values in stencil for computing slopes. More...
 

Detailed Description

template<bool is_ad>
class SlopeReconstruction1DInterface< is_ad >

Interface class for 1-D slope reconstruction.

This class provides interfaces for generating slopes for an arbitrary set of variables. A number of reconstruction options are provided, including a number of TVD slope limiters.

Definition at line 30 of file SlopeReconstruction1DInterface.h.

Member Enumeration Documentation

◆ ESlopeReconstructionType

Slope reconstruction type.

Enumerator
None 

No reconstruction; Godunov scheme.

Full 

Full reconstruction; no limitation.

Minmod 

Minmod slope limiter.

MC 

Monotonized Central-Difference slope limiter.

Superbee 

Superbee slope limiter.

Definition at line 36 of file SlopeReconstruction1DInterface.h.

37  {
38  None,
39  Full,
40  Minmod,
41  MC,
42  Superbee
43  };
Monotonized Central-Difference slope limiter.
Full reconstruction; no limitation.

Constructor & Destructor Documentation

◆ SlopeReconstruction1DInterface()

template<bool is_ad>
SlopeReconstruction1DInterface< is_ad >::SlopeReconstruction1DInterface ( const MooseObject moose_object)

Definition at line 188 of file SlopeReconstruction1DInterface.h.

190  : _moose_object(moose_object),
191  _scheme(THM::stringToEnum<ESlopeReconstructionType>(
192  moose_object->parameters().get<MooseEnum>("scheme")))
193 {
194 }
const MooseObject *const _moose_object
MooseObject this interface is extending.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const ESlopeReconstructionType _scheme
Slope reconstruction scheme.
const InputParameters & parameters() const

Member Function Documentation

◆ computeElementPrimitiveVariables()

template<bool is_ad>
virtual std::vector<GenericReal<is_ad> > SlopeReconstruction1DInterface< is_ad >::computeElementPrimitiveVariables ( const Elem *  elem) const
protectedpure virtual

Computes the cell-average primitive variable values for an element.

Parameters
[in]elemElement for which to get values
Returns
Vector of values on element

Implemented in ADJunctionOneToOne1PhaseUserObject, ADRDG3EqnMaterial, RDG3EqnMaterial, and SlopeReconstructionGasMixMaterial.

◆ getBoundaryElementSlopes()

template<bool is_ad>
std::vector< GenericReal< is_ad > > SlopeReconstruction1DInterface< is_ad >::getBoundaryElementSlopes ( const std::vector< GenericReal< is_ad >> &  W_elem,
const Point &  x_elem,
const RealVectorValue dir,
std::vector< std::vector< GenericReal< is_ad >>>  W_neighbor,
std::vector< Point >  x_neighbor,
const std::vector< GenericReal< is_ad >> &  W_boundary 
) const
protected

Gets limited slopes for the primitive variables in the 1-D direction for boundary element.

Parameters
[in]W_elemPrimitive solution for element
[in]x_elemPosition for element
[in]dirDirection for element
[in]W_neighborPrimitive solution vector for each neighbor
[in]x_neighborPosition for each neighbor
[in]W_boundaryPrimitive solution vector for boundary
Returns
Vector of slopes for the element in the 1-D direction

Definition at line 235 of file SlopeReconstruction1DInterface.h.

242 {
243  if (W_neighbor.size() == 1)
244  {
245  W_neighbor.push_back(W_boundary);
246 
247  // The boundary point will be assumed to be the same distance away as neighbor
248  const Point dx = x_elem - x_neighbor[0];
249  const Point x_boundary = x_elem + dx;
250  x_neighbor.push_back(x_boundary);
251  }
252 
253  return getElementSlopes(W_elem, x_elem, dir, W_neighbor, x_neighbor);
254 }
std::vector< GenericReal< is_ad > > getElementSlopes(const Elem *elem) const
Gets limited slopes for the primitive variables in the 1-D direction.

◆ getElementSlopes() [1/2]

template<bool is_ad>
std::vector< GenericReal< is_ad > > SlopeReconstruction1DInterface< is_ad >::getElementSlopes ( const Elem *  elem) const
protected

Gets limited slopes for the primitive variables in the 1-D direction.

Parameters
[in]elemElement for which to get slopes
Returns
Vector of slopes for the element in the 1-D direction

Definition at line 218 of file SlopeReconstruction1DInterface.h.

219 {
220  mooseAssert(elem, "The supplied element is a nullptr.");
221 
222  const auto W_elem = computeElementPrimitiveVariables(elem);
223  const Point x_elem = elem->vertex_average();
224  const RealVectorValue dir = (elem->node_ref(1) - elem->node_ref(0)).unit();
225 
226  std::vector<Point> x_neighbor;
227  std::vector<std::vector<GenericReal<is_ad>>> W_neighbor;
228  getNeighborPrimitiveVariables(elem, W_neighbor, x_neighbor);
229 
230  return getElementSlopes(W_elem, x_elem, dir, W_neighbor, x_neighbor);
231 }
virtual void getNeighborPrimitiveVariables(const Elem *elem, std::vector< std::vector< GenericReal< is_ad >>> &W_neighbor, std::vector< Point > &x_neighbor) const
Gets the primitive solution vector and position of neighbor(s)
virtual std::vector< GenericReal< is_ad > > computeElementPrimitiveVariables(const Elem *elem) const =0
Computes the cell-average primitive variable values for an element.
std::vector< GenericReal< is_ad > > getElementSlopes(const Elem *elem) const
Gets limited slopes for the primitive variables in the 1-D direction.

◆ getElementSlopes() [2/2]

template<bool is_ad>
std::vector< GenericReal< is_ad > > SlopeReconstruction1DInterface< is_ad >::getElementSlopes ( const std::vector< GenericReal< is_ad >> &  W_elem,
const Point &  x_elem,
const RealVectorValue dir,
const std::vector< std::vector< GenericReal< is_ad >>> &  W_neighbor,
const std::vector< Point > &  x_neighbor 
) const
protected

Gets limited slopes for the primitive variables in the 1-D direction.

Parameters
[in]W_elemPrimitive solution for element
[in]x_elemPosition for element
[in]dirDirection for element
[in]W_neighborPrimitive solution vector for each neighbor
[in]x_neighborPosition for each neighbor
Returns
Vector of slopes for the element in the 1-D direction

Definition at line 258 of file SlopeReconstruction1DInterface.h.

264 {
265  mooseAssert(x_neighbor.size() == W_neighbor.size(),
266  "Neighbor positions size must equal neighbor solutions size.");
267 
268  // get the number of slopes to be stored
269  const unsigned int n_slopes = W_elem.size();
270 
271  // compute one-sided slope(s)
272  std::vector<std::vector<GenericReal<is_ad>>> slopes_one_sided;
273  for (unsigned int i = 0; i < W_neighbor.size(); i++)
274  {
275  const Real dx = (x_elem - x_neighbor[i]) * dir;
276 
277  std::vector<GenericReal<is_ad>> slopes(n_slopes, 0.0);
278  for (unsigned int m = 0; m < n_slopes; m++)
279  slopes[m] = (W_elem[m] - W_neighbor[i][m]) / dx;
280 
281  slopes_one_sided.push_back(slopes);
282  }
283 
284  // Fill in any missing one-sided slopes and compute central slope
285  std::vector<GenericReal<is_ad>> slopes_central(n_slopes, 0.0);
286  if (W_neighbor.size() == 2)
287  {
288  const Real dx = (x_neighbor[0] - x_neighbor[1]) * dir;
289  for (unsigned int m = 0; m < n_slopes; m++)
290  slopes_central[m] = (W_neighbor[0][m] - W_neighbor[1][m]) / dx;
291  }
292  else if (W_neighbor.size() == 1)
293  {
294  slopes_one_sided.push_back(slopes_one_sided[0]);
295  slopes_central = slopes_one_sided[0];
296  }
297  else // only one element; use zero slopes
298  {
299  slopes_one_sided.push_back(slopes_central);
300  slopes_one_sided.push_back(slopes_central);
301  }
302 
303  // vector for the (possibly limited) slopes
304  std::vector<GenericReal<is_ad>> slopes_limited(n_slopes, 0.0);
305 
306  // limit the slopes
307  switch (_scheme)
308  {
309  // first-order, zero slope
310  case None:
311  break;
312 
313  // full reconstruction; no limitation
314  case Full:
315 
316  slopes_limited = slopes_central;
317  break;
318 
319  // minmod limiter
320  case Minmod:
321 
322  for (unsigned int m = 0; m < n_slopes; m++)
323  {
324  if ((slopes_one_sided[0][m] * slopes_one_sided[1][m]) > 0.0)
325  {
326  if (std::abs(slopes_one_sided[0][m]) < std::abs(slopes_one_sided[1][m]))
327  slopes_limited[m] = slopes_one_sided[0][m];
328  else
329  slopes_limited[m] = slopes_one_sided[1][m];
330  }
331  }
332  break;
333 
334  // MC (monotonized central-difference) limiter
335  case MC:
336 
337  for (unsigned int m = 0; m < n_slopes; m++)
338  {
339  if (slopes_central[m] > 0.0 && slopes_one_sided[0][m] > 0.0 && slopes_one_sided[1][m] > 0.0)
340  slopes_limited[m] = std::min(
341  slopes_central[m], 2.0 * std::min(slopes_one_sided[0][m], slopes_one_sided[1][m]));
342  else if (slopes_central[m] < 0.0 && slopes_one_sided[0][m] < 0.0 &&
343  slopes_one_sided[1][m] < 0.0)
344  slopes_limited[m] = std::max(
345  slopes_central[m], 2.0 * std::max(slopes_one_sided[0][m], slopes_one_sided[1][m]));
346  }
347  break;
348 
349  // superbee limiter
350  case Superbee:
351 
352  for (unsigned int m = 0; m < n_slopes; m++)
353  {
354  GenericReal<is_ad> slope1 = 0.0;
355  GenericReal<is_ad> slope2 = 0.0;
356 
357  // calculate slope1 with minmod
358  if (slopes_one_sided[1][m] > 0.0 && slopes_one_sided[0][m] > 0.0)
359  slope1 = std::min(slopes_one_sided[1][m], 2.0 * slopes_one_sided[0][m]);
360  else if (slopes_one_sided[1][m] < 0.0 && slopes_one_sided[0][m] < 0.0)
361  slope1 = std::max(slopes_one_sided[1][m], 2.0 * slopes_one_sided[0][m]);
362 
363  // calculate slope2 with minmod
364  if (slopes_one_sided[1][m] > 0.0 && slopes_one_sided[0][m] > 0.0)
365  slope2 = std::min(2.0 * slopes_one_sided[1][m], slopes_one_sided[0][m]);
366  else if (slopes_one_sided[1][m] < 0.0 && slopes_one_sided[0][m] < 0.0)
367  slope2 = std::max(2.0 * slopes_one_sided[1][m], slopes_one_sided[0][m]);
368 
369  // calculate slope with maxmod
370  if (slope1 > 0.0 && slope2 > 0.0)
371  slopes_limited[m] = std::max(slope1, slope2);
372  else if (slope1 < 0.0 && slope2 < 0.0)
373  slopes_limited[m] = std::min(slope1, slope2);
374  }
375  break;
376 
377  default:
378  mooseError("Unknown slope reconstruction scheme");
379  break;
380  }
381  return slopes_limited;
382 }
Moose::GenericType< Real, is_ad > GenericReal
Monotonized Central-Difference slope limiter.
void mooseError(Args &&... args)
Full reconstruction; no limitation.
const ESlopeReconstructionType _scheme
Slope reconstruction scheme.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ getNeighborPrimitiveVariables()

template<bool is_ad>
void SlopeReconstruction1DInterface< is_ad >::getNeighborPrimitiveVariables ( const Elem *  elem,
std::vector< std::vector< GenericReal< is_ad >>> &  W_neighbor,
std::vector< Point > &  x_neighbor 
) const
protectedvirtual

Gets the primitive solution vector and position of neighbor(s)

Parameters
[in]elemElement for which to get slopes
[in]W_neighborPrimitive solution vector for each neighbor
[in]x_neighborPosition for each neighbor

Definition at line 198 of file SlopeReconstruction1DInterface.h.

202 {
203  W_neighbor.clear();
204  x_neighbor.clear();
205  for (unsigned int i_side = 0; i_side < _n_side; i_side++)
206  {
207  auto neighbor = elem->neighbor_ptr(i_side);
208  if (neighbor && (neighbor->processor_id() == _moose_object->processor_id()))
209  {
210  x_neighbor.push_back(neighbor->vertex_average());
211  W_neighbor.push_back(computeElementPrimitiveVariables(neighbor));
212  }
213  }
214 }
const MooseObject *const _moose_object
MooseObject this interface is extending.
static const unsigned int _n_side
Number of sides.
virtual std::vector< GenericReal< is_ad > > computeElementPrimitiveVariables(const Elem *elem) const =0
Computes the cell-average primitive variable values for an element.
processor_id_type processor_id() const

◆ getSlopeReconstructionMooseEnum()

template<bool is_ad>
MooseEnum SlopeReconstruction1DInterface< is_ad >::getSlopeReconstructionMooseEnum ( const std::string &  name = "")
static

Gets a MooseEnum for slope reconstruction type.

Parameters
[in]namedefault value
Returns
MooseEnum for slope reconstruction type

Definition at line 161 of file SlopeReconstruction1DInterface.h.

Referenced by FlowChannel1PhaseBase::validParams(), and SlopeReconstruction1DInterface< true >::validParams().

162 {
163  return THM::getMooseEnum<SlopeReconstruction1DInterface<is_ad>::ESlopeReconstructionType>(
165 }
static const std::map< std::string, ESlopeReconstructionType > _slope_reconstruction_type_to_enum
Map of slope reconstruction type string to enum.
const std::string name
Definition: Setup.h:20

◆ validParams()

template<bool is_ad>
InputParameters SlopeReconstruction1DInterface< is_ad >::validParams ( )
static

Definition at line 175 of file SlopeReconstruction1DInterface.h.

Referenced by SlopeReconstructionGasMixMaterial::validParams(), RDG3EqnMaterial::validParams(), ADRDG3EqnMaterial::validParams(), and ADJunctionOneToOne1PhaseUserObject::validParams().

176 {
178 
179  params.addRequiredParam<MooseEnum>(
180  "scheme",
182  "Slope reconstruction scheme");
183 
184  return params;
185 }
void addRequiredParam(const std::string &name, const std::string &doc_string)
InputParameters emptyInputParameters()
static MooseEnum getSlopeReconstructionMooseEnum(const std::string &name="")
Gets a MooseEnum for slope reconstruction type.

Member Data Documentation

◆ _moose_object

template<bool is_ad>
const MooseObject* const SlopeReconstruction1DInterface< is_ad >::_moose_object
protected

MooseObject this interface is extending.

Definition at line 126 of file SlopeReconstruction1DInterface.h.

◆ _n_side

template<bool is_ad>
const unsigned int SlopeReconstruction1DInterface< is_ad >::_n_side = 2
staticprotected

Number of sides.

Definition at line 136 of file SlopeReconstruction1DInterface.h.

◆ _n_sten

template<bool is_ad>
const unsigned int SlopeReconstruction1DInterface< is_ad >::_n_sten = 3
staticprotected

Number of elemental values in stencil for computing slopes.

Definition at line 138 of file SlopeReconstruction1DInterface.h.

◆ _scheme

template<bool is_ad>
const ESlopeReconstructionType SlopeReconstruction1DInterface< is_ad >::_scheme
protected

Slope reconstruction scheme.

Definition at line 129 of file SlopeReconstruction1DInterface.h.

◆ _slope_reconstruction_type_to_enum

template<bool is_ad>
const std::map< std::string, typename SlopeReconstruction1DInterface< is_ad >::ESlopeReconstructionType > SlopeReconstruction1DInterface< is_ad >::_slope_reconstruction_type_to_enum
static
Initial value:
{
{"NONE", None}, {"FULL", Full}, {"MINMOD", Minmod}, {"MC", MC}, {"SUPERBEE", Superbee}}

Map of slope reconstruction type string to enum.

Definition at line 45 of file SlopeReconstruction1DInterface.h.


The documentation for this class was generated from the following file: