Skip to content

Fix deprecation warnings with deal.II master#6961

Merged
gassmoeller merged 2 commits into
geodynamics:mainfrom
gassmoeller:fix_deprecation_warnings
May 4, 2026
Merged

Fix deprecation warnings with deal.II master#6961
gassmoeller merged 2 commits into
geodynamics:mainfrom
gassmoeller:fix_deprecation_warnings

Conversation

@gassmoeller
Copy link
Copy Markdown
Member

@gassmoeller gassmoeller commented May 2, 2026

Fix some of the remaining deprecation warnings introduced by dealii/dealii#19282.

This now compiles without warnings, but I receive the error I attach below when I run our tests. I would have understood if we got another deprecation warning (because we assign an explicit function to ARKode.explicit_function which is now deprecated), but I dont understand the error.

@vovannikov: I thought I saw code in 19282 that kept the existing functions working?
Could you take a look if we are using the class wrong, or if there is a bug in the compatibility? The relevant code is here:

ode.explicit_function = [&] (const double /*time*/,

*** Timestep 1:  t=15625 years, dt=15625 years
   Solving temperature system... 0 iterations.


----------------------------------------------------
Exception 'ExcMessage( "Unable to assign the function since the target is not set in the " "proxy. Most probably, you tried to use it with a stepper that does " "not support this type of callback.")' on rank 0 on processing: 

--------------------------------------------------------
An error occurred in line <122> of file </home/rene/software/dealii/include/deal.II/sundials/arkode.h> in function
    dealii::SUNDIALS::ARKode<VectorType>::FunctionProxy<Fn>& dealii::SUNDIALS::ARKode<VectorType>::FunctionProxy<Fn>::operator=(std::function<_Signature>) [with Fn = void(double, const dealii::Vector<double>&, dealii::Vector<double>&); VectorType = dealii::Vector<double>]
The violated condition was: 
    target
Additional information: 
    Unable to assign the function since the target is not set in the
    proxy. Most probably, you tried to use it with a stepper that does not
    support this type of callback.

Stacktrace:
-----------
#0  ./aspect: dealii::SUNDIALS::ARKode<dealii::Vector<double> >::FunctionProxy<void (double, dealii::Vector<double> const&, dealii::Vector<double>&)>::operator=(std::function<void (double, dealii::Vector<double> const&, dealii::Vector<double>&)>)
#1  ./aspect: aspect::MaterialModel::ReactionModel::GrainSizeEvolution<2>::calculate_reaction_terms(aspect::MaterialModel::MaterialModelInputs<2> const&, std::vector<double, std::allocator<double> > const&, std::vector<unsigned int, std::allocator<unsigned int> > const&, std::function<double (double, double, double, dealii::SymmetricTensor<2, 2, double> const&, unsigned int, double, double)> const&, std::function<double (double, double, double, double, double, unsigned int)> const&, double, double, aspect::MaterialModel::MaterialModelOutputs<2>&) const
#2  ./aspect: aspect::MaterialModel::GrainSize<2>::evaluate(aspect::MaterialModel::MaterialModelInputs<2> const&, aspect::MaterialModel::MaterialModelOutputs<2>&) const
#3  ./aspect: void aspect::Simulator<2>::get_artificial_viscosity<double>(dealii::Vector<double>&, aspect::AdvectionField const&, bool) const
#4  ./aspect: aspect::Simulator<2>::assemble_advection_system(aspect::AdvectionField const&)
#5  ./aspect: aspect::Simulator<2>::assemble_and_solve_composition(std::vector<double, std::allocator<double> > const&, unsigned int, std::vector<double, std::allocator<double> >*)
#6  ./aspect: aspect::Simulator<2>::solve_single_advection_single_stokes()
#7  ./aspect: aspect::Simulator<2>::solve_timestep()
#8  ./aspect: aspect::Simulator<2>::run()
#9  ./aspect: 
#10  ./aspect: main
--------------------------------------------------------

Copy link
Copy Markdown

@vovannikov vovannikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you got confused with the error message. Its text stayed from one of the first implementations and has to be changed to something like
"Unable to assign the function since the target is not set in the proxy. Most probably, you explicitly provided the stepper object to ARKode in its constructor and then tried to use the old backwards compatibility callback assignment. This is discouraged: assign directly the callbacks of the provided stepper object."

Eventually, if you create a stepper object and then explicitly provide it to the ARKode constructor, then the callbacks can't be assigned to the ARKode object. This is done to discourage their usage, since callbacks are different for different ARKODE steppers. Currently, only the wrapper for ARKStep is available in deal.II, but I will add more of them.

SUNDIALS::ARKode<VectorType> ode(data);
ode.explicit_function = [&] (const double /*time*/,
const VectorType &y,
VectorType &grain_size_rates_of_change)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this code to work, this part has to look something like this:

Suggested change
VectorType &grain_size_rates_of_change)
auto explicit_function = [&] (const double /*time*/,
const VectorType &y,
VectorType &grain_size_rates_of_change) { ... };
#if DEAL_II_VERSION_GTE(9,8,0)
SUNDIALS::ARKStepper<VectorType>::AdditionalData stepper_data;
stepper_data.order = 3;
stepper_data.maximum_non_linear_iterations = 30;
SUNDIALS::ARKStepper<VectorType> stepper(stepper_data);
SUNDIALS::ARKode<VectorType> ode(stepper, ode_data);
stepper.explicit_function = explicit_function;
#else
ode_data.maximum_order = 3;
ode_data.maximum_non_linear_iterations = 30;
SUNDIALS::ARKode<VectorType> ode(ode_data);
ode.explicit_function = explicit_function;
#endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, you assign callbacks either to ode (if a stepper was not created explicitly) or to stepper (if you have created a stepper and then provided it to ode).

@gassmoeller
Copy link
Copy Markdown
Member Author

Ah, thanks for the clarification. I have updated the code to consistently use the new approach if available.

You are right, what confused me was that I assumed I could use the new stepper class for everything except for the callback function.

@bangerth
Copy link
Copy Markdown
Contributor

bangerth commented May 3, 2026

Thanks, @gassmoeller, for working on this -- I had it on my list for today (had already compiled current deal.II and ASPECT)...

@bangerth
Copy link
Copy Markdown
Contributor

bangerth commented May 3, 2026

The indent check fails with this error, which I really don't understand:

CMake Error at CMakeLists.txt:118 (message):
  

  *** Could not find a suitably recent version of deal.II.  ***

  You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake
  or set an environment variable "DEAL_II_DIR" that contains a path to a
  sufficiently recent version of deal.II.


-- Configuring incomplete, errors occurred!

Is something wrong with the docker image this check runs on?

@gassmoeller
Copy link
Copy Markdown
Member Author

The tester is still unreliable. The error you saw was because it couldnt add the repository with deal.ii version 9.6, therefore it installed the default deal.ii package of that ubuntu (9.3 i think). That then caused the error. After some restarts the tester finally worked, so I think this is ready now.

@gassmoeller gassmoeller merged commit f7e2a71 into geodynamics:main May 4, 2026
22 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants