← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2151: - More registering!

 

------------------------------------------------------------
revno: 2151
committer: Bruno Chareyre <bchareyre@r1arduina>
branch nick: trunk
timestamp: Sun 2010-04-18 19:40:36 +0200
message:
  - More registering!
modified:
  pkg/common/Engine/GlobalEngine/PersistentTriangulationCollider.cpp
  pkg/common/Engine/GlobalEngine/PersistentTriangulationCollider.hpp
  pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.cpp
  pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.hpp
  pkg/dem/Engine/GlobalEngine/TesselationWrapper.cpp
  pkg/dem/Engine/GlobalEngine/TesselationWrapper.hpp


--
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/Engine/GlobalEngine/PersistentTriangulationCollider.cpp'
--- pkg/common/Engine/GlobalEngine/PersistentTriangulationCollider.cpp	2010-03-21 15:25:50 +0000
+++ pkg/common/Engine/GlobalEngine/PersistentTriangulationCollider.cpp	2010-04-18 17:40:36 +0000
@@ -4,7 +4,6 @@
 *  This program is free software; it is licensed under the terms of the  *
 *  GNU General Public License v2 or later. See file LICENSE for details. *
 *************************************************************************/
-#include<yade/pkg-dem/TesselationWrapper.hpp>
 #include"PersistentTriangulationCollider.hpp"
 #include<yade/core/Body.hpp>
 #include<yade/core/Scene.hpp>
@@ -19,20 +18,19 @@
 YADE_REQUIRE_FEATURE(CGAL)
 using namespace std;
 		
-PersistentTriangulationCollider::PersistentTriangulationCollider() : Collider()
-{
-	noTransientIfPersistentExists=false;
-	haveDistantTransient=false;
-	isTriangulated = false;
-	Tes = new ( TesselationWrapper );
-
-	nbObjects=0;
-	xBounds.clear();
-	yBounds.clear();
-	zBounds.clear();
-	minima.clear();
-	maxima.clear();
-}
+// PersistentTriangulationCollider::PersistentTriangulationCollider() : Collider()
+// {
+// 	haveDistantTransient=false;
+// 	isTriangulated = false;
+// 	Tes = new ( TesselationWrapper );
+// 
+// 	nbObjects=0;
+// 	xBounds.clear();
+// 	yBounds.clear();
+// 	zBounds.clear();
+// 	minima.clear();
+// 	maxima.clear();
+// }
 
 
 PersistentTriangulationCollider::~PersistentTriangulationCollider()
@@ -130,7 +128,7 @@
 		I_end = interactions->end();
 		for ( InteractionContainer::iterator I=interactions->begin(); I!=I_end; ++I )
 		{
-			if ( ( ! ( *I )->isNeighbor ) && ( haveDistantTransient ? ! ( *I )->isReal() : true ) )
+			if (!(*I)->isNeighbor && !(haveDistantTransient && ( *I )->isReal()))//FIXME : isReal correct to check that the interaction has not been "requestErased"?
 			{
 				toErase.push_back ( pair<unsigned int,unsigned int> ( ( *I )->getId1() , ( *I )->getId2() ) );
 				//cerr << "to delete " << ( *I )->getId1() << "-" << ( *I )->getId2() << "(isNeighbor=" << ( *I )->isNeighbor<< endl;
@@ -145,7 +143,6 @@
 			//cerr << "deleted " << it->first << "-" << it->second<<endl;
 		}
 	}
-
 }
 
 YADE_PLUGIN((PersistentTriangulationCollider));

=== modified file 'pkg/common/Engine/GlobalEngine/PersistentTriangulationCollider.hpp'
--- pkg/common/Engine/GlobalEngine/PersistentTriangulationCollider.hpp	2010-03-21 15:25:50 +0000
+++ pkg/common/Engine/GlobalEngine/PersistentTriangulationCollider.hpp	2010-04-18 17:40:36 +0000
@@ -13,6 +13,7 @@
 #include <set>
 #include <vector>
 #include <algorithm>
