Hi Steve,
Yes I do include every header files.
The exact error is just undefined reference to
LAMMPS_NS::FixExternal::set_energy(double). However, in fix_external we
definitely defined. So the only possible reason for not defining it is
because fix.h does not define set_energy. Since we use fix_modify in the
input script to invoke adding external energy during minimization. I can
indeed use every other fix_external member functions, but not
set_energy(double). And All all the other member functions in the
fix_external are declared as virtual functions in fix.h. I think this is the
reason why. Through search in fix.h, the linker found the
set_energy(double), and go to the proper fix type to invoke this function.
no, this logic does not hold.
there is no need at all to have a virtual Fix::set_energy(double);
set_energy is a member of FixExternal only and that is why you cast
the Fix pointer to a FixExternal pointer.
what you do with fix_modify is irrerelevant, since that uses a
different mechanism to get to the information.
a more likely explanation is that you mask with the modification to
fix.h, that your lammps library is not fully up-to-date and that you
are actually not really adding the energy.
I compare fix_addforce.h, all its memeber functions are also declared as
virtual functions in fix.h. and for No need to declare set_callback, may be
because it is a call back function , no need for the help of fix.h. I am not
sure how the virtual function works, but here are the thoughts when I
compile and link the codes. And things work when add in the virtual
function.
this is irrelevant. you can add functions to derived classes any which
way you like.
i would suggest you first check your lammps library, if it is complete
by doing the equivalent of this command.
nm liblammps_linux.a | c++filt | grep FixExternal
it should look something like this:
0000000000000030 T LAMMPS_NS::FixExternal::post_force(int)
0000000000000160 T LAMMPS_NS::FixExternal::set_energy(double)
00000000000001c0 T LAMMPS_NS::FixExternal::copy_arrays(int, int, int)
0000000000000260 T LAMMPS_NS::FixExternal::grow_arrays(int)
0000000000000180 T LAMMPS_NS::FixExternal::memory_usage()
0000000000000250 T LAMMPS_NS::FixExternal::set_callback(void
(*)(void*, long, int, int*, double**, double**), void*)
00000000000001f0 T LAMMPS_NS::FixExternal::pack_exchange(int, double*)
0000000000000170 T LAMMPS_NS::FixExternal::compute_scalar()
0000000000000150 T LAMMPS_NS::FixExternal::min_post_force(int)
0000000000000220 T LAMMPS_NS::FixExternal::unpack_exchange(int, double*)
0000000000000380 T LAMMPS_NS::FixExternal::init()
0000000000000010 T LAMMPS_NS::FixExternal::setup(int)
0000000000000000 T LAMMPS_NS::FixExternal::setmask()
0000000000000020 T LAMMPS_NS::FixExternal::min_setup(int)
0000000000000440 T
LAMMPS_NS::FixExternal::FixExternal(LAMMPS_NS::LAMMPS*, int, char**)
0000000000000440 T
LAMMPS_NS::FixExternal::FixExternal(LAMMPS_NS::LAMMPS*, int, char**)
0000000000000650 T LAMMPS_NS::FixExternal::~FixExternal()
00000000000003c0 T LAMMPS_NS::FixExternal::~FixExternal()
00000000000003c0 T LAMMPS_NS::FixExternal::~FixExternal()
0000000000000000 V vtable for LAMMPS_NS::FixExternal
U
LAMMPS_NS::FixExternal::FixExternal(LAMMPS_NS::LAMMPS*, int, char**)
0000000000000000 W LAMMPS_NS::Fix*
LAMMPS_NS::Modify::fix_creator<LAMMPS_NS::FixExternal>(LAMMPS_NS::LAMMPS*,
int, char**)
axel.