← Back to team overview

yade-dev team mailing list archive

[svn] r1939 - in trunk: pkg/dem/DataClass pkg/dem/PreProcessor pkg/dem/meta py

 

Author: eudoxos
Date: 2009-08-12 23:12:21 +0200 (Wed, 12 Aug 2009)
New Revision: 1939

Modified:
   trunk/pkg/dem/DataClass/SpherePack.hpp
   trunk/pkg/dem/PreProcessor/TetraTestGen.cpp
   trunk/pkg/dem/meta/Tetra.cpp
   trunk/pkg/dem/meta/Tetra.hpp
   trunk/py/utils.py
Log:
1. Add #pragma once to SpherePack.hpp (possibly cause of https://bugs.launchpad.net/bugs/412442)
2. Fix crash in TetraTestGen (finally, I think), closing https://bugs.launchpad.net/bugs/408422
3. Add highlight parameter to utils.{facet,sphere,box}, passed to Body::geometricalModel 


Modified: trunk/pkg/dem/DataClass/SpherePack.hpp
===================================================================
--- trunk/pkg/dem/DataClass/SpherePack.hpp	2009-08-12 09:27:41 UTC (rev 1938)
+++ trunk/pkg/dem/DataClass/SpherePack.hpp	2009-08-12 21:12:21 UTC (rev 1939)
@@ -1,5 +1,7 @@
 // © 2009 Václav Šmilauer <eudoxos@xxxxxxxx>
 
+#pragma once
+
 #include<vector>
 #include<string>	
 using namespace std; // sorry

Modified: trunk/pkg/dem/PreProcessor/TetraTestGen.cpp
===================================================================
--- trunk/pkg/dem/PreProcessor/TetraTestGen.cpp	2009-08-12 09:27:41 UTC (rev 1938)
+++ trunk/pkg/dem/PreProcessor/TetraTestGen.cpp	2009-08-12 21:12:21 UTC (rev 1939)
@@ -2,6 +2,14 @@
 #include<yade/core/MetaBody.hpp>
 #include<yade/pkg-dem/Shop.hpp>
 
+#include<yade/pkg-common/BoundingVolumeMetaEngine.hpp>
+#include<yade/pkg-common/InteractionGeometryMetaEngine.hpp>
+#include<yade/pkg-common/PhysicalActionContainerReseter.hpp>
+#include<yade/pkg-common/InsertionSortCollider.hpp>
+#include<yade/pkg-common/MetaInteractingGeometry2AABB.hpp>
+#include<yade/pkg-common/GravityEngines.hpp>
+#include<yade/pkg-dem/NewtonsDampedLaw.hpp>
+
 #include"TetraTestGen.hpp"
 
 #include<yade/pkg-dem/Tetra.hpp>
@@ -12,7 +20,27 @@
 	Shop::setDefault<int>("param_timeStepUpdateInterval",-1);
 
 	rootBody=Shop::rootBody();
-	Shop::rootBodyActors(rootBody);
+
+	shared_ptr<BoundingVolumeMetaEngine> boundingVolumeDispatcher	= shared_ptr<BoundingVolumeMetaEngine>(new BoundingVolumeMetaEngine);
+	boundingVolumeDispatcher->add(new TetraAABB);
+	boundingVolumeDispatcher->add(new MetaInteractingGeometry2AABB);
+	rootBody->initializers.push_back(boundingVolumeDispatcher);
+	rootBody->engines.clear();
+	rootBody->engines.push_back(shared_ptr<Engine>(new BexResetter));
+	rootBody->engines.push_back(boundingVolumeDispatcher);
+	rootBody->engines.push_back(shared_ptr<Engine>(new InsertionSortCollider));
+	shared_ptr<InteractionGeometryMetaEngine> interactionGeometryDispatcher(new InteractionGeometryMetaEngine);
+	interactionGeometryDispatcher->add(new Tetra2TetraBang);
+	rootBody->engines.push_back(interactionGeometryDispatcher);
+	// do not add any InteractionPhysicsMetaEngine
+	shared_ptr<TetraLaw> constitutiveLaw(new TetraLaw);
+	rootBody->engines.push_back(constitutiveLaw);
+
+	shared_ptr<GravityEngine> gravityCondition(new GravityEngine);
+	gravityCondition->gravity=Vector3r(0,0,-9.81);
+	rootBody->engines.push_back(gravityCondition);
+	rootBody->engines.push_back(shared_ptr<Engine>(new NewtonsDampedLaw));
+
 	rootBody->dt=1e-5;
 	
 	#if 0

