-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Finish support for AD time derivatives of dofs #28857
base: next
Are you sure you want to change the base?
Changes from all commits
670f857
8d6b522
6b87965
6019458
50196c4
daf8845
e71c341
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1168,6 +1168,20 @@ Coupleable::coupledDotDot(const std::string & var_name, unsigned int comp) const | |||||
} | ||||||
} | ||||||
|
||||||
template <> | ||||||
const GenericVariableValue<false> & | ||||||
Coupleable::coupledGenericDotDot<false>(const std::string & var_name, unsigned int comp) const | ||||||
{ | ||||||
return coupledDotDot(var_name, comp); | ||||||
} | ||||||
|
||||||
template <> | ||||||
const GenericVariableValue<true> & | ||||||
Coupleable::coupledGenericDotDot<true>(const std::string & var_name, unsigned int comp) const | ||||||
{ | ||||||
return adCoupledDotDot(var_name, comp); | ||||||
} | ||||||
|
||||||
const VariableValue & | ||||||
Coupleable::coupledDotOld(const std::string & var_name, unsigned int comp) const | ||||||
{ | ||||||
|
@@ -2207,12 +2221,18 @@ Coupleable::adCoupledDot(const std::string & var_name, unsigned int comp) const | |||||
return *getADDefaultValue(var_name); | ||||||
checkFuncType(var_name, VarType::Dot, FuncAge::Curr); | ||||||
|
||||||
if (_c_nodal) | ||||||
mooseError("Not implemented"); | ||||||
|
||||||
if (!_coupleable_neighbor) | ||||||
{ | ||||||
if (_c_nodal) | ||||||
return var->adDofValuesDot(); | ||||||
return var->adUDot(); | ||||||
return var->adUDotNeighbor(); | ||||||
} | ||||||
else | ||||||
{ | ||||||
if (_c_nodal) | ||||||
mooseError("AD neighbor nodal dof dot implemented"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return var->adUDotNeighbor(); | ||||||
} | ||||||
} | ||||||
|
||||||
const ADVariableValue & | ||||||
|
@@ -2687,6 +2707,20 @@ Coupleable::adCoupledDots(const std::string & var_name) const | |||||
return coupledVectorHelper<const ADVariableValue *>(var_name, func); | ||||||
} | ||||||
|
||||||
template <> | ||||||
const GenericVariableValue<false> & | ||||||
Coupleable::coupledGenericDot<false>(const std::string & var_name, unsigned int comp) const | ||||||
{ | ||||||
return coupledDot(var_name, comp); | ||||||
} | ||||||
|
||||||
template <> | ||||||
const GenericVariableValue<true> & | ||||||
Coupleable::coupledGenericDot<true>(const std::string & var_name, unsigned int comp) const | ||||||
{ | ||||||
return adCoupledDot(var_name, comp); | ||||||
} | ||||||
|
||||||
// Explicit instantiations | ||||||
|
||||||
template const Real & Coupleable::getDefaultNodalValue<Real>(const std::string & var_name, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1149,7 +1149,7 @@ template <> | |
void | ||
MooseVariableData<RealEigenVector>::computeMonomialValues() | ||
{ | ||
// Fixeme: will think of optimization later | ||
// FIXME: will think of optimization later | ||
computeValues(); | ||
} | ||
|
||
|
@@ -1271,12 +1271,16 @@ MooseVariableData<OutputType>::computeAD(const unsigned int num_dofs, const unsi | |
} | ||
|
||
if (_need_ad_u_dot && !_time_integrator) | ||
{ | ||
for (MooseIndex(nqp) qp = 0; qp < nqp; ++qp) | ||
{ | ||
_ad_u_dot[qp] = _u_dot[qp]; | ||
if (_need_ad_u_dotdot) | ||
_ad_u_dotdot[qp] = _u_dotdot[qp]; | ||
} | ||
for (unsigned int i = 0; i < num_dofs; i++) | ||
_ad_dofs_dot[i] = _dof_values_dot[i]; | ||
} | ||
|
||
if (_need_ad_grad_u_dot && !_time_integrator) | ||
for (MooseIndex(nqp) qp = 0; qp < nqp; ++qp) | ||
|
@@ -1785,6 +1789,11 @@ MooseVariableData<OutputType>::fetchADDoFValues() | |
libmesh_assert(n); | ||
_ad_dof_values.resize(n); | ||
|
||
if (_need_ad_u_dot) | ||
_ad_dofs_dot.resize(n); | ||
if (_need_ad_u_dotdot) | ||
_ad_dofs_dotdot.resize(n); | ||
|
||
const bool do_derivatives = | ||
ADReal::do_derivatives && _sys.number() == _subproblem.currentNlSysNum(); | ||
|
||
|
@@ -1794,6 +1803,24 @@ MooseVariableData<OutputType>::fetchADDoFValues() | |
if (do_derivatives) | ||
Moose::derivInsert(_ad_dof_values[i].derivatives(), _dof_indices[i], 1.); | ||
assignADNodalValue(_ad_dof_values[i], i); | ||
|
||
if (_need_ad_u_dot) | ||
{ | ||
if (_time_integrator && _time_integrator->dt()) | ||
{ | ||
_ad_dofs_dot[i] = _ad_dof_values[i]; | ||
_time_integrator->computeADTimeDerivatives(_ad_dofs_dot[i], | ||
_dof_indices[i], | ||
_need_ad_u_dotdot ? _ad_dofs_dotdot[i] | ||
: _ad_real_dummy); | ||
} | ||
// Executing something with a time derivative at initial should not put a NaN | ||
else if (_time_integrator && !_time_integrator->dt()) | ||
_ad_dofs_dot[i] = 0; | ||
else | ||
mooseError("AD nodal time derivatives not implemented for variables without a time " | ||
"integrator (auxiliary variables)"); | ||
} | ||
Comment on lines
+1807
to
+1823
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok I ll rename! |
||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.