Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor optimizations on MooseVariableData #29697

Open
wants to merge 18 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion framework/include/utils/MooseTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ struct IsADType<MetaPhysicL::DualNumber<T, Args...>>
* error with constexpr-based if conditions. The templating delays the triggering
* of the static assertion until the template is instantiated.
*/
template <class T>
template <class... Ts>
constexpr std::false_type always_false{};

} // namespace Moose
Expand Down
17 changes: 13 additions & 4 deletions framework/include/variables/MooseVariableData.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,15 @@ class MooseVariableData : public MooseVariableDataBase<OutputType>
void assignADNodalValue(const ADReal & value, const unsigned int & component);
void fetchADNodalValues();

/**
* Internal method for computeValues() and computeMonomialValues()
*
* Monomial is a template parameter so that we get compile time optimization
* for monomial vs non-monomial
*/
template <bool monomial>
void computeValuesInternal();

const libMesh::FEType & _fe_type;

const unsigned int _var_num;
Expand Down Expand Up @@ -554,19 +563,19 @@ class MooseVariableData : public MooseVariableDataBase<OutputType>
FieldVariableValue _u_dot;

/// u_dotdot (second time derivative)
FieldVariableValue _u_dotdot, _u_dotdot_bak;
FieldVariableValue _u_dotdot;

/// u_dot_old (time derivative)
FieldVariableValue _u_dot_old, _u_dot_old_bak;
FieldVariableValue _u_dot_old;

/// u_dotdot_old (second time derivative)
FieldVariableValue _u_dotdot_old, _u_dotdot_old_bak;
FieldVariableValue _u_dotdot_old;

/// derivative of u_dot wrt u
VariableValue _du_dot_du;

/// derivative of u_dotdot wrt u
VariableValue _du_dotdot_du, _du_dotdot_du_bak;
VariableValue _du_dotdot_du;

/// The current qrule. This has to be a reference because the current qrule will be constantly
/// changing. If we initialized this to point to one qrule, then in the next calculation we would
Expand Down
8 changes: 4 additions & 4 deletions framework/include/variables/MooseVariableDataFV.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,19 @@ class MooseVariableDataFV : public MooseVariableDataBase<OutputType>, public Mes
FieldVariableValue _u_dot;

/// u_dotdot (second time derivative)
FieldVariableValue _u_dotdot, _u_dotdot_bak;
FieldVariableValue _u_dotdot;

/// u_dot_old (time derivative)
FieldVariableValue _u_dot_old, _u_dot_old_bak;
FieldVariableValue _u_dot_old;

/// u_dotdot_old (second time derivative)
FieldVariableValue _u_dotdot_old, _u_dotdot_old_bak;
FieldVariableValue _u_dotdot_old;

/// derivative of u_dot wrt u
VariableValue _du_dot_du;

/// derivative of u_dotdot wrt u
VariableValue _du_dotdot_du, _du_dotdot_du_bak;
VariableValue _du_dotdot_du;

/// Pointer to time integrator
const TimeIntegrator * const _time_integrator;
Expand Down
32 changes: 4 additions & 28 deletions framework/src/variables/MooseVariableConstMonomial.C
Original file line number Diff line number Diff line change
Expand Up @@ -42,50 +42,26 @@ void
MooseVariableConstMonomial::computeElemValues()
{
_element_data->setGeometry(Moose::Volume);

// We have not optimized AD calculations for const monomials yet, so we fall back on the
// non-optimized routine
if (_element_data->needsAD())
_element_data->computeValues();
else
_element_data->computeMonomialValues();
_element_data->computeMonomialValues();
}

void
MooseVariableConstMonomial::computeElemValuesFace()
{
_element_data->setGeometry(Moose::Face);

// We have not optimized AD calculations for const monomials yet, so we fall back on the
// non-optimized routine
if (_element_data->needsAD())
_element_data->computeValues();
else
_element_data->computeMonomialValues();
_element_data->computeMonomialValues();
}

void
MooseVariableConstMonomial::computeNeighborValues()
{
_neighbor_data->setGeometry(Moose::Volume);

// We have not optimized AD calculations for const monomials yet, so we fall back on the
// non-optimized routine
if (_neighbor_data->needsAD())
_neighbor_data->computeValues();
else
_neighbor_data->computeMonomialValues();
_neighbor_data->computeMonomialValues();
}

void
MooseVariableConstMonomial::computeNeighborValuesFace()
{
_neighbor_data->setGeometry(Moose::Face);

// We have not optimized AD calculations for const monomials yet, so we fall back on the
// non-optimized routine
if (_neighbor_data->needsAD())
_neighbor_data->computeValues();
else
_neighbor_data->computeMonomialValues();
_neighbor_data->computeMonomialValues();
}
Loading