← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 1819: 1. Created yade.ymport.gengeo() function for importing LSMGenGeo geometry directly to the YADE si...

 

------------------------------------------------------------
revno: 1819
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2009-11-27 15:42:21 +0100
message:
  1. Created yade.ymport.gengeo() function for importing LSMGenGeo geometry directly to the YADE simulation without intermediate files. See ./scripts/test/genCylLSM.py
  2. yade.ymport.gengeo() (import .geo-files function) was renamed to yade.ymport.gengeoFile()
  3. CohesiveStateRPMRecorder is now working. (thanks Vaclav)
modified:
  pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.cpp
  pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.hpp
  py/ymport.py
  scripts/test/genCylLSM.py
  scripts/test/regular-sphere-pack.py


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

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription.
=== modified file 'pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.cpp'
--- pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.cpp	2009-11-26 16:27:21 +0000
+++ pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.cpp	2009-11-27 14:42:21 +0000
@@ -3,31 +3,28 @@
 YADE_PLUGIN((CohesiveStateRPMRecorder));
 CREATE_LOGGER(CohesiveStateRPMRecorder);
 
-CohesiveStateRPMRecorder::CohesiveStateRPMRecorder() 
-{
+CohesiveStateRPMRecorder::CohesiveStateRPMRecorder() {
 	initRun=true;
 	numberCohesiveContacts=0;
 }
 
-CohesiveStateRPMRecorder::~CohesiveStateRPMRecorder()
-{
-}
-
-void CohesiveStateRPMRecorder::init(MetaBody* rootBody)
-{
-}
-
-void CohesiveStateRPMRecorder::action(MetaBody* rootBody)
-{
-	InteractionContainer::iterator ii = rootBody->interactions->begin();
-	InteractionContainer::iterator iiEnd = rootBody->interactions->end(); 
-	LOG_WARN("START !!!");
+CohesiveStateRPMRecorder::~CohesiveStateRPMRecorder() {
+}
+
+void CohesiveStateRPMRecorder::init(MetaBody* rootBody) {
+}
+
+void CohesiveStateRPMRecorder::action(MetaBody* rootBody) {
 	numberCohesiveContacts=0;
-	for(; ii!=iiEnd; ++ii ) {
-		const shared_ptr<Interaction>& interaction = *ii;
-		RpmPhys* contPhys = static_cast<RpmPhys*>(interaction->interactionPhysics.get());
+	FOREACH(const shared_ptr<Interaction>& i, *rootBody->interactions){
+		if(!i->isReal()) continue;
+		const shared_ptr<RpmPhys>& contPhys = YADE_PTR_CAST<RpmPhys>(i->interactionPhysics);
 		if (contPhys->isCohesive==true) {
-		
+			numberCohesiveContacts++;
 		}
 	}
+	//Temporary solution, while flieRecorder class is not ready
+	outFile.open(outFileName.c_str(), ios::out | ios::app);
+	outFile<<Omega::instance().getCurrentIteration()<<" "<<numberCohesiveContacts<<"\n";
+	outFile.close();
 }

=== modified file 'pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.hpp'
--- pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.hpp	2009-11-26 16:27:21 +0000
+++ pkg/dem/Engine/StandAloneEngine/CohesiveStateRPMRecorder.hpp	2009-11-27 14:42:21 +0000
@@ -1,3 +1,6 @@
+/*! This class is for storing the cohesive contacts number 
+ * of RPM model in file
+*/
 #pragma once
 #include<yade/pkg-common/PeriodicEngines.hpp>
 #include<yade/pkg-common/InteractionPhysicsEngineUnit.hpp>
@@ -6,15 +9,17 @@
 
 class CohesiveStateRPMRecorder: public PeriodicEngine {
 	public:
-		string fileName;
+		string outFileName;
 		int numberCohesiveContacts;
 		CohesiveStateRPMRecorder(); 
 		~CohesiveStateRPMRecorder();
 		void init(MetaBody*);
 		virtual void action(MetaBody*);
+		
 	private:
+		std::ofstream outFile;
 		
-	REGISTER_ATTRIBUTES(PeriodicEngine,(fileName));
+	REGISTER_ATTRIBUTES(PeriodicEngine,(outFileName));
 	REGISTER_CLASS_AND_BASE(CohesiveStateRPMRecorder,PeriodicEngine);
 	DECLARE_LOGGER;
 };

=== modified file 'py/ymport.py'
--- py/ymport.py	2009-11-26 15:57:19 +0000
+++ py/ymport.py	2009-11-27 14:42:21 +0000
@@ -89,7 +89,7 @@
 		ret.append(utils.facet((nodelistVector3[i[1]],nodelistVector3[i[2]],nodelistVector3[i[3]]),**kw))
 	return ret
 
-def gengeo(fileName="file.geo",moveTo=[0.0,0.0,0.0],scale=1.0,**kw):
+def gengeoFile(fileName="file.geo",moveTo=[0.0,0.0,0.0],scale=1.0,**kw):
 	""" Imports geometry from LSMGenGeo .geo file and creates spheres.
 	moveTo[X,Y,Z] parameter moves the specimen.
 	Remaining **kw arguments are passed to utils.sphere; 
@@ -116,3 +116,26 @@
 		ret.append(utils.sphere([moveTo[0]+scale*float(data[0]),moveTo[1]+scale*float(data[1]),moveTo[2]+scale*float(data[2])],scale*float(data[3]),**kw))
 	return ret
 
+def gengeo(mntable,moveTo=[0.0,0.0,0.0],scale=1.0,**kw):
+	""" Imports geometry from LSMGenGeo library and creates spheres.
+	moveTo[X,Y,Z] parameter moves the specimen.
+	Remaining **kw arguments are passed to utils.sphere; 
+	
+	LSMGenGeo library allows to create pack of spheres
+	with given [Rmin:Rmax] with null stress inside the specimen.
+	Can be usefull for Mining Rock simulation.
+	
+	Example added to scripts/test/regular-sphere-pack.py
+	Example of LSMGenGeo library using is added to genCylLSM.py
+	
+	http://www.access.edu.au/lsmgengeo_python_doc/current/pythonapi/html/GenGeo-module.html
+	https://svn.esscc.uq.edu.au/svn/esys3/lsm/contrib/LSMGenGeo/""";
+	from GenGeo import MNTable3D,Sphere
+	
+	ret=[]
+	sphereList=mntable.getSphereListFromGroup(0)
+	for i in range(0, len(sphereList)):
+		r=sphereList[i].Radius()
+		c=sphereList[i].Centre()
+		ret.append(utils.sphere([moveTo[0]+scale*float(c.X()),moveTo[1]+scale*float(c.Y()),moveTo[2]+scale*float(c.Z())],scale*float(r),**kw))
+	return ret

=== modified file 'scripts/test/genCylLSM.py'
--- scripts/test/genCylLSM.py	2009-11-20 14:24:50 +0000
+++ scripts/test/genCylLSM.py	2009-11-27 14:42:21 +0000
@@ -4,16 +4,18 @@
 
 Be sure LSMGenGeo library is installed.
 
-Symply start this script:
-  python genCylLSM.py
-
-The result is 2 files:
-  "cyl.geo" is the geometry file which can be imported into YADE with import_LSMGenGeo_geometry() function
-  "cyl.vtk" is the VTK-filed which can be opened by any VTK-based software, for example Paraview
+The result is:
+	2 files:
+		"cyl.geo" is the geometry file which can be imported into YADE with import_LSMGenGeo_geometry() function
+		"cyl.vtk" is the VTK-filed which can be opened by any VTK-based software, for example Paraview
+	spheres, imported into the YADE simulation, according to generated geometry
 
 http://www.access.edu.au/lsmgengeo_python_doc/current/pythonapi/html/GenGeo-module.html
 https://svn.esscc.uq.edu.au/svn/esys3/lsm/contrib/LSMGenGeo/
 """
+from yade import pack,ymport
+from yade import utils
+from math import *
 from GenGeo import *
 import sys
 
@@ -59,5 +61,22 @@
   groupID=0
 )
 
+#Write data to files
 mntable.write(fileName+".geo",1)
 mntable.write(fileName+".vtu",2)
+
+#Add material
+O.materials.append(GranularMat(young=1e9,poisson=.25,frictionAngle=0.5,density=1e3))
+
+#Parameters, which will be passed into spheres and facets creators
+kw={'material':0}
+
+#Import the GenGeo geometry directly into the YADE simulation
+O.bodies.append(ymport.gengeo(mntable,moveTo=[-1.0,-1.0,-1.0],scale=2.0,color=(1,1,0),**kw))
+
+try:
+	from yade import qt
+	qt.Controller()
+	qt.View()
+except ImportError: pass
+

=== modified file 'scripts/test/regular-sphere-pack.py'
--- scripts/test/regular-sphere-pack.py	2009-11-26 07:21:42 +0000
+++ scripts/test/regular-sphere-pack.py	2009-11-27 14:42:21 +0000
@@ -60,7 +60,7 @@
 O.bodies.append(ymport.gmsh('regular-sphere-pack.mesh',**kwMeshes))#generates facets from the mesh file
 
 """Import regular-sphere-pack-LSMGenGeo.geo into the YADE simulation"""
-O.bodies.append(ymport.gengeo('regular-sphere-pack-LSMGenGeo.geo',moveTo=[-7.0,-7.0,-5.9],scale=1.0,color=(1,0,1),**kw))
+O.bodies.append(ymport.gengeoFile('regular-sphere-pack-LSMGenGeo.geo',moveTo=[-7.0,-7.0,-5.9],scale=1.0,color=(1,0,1),**kw))
 
 
 try: