yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07077
[Branch ~yade-dev/yade/trunk] Rev 2736: 1. Rename QuadroFactory to BoxFactory; some fixing SpheresFactory
------------------------------------------------------------
revno: 2736
committer: Sergei D. sj2001@xxxxxxxxx
branch nick: yade
timestamp: Mon 2011-02-14 11:05:09 +0300
message:
1. Rename QuadroFactory to BoxFactory; some fixing SpheresFactory
2. Rename facet->nf to facet->normal; access to the facet's normal from python
3. Fix examples
removed:
scripts/test/SpheresFactory/
scripts/test/SpheresFactory/circle.stl
scripts/test/SpheresFactory/model.py
scripts/test/SpheresFactory/plane.stl
scripts/test/SpheresFactory/square.stl
scripts/test/SpheresFactory/yade.stl
modified:
core/State.hpp
pkg/common/Facet.cpp
pkg/common/Facet.hpp
pkg/common/Gl1_Facet.cpp
pkg/dem/Dem3DofGeom_FacetSphere.cpp
pkg/dem/FacetTopologyAnalyzer.cpp
pkg/dem/Ig2_Facet_Sphere_ScGeom.cpp
pkg/dem/L3Geom.cpp
pkg/dem/SpheresFactory.cpp
pkg/dem/SpheresFactory.hpp
py/_utils.cpp
scripts/test/facet-sphere-ViscElBasic.py
scripts/test/spheresFactory.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 'core/State.hpp'
--- core/State.hpp 2011-01-12 12:01:03 +0000
+++ core/State.hpp 2011-02-14 08:05:09 +0000
@@ -5,7 +5,7 @@
#include<yade/core/Dispatcher.hpp>
// delete later and remove relevant code, to not support old State.blockedDOFs=['x','y','rz'] syntax anymore
-#define YADE_DEPREC_DOF_LIST
+//#define YADE_DEPREC_DOF_LIST
class State: public Serializable, public Indexable{
public:
=== modified file 'pkg/common/Facet.cpp'
--- pkg/common/Facet.cpp 2010-12-09 12:38:42 +0000
+++ pkg/common/Facet.cpp 2011-02-14 08:05:09 +0000
@@ -25,9 +25,9 @@
#define CHECK_EDGE(i) if(e[i].squaredNorm()==0){LOG_FATAL("Facet has coincident vertices "<<i<<" ("<<vertices[i]<<") and "<<(i+1)%3<<" ("<<vertices[(i+1)%3]<<")!");}
CHECK_EDGE(0); CHECK_EDGE(1);CHECK_EDGE(2);
#undef CHECK_EDGE
- nf = e[0].cross(e[1]); nf.normalize();
+ normal = e[0].cross(e[1]); normal.normalize();
for(int i=0; i<3; ++i){
- ne[i]=e[i].cross(nf); ne[i].normalize();
+ ne[i]=e[i].cross(normal); ne[i].normalize();
vl[i]=vertices[i].norm();
vu[i]=vertices[i]/vl[i];
}
=== modified file 'pkg/common/Facet.hpp'
--- pkg/common/Facet.hpp 2010-12-09 12:38:42 +0000
+++ pkg/common/Facet.hpp 2011-02-14 08:05:09 +0000
@@ -23,7 +23,7 @@
// Postprocessed attributes
/// Facet's normal
- Vector3r nf;
+ //Vector3r nf;
/// Normals of edges
Vector3r ne[3];
/// Inscribing cirle radius
@@ -37,6 +37,7 @@
YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(Facet,Shape,"Facet (triangular particle) geometry.",
((vector<Vector3r>,vertices,vector<Vector3r>(3,Vector3r(NaN,NaN,NaN)),(Attr::triggerPostLoad | Attr::noResize),"Vertex positions in local coordinates."))
+ ((Vector3r,normal,Vector3r(NaN,NaN,NaN),(Attr::readonly | Attr::noSave),"Facet's normal"))
#ifdef FACET_TOPO
((vector<Body::id_t>,edgeAdjIds,vector<Body::id_t>(3,Body::ID_NONE),,"Facet id's that are adjacent to respective edges [experimental]"))
((vector<Real>,edgeAdjHalfAngle,vector<Real>(3,0),,"half angle between normals of this facet and the adjacent facet [experimental]"))
=== modified file 'pkg/common/Gl1_Facet.cpp'
--- pkg/common/Gl1_Facet.cpp 2010-11-19 12:30:08 +0000
+++ pkg/common/Gl1_Facet.cpp 2011-02-14 08:05:09 +0000
@@ -34,7 +34,7 @@
glBegin(GL_LINES);
glColor3(0.0,0.0,1.0);
glVertex3(0.0,0.0,0.0);
- glVertex3v(facet->nf);
+ glVertex3v(facet->normal);
glEnd();
// normal of edges
glColor3(0.0,0.0,1.0);
=== modified file 'pkg/dem/Dem3DofGeom_FacetSphere.cpp'
--- pkg/dem/Dem3DofGeom_FacetSphere.cpp 2010-12-26 15:42:43 +0000
+++ pkg/dem/Dem3DofGeom_FacetSphere.cpp 2011-02-14 08:05:09 +0000
@@ -52,7 +52,7 @@
// begin facet-local coordinates
Vector3r cogLine=state1.ori.conjugate()*(state2.pos+shift2-state1.pos); // connect centers of gravity
//TRVAR4(state1.pos,state1.ori,state2.pos,cogLine);
- Vector3r normal=facet->nf;
+ Vector3r normal=facet->normal;
Real planeDist=normal.dot(cogLine);
if(planeDist<0){normal*=-1; planeDist*=-1; }
if(planeDist>sphereRadius && !c->isReal() && !force) { /* LOG_TRACE("Sphere too far ("<<planeDist<<") from plane"); */ return false; }
@@ -84,7 +84,7 @@
/* This code was mostly copied from InteractingFacet2InteractinSphere4SpheresContactGeometry */
// begin facet-local coordinates
Vector3r contactLine=state1.ori.Conjugate()*(state2.pos+shift2-state1.pos);
- Vector3r normal=facet->nf;
+ Vector3r normal=facet->normal;
Real L=normal.Dot(contactLine); // height/depth of sphere's center from facet's plane
if(L<0){normal*=-1; L*=-1;}
if(L>sphereRadius && !c->isReal()) return false; // sphere too far away from the plane
@@ -121,10 +121,10 @@
#ifdef FACET_TOPO
if(noVertexContact && facet->edgeAdjIds[edgeMax]!=Body::ID_NONE){
// find angle between our normal and the facet's normal (still local coords)
- Quaternionr q; q.Align(facet->nf,normal); AngleAxisr aa(q);
+ Quaternionr q; q.Align(facet->normal,normal); AngleAxisr aa(q);
assert(aa.angle()>=0 && aa.angle()<=Mathr::PI);
if(edgeNormals[edgeMax].Dot(aa.axis())<0) aa.angle()*=-1.;
- bool negFace=normal.Dot(facet->nf)<0; // contact in on the negative facet's face
+ bool negFace=normal.Dot(facet->normal)<0; // contact in on the negative facet's face
Real halfAngle=(negFace?-1.:1.)*facet->edgeAdjHalfAngle[edgeMax];
if(halfAngle<0 && aa.angle()>halfAngle) return false; // on concave boundary, and if in the other facet's sector, no contact
// otherwise the contact will be created
@@ -161,7 +161,7 @@
// contact as soon as it was created.
// fs->refLength=â¦
fs->cp1pt=contactPt; // facet-local intial contact point
- fs->localFacetNormal=facet->nf;
+ fs->localFacetNormal=facet->normal;
fs->cp2rel.setFromTwoVectors(Vector3r::UnitX(),state2.ori.conjugate()*(-normalGlob)); // initial sphere-local center-contactPt orientation WRT +x
fs->cp2rel.normalize();
}
=== modified file 'pkg/dem/FacetTopologyAnalyzer.cpp'
--- pkg/dem/FacetTopologyAnalyzer.cpp 2010-11-07 11:46:20 +0000
+++ pkg/dem/FacetTopologyAnalyzer.cpp 2011-02-14 08:05:09 +0000
@@ -124,7 +124,7 @@
(!invNormals && (ti->vertices[(ei+1)%3]==tj->vertices[ej]) && (ti->vertices[ ei ]==tj->vertices[(ej+1)%3]) ));
// angle between normals
const shared_ptr<Body>& b1=Body::byId(ti->id,scene); const shared_ptr<Body>& b2=Body::byId(tj->id,scene);
- Vector3r n1g=b1->state->ori*f1->nf, n2g=b2->state->ori*f2->nf;
+ Vector3r n1g=b1->state->ori*f1->normal, n2g=b2->state->ori*f2->normal;
//TRVAR2(n1g,n2g);
Vector3r contEdge1g=b1->state->ori*(f1->vertices[(ei+1)%3]-f1->vertices[ei]); // vector of the edge of contact in global coords
Quaternionr q12; q12.setFromTwoVectors(n1g,(invNormals?-1.:1.)*n2g); AngleAxisr aa12(q12); Real halfAngle=.5*aa12.angle();
=== modified file 'pkg/dem/Ig2_Facet_Sphere_ScGeom.cpp'
--- pkg/dem/Ig2_Facet_Sphere_ScGeom.cpp 2010-11-12 08:03:16 +0000
+++ pkg/dem/Ig2_Facet_Sphere_ScGeom.cpp 2011-02-14 08:05:09 +0000
@@ -40,7 +40,7 @@
// BEGIN everything in facet-local coordinates
//
- Vector3r normal = facet->nf;
+ Vector3r normal = facet->normal;
Real L = normal.dot(cl);
if (L<0) {normal=-normal; L=-L; }
=== modified file 'pkg/dem/L3Geom.cpp'
--- pkg/dem/L3Geom.cpp 2011-01-29 22:47:18 +0000
+++ pkg/dem/L3Geom.cpp 2011-02-14 08:05:09 +0000
@@ -257,7 +257,7 @@
Real radius=s2->cast<Sphere>().radius;
// begin facet-local coordinates
Vector3r cogLine=state1.ori.conjugate()*(state2.pos+shift2-state1.pos); // connect centers of gravity
- Vector3r normal=facet.nf; // trial contact normal
+ Vector3r normal=facet.normal; // trial contact normal
Real planeDist=normal.dot(cogLine);
if(abs(planeDist)>radius && !I->isReal() && !force) return false; // sphere too far
if(planeDist<0){normal*=-1; planeDist*=-1; }
=== modified file 'pkg/dem/SpheresFactory.cpp'
--- pkg/dem/SpheresFactory.cpp 2011-01-26 12:39:07 +0000
+++ pkg/dem/SpheresFactory.cpp 2011-02-14 08:05:09 +0000
@@ -7,10 +7,10 @@
//YADE_PLUGIN((SpheresFactory)(DragForceApplier));
-YADE_PLUGIN((SpheresFactory)(CircularFactory)(QuadroFactory)(DragForceApplier));
+YADE_PLUGIN((SpheresFactory)(CircularFactory)(BoxFactory)(DragForceApplier));
CREATE_LOGGER(SpheresFactory);
CREATE_LOGGER(CircularFactory);
-CREATE_LOGGER(QuadroFactory);
+CREATE_LOGGER(BoxFactory);
void DragForceApplier::action(){
FOREACH(const shared_ptr<Body>& b, *scene->bodies){
@@ -27,7 +27,7 @@
static boost::variate_generator<boost::minstd_rand&, boost::uniform_real<Real> > randomUnit(randGen, boost::uniform_real<Real>(0,1));
void SpheresFactory::pickRandomPosition(Vector3r&,Real){
- LOG_FATAL("Engine "<<getClassName()<<" calling virtual method SpheresFactory::pickRandomPosition(). Please submit bug report at http://bugs.launchpad.net/yade.");
+ LOG_FATAL("Engine "<<getClassName()<<" calling virtual method SpheresFactory::pickRandomPosition(), but had to call derived class. This could occur if you use SpheresFactory directly instead derived engines. If not, please submit bug report at http://bugs.launchpad.net/yade.");
throw std::logic_error("SpheresFactory::pickRandomPosition() called.");
}
@@ -61,7 +61,7 @@
#endif
}
if(attempt==maxAttempt) {
- if (silent) {massFlowRate=0;goalMass=0;LOG_INFO("Unable to place new sphere after "<<maxAttempt<<" attempts, SpheresFactory disabled.");}
+ if (silent) {massFlowRate=0; goalMass=totalMass; LOG_INFO("Unable to place new sphere after "<<maxAttempt<<" attempts, SpheresFactory disabled.");}
else {LOG_WARN("Unable to place new sphere after "<<maxAttempt<<" attempts, giving up.");}
return;
}
@@ -84,6 +84,7 @@
Real vol=(4/3.)*Mathr::PI*pow(r,3);
state->mass=vol*material->density;
state->inertia=(2./5.)*vol*r*r*material->density*Vector3r::Ones();
+ state->blockedDOFs_vec_set(blockedDOFs);
b->shape=sphere;
b->state=state;
@@ -100,12 +101,13 @@
void CircularFactory::pickRandomPosition(Vector3r& c, Real r){
const Quaternionr q(Quaternionr().setFromTwoVectors(Vector3r::UnitZ(),normal));
- Real angle=randomUnit()*2*Mathr::PI, rr=randomUnit()*(radius-r); // random polar coordinate inside the nozzle
+ Real angle=randomUnit()*2*Mathr::PI, rr=randomUnit()*(radius-r); // random polar coordinate inside the circle
Real l=(randomUnit()-0.5)*length;
c = center+q*Vector3r(cos(angle)*rr,sin(angle)*rr,0)+normal*l;
}
-void QuadroFactory::pickRandomPosition(Vector3r& c, Real r){
+void BoxFactory::pickRandomPosition(Vector3r& c, Real r){
const Quaternionr q(Quaternionr().setFromTwoVectors(Vector3r::UnitZ(),normal));
- c=center+q*Vector3r((randomUnit()-.5)*2*(extents[0]-r),(randomUnit()-.5)*2*(extents[1]-r),(randomUnit()-.5)*2*(extents[2]-r));
+ //c=center+q*Vector3r((randomUnit()-.5)*2*(extents[0]-r),(randomUnit()-.5)*2*(extents[1]-r),(randomUnit()-.5)*2*(extents[2]-r));
+ c=center+q*Vector3r((randomUnit()-.5)*2*(extents[0]),(randomUnit()-.5)*2*(extents[1]),(randomUnit()-.5)*2*(extents[2]));
}
=== modified file 'pkg/dem/SpheresFactory.hpp'
--- pkg/dem/SpheresFactory.hpp 2011-01-26 12:39:07 +0000
+++ pkg/dem/SpheresFactory.hpp 2011-02-14 08:05:09 +0000
@@ -18,7 +18,7 @@
((Real,rMax,NaN,,"Maximum radius of generated spheres (uniform distribution)"))
((Real,vMin,NaN,,"Minimum velocity norm of generated spheres (uniform distribution)"))
((Real,vMax,NaN,,"Maximum velocity norm of generated spheres (uniform distribution)"))
- ((Real,vAngle,NaN,,"Maximum angle by which the initial sphere velocity deviates from the nozzle normal."))
+ ((Real,vAngle,NaN,,"Maximum angle by which the initial sphere velocity deviates from the normal."))
((Vector3r,normal,Vector3r(NaN,NaN,NaN),,"Spitting direction (and orientation of the region's geometry)."))
((int,materialId,-1,,"Shared material id to use for newly created spheres (can be negative to count from the end)"))
((Real,totalMass,0,,"Mass of spheres that was produced so far. |yupdate|"))
@@ -27,6 +27,7 @@
((int,numParticles,0,,"Cummulative number of particles produces so far |yupdate|"))
((int,maxAttempt,5000 ,,"Maximum number of attempts to position a new sphere randomly."))
((bool,silent,false ,,"If true no complain about excessing maxAttempt but disable the factory (by set massFlowRate=0)."))
+ ((std::string,blockedDOFs,"" ,,"Blocked degress of freedom"))
);
};
REGISTER_SERIALIZABLE(SpheresFactory);
@@ -45,18 +46,18 @@
};
REGISTER_SERIALIZABLE(CircularFactory);
-class QuadroFactory: public SpheresFactory {
+class BoxFactory: public SpheresFactory {
protected:
virtual void pickRandomPosition(Vector3r&, Real);
public:
- virtual ~QuadroFactory(){};
+ virtual ~BoxFactory(){};
DECLARE_LOGGER;
- YADE_CLASS_BASE_DOC_ATTRS(QuadroFactory,SpheresFactory,"Quadro geometry of the SpheresFactory region, given by extents and center",
+ YADE_CLASS_BASE_DOC_ATTRS(BoxFactory,SpheresFactory,"Box geometry of the SpheresFactory region, given by extents and center",
((Vector3r,extents,Vector3r(NaN,NaN,NaN),,"Extents of the region"))
((Vector3r,center,Vector3r(NaN,NaN,NaN),,"Center of the region"))
);
};
-REGISTER_SERIALIZABLE(QuadroFactory);
+REGISTER_SERIALIZABLE(BoxFactory);
class DragForceApplier: public GlobalEngine{
public: virtual void action();
=== modified file 'py/_utils.cpp'
--- py/_utils.cpp 2011-02-09 11:58:56 +0000
+++ py/_utils.cpp 2011-02-14 08:05:09 +0000
@@ -242,10 +242,10 @@
Real ret=0;
FOREACH(const Body::id_t id, ids){
Facet* f=YADE_CAST<Facet*>(Body::byId(id,rb)->shape.get());
- if(axis<0) ret+=rb->forces.getForce(id).dot(f->nf);
+ if(axis<0) ret+=rb->forces.getForce(id).dot(f->normal);
else {
Vector3r ff=rb->forces.getForce(id); ff[axis]=0;
- ret+=ff.dot(f->nf);
+ ret+=ff.dot(f->normal);
}
}
return ret;
=== removed directory 'scripts/test/SpheresFactory'
=== removed file 'scripts/test/SpheresFactory/circle.stl'
Binary files scripts/test/SpheresFactory/circle.stl 2009-01-25 14:28:37 +0000 and scripts/test/SpheresFactory/circle.stl 1970-01-01 00:00:00 +0000 differ
=== removed file 'scripts/test/SpheresFactory/model.py'
--- scripts/test/SpheresFactory/model.py 2010-09-30 18:00:41 +0000
+++ scripts/test/SpheresFactory/model.py 1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
-# -*- encoding=utf-8 -*-
-
-from yade import utils
-
-## PhysicalParameters
-Young = 0.15e9
-Poisson = 0.3
-density=2700
-
-## Import box geometry
-box = utils.import_stl_geometry('plane.stl',young=Young,poisson=Poisson,color=[0.7,0.7,0.7],wire=False)
-## Import factory geometry
-factory1 = utils.import_stl_geometry('yade.stl',color=[0.7,0.4,0.4],noInteractingGeometry=True)
-factory2 = utils.import_stl_geometry('circle.stl',color=[0.4,0.7,0.4],noInteractingGeometry=True)
-factory3 = utils.import_stl_geometry('square.stl',color=[0.4,0.4,0.7],noInteractingGeometry=True)
-
-## Timestep
-O.dt=0.0001
-
-
-## Engines
-O.engines=[
- ForceResetter(),
- InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
- IGeomDispatcher([ef2_Facet_Sphere_Dem3DofGeom(),ef2_Sphere_Sphere_Dem3DofGeom()]),
- IPhysDispatcher([Ip2_FrictMat_FrictMat_FrictPhys()]),
- ConstitutiveLawDispatcher([Law2_Dem3DofGeom_FrictPhys_Basic()]),
- GravityEngine(gravity=(0,0,-9.81)),
- NewtonIntegrator(damping=0.3),
- ## Spheres factory engines
- SpheresFactory(factoryFacets=factory1,virtPeriod=0.005,radius=0.07,radiusRange=0.03,young=Young,pySpheresCreator='spheresCreator',color=(1,0,0)),
- SpheresFactory(factoryFacets=factory2,virtPeriod= 0.01,radius=0.08,young=Young,color=(0,1,0)),
- SpheresFactory(factoryFacets=factory3,virtPeriod= 0.01,radius=0.05,young=Young,color=(0,0,1))
-]
-O.saveTmp()
-
-def spheresCreator( center, radius ):
- s = utils.sphere(center=center, radius=radius, poisson=Poisson, young=Young, density=density )
- O.bodies.append(s)
-
-from yade import qt
-qt.View()
-O.run()
-
-
=== removed file 'scripts/test/SpheresFactory/plane.stl'
Binary files scripts/test/SpheresFactory/plane.stl 2009-01-25 14:28:37 +0000 and scripts/test/SpheresFactory/plane.stl 1970-01-01 00:00:00 +0000 differ
=== removed file 'scripts/test/SpheresFactory/square.stl'
Binary files scripts/test/SpheresFactory/square.stl 2009-01-25 14:28:37 +0000 and scripts/test/SpheresFactory/square.stl 1970-01-01 00:00:00 +0000 differ
=== removed file 'scripts/test/SpheresFactory/yade.stl'
Binary files scripts/test/SpheresFactory/yade.stl 2009-01-25 14:28:37 +0000 and scripts/test/SpheresFactory/yade.stl 1970-01-01 00:00:00 +0000 differ
=== modified file 'scripts/test/facet-sphere-ViscElBasic.py'
--- scripts/test/facet-sphere-ViscElBasic.py 2010-12-26 15:42:43 +0000
+++ scripts/test/facet-sphere-ViscElBasic.py 2011-02-14 08:05:09 +0000
@@ -38,7 +38,7 @@
),
GravityEngine(gravity=[0,0,-9.81]),
NewtonIntegrator(damping=0),
- RotationEngine(subscribedBodies=[facetId],rotationAxis=[0,0,1],rotateAroundZero=True,angularVelocity=0.1)
+ RotationEngine(ids=[facetId],rotationAxis=[0,0,1],rotateAroundZero=True,angularVelocity=0.1)
]
from yade import qt
=== modified file 'scripts/test/spheresFactory.py'
--- scripts/test/spheresFactory.py 2011-01-26 12:39:07 +0000
+++ scripts/test/spheresFactory.py 2011-02-14 08:05:09 +0000
@@ -26,9 +26,9 @@
),
NewtonIntegrator(damping=0),
## CircularFactory: disk if length=0 or cylinder if length>0
- CircularFactory(maxParticles=10000,radius=8e-3,length=16e-3,center=(0,-15e-3,15e-3),rMin=0.28e-3,rMax=0.29e-3,vMin=100,vMax=100,vAngle=0,massFlowRate=100./60,normal=(0,1.5,-1),label='factory',materialId=shotsId),
- ## QuadroFactory: a line, plane or cuboid
- #QuadroFactory(maxParticles=10000,extents=(8e-3,8e-3,8e-3),center=(0,-15e-3,15e-3),rMin=0.28e-3,rMax=0.29e-3,vMin=100,vMax=100,vAngle=0,massFlowRate=100./60,normal=(0,1.5,-1),label='factory',materialId=shotsId),
+ #CircularFactory(maxParticles=10000,radius=8e-3,length=16e-3,center=(0,-15e-3,15e-3),rMin=0.28e-3,rMax=0.29e-3,vMin=100,vMax=100,vAngle=0,massFlowRate=100./60,normal=(0,1.5,-1),label='factory',materialId=shotsId),
+ ## BoxFactory: a line, plane or cuboid
+ BoxFactory(maxParticles=10000,extents=(8e-3,8e-3,8e-3),center=(0,-15e-3,15e-3),rMin=0.28e-3,rMax=0.29e-3,vMin=100,vMax=100,vAngle=0,massFlowRate=100./60,normal=(0,1.5,-1),label='factory',materialId=shotsId),
DomainLimiter(lo=(-30e-3,-30e-3,0),hi=(30e-3,30e-3,60e-3),iterPeriod=200),
#VTKRecorder(recorders=['spheres','facets','velocity'],fileName='/tmp/nozzle-',iterPeriod=500),