vector creation

I need to create a vector to store the centroid-to-centroid direction for each pair of contacting particles. How should I properly allocate and call it in allocate() and compute()? I’ve tried many approaches, but all encountered memory allocation issues.

Your description is far to vague and lacking too much context to give any kind of meaningful recommendation.

Since you want to store information about “pairs” you will need to use some allocation method related to neighbor lists. For pair styles in the GRANULAR package, there is the internal fix NEIGH_HISTORY command for example. Storing data about pairs of particles is complicated because atoms move between subdomains and and the number of neighbors can vary quite a bit.