# Moving mesh example

atom_style	granular
boundary	m m m
newton		off

communicate	single vel yes
units		si

#region		reg block -.1 0.6 -.1 0.2 -0.3 0.25 units box
region		reg block -1 1 -.5 .5 -.5 .5 units box
create_box	1 reg

neighbor	0.05 bin
neigh_modify	delay 0

#Material properties 
fix 		m1 all property/global youngsModulus peratomtype 5.e6
fix 		m2 all property/global poissonsRatio peratomtype 0.45
fix 		m3 all property/global coefficientRestitution peratomtypepair 1 0.9
fix 		m4 all property/global coefficientFriction peratomtypepair 1 0.05
fix 		m5 all property/global characteristicVelocity scalar 2.

#pair style
pair_style gran model hooke tangential history #Hooke without cohesion
pair_coeff	* *

timestep	0.00005

fix		1 all nve/sphere
fix		2 all gravity 9.81 vector 0.0 0.0 -1.0

#box walls
fix boxwalls_x1 all wall/gran model hooke tangential history primitive type 1 xplane -1.0
fix boxwalls_x2 all wall/gran model hooke tangential history primitive type 1 xplane +1.0
fix boxwalls_y1 all wall/gran model hooke tangential history primitive type 1 yplane -0.5
fix boxwalls_y2 all wall/gran model hooke tangential history primitive type 1 yplane +0.5
fix boxwalls_z1 all wall/gran model hooke tangential history primitive type 1 zplane -0.5
fix boxwalls_z2 all wall/gran model hooke tangential history primitive type 1 zplane +0.5

#import mesh from cad:
fix		cad1 all mesh/surface file meshes/bucket.stl type 1  move -50. -250. 0. &
		scale 0.002  rotate axis 0. 1. 0. angle 90.  rotate axis 0. 0. 1. angle 90.

#region of insertion
region		bc block -0.9 0.9 -0.4 0.4 -0.5 -0.0 units box

#particle distributions
fix			pts1 all particletemplate/sphere 1 atom_type 1 density constant 2500 radius constant 0.04
fix			pdd1 all particledistribution/discrete 1.  1 pts1 1.0

fix			ins all insert/pack seed 100001 distributiontemplate pdd1 vel constant 0. 0. -0.8 &
				insert_every 2000 overlapcheck yes all_in yes particles_in_region 1500 region bc

#thermo settings
compute		1 all erotate/sphere
thermo_style	custom step atoms ke c_1 vol
thermo		1000
thermo_modify	lost ignore norm no
compute_modify	thermo_temp dynamic yes


#make a dump of particles and the stl file 
dump	dmp all custom 200 post/dump*.movingMesh id type type x y z ix iy iz vx vy vz fx fy fz omegax omegay omegaz radius
dump 	dumpstl all mesh/stl 200 post/dump*.stl

#run with particle insertion
run		8000 upto
unfix	ins

#run to let particle settle
run		29999 upto

#use the imported mesh as granular wall
fix bucket_wall all wall/gran model hooke tangential history mesh n_meshes 1 meshes cad1
run		30000 upto

#moving mesh
fix		movecad1 all move/mesh mesh cad1  linear -0.5 0. -0.3

#run
run		15000

#now lift the particles up
unfix		movecad1
fix			movecad2 all move/mesh mesh cad1   rotate origin 0. 0. 0. axis 0. 1. 0. period 2.
run			25000

