Bug report: Region union doesn't work with rotated sub-regions

Dear LAMMPS developers,

I would like to report an issue that likely is a bug in the code:

The user manual suggests that it is possible to use the "region union" command with sub-regions that are rotated, i.e., which were defined with the "rotate" keyword. My observation is that this doesn't work. For example:

region cyl1 cylinder z 0 0 \{radius\} INF INF units lattice rotate v\_rotangle 0 0 0 1 1 0 region cyl2 cylinder z 0 0 {radius} INF INF units lattice rotate v_rotangle 0 0 0 1 -1 0
region combined union 2 cyl1 cyl2

While the rotation works for the individual regions 'cyl1' and 'cyl2' (when using them in a create_atoms command, for example), it doesn't work when I use the region 'combined'. The rotation of the sub-regions is ignored.

I looked into the source code and found that the Region::pretransform() method never gets called on the cylinder regions when they are part of a union. This method is responsible for evaluating the dynamic variable for the rotation angle. As a consequence, the rotation angle subsequently used by Region::rotate() is zero.

I tested this with the current SVN version of LAMMPS.

Best regards,
Alex Stukowski

Think I fixed it - will be in a patch later today.
The attached script seems to work, while it didn’t before.
Please try your problem too?

Thanks Alex for digging into the problem a bit to point
to the offending code.

Steve

test problem for intersect regions

units lj
dimension 2
atom_style atomic
boundary s p p

lattice hex 0.7
region box block 0 20 0 20 -0.5 0.5
create_box 1 box
create_atoms 1 box
mass * 1.0

pair_style lj/cut 2.5
pair_coeff * * 1.0 1.0

velocity all create 1.0 989208
fix 1 all nve

variable x1 equal swiggle(0,2,5)
region bbox1 block -2 -1 0 20 -0.5 0.5 side out move v_x1 NULL NULL
variable x2 equal swiggle(0,-2,5)
region bbox2 block 21 22 0 20 -0.5 0.5 side out move v_x2 NULL NULL
region combine intersect 2 bbox1 bbox2

using both fixes 2,3 should be same as just fix 4

#fix 2 all wall/region bbox1 lj93 1.0 1.0 2.5
#fix 3 all wall/region bbox2 lj93 1.0 1.0 2.5

fix 4 all wall/region combine lj93 1.0 1.0 2.5

dump 1 all atom 10 tmp.dump

thermo 50
run 2000