+#include<yade/pkg-dem/TesselationWrapper.hpp>
 
 /*! \brief Collision detection engine based on regular triangulation.
  
@@ -27,93 +28,24 @@
 
 class PersistentTriangulationCollider : public Collider
 {
-	private :
-	
+	private :	
 		TesselationWrapper* Tes;	
-		// represent an extrmity of an Axis ALigned bounding box
-		struct AABBBound
-		{
-			AABBBound(int i, char l) : id(i),lower(l) {};
-			int		id;		// Aabb of the "id" shpere
-			char		lower;		// is it the lower or upper bound of the Aabb
-			Real		value;		// value of the bound
-		};
-		// strucuture that compare 2 AABBBounds => used in the sort algorithm
-		struct AABBBoundComparator
-		{
-			bool operator() (shared_ptr<AABBBound> b1, shared_ptr<AABBBound> b2)
-			{
-				return b1->value<b2->value;
-			}
-		};
-
-	protected :
-		/// number of potential interactions = number of interacting Aabb
-		int nbPotentialInteractions;
-
-		/// number of Aabb
-		unsigned int nbObjects;
-
-		/// Aabb extremity of the sphere number "id" projected onto the X axis
-		std::vector<shared_ptr<AABBBound> > xBounds;
-
-		/// Aabb extremity of the sphere number "id" projected onto the Y axis
-		std::vector<shared_ptr<AABBBound> > yBounds;
-
-		/// Aabb extremity of the sphere number "id" projected onto the Z axis
-		std::vector<shared_ptr<AABBBound> > zBounds;
-
-		// collection of Aabb that are in interaction
-		//protected : vector< set<unsigned int> > overlappingBB;
-		shared_ptr<InteractionContainer> interactions;
-		/// upper right corner of the Aabb of the objects =>  for spheres = center[i]-radius
-		std::vector<Real> maxima;
-
-		/// lower left corner of the Aabb of the objects =>  for spheres = center[i]+radius
-		std::vector<Real> minima;
-
-		/// Used the first time broadInteractionTest is called, to initialize and sort the xBounds, yBounds,
-		/// and zBounds arrays and to initialize the overlappingBB collection
-		void updateIds(unsigned int nbElements);
-
-		/// Permutation sort the xBounds, yBounds, zBounds arrays according to the "value" field
-		/// Calls updateOverlapingBBSet every time a permutation between 2 Aabb i and j occurs
-		void sortBounds(vector<shared_ptr<AABBBound> >& bounds, int nbElements);
-
-		/// Tests if the AABBi and AABBj really overlap.
-		/// If yes, adds the pair (id1,id2) to the collection of overlapping AABBs
-		/// If no, removes the (id1,id2) to the collection of overlapping AABBs if necessary
-		void updateOverlapingBBSet(int id1,int id2);
-
-		/// update the "value" field of the xBounds, yBounds, zBounds arrays
-		void updateBounds(int nbElements);
-
-		/// Used the first time broadInteractionTest is called
-		/// It is necessary to initialise the overlapping Aabb collection because this collection is only
-		/// incrementally udated each time step
-		void findOverlappingBB(vector<shared_ptr<AABBBound> >& bounds, int nbElements);
-
-	public :
-		PersistentTriangulationCollider();
-
+
+	public :		
 		virtual ~PersistentTriangulationCollider();
-
-		/// return a list "interactions" of pairs of Body which Bounding volume are in potential interaction
+		/// return a list "interactions" of pairs of Body which bounding spheres are overlapping
 		void action();
-
-		//! When creating transient interaction, look first if a persistent link between the pair in question exists; in that case, skip it.
-		bool noTransientIfPersistentExists;
-		//! Don't break transient interaction once bodies don't overlap anymore; material law will be responsible for breaking it.
-		bool haveDistantTransient;
 		//! this flag is used to check if the packing has been triangulated
 		bool isTriangulated;
-
-	REGISTER_ATTRIBUTES(Collider,(noTransientIfPersistentExists)(haveDistantTransient));
-	REGISTER_CLASS_NAME(PersistentTriangulationCollider);
-	REGISTER_BASE_CLASS_NAME(Collider);
-
+		shared_ptr<InteractionContainer> interactions;
+		
+	YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(
+		PersistentTriangulationCollider,Collider,"Collision detection engine based on regular triangulation. Handles spheres and flat boundaries (considered as infinite-sized bounding spheres).",
+		((bool,haveDistantTransient,false,"Keep distant interactions? If True, don't delete interactions once bodies don't overlap anymore; constitutive laws will be responsible for requesting deletion. If False, delete as soon as there is no object penetration."))
+		,
+		isTriangulated = false;
+		Tes = new (TesselationWrapper);
+  	,);
 };
 
 REGISTER_SERIALIZABLE(PersistentTriangulationCollider);
-
-

=== modified file 'pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.cpp'
--- pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.cpp	2010-03-20 12:40:44 +0000
+++ pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.cpp	2010-04-18 17:40:36 +0000
@@ -13,34 +13,20 @@
 #include<yade/core/Omega.hpp>
 #include<yade/core/Scene.hpp>
 #include <yade/pkg-common/Sphere.hpp>
-#include "MicroMacroAnalyser.hpp"
 #include<yade/lib-triangulation/KinematicLocalisationAnalyser.hpp>
 #include<yade/lib-triangulation/TriaxialState.h>
 #include <yade/lib-triangulation/Tenseur3.h>
 #include<boost/iostreams/filtering_stream.hpp>
 #include<boost/iostreams/filter/bzip2.hpp>
 #include<boost/iostreams/device/file.hpp>
+#include<yade/pkg-dem/TriaxialCompressionEngine.hpp>
+#include "MicroMacroAnalyser.hpp"
 
 YADE_PLUGIN((MicroMacroAnalyser));
 YADE_REQUIRE_FEATURE(CGAL)
 CREATE_LOGGER(MicroMacroAnalyser);
 
-MicroMacroAnalyser::MicroMacroAnalyser() : GlobalEngine()
-{
-	analyser = shared_ptr<CGT::KinematicLocalisationAnalyser> (new CGT::KinematicLocalisationAnalyser);
-	analyser->SetConsecutive(true);
-	analyser->SetNO_ZERO_ID(false);
-	interval = 100;
-	outputFile = "MicroMacroAnalysis";
-	stateFileName = "state";
-	initialized = false;
-	incrtNumber=1;
-	stateNumber=0;
-	compDeformation=false;
-	compIncrt=false;
-}
-
-//MicroMacroAnalyser::~MicroMacroAnalyser(){ delete analyser;}
+MicroMacroAnalyser::~MicroMacroAnalyser(){ /*delete analyser;*/} //no need, its a shared_ptr now...
 
 void MicroMacroAnalyser::postProcessAttributes(bool deserializing)
 {

=== modified file 'pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.hpp'
--- pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.hpp	2010-03-20 12:40:44 +0000
+++ pkg/dem/Engine/GlobalEngine/MicroMacroAnalyser.hpp	2010-04-18 17:40:36 +0000
@@ -9,7 +9,6 @@
 #pragma once
 
 #include<yade/core/GlobalEngine.hpp>
-#include<yade/pkg-dem/TriaxialCompressionEngine.hpp>
 #include<yade/lib-triangulation/KinematicLocalisationAnalyser.hpp>
 #include <set>
 #include <boost/tuple/tuple.hpp>
@@ -24,43 +23,45 @@
 class TriaxialState;
 class Tenseur3;
 }
