← Back to team overview

yade-dev team mailing list archive

Re: [Yade-commits] r1283 - in trunk: . core extra extra/clump gui gui/cmd lib/serialization pkg/common/DataClass/PhysicalParameters pkg/common/Engine/EngineUnit pkg/common/Engine/StandAloneEngine pkg/dem/Engine/EngineUnit scripts

 

Compilation is broken for me after this commit, because I don't have 
boost/foreach.hpp.
It is a file from boost 1.34 and I can install only 1.33 on feisty.

Bruno



eudoxos at BerliOS a écrit :
> Author: eudoxos
> Date: 2008-03-22 09:40:15 +0100 (Sat, 22 Mar 2008)
> New Revision: 1283
>
> Added:
>    trunk/scripts/simple-scene.py
> Modified:
>    trunk/SConstruct
>    trunk/core/GeometricalModel.hpp
>    trunk/extra/Brefcom.hpp
>    trunk/extra/clump/Shop.cpp
>    trunk/gui/SConscript
>    trunk/gui/cmd/attrUtils.cpp
>    trunk/gui/cmd/yadeControl.cpp
>    trunk/lib/serialization/Serializable.hpp
>    trunk/pkg/common/DataClass/PhysicalParameters/ParticleParameters.cpp
>    trunk/pkg/common/Engine/EngineUnit/InteractingSphere2AABB.cpp
>    trunk/pkg/common/Engine/EngineUnit/InteractingSphere2AABB.hpp
>    trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp
>    trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4DistantSpheresContactGeometry.cpp
>    trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4DistantSpheresContactGeometry.hpp
>    trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4SpheresContactGeometry.cpp
>    trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4SpheresContactGeometry.hpp
> Log:
> 1. MAJOR improvements of the python wrappers (constructors take attributes etc.)
> 2. FIRST proof-of-implementation simulation completely created in python: scripts/simple-scene.py. This file will be commented abundantly shortly.
> 3. Add default values to some bool params so that there is no serializer error if they are uninitialized.
> 4. Add aabbEnlargeFactor to InteractingSphere2AABB?\194?\160(should be added to InteractingBox2AABB as well?) (not tested yet)
> 5. rename InteractionDetectionFactor to interactinDetectionFactor
> 6. Serialization now registers only attributes that have not yet been registered (there were problems with python because of that: at first save, attributes were duplicated and the xml file was less readble, although loadable)
> 7. Scan .tpp and .ipp for c++ tags as well
> 8. Some documentation.
>
> [scripts/default-test.py passes as normally]
>
>
>
> Modified: trunk/SConstruct
> ===================================================================
> --- trunk/SConstruct	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/SConstruct	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -161,7 +161,7 @@
>  		else: print "Nothing to clean: %s."%buildDir
>  		sys.argv.remove('clean')
>  	if 'tags' in sys.argv:
> -		cmd="ctags -R --extra=+q --fields=+n --exclude='.*' --exclude=scons-local --exclude=include --exclude='*.so' --langmap=c++:+.inl"
> +		cmd="ctags -R --extra=+q --fields=+n --exclude='.*' --exclude=scons-local --exclude=include --exclude='*.so' --langmap=c++:+.inl,c++:+.tpp,c++:+.ipp"
>  		print cmd; os.system(cmd)
>  		sys.argv.remove('tags')
>  	if 'doc' in sys.argv:
>
> Modified: trunk/core/GeometricalModel.hpp
> ===================================================================
> --- trunk/core/GeometricalModel.hpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/core/GeometricalModel.hpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -26,6 +26,8 @@
>  
>  		Vector3r	diffuseColor;
>  
> +		GeometricalModel(): visible(true),wire(false),shadowCaster(false),diffuseColor(Vector3r(1,1,1)){}
> +
>  	protected : 
>  		void registerAttributes();
>  
>
> Modified: trunk/extra/Brefcom.hpp
> ===================================================================
> --- trunk/extra/Brefcom.hpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/extra/Brefcom.hpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -159,8 +159,8 @@
>  			Real E=Shop::getDefault<double>("phys_young");
>  			Real epsCrackOnset=sigmaC/E;
>  			calibratedEpsFracture=BrefcomLaw::calibrateEpsFracture(Gf,E,expBending,epsCrackOnset);
> -			assert(calibratedEpsFracture>epsCrackOnset);
> -			LOG_DEBUG("calibratedEpsFracture="<<calibratedEpsFracture<<" for Gf="<<Gf<<", expCrackOnset="<<epsCrackOnset<<", E="<<E<<" and expBending="<<expBending);
> +			LOG_DEBUG("calibratedEpsFracture="<<calibratedEpsFracture);
> +			if(calibratedEpsFracture>epsCrackOnset) LOG_WARN("calibratedEpsFracture="<<calibratedEpsFracture<<" < epsCrackOnset="<<epsCrackOnset<<", Gf="<<Gf<<", E="<<E<<", expBending="<<expBending);
>  		}
>  
>  		virtual void go(const shared_ptr<PhysicalParameters>& pp1, const shared_ptr<PhysicalParameters>& pp2, const shared_ptr<Interaction>& interaction);
>
> Modified: trunk/extra/clump/Shop.cpp
> ===================================================================
> --- trunk/extra/clump/Shop.cpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/extra/clump/Shop.cpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -106,7 +106,7 @@
>  	setDefault<int>("body_sdecGroupMask",55);
>  	
>  	setDefault("phys_density",2e3);
> -	setDefault("phys_young",30e10);
> +	setDefault("phys_young",30e9);
>  	setDefault("phys_poisson",.3);
>  	setDefault("phys_frictionAngle",0.5236); //30˚
>  	setDefault("phys_se3_orientation",Quaternionr(Vector3r(0,0,1),0));
>
> Modified: trunk/gui/SConscript
> ===================================================================
> --- trunk/gui/SConscript	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/gui/SConscript	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -38,7 +38,14 @@
>  	env.Install('$PREFIX/lib/yade$SUFFIX/gui',[
>  		env.SharedLibrary('cmdGui',['cmd/cmdGui.cpp']),
>  		env.SharedLibrary('yadeControl',['cmd/yadeControl.cpp','cmd/GLViewer4.cpp'],SHLIBPREFIX='',
> -			LIBS=env['LIBS']+['yade-base','libboost_python','XMLFormatManager','yade-factory','yade-serialization',],
> +			LIBS=env['LIBS']+['yade-base','libboost_python','XMLFormatManager','yade-factory','yade-serialization','Shop',
> +				'BoundingVolumeMetaEngine',
> +				'GeometricalModelMetaEngine',
> +				'InteractingGeometryMetaEngine',
> +				'InteractionGeometryMetaEngine',
> +				'InteractionPhysicsMetaEngine',
> +				'PhysicalParametersMetaEngine',
> +			],
>  			# '$QGLVIEWER_LIB'
>  			#CPPPATH=env['CPPPATH']+['/usr/include/qt4','/usr/include/qt4/Qt','/usr/include/qt4/QtXml','/usr/include/qt4/QtOpenGL','/usr/include/qt4/QtCore','/usr/include/qt4/QtGui'],
>  			CPPDEFINES=env['CPPDEFINES']+['NO_PYGLVIEWER'],
>
> Modified: trunk/gui/cmd/attrUtils.cpp
> ===================================================================
> --- trunk/gui/cmd/attrUtils.cpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/gui/cmd/attrUtils.cpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -32,7 +32,7 @@
>   * This class exposes pySet, pyGet and pyKeys methods to python so that associated object supports python syntax for dictionary member access.
>   */
>  class AttrAccess{
> -	struct AttrDesc{vector<int> types; shared_ptr<Archive> archive;};
> +	struct AttrDesc{int type; shared_ptr<Archive> archive;};
>  	private:
>  		const shared_ptr<Serializable> ser;
>  		Serializable::Archives archives;
> @@ -42,7 +42,7 @@
>  		//! maps attribute name to its archive and vector of its types (given as ints, from the following enum)
>  		DescriptorMap descriptors;
>  		//! allowed types
> -		enum {BOOL,STRING,NUMBER}; // allowed types
> +		enum {BOOL,STRING,NUMBER, SEQ_NUMBER, SEQ_STRING }; // allowed types
>  		
>  		AttrAccess(Serializable* _ser): ser(shared_ptr<Serializable>(_ser)){init();}
>  		AttrAccess(shared_ptr<Serializable> _ser):ser(_ser){init();}
> @@ -55,14 +55,14 @@
>  				if((*ai)->isFundamental() && (*ai)->getName()!="serializationDynlib"){
>  					AttrDesc desc; 
>  					desc.archive=*ai;
> -					// serialize to get size
> -					stringstream stream; vector<string> values;
> -					(*ai)->serialize(stream,**ai,0); IOFormatManager::parseFundamental(stream.str(),values);
>  					any instance=(*ai)->getAddress(); // gets pointer to the stored value
>  					// 3 possibilities: one BOOL, one STRING, one or more NUMBERs
> -					if     (values.size()==1 && any_cast<bool*>(&instance))   desc.types.push_back(AttrAccess::BOOL);
> -					else if(values.size()==1 && any_cast<string*>(&instance)) desc.types.push_back(AttrAccess::STRING);
> -					else {for(size_t i=0; i<values.size(); i++)               desc.types.push_back(AttrAccess::NUMBER);};
> +					if      (any_cast<string*>(&instance)) desc.type=AttrAccess::STRING;
> +					else if (any_cast<bool*>(&instance))   desc.type=AttrAccess::BOOL;
> +					else if (any_cast<Real*>(&instance) || any_cast<int*>(&instance) || any_cast<unsigned int*>(&instance) || any_cast<long*>(&instance) || any_cast<unsigned long*>(&instance)) desc.type=AttrAccess::NUMBER;
> +					else if (any_cast<vector<string>*>(&instance)) desc.type=AttrAccess::SEQ_STRING;
> +					//else if (any_cast<vector<Real>*>(&instance)) desc.type=AttrAccess::SEQ_NUMBER;
> +					else desc.type=AttrAccess::SEQ_NUMBER;
>  					descriptors[(*ai)->getName()]=desc;
>  				}
>  			}
> @@ -81,8 +81,8 @@
>  		string dumpAttr(string name){
>  			string vals,types; AttrDesc desc=descriptors[name]; vector<string> values=getAttrStr(name);
>  			for(size_t i=0; i<values.size(); i++) vals+=(i>0?" ":"")+values[i];
> -			for(size_t i=0; i<desc.types.size(); i++) types+=string(i>0?" ":"")+(desc.types[i]==BOOL?"BOOL":(desc.types[i]==STRING?"STRING":"NUMBER"));
> -			return name+" =\t"+vals+"\t ("+types+")";
> +			string typeDesc(desc.type==BOOL?"BOOL":(desc.type==STRING?"STRING":(desc.type==NUMBER?"NUMBER":(desc.type==SEQ_NUMBER?"SEQ_NUMBER":(desc.type==SEQ_STRING?"SEQ_STRING":"<unknown>")))));
> +			return name+" =\t"+vals+"\t ("+typeDesc+")";
>  		}
>  		//! call dumpAttr for all attributes (used for debugging)
>  		string dumpAttrs(){ string ret; for(DescriptorMap::iterator I=descriptors.begin();I!=descriptors.end();I++) ret+=dumpAttr(I->first)+"\n"; return ret;}
> @@ -92,12 +92,6 @@
>  			stringstream voidStream;
>  			descriptors[name].archive->deserialize(voidStream,*(descriptors[name].archive),value);
>  		}
> -		//! set attribute from its (non-serialized) value, for all possible types
> -		void setAttr(string name, bool value){setAttrStr(name,value?"1":"0");}
> -		void setAttr(string name, string value){setAttrStr(name,value);}
> -		void setAttr(string name, double value){setAttrStr(name,lexical_cast<string>(value));}
> -		void setAttr(string name, vector<double> values){string val("{"); for(size_t i=0; i<values.size();i++) val+=(lexical_cast<string>(values[i]))+" "; setAttrStr(name,val+"}"); }
> -
>  		//! return python list of keys (attribute names)
>  		boost::python::list pyKeys(){boost::python::list ret; for(DescriptorMap::iterator I=descriptors.begin();I!=descriptors.end();I++)ret.append(I->first); return ret;}
>  
> @@ -106,34 +100,39 @@
>  			DescriptorMap::iterator I=descriptors.find(key);
>  			if(I==descriptors.end()) throw std::invalid_argument(string("Invalid key: `")+key+"'.");
>  			vector<string> raw=getAttrStr(key);
> -			if(raw.size()==1){
> -				if(descriptors[key].types[0]==BOOL) return boost::python::object(lexical_cast<bool>(raw[0]));
> -				if(descriptors[key].types[0]==STRING) return boost::python::object(raw[0]);
> -				if(descriptors[key].types[0]==NUMBER) return boost::python::object(lexical_cast<double>(raw[0]));
> -			} else { // list of numbers
> -				/*list<double> ret;
> -				for(vector<string>::iterator I=raw.begin();I!=raw.end();I++)ret.push_back(lexical_cast<double>(*I));
> -				return boost::python::object<list<double> >(ret);*/
> -				boost::python::list ret;
> -				for(vector<string>::iterator I=raw.begin();I!=raw.end();I++)ret.append(lexical_cast<double>(*I));
> -				return ret;
> +			switch(descriptors[key].type){
> +				case BOOL: return python::object(lexical_cast<bool>(raw[0]));
> +				case NUMBER: return python::object(lexical_cast<double>(raw[0]));
> +				case STRING: return python::object(raw[0]);
> +				case SEQ_STRING: {python::list ret; for(size_t i=0; i<raw.size(); i++) ret.append(python::object(raw[i])); return ret;}
> +				case SEQ_NUMBER: {python::list ret; for(size_t i=0; i<raw.size(); i++) ret.append(python::object(lexical_cast<double>(raw[i]))); return ret; }
> +				default: throw runtime_error("Unhandled attribute type!");
>  			}
> -			return boost::python::object();
>  		}
>  		//! set attribute value from python object
>  		void pySet(std::string key, python::object val){
>  			DescriptorMap::iterator I=descriptors.find(key);
>  			if(I==descriptors.end()) throw std::invalid_argument(string("Invalid key: `")+key+"'.");
> -			if(descriptors[key].types.size()==1){
> -				if(descriptors[key].types[0]==BOOL) { setAttr(key,python::extract<bool>(val)); return;}
> -				if(descriptors[key].types[0]==STRING){setAttr(key,python::extract<string>(val)); return;}
> -				if(descriptors[key].types[0]==NUMBER){setAttr(key,python::extract<double>(val)); return;}
> -			} else {
> -				if(PySequence_Check(val.ptr()) && PySequence_Size(val.ptr())==(int)descriptors[key].types.size()){
> -					vector<double> cval;
> -					for(int i=0; i<PySequence_Size(val.ptr()); i++) cval.push_back(python::extract<double>(PySequence_GetItem(val.ptr(),i)));
> -					setAttr(key,cval);
> -				} else {	throw std::invalid_argument(string("Value for `")+key+"' not sequence or not of the expected length ("+lexical_cast<string>(descriptors[key].types.size())+")"); }
> +			#define SAFE_EXTRACT(from,to,type) python::extract<type> to(from); if(!to.check()) throw invalid_argument(string("Could not extract type ")+#type);
> +			switch(descriptors[key].type){
> +				case BOOL: {SAFE_EXTRACT(val.ptr(),extr,bool); setAttrStr(key,extr()?"1":"0"); break;}
> +				case NUMBER: {SAFE_EXTRACT(val.ptr(),extr,double); setAttrStr(key,lexical_cast<string>(extr())); break; }
> +				case STRING: {SAFE_EXTRACT(val.ptr(),extr,string); setAttrStr(key,extr()); break;}
> +				case SEQ_STRING:{
> +					if(!PySequence_Check(val.ptr())) throw invalid_argument("String sequence argument required.");
> +					string strVal("[");
> +					for(int i=0; i<PySequence_Size(val.ptr()); i++){SAFE_EXTRACT(PySequence_GetItem(val.ptr(),i),extr,string); strVal+=extr()+" ";}
> +					setAttrStr(key,strVal+"]");
> +				} 
> +				break;
> +				case SEQ_NUMBER:{
> +					if(!PySequence_Check(val.ptr())) throw invalid_argument("Number sequence argument required.");
> +					string strVal("{");
> +					for(int i=0; i<PySequence_Size(val.ptr()); i++){SAFE_EXTRACT(PySequence_GetItem(val.ptr(),i),extr,double); strVal+=lexical_cast<string>(extr())+" ";}
> +					setAttrStr(key,strVal+"}");
> +				}
> +				break;
> +				default: throw runtime_error("Invalid argument types!!");
>  			}
>  		}
>  };
>
> Modified: trunk/gui/cmd/yadeControl.cpp
> ===================================================================
> --- trunk/gui/cmd/yadeControl.cpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/gui/cmd/yadeControl.cpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -13,6 +13,7 @@
>  #include<boost/any.hpp>
>  #include<boost/shared_ptr.hpp>
>  #include<boost/python.hpp>
> +#include<boost/foreach.hpp>
>  // [boost1.34] #include<boost/python/stl_iterator.hpp>
>  
>  #include<yade/lib-base/Logging.hpp>
> @@ -22,12 +23,34 @@
>  
>  
>  #include<yade/core/MetaDispatchingEngine.hpp>
> +#include<yade/core/MetaDispatchingEngine1D.hpp>
> +#include<yade/core/MetaDispatchingEngine2D.hpp>
>  #include<yade/core/StandAloneEngine.hpp>
>  #include<yade/core/DeusExMachina.hpp>
>  #include<yade/core/EngineUnit.hpp>
>  #include<yade/core/EngineUnit1D.hpp>
>  #include<yade/core/EngineUnit2D.hpp>
>  
> +#include<yade/pkg-common/BoundingVolumeMetaEngine.hpp>
> +#include<yade/pkg-common/GeometricalModelMetaEngine.hpp>
> +#include<yade/pkg-common/InteractingGeometryMetaEngine.hpp>
> +#include<yade/pkg-common/InteractionGeometryMetaEngine.hpp>
> +#include<yade/pkg-common/InteractionPhysicsMetaEngine.hpp>
> +#include<yade/pkg-common/PhysicalParametersMetaEngine.hpp>
> +#include<yade/pkg-common/PhysicalActionDamper.hpp>
> +#include<yade/pkg-common/PhysicalActionApplier.hpp>
> +
> +#include<yade/pkg-common/BoundingVolumeEngineUnit.hpp>
> +#include<yade/pkg-common/GeometricalModelEngineUnit.hpp>
> +#include<yade/pkg-common/InteractingGeometryEngineUnit.hpp>
> +#include<yade/pkg-common/InteractionGeometryEngineUnit.hpp>
> +#include<yade/pkg-common/InteractionPhysicsEngineUnit.hpp>
> +#include<yade/pkg-common/PhysicalParametersEngineUnit.hpp>
> +#include<yade/pkg-common/PhysicalActionDamperUnit.hpp>
> +#include<yade/pkg-common/PhysicalActionApplierUnit.hpp>
> +
> +#include<yade/extra/Shop.hpp>
> +
>  #ifdef USE_PYGLVIEWER
>  	#include"GLViewer4.hpp"
>  	#include<Qt/qapplication.h>
> @@ -43,16 +66,17 @@
>  
>  /*
>  TODO:
> -	1. InteractionContainer with iteration
> +	1. [DONE] InteractionContainer with iteration
>  	2. PhysicalActionContainer (constructor with actionName) with iteration
>  	3. from yadeControl import Omega as _Omega, inherit from that and add other convenience functions
>  */
>  
>  #define BASIC_PY_PROXY_HEAD(pyClass,yadeClass) \
>  class pyClass{shared_ptr<AttrAccess> accessor; \
> +	private: void init(string clss){ proxee=dynamic_pointer_cast<yadeClass>(ClassFactory::instance().createShared(clss.empty()? #yadeClass : clss)); if(!proxee) throw runtime_error("Invalid class `"+clss+"': either nonexistent, or unable to cast to `"+#yadeClass+"'"); } \
>  	public: shared_ptr<yadeClass> proxee; \
>  		void ensureAcc(void){ if(!proxee) throw runtime_error(string("No proxied `")+#yadeClass+"'."); if(!accessor) accessor=shared_ptr<AttrAccess>(new AttrAccess(proxee));} \
> -		pyClass(string clss=""){proxee=dynamic_pointer_cast<yadeClass>(ClassFactory::instance().createShared(clss.empty()? #yadeClass : clss)); if(!proxee) throw runtime_error("Invalid class `"+clss+"': either nonexistent, or unable to cast to `"+#yadeClass+"'"); } \
> +		pyClass(string clss="", python::dict attrs=python::dict()){ init(clss); python::list l=attrs.items(); int len=PySequence_Size(l.ptr()); for(int i=0; i<len; i++){ python::extract<python::tuple> t(l[i]); python::extract<string> keyEx(t()[0]); if(!keyEx.check()) throw invalid_argument("Attribute keys must be strings."); wrappedPySet(keyEx(),t()[1]); } } \
>  		pyClass(const shared_ptr<yadeClass>& _proxee): proxee(_proxee) {} \
>  		std::string pyStr(void){ ensureAcc(); return string(proxee->getClassName()==#yadeClass ? "<"+proxee->getClassName()+">" : "<"+proxee->getClassName()+" "+ #yadeClass +">"); } \
>  		string className(void){ ensureAcc(); return proxee->getClassName(); } \
> @@ -80,6 +104,8 @@
>  
>  
>  BASIC_PY_PROXY_HEAD(pyMetaEngine,MetaDispatchingEngine)
> +		// additional constructor
> +		pyMetaEngine(string clss, python::list functors){init(clss); functors_set(functors);}
>  		python::list functors_get(void){
>  			ensureAcc(); shared_ptr<MetaDispatchingEngine> me=dynamic_pointer_cast<MetaDispatchingEngine>(proxee); if(!me) throw runtime_error("Proxied class not a MetaDispatchingEngine (WTF?)"); python::list ret;
>  			/* garbage design: functorArguments are instances of EngineUnits, but they may not be present; therefore, only use them if they exist; our pyMetaEngine, however, will always have both names and EnguneUnit objects in the same count */
> @@ -95,10 +121,27 @@
>  			}
>  			return ret;
>  		}
> -		void functors_set(python::object ftrs){
> +		void functors_set(python::list ftrs){
>  			ensureAcc(); shared_ptr<MetaDispatchingEngine> me=dynamic_pointer_cast<MetaDispatchingEngine>(proxee); if(!me) throw runtime_error("Proxied class not a MetaDispatchingEngine. (WTF?)");
>  			me->clear(); int len=PySequence_Size(ftrs.ptr()) /*[boost1.34] python::len(ftrs)*/;
> -			for(int i=0; i<len; i++){ const pyEngineUnit& eu=python::extract<pyEngineUnit>(PySequence_GetItem(ftrs.ptr(),i)); me->add(eu.proxee); }
> +			for(int i=0; i<len; i++){
> +				python::extract<pyEngineUnit> euEx(ftrs[i]); if(!euEx.check()) throw invalid_argument("Unable to extract type EngineUnit from sequence.");
> +				bool ok=false;
> +				/* FIXME: casting engine unit to the right type via dynamic_cast doesn't work (always unusuccessful),
> +				 * do static_cast and if the EngineUnit is of wrong type, it will crash badly immediately. */
> +				#define TRY_ADD_FUNCTOR(P,Q) {shared_ptr<P> p(dynamic_pointer_cast<P>(me)); shared_ptr<EngineUnit> eu(euEx().proxee); if(p&&eu){p->add(static_pointer_cast<Q>(eu)); ok=true; }}
> +				// shared_ptr<Q> q(dynamic_pointer_cast<Q>(eu)); cerr<<#P<<" "<<#Q<<":"<<(bool)p<<" "<<(bool)q<<endl;
> +				TRY_ADD_FUNCTOR(BoundingVolumeMetaEngine,BoundingVolumeEngineUnit);
> +				TRY_ADD_FUNCTOR(GeometricalModelMetaEngine,GeometricalModelEngineUnit);
> +				TRY_ADD_FUNCTOR(InteractingGeometryMetaEngine,InteractingGeometryEngineUnit);
> +				TRY_ADD_FUNCTOR(InteractionGeometryMetaEngine,InteractionGeometryEngineUnit);
> +				TRY_ADD_FUNCTOR(InteractionPhysicsMetaEngine,InteractionPhysicsEngineUnit);
> +				TRY_ADD_FUNCTOR(PhysicalParametersMetaEngine,PhysicalParametersEngineUnit);
> +				TRY_ADD_FUNCTOR(PhysicalActionDamper,PhysicalActionDamperUnit);
> +				TRY_ADD_FUNCTOR(PhysicalActionApplier,PhysicalActionApplierUnit);
> +				if(!ok) throw runtime_error(string("Unable to cast to suitable MetaEngine type when adding functor (MetaEngine: ")+me->getClassName()+", functor: "+euEx().proxee->getClassName()+")");
> +				#undef TRY_ADD_FUNCTOR
> +			}
>  		}
>  BASIC_PY_PROXY_TAIL;
>  
> @@ -129,8 +172,35 @@
>  		if(id>=proxee->size()){ PyErr_SetString(PyExc_IndexError, "Body id out of range."); python::throw_error_already_set(); /* make compiler happy; never reached */ return pyBody(); }
>  		else return pyBody(proxee->operator[](id));
>  	}
> +	body_id_t insert(pyBody b){return proxee->insert(b.proxee);}
> +	void clear(){proxee->clear();}
>  };
>  
> +class pyInteractionIterator{
> +	InteractionContainer::iterator I, Iend;
> +	public:
> +	pyInteractionIterator(const shared_ptr<InteractionContainer>& ic){ I=ic->begin(); Iend=ic->end(); }
> +	pyInteractionIterator pyIter(){return *this;}
> +	pyInteraction pyNext(){ if(!(I!=Iend)){ PyErr_SetNone(PyExc_StopIteration); python::throw_error_already_set(); }
> +		InteractionContainer::iterator ret=I; ++I; return pyInteraction(*ret); }
> +};
> +
> +class pyInteractionContainer{
> +	public:
> +		const shared_ptr<InteractionContainer> proxee;
> +		pyInteractionContainer(const shared_ptr<InteractionContainer>& _proxee): proxee(_proxee){}
> +		pyInteractionIterator pyIter(){return pyInteractionIterator(proxee);}
> +		pyInteraction pyGetitem(python::object id12){
> +			if(!PySequence_Check(id12.ptr())) throw invalid_argument("Key must be a tuple");
> +			if(PySequence_Size(id12.ptr())!=2) throw invalid_argument("Key must be a 2-tuple: id1,id2.");
> +			python::extract<body_id_t> id1_(PySequence_GetItem(id12.ptr(),0)), id2_(PySequence_GetItem(id12.ptr(),1));
> +			if(!id1_.check()) throw invalid_argument("Could not extract id1");
> +			if(!id2_.check()) throw invalid_argument("Could not extract id2");
> +			shared_ptr<Interaction> i=proxee->find(id1_(),id2_());
> +			if(i) return pyInteraction(i); else throw invalid_argument("No such interaction.");
> +		}
> +};
> +
>  BASIC_PY_PROXY_HEAD(pyFileGenerator,FileGenerator)
>  	bool generate(string outFile){ensureAcc(); proxee->setFileName(outFile); proxee->setSerializationLibrary("XMLFormatManager"); bool ret=proxee->generateAndSave(); cerr<<(ret?"SUCCESS:\n":"FAILURE:\n")<<proxee->message<<endl; return ret; };
>  BASIC_PY_PROXY_TAIL;
> @@ -139,9 +209,10 @@
>  class pyOmega{
>  	#define OMEGA Omega::instance()
>  	private:
> +		// can be safely removed now, since pyOmega makes an empty rootBody in the constructor, if there is none
>  		void assertRootBody(){if(!OMEGA.getRootBody()) throw std::runtime_error("No root body."); }
>  	public:
> -	pyOmega(){};
> +	pyOmega(){ if(!OMEGA.getRootBody()){shared_ptr<MetaBody> mb=Shop::rootBody(); OMEGA.setRootBody(mb);} };
>  
>  	long iter(){ return OMEGA.getCurrentIteration();}
>  	double simulationTime(){return OMEGA.getSimulationTime();}
> @@ -187,29 +258,38 @@
>  		cerr<<"SAVE!"<<endl;
>  	}
>  
> -	python::list engines_get(void){
> -		assertRootBody(); python::list ret; const shared_ptr<MetaBody>& rootBody=OMEGA.getRootBody();
> -		for(vector<shared_ptr<Engine> >::iterator I=rootBody->engines.begin(); I!=rootBody->engines.end(); ++I){
> -			#define APPEND_ENGINE_IF_POSSIBLE(engineType,pyEngineType) { shared_ptr<engineType> e=dynamic_pointer_cast<engineType>(*I); if(e) { ret.append(pyEngineType(e)); continue; } }
> +	python::list anyEngines_get(vector<shared_ptr<Engine> >& engContainer){
> +		python::list ret; 
> +		//for(vector<shared_ptr<Engine> >::iterator I=engContainer.begin(); I!=engContainer.end(); ++I){
> +		BOOST_FOREACH(shared_ptr<Engine>& eng, engContainer){
> +			#define APPEND_ENGINE_IF_POSSIBLE(engineType,pyEngineType) { shared_ptr<engineType> e=dynamic_pointer_cast<engineType>(eng); if(e) { ret.append(pyEngineType(e)); continue; } }
>  			APPEND_ENGINE_IF_POSSIBLE(MetaDispatchingEngine,pyMetaEngine); APPEND_ENGINE_IF_POSSIBLE(StandAloneEngine,pyStandAloneEngine); APPEND_ENGINE_IF_POSSIBLE(DeusExMachina,pyDeusExMachina);
> -			throw std::runtime_error("Unknown engine type: `"+(*I)->getClassName()+"' (only MetaDispatchingEngine, StandAloneEngine and DeusExMachina are supported)");
> +			throw std::runtime_error("Unknown engine type: `"+eng->getClassName()+"' (only MetaDispatchingEngine, StandAloneEngine and DeusExMachina are supported)");
>  		}
>  		return ret;
>  	}
>  
> -	void engines_set(python::object egs){
> -		assertRootBody(); int len=PySequence_Size(egs.ptr()) /*[boost1.34] python::len(egs)*/; const shared_ptr<MetaBody>& rootBody=OMEGA.getRootBody(); rootBody->engines.clear();
> +	void anyEngines_set(vector<shared_ptr<Engine> >& engContainer, python::object egs){
> +		assertRootBody(); int len=PySequence_Size(egs.ptr()) /*[boost1.34] python::len(egs)*/;
> +		//const shared_ptr<MetaBody>& rootBody=OMEGA.getRootBody(); rootBody->engines.clear();
> +		engContainer.clear();
>  		for(int i=0; i<len; i++){
> -			#define PUSH_BACK_ENGINE_IF_POSSIBLE(pyEngineType) if(python::extract<pyEngineType>(PySequence_GetItem(egs.ptr(),i)).check()){ pyEngineType e=python::extract<pyEngineType>(PySequence_GetItem(egs.ptr(),i)); rootBody->engines.push_back(e.proxee); /* cerr<<"added "<<e.pyStr()<<", a "<<#pyEngineType<<endl; */ continue; }
> +			#define PUSH_BACK_ENGINE_IF_POSSIBLE(pyEngineType) if(python::extract<pyEngineType>(PySequence_GetItem(egs.ptr(),i)).check()){ pyEngineType e=python::extract<pyEngineType>(PySequence_GetItem(egs.ptr(),i)); engContainer.push_back(e.proxee); /* cerr<<"added "<<e.pyStr()<<", a "<<#pyEngineType<<endl; */ continue; }
>  			PUSH_BACK_ENGINE_IF_POSSIBLE(pyStandAloneEngine); PUSH_BACK_ENGINE_IF_POSSIBLE(pyMetaEngine); PUSH_BACK_ENGINE_IF_POSSIBLE(pyDeusExMachina);
>  			throw std::runtime_error("Encountered unknown engine type (unable to extract from python object)");
>  		}
>  	}
> +	python::list engines_get(void){assertRootBody(); return anyEngines_get(OMEGA.getRootBody()->engines);}
> +	void engines_set(python::object egs){assertRootBody(); anyEngines_set(OMEGA.getRootBody()->engines,egs);}
> +	python::list initializers_get(void){assertRootBody(); return anyEngines_get(OMEGA.getRootBody()->initializers);}
> +	void initializers_set(python::object egs){assertRootBody(); anyEngines_set(OMEGA.getRootBody()->initializers,egs);}
>  
> +
>  	//void join(){cerr<<"JOIN!"<<endl; OMEGA.joinSimulationLoop(); /* FIXME: this is OK, but must create simulation loop again! */ }
>  	void wait(){ if(OMEGA.isRunning()){cerr<<"WAIT!"<<endl;} while(OMEGA.isRunning()) usleep(20000 /*20 ms*/); }
>  	
>  	pyBodyContainer bodies_get(void){assertRootBody(); return pyBodyContainer(OMEGA.getRootBody()->bodies); }
> +	pyInteractionContainer interactions_get(void){assertRootBody(); return pyInteractionContainer(OMEGA.getRootBody()->transientInteractions); }
>  
>  	boost::python::list listChildClasses(const string& base){
>  		boost::python::list ret;
> @@ -340,13 +420,27 @@
>  		.def("step",&pyOmega::step)
>  		.def("wait",&pyOmega::wait)
>  		.add_property("engines",&pyOmega::engines_get,&pyOmega::engines_set)
> +		.add_property("initializers",&pyOmega::initializers_get,&pyOmega::initializers_set)
>  		.add_property("bodies",&pyOmega::bodies_get)
> +		.add_property("interactions",&pyOmega::interactions_get)
>  		.def("childClasses",&pyOmega::listChildClasses)
>  		;
>  	
>  	boost::python::class_<pyBodyContainer>("BodyContainer",python::init<pyBodyContainer&>())
> -		.def("__getitem__",&pyBodyContainer::pyGetitem);
> +		.def("__getitem__",&pyBodyContainer::pyGetitem)
> +		.def("append",&pyBodyContainer::insert)
> +		.def("clear", &pyBodyContainer::clear);
> +	boost::python::class_<pyInteractionContainer>("InteractionContainer",python::init<pyInteractionContainer&>())
> +		.def("__iter__",&pyInteractionContainer::pyIter)
> +		.def("__getitem__",&pyInteractionContainer::pyGetitem);
> +	boost::python::class_<pyInteractionIterator>("InteractionIterator",python::init<pyInteractionIterator&>())
> +		.def("__iter__",&pyInteractionIterator::pyIter)
> +		.def("next",&pyInteractionIterator::pyNext);
> +	
>  
> +//	boost::python::class_<pyBodyContainer>("BodyContainer",python::init<pyBodyContainer&>())
> +//		.def("__getitem__",&pyBodyContainer::pyGetitem);
> +
>  		#if 0
>  			.def("oneStep",&oneStep)
>  			.def("newView", &newView)
> @@ -358,24 +452,25 @@
>  #endif
>  
>  #define BASIC_PY_PROXY_WRAPPER(pyClass,pyName)  \
> -	boost::python::class_<pyClass>(pyName,python::init<python::optional<string> >()) \
> +	boost::python::class_<pyClass>(pyName,python::init<python::optional<string,python::dict> >()) \
>  	.ATTR_ACCESS_PY(pyClass) \
>  	.def("__str__",&pyClass::pyStr).def("__repr__",&pyClass::pyStr) \
>  	.add_property("name",&pyClass::className)
>  
>  	BASIC_PY_PROXY_WRAPPER(pyStandAloneEngine,"StandAloneEngine");
>  	BASIC_PY_PROXY_WRAPPER(pyMetaEngine,"MetaEngine")
> -		.add_property("functors",&pyMetaEngine::functors_get,&pyMetaEngine::functors_set);
> +		.add_property("functors",&pyMetaEngine::functors_get,&pyMetaEngine::functors_set)
> +		.def(python::init<string,python::list>());
>  	BASIC_PY_PROXY_WRAPPER(pyDeusExMachina,"DeusExMachina");
>  	BASIC_PY_PROXY_WRAPPER(pyEngineUnit,"EngineUnit")
>  		.add_property("bases",&pyEngineUnit::bases_get);
>  
> -	BASIC_PY_PROXY_WRAPPER(pyGeometricalModel,"Shape");
> -	BASIC_PY_PROXY_WRAPPER(pyInteractingGeometry,"Mold");
> -	BASIC_PY_PROXY_WRAPPER(pyPhysicalParameters,"Phys");
> -	BASIC_PY_PROXY_WRAPPER(pyBoundingVolume,"Bound");
> -	BASIC_PY_PROXY_WRAPPER(pyInteractionGeometry,"InterGeom");
> -	BASIC_PY_PROXY_WRAPPER(pyInteractionPhysics,"InterPhys");
> +	BASIC_PY_PROXY_WRAPPER(pyGeometricalModel,"GeometricalModel");
> +	BASIC_PY_PROXY_WRAPPER(pyInteractingGeometry,"InteractingGeometry");
> +	BASIC_PY_PROXY_WRAPPER(pyPhysicalParameters,"PhysicalParameters");
> +	BASIC_PY_PROXY_WRAPPER(pyBoundingVolume,"BoundingVolume");
> +	BASIC_PY_PROXY_WRAPPER(pyInteractionGeometry,"InteractionGeometry");
> +	BASIC_PY_PROXY_WRAPPER(pyInteractionPhysics,"InteractionPhysics");
>  
>  	BASIC_PY_PROXY_WRAPPER(pyBody,"Body")
>  		.add_property("shape",&pyBody::shape_get,&pyBody::shape_set)
> @@ -389,7 +484,9 @@
>  
>  	BASIC_PY_PROXY_WRAPPER(pyInteraction,"Interaction")
>  		.add_property("phys",&pyInteraction::phys_get,&pyInteraction::phys_set)
> -		.add_property("geom",&pyInteraction::geom_get,&pyInteraction::geom_set);
> +		.add_property("geom",&pyInteraction::geom_get,&pyInteraction::geom_set)
> +		.add_property("id1",&pyInteraction::id1_get)
> +		.add_property("id2",&pyInteraction::id2_get);
>  
>  	BASIC_PY_PROXY_WRAPPER(pyFileGenerator,"Preprocessor")
>  		.def("generate",&pyFileGenerator::generate);
>
> Modified: trunk/lib/serialization/Serializable.hpp
> ===================================================================
> --- trunk/lib/serialization/Serializable.hpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/lib/serialization/Serializable.hpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -12,6 +12,7 @@
>  #define SERIALIZABLE_HPP
>  
>  #include <boost/any.hpp>
> +#include <boost/foreach.hpp>
>  #include <boost/shared_ptr.hpp>
>  #include <boost/type_traits.hpp>
>  #include <boost/lexical_cast.hpp>
> @@ -71,6 +72,7 @@
>  		template <typename Type>
>  		void registerAttribute(const string& name, Type& attribute)
>  		{
> +			BOOST_FOREACH(shared_ptr<Archive> a,archives){if(a->getName()==name){ /* cerr<<"Attribute "<<name<<" already registered."<<endl; */ return;}};
>  			shared_ptr<Archive> ac = Archive::create(name,attribute);
>  			archives.push_back(ac);
>  		}
>
> Modified: trunk/pkg/common/DataClass/PhysicalParameters/ParticleParameters.cpp
> ===================================================================
> --- trunk/pkg/common/DataClass/PhysicalParameters/ParticleParameters.cpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/pkg/common/DataClass/PhysicalParameters/ParticleParameters.cpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -15,6 +15,8 @@
>  {
>  	createIndex();
>  	acceleration = Vector3r(0,0,0);
> +	velocity = Vector3r(0,0,0);
> +	mass=0;
>  }
>  
>  ParticleParameters::~ParticleParameters()
>
> Modified: trunk/pkg/common/Engine/EngineUnit/InteractingSphere2AABB.cpp
> ===================================================================
> --- trunk/pkg/common/Engine/EngineUnit/InteractingSphere2AABB.cpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/pkg/common/Engine/EngineUnit/InteractingSphere2AABB.cpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -10,21 +10,14 @@
>  #include "InteractingSphere.hpp"
>  #include "AABB.hpp"
>  
> -void InteractingSphere2AABB::go(	  const shared_ptr<InteractingGeometry>& cm
> -				, shared_ptr<BoundingVolume>& bv
> -				, const Se3r& se3
> -				, const Body*	)
> -{
> +void InteractingSphere2AABB::go(const shared_ptr<InteractingGeometry>& cm, shared_ptr<BoundingVolume>& bv, const Se3r& se3, const Body*){
>  	InteractingSphere* sphere = static_cast<InteractingSphere*>(cm.get());
>  	AABB* aabb = static_cast<AABB*>(bv.get());
> -	
>  	aabb->center = se3.position;
> -	
>  	aabb->halfSize = Vector3r(sphere->radius,sphere->radius,sphere->radius);
>  	
> -	aabb->min = aabb->center-aabb->halfSize;
> -	aabb->max = aabb->center+aabb->halfSize;	
> -
> +	aabb->min = aabb->center-aabb->halfSize*aabbEnlargeFactor;
> +	aabb->max = aabb->center+aabb->halfSize*aabbEnlargeFactor;	
>  }
>  	
>  YADE_PLUGIN();
>
> Modified: trunk/pkg/common/Engine/EngineUnit/InteractingSphere2AABB.hpp
> ===================================================================
> --- trunk/pkg/common/Engine/EngineUnit/InteractingSphere2AABB.hpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/pkg/common/Engine/EngineUnit/InteractingSphere2AABB.hpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -14,11 +14,11 @@
>  class InteractingSphere2AABB : public BoundingVolumeEngineUnit
>  {
>  	public :
> -		void go(	  const shared_ptr<InteractingGeometry>& cm
> -				, shared_ptr<BoundingVolume>& bv
> -				, const Se3r& se3
> -				, const Body*	);
> +		InteractingSphere2AABB(): aabbEnlargeFactor(1.) {}
> +		void go(const shared_ptr<InteractingGeometry>& cm, shared_ptr<BoundingVolume>& bv, const Se3r& se3, const Body*);
> +		double aabbEnlargeFactor;
>  	FUNCTOR2D(InteractingSphere,AABB);
> +	virtual void registerAttributes(){REGISTER_ATTRIBUTE(aabbEnlargeFactor);}
>  	REGISTER_CLASS_NAME(InteractingSphere2AABB);
>  	REGISTER_BASE_CLASS_NAME(BoundingVolumeEngineUnit);
>  };
>
> Modified: trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp
> ===================================================================
> --- trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/pkg/common/Engine/StandAloneEngine/PersistentSAPCollider.cpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -20,11 +20,6 @@
>  	haveDistantTransient=false;
>  
>  	nbObjects=0;
> -	//xBounds.resize(2*maxObject);
> -	//yBounds.resize(2*maxObject);
> -	//zBounds.resize(2*maxObject);
> -	//minima = new Real[3*maxObject];
> -	//maxima = new Real[3*maxObject];
>  	xBounds.clear();
>  	yBounds.clear();
>  	zBounds.clear();
> @@ -67,8 +62,6 @@
>  			maxima[offset+0]=max[0]; maxima[offset+1]=max[1]; maxima[offset+2]=max[2];
>  		}
>  		else {
> -			// double nan=std::numeric_limits<Real>::quiet_NaN();
> -			// cerr<<"Assigning nan's, not tested! (hangs during sort?)"<<endl;
>  			/* assign the center of gravity as zero-volume bounding box;
>  			 * it should not create spurious interactions and
>  			 * is a better solution that putting nan's into minima and maxima which crashes on _some_ machines */
>
> Modified: trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4DistantSpheresContactGeometry.cpp
> ===================================================================
> --- trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4DistantSpheresContactGeometry.cpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4DistantSpheresContactGeometry.cpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -18,12 +18,12 @@
>  
>  InteractingSphere2InteractingSphere4DistantSpheresContactGeometry::InteractingSphere2InteractingSphere4DistantSpheresContactGeometry()
>  {
> -	InteractionDetectionFactor = 1;
> +	interactionDetectionFactor = 1;
>  }
>  
>  void InteractingSphere2InteractingSphere4DistantSpheresContactGeometry::registerAttributes()
>  {	
> -	REGISTER_ATTRIBUTE(InteractionDetectionFactor);
> +	REGISTER_ATTRIBUTE(interactionDetectionFactor);
>  }
>  
>  bool InteractingSphere2InteractingSphere4DistantSpheresContactGeometry::go(	const shared_ptr<InteractingGeometry>& cm1,
> @@ -36,7 +36,7 @@
>  	InteractingSphere* s2 = static_cast<InteractingSphere*>(cm2.get());
>  
>  	Vector3r normal = se32.position-se31.position;
> -	Real penetrationDepth = pow(InteractionDetectionFactor*(s1->radius+s2->radius), 2) - normal.SquaredLength();// Compute a wrong value just to check sign - faster than computing distances
> +	Real penetrationDepth = pow(interactionDetectionFactor*(s1->radius+s2->radius), 2) - normal.SquaredLength();// Compute a wrong value just to check sign - faster than computing distances
>  	//Real penetrationDepth = s1->radius+s2->radius-normal.Normalize();
>  
>  	shared_ptr<SpheresContactGeometry> scm;
>
> Modified: trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4DistantSpheresContactGeometry.hpp
> ===================================================================
> --- trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4DistantSpheresContactGeometry.hpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4DistantSpheresContactGeometry.hpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -31,7 +31,7 @@
>  					
>  		InteractingSphere2InteractingSphere4DistantSpheresContactGeometry();		
>  					
> -		double InteractionDetectionFactor;// InteractionGeometry will be computed when InteractionDetectionFactor*(rad1+rad2) > distance 		
> +		double interactionDetectionFactor;// InteractionGeometry will be computed when interactionDetectionFactor*(rad1+rad2) > distance 		
>  	
>  	FUNCTOR2D(InteractingSphere,InteractingSphere);
>  
>
> Modified: trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4SpheresContactGeometry.cpp
> ===================================================================
> --- trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4SpheresContactGeometry.cpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4SpheresContactGeometry.cpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -18,12 +18,12 @@
>  
>  InteractingSphere2InteractingSphere4SpheresContactGeometry::InteractingSphere2InteractingSphere4SpheresContactGeometry()
>  {
> -	InteractionDetectionFactor = 1;
> +	interactionDetectionFactor = 1;
>  }
>  
>  void InteractingSphere2InteractingSphere4SpheresContactGeometry::registerAttributes()
>  {	
> -	REGISTER_ATTRIBUTE(InteractionDetectionFactor);
> +	REGISTER_ATTRIBUTE(interactionDetectionFactor);
>  }
>  
>  bool InteractingSphere2InteractingSphere4SpheresContactGeometry::go(	const shared_ptr<InteractingGeometry>& cm1,
> @@ -36,58 +36,44 @@
>  	InteractingSphere* s2 = static_cast<InteractingSphere*>(cm2.get());
>  
>  	Vector3r normal = se32.position-se31.position;
> -	Real penetrationDepth = pow(InteractionDetectionFactor*(s1->radius+s2->radius), 2) - normal.SquaredLength();// Compute a wrong value just to check sign - faster than computing distances
> +	Real penetrationDepth = pow(interactionDetectionFactor*(s1->radius+s2->radius), 2) - normal.SquaredLength();// Compute a wrong value just to check sign - faster than computing distances
>  	//Real penetrationDepth = s1->radius+s2->radius-normal.Normalize();
> -	if (penetrationDepth>0 || c->isReal)
> -	{
> -
> -	shared_ptr<SpheresContactGeometry> scm;
> -	if (c->interactionGeometry)
> -	{
> -		//scm = YADE_PTR_CAST<SpheresContactGeometry>(c->interactionGeometry);
> -	//
> -	// WARNING! 
> -	//
> -	// FIXME - this must be dynamic cast until the contaners are rewritten to support multiple interactions types
> -	//         the problem is that scm can be either SDECLinkGeometry or SpheresContactGeometry and the only way CURRENTLY
> -	//         to check this is by dynamic cast. This has to be fixed.
> -	//
> -		scm = YADE_PTR_CAST<SpheresContactGeometry>(c->interactionGeometry);
> -		//scm = dynamic_cast<SpheresContactGeometry*>(c->interactionGeometry.get());
> -	// BEGIN .......  FIXME FIXME	- wrong hack, to make cohesion work.
> -// 		if(! scm) // this is not SpheresContactGeometry, so it is SDECLinkGeometry, dispatcher should do this job.
> -// 		{
> -// 			shared_ptr<SDECLinkGeometry> linkGeometry = dynamic_pointer_cast<SDECLinkGeometry>(c->interactionGeometry);
> -// //			cerr << "it is SpringGeometry ???: " << c->interactionGeometry->getClassName() << endl;
> -// //			assert(linkGeometry);
> -// 			if(linkGeometry)
> -// 			{
> -// 				linkGeometry->normal 			= se32.position-se31.position;
> -// 				linkGeometry->normal.Normalize();
> -// 				return true;
> -// 			}
> -// 			else
> -// 				return false; // SpringGeometry !!!???????
> -// 		}
> -	// END
> -	}
> -	else
> -		scm = shared_ptr<SpheresContactGeometry>(new SpheresContactGeometry());
> -		
> -	
> +	if (penetrationDepth>0 || c->isReal){
> +		shared_ptr<SpheresContactGeometry> scm;
> +		if (c->interactionGeometry){
> +			// WARNING! 
> +			// FIXME - this must be dynamic cast until the contaners are rewritten to support multiple interactions types
> +			//         the problem is that scm can be either SDECLinkGeometry or SpheresContactGeometry and the only way CURRENTLY
> +			//         to check this is by dynamic cast. This has to be fixed.
> +			scm = YADE_PTR_CAST<SpheresContactGeometry>(c->interactionGeometry);
> +			#if 0
> +				// BEGIN .......  FIXME FIXME	- wrong hack, to make cohesion work.
> +					if(! scm) // this is not SpheresContactGeometry, so it is SDECLinkGeometry, dispatcher should do this job.
> +					{
> +						shared_ptr<SDECLinkGeometry> linkGeometry = dynamic_pointer_cast<SDECLinkGeometry>(c->interactionGeometry);
> +							cerr << "it is SpringGeometry ???: " << c->interactionGeometry->getClassName() << endl;
> +							assert(linkGeometry);
> +						if(linkGeometry)
> +						{
> +							linkGeometry->normal 			= se32.position-se31.position;
> +							linkGeometry->normal.Normalize();
> +							return true;
> +						}
> +						else
> +							return false; // SpringGeometry !!!???????
> +					}
> +					// END
> +			#endif
> +		} else scm = shared_ptr<SpheresContactGeometry>(new SpheresContactGeometry());
>  		penetrationDepth = s1->radius+s2->radius-normal.Normalize();
>  		scm->contactPoint = se31.position+(s1->radius-0.5*penetrationDepth)*normal;//0.5*(pt1+pt2);
>  		scm->normal = normal;
>  		scm->penetrationDepth = penetrationDepth;
>  		scm->radius1 = s1->radius;
>  		scm->radius2 = s2->radius;
> -				
> -		if (!c->interactionGeometry)
> -			c->interactionGeometry = scm;
> -	
> +		if (!c->interactionGeometry) c->interactionGeometry = scm;
>  		return true;
> -	}
> -	else return false;
> +	} else return false;
>  }
>  
>  
>
> Modified: trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4SpheresContactGeometry.hpp
> ===================================================================
> --- trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4SpheresContactGeometry.hpp	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/pkg/dem/Engine/EngineUnit/InteractingSphere2InteractingSphere4SpheresContactGeometry.hpp	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -14,21 +14,18 @@
>  class InteractingSphere2InteractingSphere4SpheresContactGeometry : public InteractionGeometryEngineUnit
>  {
>  	public :
> -		virtual bool go(	const shared_ptr<InteractingGeometry>& cm1,
> -					const shared_ptr<InteractingGeometry>& cm2,
> -					const Se3r& se31,
> -					const Se3r& se32,
> -					const shared_ptr<Interaction>& c);
> -		virtual bool goReverse(	const shared_ptr<InteractingGeometry>& cm1,
> -					const shared_ptr<InteractingGeometry>& cm2,
> -					const Se3r& se31,
> -					const Se3r& se32,
> -					const shared_ptr<Interaction>& c);
> +		virtual bool go(const shared_ptr<InteractingGeometry>& cm1, const shared_ptr<InteractingGeometry>& cm2, const Se3r& se31, const Se3r& se32, const shared_ptr<Interaction>& c);
> +		virtual bool goReverse(	const shared_ptr<InteractingGeometry>& cm1, const shared_ptr<InteractingGeometry>& cm2, const Se3r& se31, const Se3r& se32, const shared_ptr<Interaction>& c);
>  					
>  		InteractingSphere2InteractingSphere4SpheresContactGeometry();		
> -					
> -		double InteractionDetectionFactor;// InteractionGeometry will be computed when InteractionDetectionFactor*(rad1+rad2) > distance 		
> -	
> +		
> +		/*! enlarge both radii by this factor (if >1), to permit creation of distant interactions.
> +		 *
> +		 * InteractionGeometry will be computed when interactionDetectionFactor*(rad1+rad2) > distance.
> +		 *
> +		 * @note This parameter is functionally coupled with InteractinSphere2AABB::aabbEnlargeFactor,
> +		 * which will create larger bounding boxes and should be of the same value. */
> +		double interactionDetectionFactor;
>  
>  	REGISTER_CLASS_NAME(InteractingSphere2InteractingSphere4SpheresContactGeometry);
>  	REGISTER_BASE_CLASS_NAME(InteractionGeometryEngineUnit);
>
> Added: trunk/scripts/simple-scene.py
> ===================================================================
> --- trunk/scripts/simple-scene.py	2008-03-20 20:14:47 UTC (rev 1282)
> +++ trunk/scripts/simple-scene.py	2008-03-22 08:40:15 UTC (rev 1283)
> @@ -0,0 +1,58 @@
> +# -*- encoding=utf-8 -*-
> +o=Omega() # this creates default rootBody as well
> +
> +# is used in both initializers and engines, assign to a temporary
> +aabbDisp=MetaEngine('BoundingVolumeMetaEngine',[EngineUnit('InteractingSphere2AABB'),EngineUnit('InteractingBox2AABB'),EngineUnit('MetaInteractingGeometry2AABB')])
> +
> +o.initializers=[
> +	StandAloneEngine('PhysicalActionContainerInitializer',{'physicalActionNames':['Force','Momentum','GlobalStiffness']}),
> +	aabbDisp]
> +
> +o.engines=[
> +	StandAloneEngine('PhysicalActionContainerReseter'),
> +	aabbDisp,
> +	StandAloneEngine('PersistentSAPCollider'),
> +	MetaEngine('InteractionGeometryMetaEngine',[
> +		EngineUnit('InteractingSphere2InteractingSphere4SpheresContactGeometry'),
> +		EngineUnit('InteractingBox2InteractingSphere4SpheresContactGeometry')
> +	]),
> +	MetaEngine('InteractionPhysicsMetaEngine',[EngineUnit('SimpleElasticRelationships')]),
> +	StandAloneEngine('ElasticContactLaw'),
> +	StandAloneEngine('GlobalStiffnessCounter',{'interval':50}),
> +	StandAloneEngine('GlobalStiffnessTimeStepper',{'defaultDt':1e-4,'active':True,'timeStepUpdateInterval':50}),
> +	DeusExMachina('GravityEngine',{'gravity':[0,0,-9.81]}),
> +	MetaEngine('PhysicalActionDamper',[
> +		EngineUnit('CundallNonViscousForceDamping',{'damping':0.2}),
> +		EngineUnit('CundallNonViscousMomentumDamping',{'damping':0.2})
> +	]),
> +	MetaEngine('PhysicalActionApplier',[
> +		EngineUnit('NewtonsForceLaw'),
> +		EngineUnit('NewtonsMomentumLaw'),
> +	]),
> +	MetaEngine('PhysicalParametersMetaEngine',[EngineUnit('LeapFrogPositionIntegrator')]),
> +	MetaEngine('PhysicalParametersMetaEngine',[EngineUnit('LeapFrogOrientationIntegrator')]),
> +]
> +
> +s=Body()
> +s.shape=GeometricalModel('Sphere',{'radius':1,'diffuseColor':[0,1,0]})
> +s.mold=InteractingGeometry('InteractingSphere',{'radius':1,'diffuseColor':[1,0,0]})
> +s.phys=PhysicalParameters('BodyMacroParameters',{'se3':[0,0,2,1,0,0,0],'mass':1000,'inertia':[7e4,7e4,7e4],'young':3e9,'poisson':0.3})
> +s.bound=BoundingVolume('AABB',{'diffuseColor':[0,0,1]})
> +s['isDynamic']=True
> +
> +b=Body()
> +b.shape=GeometricalModel('Box',{'extents':[.5,.5,.5],'diffuseColor':[1,0,0]})
> +b.mold=InteractingGeometry('InteractingBox',{'extents':[.5,.5,.5],'diffuseColor':[0,1,0]})
> +b.phys=PhysicalParameters('BodyMacroParameters',{'se3':[0,0,0,1,0,0,0],'mass':2000,'inertia':[1e5,1e5,1e5],'young':3e9,'poisson':0.3})
> +b.bound=BoundingVolume('AABB',{'diffuseColor':[0,0,1]})
> +b['isDynamic']=False
> +
> +o.bodies.append(b)
> +o.bodies.append(s)
> +
> +o.save('/tmp/a.xml')
> +
> +# load that with the QtGUI
> +import os
> +os.system(yadeExecutable+' -N QtGUI -S /tmp/a.xml')
> +
>
> _______________________________________________
> Yade-commits mailing list
> Yade-commits@xxxxxxxxxxxxxxxx
> https://lists.berlios.de/mailman/listinfo/yade-commits
>   


-- 
 
_______________
Chareyre Bruno
Maitre de conference

Institut National Polytechnique de Grenoble
Laboratoire 3S (Soils Solids Structures) - bureau E145
BP 53 - 38041, Grenoble cedex 9 - France
Tél : 33 4 56 52 86 21
Fax : 33 4 76 82 70 43
________________

_______________________________________________
yade-dev mailing list
yade-dev@xxxxxxxxxxxxxxxx
https://lists.berlios.de/mailman/listinfo/yade-dev

Follow ups