yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #08178
[Branch ~yade-dev/yade/trunk] Rev 2984: - make it possible to include bodies larger than period conditionally, using allowLargerThanPerio...
------------------------------------------------------------
revno: 2984
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2011-12-16 20:41:14 +0100
message:
- make it possible to include bodies larger than period conditionally, using allowLargerThanPeriod flag (as discussed in https://answers.launchpad.net/yade/+question/181411, thanks Giulia for the scipt)
- document undocumented parameters of bodies creation (in utils.sphere)
modified:
pkg/common/InsertionSortCollider.cpp
pkg/common/InsertionSortCollider.hpp
py/utils.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/common/InsertionSortCollider.cpp'
--- pkg/common/InsertionSortCollider.cpp 2011-02-27 13:54:43 +0000
+++ pkg/common/InsertionSortCollider.cpp 2011-12-16 19:41:14 +0000
@@ -442,8 +442,8 @@
for(int axis=0; axis<3; axis++){
Real dim=scene->cell->getSize()[axis];
// LOG_DEBUG("dim["<<axis<<"]="<<dim);
- // too big bodies in interaction
- assert(maxima[3*id1+axis]-minima[3*id1+axis]<.99*dim); assert(maxima[3*id2+axis]-minima[3*id2+axis]<.99*dim);
+ // too big bodies
+ if (!allowBiggerThanPeriod){ assert(maxima[3*id1+axis]-minima[3*id1+axis]<.99*dim); assert(maxima[3*id2+axis]-minima[3*id2+axis]<.99*dim);}
// find body of which minimum when taken as period start will make the gap smaller
Real m1=minima[3*id1+axis],m2=minima[3*id2+axis];
Real wMn=(cellWrapRel(m1,m2,m2+dim)<cellWrapRel(m2,m1,m1+dim)) ? m2 : m1;
@@ -456,19 +456,24 @@
}
#endif
int pmn1,pmx1,pmn2,pmx2;
- Real mn1=cellWrap(minima[3*id1+axis],wMn,wMn+dim,pmn1), mx1=cellWrap(maxima[3*id1+axis],wMn,wMn+dim,pmx1);
- Real mn2=cellWrap(minima[3*id2+axis],wMn,wMn+dim,pmn2), mx2=cellWrap(maxima[3*id2+axis],wMn,wMn+dim,pmx2);
+ Real mn1=cellWrap(m1,wMn,wMn+dim,pmn1), mx1=cellWrap(maxima[3*id1+axis],wMn,wMn+dim,pmx1);
+ Real mn2=cellWrap(m2,wMn,wMn+dim,pmn2), mx2=cellWrap(maxima[3*id2+axis],wMn,wMn+dim,pmx2);
#ifdef PISC_DEBUG
if(watchIds(id1,id2)){
TRVAR4(mn1,mx1,mn2,mx2);
TRVAR4(pmn1,pmx1,pmn2,pmx2);
}
#endif
- if(unlikely((pmn1!=pmx1) || (pmn2!=pmx2))){
+ if (allowBiggerThanPeriod && ((pmn1!=pmx1) || (pmn2!=pmx2)) ){
+ // If both bodies are bigger, we don't handle the interaction, return
+ if(unlikely((pmn1!=pmx1) && (pmn2!=pmx2))) return false;
+ // else we define period with the position of the small body (we assume the big one sits in period (0,0,0), keep that in mind if velGrad(.,axis) is not a null vector)
+ else {periods[axis]=(pmn1==pmx1)? pmn1 : -pmn2; return true;}
+ } else if(unlikely((pmn1!=pmx1) || (pmn2!=pmx2))){
Real span=(pmn1!=pmx1?mx1-mn1:mx2-mn2); if(span<0) span=dim-span;
LOG_FATAL("Body #"<<(pmn1!=pmx1?id1:id2)<<" spans over half of the cell size "<<dim<<" (axis="<<axis<<", min="<<(pmn1!=pmx1?mn1:mn2)<<", max="<<(pmn1!=pmx1?mx1:mx2)<<", span="<<span<<")");
throw runtime_error(__FILE__ ": Body larger than half of the cell size encountered.");
- }
+ }
periods[axis]=(int)(pmn1-pmn2);
if(!(mn1<=mx2 && mx1 >= mn2)) return false;
}
=== modified file 'pkg/common/InsertionSortCollider.hpp'
--- pkg/common/InsertionSortCollider.hpp 2011-01-09 16:34:50 +0000
+++ pkg/common/InsertionSortCollider.hpp 2011-12-16 19:41:14 +0000
@@ -199,6 +199,7 @@
",
((int,sortAxis,0,,"Axis for the initial contact detection."))
((bool,sortThenCollide,false,,"Separate sorting and colliding phase; it is MUCH slower, but all interactions are processed at every step; this effectively makes the collider non-persistent, not remembering last state. (The default behavior relies on the fact that inversions during insertion sort are overlaps of bounding boxes that just started/ceased to exist, and only processes those; this makes the collider much more efficient.)"))
+ ((bool,allowBiggerThanPeriod,false,,"If true, tests on bodies sizes will be disabled, and the simulation will run normaly even if bodies larger than period are found. It can be usefull when the periodic problem include e.g. a floor modelized with wall/box/facet.\nBe sure you know what you are doing if you touch this flag. Bodies larger than period are acceptable only if they should not interact with other larger-than-period bodies, else it will result in undefined behaviour without any warning at run-time. It is safer to keep the flag false in general."))
((Real,verletDist,((void)"Automatically initialized",-.05),,"Length by which to enlarge particle bounds, to avoid running collider at every step. Stride disabled if zero. Negative value will trigger automatic computation, so that the real value will be |verletDist| × minimum spherical particle radius; if there are no spherical particles, it will be disabled."))
((Real,sweepFactor,1.05,,"Overestimation factor for the sweep velocity; must be >=1.0. Has no influence on verletDist, only on the computed stride. [DEPRECATED, is used only when bins are not used]."))
((Real,fastestBodyMaxDist,-1,,"Maximum displacement of the fastest body since last run; if >= verletDist, we could get out of bboxes and will trigger full run. DEPRECATED, was only used without bins. |yupdate|"))
=== modified file 'py/utils.py'
--- py/utils.py 2011-10-17 07:33:59 +0000
+++ py/utils.py 2011-12-16 19:41:14 +0000
@@ -132,7 +132,8 @@
:param Vector3 center: center
:param float radius: radius
- :param Vector3-or-None: body's color, as normalized RGB; random color will be assigned if ``None`.
+ :param float dynamic: deprecated, see "fixed"
+ :param float fixed: generate the body with all DOFs blocked?
:param material:
specify :yref:`Body.material`; different types are accepted:
* int: O.materials[material] will be used; as a special case, if material==-1 and there is no shared materials defined, utils.defaultMaterial() will be assigned to O.materials[0]
@@ -140,7 +141,10 @@
* :yref:`Material` instance: this instance will be used
* callable: will be called without arguments; returned Material value will be used (Material factory object, if you like)
:param int mask: :yref:`Body.mask` for the body
-
+ :param wire: display as wire sphere?
+ :param highlight: highlight this body in the viewer?
+ :param Vector3-or-None: body's color, as normalized RGB; random color will be assigned if ``None`.
+
:return:
A Body instance with desired characteristics.