+class TriaxialCompressionEngine;
 
 class MicroMacroAnalyser : public GlobalEngine
 {
 /// Attributes
 	private :
-		std::ofstream ofile;		
+		std::ofstream ofile;
 		shared_ptr<TriaxialCompressionEngine> triaxialCompressionEngine;
 		bool initialized;
-		/// A number apended at the end of deformation output files 
-		unsigned int stateNumber;
-		unsigned int incrtNumber;
 		
 	public :
-		std::string	 outputFile;
-		std::string	 stateFileName;
-		
-		MicroMacroAnalyser();
+		~MicroMacroAnalyser();
 		void action();
 		/// Set current state as initial (state=1) or final (state=2) congiguration for later kinematic analysis on the increment; if requested : save snapshots (with specific format) - possibly including contact forces increments on the state1->state2 interval
 		void setState(unsigned int state, bool save_states = false, bool computeIncrement = false);
 		/// Copy the current simulation in a TriaxialState structure. If filename!=NULL, save it to a file that can be reloaded later for computing strain increments, state must be 1 or 2.
 		CGT::TriaxialState& makeState(unsigned int state, const char* filename = NULL);
 		//const vector<CGT::Tenseur3>& makeDeformationArray(const char* state_file1, const char* state_file0);
-		int interval;
-		/// Is the engine just saving states or also computing and outputing deformations for each increment?
-		bool compDeformation;
-		/// Should increments of force and displacements be defined on [n,n+1]? If not, states will be saved with only positions and forces
-		bool compIncrt;
 		shared_ptr<CGT::KinematicLocalisationAnalyser> analyser;
-		
-	DECLARE_LOGGER;
-	
-	protected :
 		virtual void postProcessAttributes(bool deserializing);
-		REGISTER_ATTRIBUTES(GlobalEngine,(stateNumber)(incrtNumber)(outputFile)(stateFileName)(interval)(compDeformation)(compIncrt));
-	REGISTER_CLASS_NAME(MicroMacroAnalyser);
-	REGISTER_BASE_CLASS_NAME(GlobalEngine);
+		
+		YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(MicroMacroAnalyser,GlobalEngine,"Compute fabric tensor, local porosity, local deformation, and other micromechanicaly defined quantities based on triangulation/tesselation of the packing.",
+		((unsigned int,stateNumber,0,"A number incremented and appended at the end of output files to reflect increment number."))
+		((unsigned int,incrtNumber,1,""))
+		((std::string,outputFile,"MicroMacroAnalysis","Base name for increment analysis output file."))
+		((std::string,stateFileName,"state","Base name of state files."))
+		((int,interval,100,"Number of timesteps between analyzed states."))
+		((bool,compDeformation,false,"Is the engine just saving states or also computing and outputing deformations for each increment?"))
+		((bool,compIncrt,false,"Should increments of force and displacements be defined on [n,n+1]? If not, states will be saved with only positions and forces (no displacements)."))
+		,/*init*/
+  		,/*ctor*/
+		analyser = shared_ptr<CGT::KinematicLocalisationAnalyser> (new CGT::KinematicLocalisationAnalyser);
+		analyser->SetConsecutive(true);
+		analyser->SetNO_ZERO_ID(false);
+		initialized = false;
+		,/*py*/
+		);
+		DECLARE_LOGGER;
+		//REGISTER_ATTRIBUTES(GlobalEngine,(stateNumber)(incrtNumber)(outputFile)(stateFileName)(interval)(compDeformation)(compIncrt));
 };
 
 REGISTER_SERIALIZABLE(MicroMacroAnalyser);

