Doubt to save the center of mass of previous timestep

Hello Lammps users!
I have a system consisting of a lipid bilayer separating two aqueous regions in the z direction. This system is subjected to a shock wave and, therefore, the center of mass of the lipid bilayer moves with the simulation.

I am trying to separate the two aqueous zones into Lammps regions. The problem is that the boundary of this region is variable, so I should use the move keyword of the region command. However, to do this I need to specify a variable that determines how the boundary changes. One way to do this is to measure the center of mass of the bilayer in a given time-step and decrease the center of mass of the previous step. However, I am having trouble finding a way to store the information relative to the previous com. Can anyone help me with this?

Thanks in advance!

That is quite tricky business, but here is a possible way to do what you want:

reset_timestep  0
compute         com mygroup com
fix             com all vector 1 c_com[1] c_com[2] c_com[3]
variable        step equal (step<1)+step
variable        cx equal f_com[v_step][1]
variable        cy equal f_com[v_step][2]
variable        cz equal f_com[v_step][3]

Here the variables cx, cy, and cz will contain the values of the com compute of the previous step, exept for the first step.