← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3706: Add export into LIGGGHTS-format.

 

------------------------------------------------------------
revno: 3706
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Tue 2013-09-24 16:55:35 +0200
message:
  Add export into LIGGGHTS-format.
  
  It is possible to import it into LIGGGHTS-script, using read_data
  command.
modified:
  doc/sphinx/installation.rst
  py/export.py


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'doc/sphinx/installation.rst'
--- doc/sphinx/installation.rst	2013-09-23 17:56:31 +0000
+++ doc/sphinx/installation.rst	2013-09-24 14:55:35 +0000
@@ -165,8 +165,8 @@
 	* ENABLE_OPENMP: enable OpenMP-parallelizing option (ON by default)
 	* ENABLE_GTS: enable GTS-option (ON by default)
 	* ENABLE_GL2PS: enable GL2PS-option (ON by default)
-  * ENABLE_LINSOLV: enable LINSOLV-option (ON by default)
-  * ENABLE_PFVFLOW: enable PFVFLOW-option, FlowEngine (ON by default)
+	* ENABLE_LINSOLV: enable LINSOLV-option (ON by default)
+	* ENABLE_PFVFLOW: enable PFVFLOW-option, FlowEngine (ON by default)
 	* runtimePREFIX: used for packaging, when install directory is not the same is runtime directory (/usr/local by default)
 	* CHUNKSIZE: used, if you want several sources to be compiled at once. Increases compilation speed and RAM-consumption during it (1 by default).
 

=== modified file 'py/export.py'
--- py/export.py	2013-08-14 09:03:28 +0000
+++ py/export.py	2013-09-24 14:55:35 +0000
@@ -26,25 +26,53 @@
 	
 	count=0
 	
-	out.write('#format ' + format + '\n')
-	if (comment):
-		out.write('# ' + comment + '\n')
+	output = ''
+	outputVel=''
+	if (format<>'liggghts_in'):
+		output = '#format ' + format + '\n'
+		if (comment):
+			output += '# ' + comment + '\n'
+	
+	minCoord= Vector3.Zero
+	maxCoord= Vector3.Zero
+	maskNumber = []
+	
 	for b in O.bodies:
 		try:
 			if (isinstance(b.shape,Sphere) and ((mask<0) or ((mask&b.mask)>0))):
 				if (format=='x_y_z_r'):
-					out.write('%g\t%g\t%g\t%g\n'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius))
+					output+=('%g\t%g\t%g\t%g\n'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius))
 				elif (format=='x_y_z_r_matId'):
-					out.write('%g\t%g\t%g\t%g\t%d\n'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius,b.material.id))
+					output+=('%g\t%g\t%g\t%g\t%d\n'%(b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius,b.material.id))
 				elif (format=='id_x_y_z_r_matId'):
-					out.write('%d\t%g\t%g\t%g\t%g\t%d\n'%(b.id,b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius,b.material.id))
+					output+=('%d\t%g\t%g\t%g\t%g\t%d\n'%(b.id,b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius,b.material.id))
 				elif (format=='jointedPM'):
-					out.write('%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n'%(b.id,b.mat.onJoint,b.mat.joint,b.mat.jointNormal1[0],b.mat.jointNormal1[1],b.mat.jointNormal1[2],b.mat.jointNormal2[0],b.mat.jointNormal2[1],b.mat.jointNormal2[2],b.mat.jointNormal3[0],b.mat.jointNormal3[1],b.mat.jointNormal3[2]))
+					output+=('%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\t%g\n'%(b.id,b.mat.onJoint,b.mat.joint,b.mat.jointNormal1[0],b.mat.jointNormal1[1],b.mat.jointNormal1[2],b.mat.jointNormal2[0],b.mat.jointNormal2[1],b.mat.jointNormal2[2],b.mat.jointNormal3[0],b.mat.jointNormal3[1],b.mat.jointNormal3[2]))
+				elif (format=='liggghts_in'):
+					output+=('%g %g %g %g %g %g %g\n'%(count+1,b.mask,b.shape.radius,b.material.density,b.state.pos[0],b.state.pos[1],b.state.pos[2]))
+					outputVel+=('%g %g %g %g %g %g %g\n'%(count+1,b.state.vel[0],b.state.vel[1],b.state.vel[2],b.state.angVel[0],b.state.angVel[1],b.state.angVel[2]))
 				else:
 					raise RuntimeError("Please, specify a correct format output!");
 				count+=1
+				if  (count==1):
+					minCoord = b.state.pos - Vector3(b.shape.radius,b.shape.radius,b.shape.radius)
+					maxCoord = b.state.pos + Vector3(b.shape.radius,b.shape.radius,b.shape.radius)
+				else:
+					minCoord = Vector3(min(minCoord[0], b.state.pos[0]-b.shape.radius),min(minCoord[1], b.state.pos[1]-b.shape.radius),min(minCoord[2], b.state.pos[2]-b.shape.radius))
+					maxCoord = Vector3(max(maxCoord[0], b.state.pos[0]+b.shape.radius),max(maxCoord[1], b.state.pos[1]+b.shape.radius),max(minCoord[2], b.state.pos[2]+b.shape.radius))
+				if b.mask not in maskNumber:
+					maskNumber.append(b.mask)
 		except AttributeError:
 			pass
+			
+	if (format=='liggghts_in'):
+		outputHeader = 'LIGGGHTS Description\n\n'
+		outputHeader += '%d atoms\n%d atom types\n\n'%(count,len(maskNumber))
+		outputHeader += '%g %g xlo xhi\n%g %g ylo yhi\n%g %g zlo zhi\n\n'%(minCoord[0],maxCoord[0],minCoord[1],maxCoord[1],minCoord[2],maxCoord[2])
+		
+		
+		output=outputHeader + 'Atoms\n\n' + output + '\nVelocities\n\n' + outputVel
+	out.write(output)
 	out.close()
 	return count