www.mooseframework.org
MooseVariableConstMonomial.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
11 #include "SubProblem.h"
12 #include "SystemBase.h"
13 #include "Assembly.h"
14 
15 #include "libmesh/quadrature.h"
16 #include "libmesh/enum_to_string.h"
17 
19 
22 {
23  auto params = MooseVariableBase::validParams();
24  params.addClassDescription("Specialization for constant monomials that avoids unnecessary loops");
25  params.set<MooseEnum>("family") = "MONOMIAL";
26  params.set<MooseEnum>("order") = "CONSTANT";
27  return params;
28 }
29 
31  : MooseVariable(parameters)
32 {
33  if (_fe_type.order != CONSTANT || _fe_type.family != MONOMIAL)
34  mooseError("This type is only meant for a CONSTANT "
35  "MONOMIAL finite element basis. You have requested a ",
36  Utility::enum_to_string(_fe_type.family),
37  " family and order ",
38  Utility::enum_to_string(Order(_fe_type.order)));
39 }
40 
41 void
43 {
44  _element_data->setGeometry(Moose::Volume);
45 
46  // We have not optimized AD calculations for const monomials yet, so we fall back on the
47  // non-optimized routine
48  if (_element_data->needsAD())
49  _element_data->computeValues();
50  else
51  _element_data->computeMonomialValues();
52 }
53 
54 void
56 {
57  _element_data->setGeometry(Moose::Face);
58 
59  // We have not optimized AD calculations for const monomials yet, so we fall back on the
60  // non-optimized routine
61  if (_element_data->needsAD())
62  _element_data->computeValues();
63  else
64  _element_data->computeMonomialValues();
65 }
66 
67 void
69 {
70  _neighbor_data->setGeometry(Moose::Volume);
71 
72  // We have not optimized AD calculations for const monomials yet, so we fall back on the
73  // non-optimized routine
74  if (_neighbor_data->needsAD())
75  _neighbor_data->computeValues();
76  else
77  _neighbor_data->computeMonomialValues();
78 }
79 
80 void
82 {
83  _neighbor_data->setGeometry(Moose::Face);
84 
85  // We have not optimized AD calculations for const monomials yet, so we fall back on the
86  // non-optimized routine
87  if (_neighbor_data->needsAD())
88  _neighbor_data->computeValues();
89  else
90  _neighbor_data->computeMonomialValues();
91 }
static InputParameters validParams()
Order
FEType _fe_type
The FEType associated with this variable.
virtual void computeElemValues() override
Actually compute variable values from the solution vectors.
MooseVariableConstMonomial(const InputParameters &parameters)
std::unique_ptr< MooseVariableData< Real > > _neighbor_data
Holder for all the data associated with the neighbor element.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
registerMooseObject("MooseApp", MooseVariableConstMonomial)
virtual void computeNeighborValuesFace() override
Compute values at facial quadrature points for the neighbor.
CONSTANT
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
MONOMIAL
virtual void computeNeighborValues() override
Compute values at quadrature points for the neighbor.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual void computeElemValuesFace() override
Compute values at facial quadrature points.
std::unique_ptr< MooseVariableData< Real > > _element_data
Holder for all the data associated with the "main" element.
static InputParameters validParams()