Modified: trunk/pkg/dem/meta/Tetra.cpp
===================================================================
--- trunk/pkg/dem/meta/Tetra.cpp	2009-08-12 09:27:41 UTC (rev 1938)
+++ trunk/pkg/dem/meta/Tetra.cpp	2009-08-12 21:12:21 UTC (rev 1939)
@@ -373,16 +373,17 @@
 
 /*! Apply forces on tetrahedra in collision based on geometric configuration provided by Tetra2TetraBang.
  *
+ * DO NOT USE, probably doesn't work.
  * Comments on functionality limitations are in the code. It has not been tested at all!!! */
 void TetraLaw::action(MetaBody* rootBody)
 {
-
-	for(InteractionContainer::iterator contactI=rootBody->transientInteractions->begin(); contactI!=rootBody->transientInteractions->end(); ++contactI){
-		if (!(*contactI)->isReal()) continue; // Tetra2TetraBang::go returned false for this interaction, skip it
-		const shared_ptr<TetraBang>& contactGeom(dynamic_pointer_cast<TetraBang>((*contactI)->interactionGeometry));
+	FOREACH(const shared_ptr<Interaction>& I, *rootBody->interactions){
+		// normally, we would test isReal(), but TetraLaw doesn't use interactionPhysics at all
+		if (!I->interactionGeometry) continue; // Tetra2TetraBang::go returned false for this interaction, skip it
+		const shared_ptr<TetraBang>& contactGeom(dynamic_pointer_cast<TetraBang>(I->interactionGeometry));
 		if(!contactGeom) continue;
 
-		const body_id_t idA=(*contactI)->getId1(), idB=(*contactI)->getId2();
+		const body_id_t idA=I->getId1(), idB=I->getId2();
 		const shared_ptr<Body>& A=Body::byId(idA), B=Body::byId(idB);
 			
 		if(!(A->getGroupMask()&B->getGroupMask()&sdecGroupMask)) continue; // no bits overlap in masks, skip this one

Modified: trunk/pkg/dem/meta/Tetra.hpp
===================================================================
--- trunk/pkg/dem/meta/Tetra.hpp	2009-08-12 09:27:41 UTC (rev 1938)
+++ trunk/pkg/dem/meta/Tetra.hpp	2009-08-12 21:12:21 UTC (rev 1939)
@@ -161,7 +161,6 @@
 
 REGISTER_SERIALIZABLE(Tetra2TetraBang);
 
-
 // Miscillaneous functions
 //! Tetrahedron's volume.
 /// http://en.wikipedia.org/wiki/Tetrahedron#Surface_area_and_volume

Modified: trunk/py/utils.py
===================================================================
--- trunk/py/utils.py	2009-08-12 09:27:41 UTC (rev 1938)
+++ trunk/py/utils.py	2009-08-12 21:12:21 UTC (rev 1939)
@@ -67,12 +67,12 @@
 
 bodiesPhysDefaults={'young':30e9,'poisson':.3,'frictionAngle':.5236}
 
-def sphere(center,radius,dynamic=True,wire=False,color=None,density=1,physParamsClass='BodyMacroParameters',**physParamsAttr):
+def sphere(center,radius,dynamic=True,wire=False,color=None,density=1,highlight=False,physParamsClass='BodyMacroParameters',**physParamsAttr):
 	"""Create default sphere, with given parameters. Physical properties such as mass and inertia are calculated automatically."""
 	s=Body()
 	if not color: color=randomColor()
 	pp=bodiesPhysDefaults.copy(); pp.update(physParamsAttr);
-	s.shape=GeometricalModel('Sphere',radius=radius,diffuseColor=color,wire=wire)
+	s.shape=GeometricalModel('Sphere',radius=radius,diffuseColor=color,wire=wire,highlight=highlight)
 	s.mold=InteractingGeometry('InteractingSphere',radius=radius,diffuseColor=color)
 	V=(4./3)*math.pi*radius**3
 	inert=(2./5.)*V*density*radius**2
@@ -83,12 +83,12 @@
 	s['isDynamic']=dynamic
 	return s
 
-def box(center,extents,orientation=[1,0,0,0],dynamic=True,wire=False,color=None,density=1,physParamsClass='BodyMacroParameters',**physParamsAttr):
+def box(center,extents,orientation=[1,0,0,0],dynamic=True,wire=False,color=None,density=1,highlight=False,physParamsClass='BodyMacroParameters',**physParamsAttr):
 	"""Create default box (cuboid), with given parameters. Physical properties such as mass and inertia are calculated automatically."""
 	b=Body()
 	if not color: color=randomColor()
 	pp=bodiesPhysDefaults.copy(); pp.update(physParamsAttr);
-	b.shape=GeometricalModel('Box',extents=extents,diffuseColor=color,wire=wire)
+	b.shape=GeometricalModel('Box',extents=extents,diffuseColor=color,wire=wire,highlight=highlight)
 	b.mold=InteractingGeometry('InteractingBox',extents=extents,diffuseColor=color)
 	mass=8*extents[0]*extents[1]*extents[2]*density
 	V=extents[0]*extents[1]*extents[2]
@@ -99,12 +99,12 @@
 	b['isDynamic']=dynamic
 	return b
 
-def facet(vertices,dynamic=False,wire=True,color=None,density=1,physParamsClass='BodyMacroParameters',**physParamsAttr):
+def facet(vertices,dynamic=False,wire=True,color=None,density=1,highlight=False,physParamsClass='BodyMacroParameters',**physParamsAttr):
 	"""Create default facet with given parameters. Vertices are given as sequence of 3 3-tuple and they, all in global coordinates."""
 	b=Body()
 	if not color: color=randomColor()
 	pp=bodiesPhysDefaults.copy(); pp.update(physParamsAttr);
-	b.shape=GeometricalModel('Facet',diffuseColor=color,wire=wire)
+	b.shape=GeometricalModel('Facet',diffuseColor=color,wire=wire,highlight=highlight)
 	b.mold=InteractingGeometry('InteractingFacet',diffuseColor=color)
 	center=inscribedCircleCenter(vertices[0],vertices[1],vertices[2])
 	vertices=Vector3(vertices[0])-center,Vector3(vertices[1])-center,Vector3(vertices[2])-center