Storing Values in custom class

Hi all,

I am seeking to store interaction parameters for a class I am building. The values are read in via the modify_param command. I currently store them in double param where the indices are the group numbers and the value is the interaction parameter. The double is a member variable in my class (which is a child class of the KSpace class).

Despite having a memory->create(param, group->ngroup, group->ngroup,“tild:param”) command in allocate() and a destory command in deallocate(), I have a segmentation fault when entering the modify_param() command. If I add a if (param==NULL) memory->create(...) line to modify_param, the values are stored when assigning the parameters, but during compute() step, they are back to all 0’s as opposed to the populated values.

What would be the proper way of storing these interaction parameters such that they exist during the compute step?

Thanks in advance,


Allocate the memory you want in the constructor and destroy the memory in the deconstructor.


Not clear if you are saying you solved your problem. But in your first email.
you simply need to make your double array a class variable to make
it visible in a different method of the class. You should also insure
you are only allocating it once.