diff --git a/framework/src/base/MooseApp.C b/framework/src/base/MooseApp.C index cc84d2b8d636..f55610c1d64c 100644 --- a/framework/src/base/MooseApp.C +++ b/framework/src/base/MooseApp.C @@ -352,6 +352,8 @@ MooseApp::MooseApp(InputParameters parameters) } #endif + ADReal::do_derivatives = false; + Registry::addKnownLabel(_type); Moose::registerAll(_factory, _action_factory, _syntax); diff --git a/framework/src/problems/FEProblemBase.C b/framework/src/problems/FEProblemBase.C index 79ddbcd048d1..e983b5fe7484 100644 --- a/framework/src/problems/FEProblemBase.C +++ b/framework/src/problems/FEProblemBase.C @@ -349,11 +349,6 @@ FEProblemBase::FEProblemBase(const InputParameters & parameters) _num_grid_steps(0), _displaced_neighbor_ref_pts("invert_elem_phys use_undisplaced_ref unset", "unset") { - // Initialize static do_derivatives member. We initialize this to true so that all the default AD - // things that we setup early in the simulation actually get their derivative vectors initalized. - // We will toggle this to false when doing residual evaluations - ADReal::do_derivatives = true; - _time = 0.0; _time_old = 0.0; _t_step = 0; @@ -5156,12 +5151,7 @@ FEProblemBase::computeResidualSys(NonlinearImplicitSystem & /*sys*/, NumericVector & residual) { TIME_SECTION(_compute_residual_sys_timer); - - ADReal::do_derivatives = false; - computeResidual(soln, residual); - - ADReal::do_derivatives = true; } void @@ -5449,6 +5439,8 @@ FEProblemBase::computeJacobianInternal(const NumericVector & soln, void FEProblemBase::computeJacobianTags(const std::set & tags) { + ADReal::do_derivatives = true; + if (!_has_jacobian || !_const_jacobian) { TIME_SECTION(_compute_jacobian_tags_timer); @@ -5538,6 +5530,8 @@ FEProblemBase::computeJacobianTags(const std::set & tags) _displaced_problem->setCurrentlyComputingJacobian(false); _safe_access_tagged_matrices = true; } + + ADReal::do_derivatives = false; } void