[lammps-users] Where is update->minimize->setup()

I am trying to understand the minimize code. Where is the definition for the following function update->minimize->setup();
I saw that update.cpp creates it’s own minimize using minimize = minimize_creator(lmp); But minimize does not appear to have a setup function that takes no parameters.
Thank you,


two things up front:
a) you have to make yourself familiar with C++ polymorphism
b) you have to realize that a class instance e.g. at Update::minimize is different from a class definition e.g. the Minimize class.

now, what LAMMPS does has grown historically, so not everything is perfectly consistent (or rather it depends on your perspective).

if you look at src/update.h, then you can see that the member “minimize” is a pointer of type “Min”.
if you look at src/minimize.h then you can see that this is providing a class “Minimize”, which is a “command style”, not a “min style”.
so the base class for minimization styles is “Min” which is defined in the file src/min.h. the actual minimizers are classes derived from “Min”.

the minimize_creator() function now will create an instance of a minimizer class based on the “min_style” setting (by default MinCG from src/min_cg.h).
but if you issue a “min_style” command that instance will be deleted and a new instance of whatever minimizer style you choose created instead.
because of polymorphism, the Update class will only call the functions in the base class (Min) but those may be delegated or overridden in the derived classes.
in some cases the base class has no definition, just a null pointer (a “pure” function) in those cases the function must be implemented by the derived class, otherwise the implementation is optional.

the Minimize class from minimize.h on the other hand provides the “minmize” command that will actually trigger the minimization and call the necessary methods in update and elsewhere (which will then delegate the necessary steps to individual class instances according to your input)

Please also have a look at: https://docs.lammps.org/Developer.html


Thank you very much for the information