=== modified file 'pkg/dem/Engine/GlobalEngine/TesselationWrapper.cpp'
--- pkg/dem/Engine/GlobalEngine/TesselationWrapper.cpp	2010-02-18 22:47:05 +0000
+++ pkg/dem/Engine/GlobalEngine/TesselationWrapper.cpp	2010-04-18 17:40:36 +0000
@@ -126,15 +126,7 @@
 //  Finite_edges_iterator facet_it; //an edge in a triangulation is a facet in corresponding tesselation, remember...
 //That explain the name.
 
-TesselationWrapper::TesselationWrapper()
-{
-	Tes = new CGT::Tesselation;
-	inf = 1e10;
-	clear();
-	facet_begin = Tes->Triangulation().finite_edges_begin();
-	facet_end = Tes->Triangulation().finite_edges_end();
-	facet_it = Tes->Triangulation().finite_edges_begin();
-}
+
 
 TesselationWrapper::~TesselationWrapper() { delete Tes;}
 

=== modified file 'pkg/dem/Engine/GlobalEngine/TesselationWrapper.hpp'
--- pkg/dem/Engine/GlobalEngine/TesselationWrapper.hpp	2010-02-02 09:59:57 +0000
+++ pkg/dem/Engine/GlobalEngine/TesselationWrapper.hpp	2010-04-18 17:40:36 +0000
@@ -13,8 +13,8 @@
 #include<yade/core/Scene.hpp>
 #include<yade/lib-triangulation/Tesselation.h>
 #include<boost/python.hpp>
+#include<yade/extra/boost_python_len.hpp>
 #include<yade/pkg-dem/MicroMacroAnalyser.hpp>
-#include<yade/extra/boost_python_len.hpp>
 
 /*! \class TesselationWrapper
  * \brief Handle the triangulation of spheres in a scene, build tesselation on request, and give access to computed quantities : currently volume and porosity of each Voronoï sphere.
@@ -33,14 +33,12 @@
 public:
 
 	CGT::Tesselation* Tes;
-	double mean_radius;
-	unsigned int n_spheres;
+	double mean_radius, inf;
 	bool rad_divided;
 	bool bounded;
 	CGT::Point Pmin;
 	CGT::Point Pmax;
-
-	TesselationWrapper();
+	
 	~TesselationWrapper();
     
     	/// Insert a sphere, "id" will be used by some getters to retrieve spheres
@@ -98,16 +96,23 @@
 // 	}
 
 	
-private:
+public:
 	/// edge iterators are used for returning tesselation "facets", i.e. spheres with a common branch in the triangulation, convert CGAL::edge to int pair (b1->id, b2->id)
 	CGT::Finite_edges_iterator facet_begin;
 	CGT::Finite_edges_iterator facet_end;
 	CGT::Finite_edges_iterator facet_it;
 	MicroMacroAnalyser mma;
-public:	
-	REGISTER_ATTRIBUTES(GlobalEngine,(n_spheres));
-	REGISTER_CLASS_NAME(TesselationWrapper);
-	REGISTER_BASE_CLASS_NAME(GlobalEngine);
+	
+	YADE_CLASS_BASE_DOC_ATTRS_CTOR_PY(TesselationWrapper,GlobalEngine,"Handle the triangulation of spheres in a scene, build tesselation on request, and give access to computed quantities : currently volume and porosity of each Voronoï sphere.",
+	((unsigned int,n_spheres,0,"|ycomp|"))
+	,/*ctor*/
+  	Tes = new CGT::Tesselation;
+	clear();
+	facet_begin = Tes->Triangulation().finite_edges_begin();
+	facet_end = Tes->Triangulation().finite_edges_end();
+	facet_it = Tes->Triangulation().finite_edges_begin();
+	,/*py*/
+	);	
 	DECLARE_LOGGER;
 };
 REGISTER_SERIALIZABLE(TesselationWrapper);