← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 4114: fix typos and indents; cut long lines in TriaxialStressController; bit more documentation of stre...

 

------------------------------------------------------------
revno: 4114
committer: Christian Jakob <jakob@xxxxxxxxxxxxxxxxxxx>
timestamp: Thu 2014-07-24 09:33:43 +0200
message:
  fix typos and indents; cut long lines in TriaxialStressController; bit more documentation of stressMask
modified:
  pkg/dem/TriaxialStressController.cpp
  pkg/dem/TriaxialStressController.hpp


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/dem/TriaxialStressController.cpp'
--- pkg/dem/TriaxialStressController.cpp	2013-07-16 09:57:52 +0000
+++ pkg/dem/TriaxialStressController.cpp	2014-07-24 07:33:43 +0000
@@ -31,8 +31,7 @@
 	);
 }
 
-void TriaxialStressController::updateStiffness ()
-{
+void TriaxialStressController::updateStiffness () {
 	for (int i=0; i<6; ++i) stiffness[i] = 0;
 	InteractionContainer::iterator ii    = scene->interactions->begin();
 	InteractionContainer::iterator iiEnd = scene->interactions->end();
@@ -53,42 +52,39 @@
 	}
 }
 
-void TriaxialStressController::controlExternalStress(int wall, Vector3r resultantForce, State* p, Real wall_max_vel)
-{
+void TriaxialStressController::controlExternalStress(int wall, Vector3r resultantForce, State* p, Real wall_max_vel) {
 	scene->forces.sync();
 	Real translation=normal[wall].dot(getForce(scene,wall_id[wall])-resultantForce);
 	const bool log=false;
 	if(log) LOG_DEBUG("wall="<<wall<<" actualForce="<<getForce(scene,wall_id[wall])<<", resultantForce="<<resultantForce<<", translation="<<translation);
-	if (translation!=0)
-	{
-	   if (stiffness[wall]!=0)
-	   {
+	if (translation!=0) {
+		if (stiffness[wall]!=0) {
 			translation /= stiffness[wall];
 			if(log) TRVAR2(translation,wall_max_vel*scene->dt)
 			translation = std::min( std::abs(translation), wall_max_vel*scene->dt ) * Mathr::Sign(translation);
-	   }
-	   else translation = wall_max_vel * Mathr::Sign(translation)*scene->dt;
+		}
+		else translation = wall_max_vel * Mathr::Sign(translation)*scene->dt;
 	}
 	previousTranslation[wall] = (1-stressDamping)*translation*normal[wall] + 0.8*previousTranslation[wall];// formula for "steady-flow" evolution with fluctuations
 	//Don't update position since Newton is doing that starting from bzr2612
-// 	p->se3.position += previousTranslation[wall];
+	//p->se3.position += previousTranslation[wall];
 	externalWork += previousTranslation[wall].dot(getForce(scene,wall_id[wall]));
-	// this is important is using VelocityBins. Otherwise the motion is never detected. Related to https://bugs.launchpad.net/yade/+bug/398089
+	//this is important is using VelocityBins. Otherwise the motion is never detected. Related to https://bugs.launchpad.net/yade/+bug/398089
 	p->vel=previousTranslation[wall]/scene->dt;
 	//if(log)TRVAR2(previousTranslation,p->se3.position);
 }
 
-void TriaxialStressController::action()
-{
+void TriaxialStressController::action() {
 	// sync thread storage of ForceContainer
 	scene->forces.sync();
 	if (first) {// sync boundaries ids in the table
 		wall_id[wall_bottom] = wall_bottom_id;
- 		wall_id[wall_top] = wall_top_id;
- 		wall_id[wall_left] = wall_left_id;
- 		wall_id[wall_right] = wall_right_id;
- 		wall_id[wall_front] = wall_front_id;
- 		wall_id[wall_back] = wall_back_id;}
+		wall_id[wall_top] = wall_top_id;
+		wall_id[wall_left] = wall_left_id;
+		wall_id[wall_right] = wall_right_id;
+		wall_id[wall_front] = wall_front_id;
+		wall_id[wall_back] = wall_back_id;
+	}
 
 	if(thickness<0) thickness=2.0*YADE_PTR_CAST<Box>(Body::byId(wall_bottom_id,scene)->shape)->extents.y();
 	State* p_bottom=Body::byId(wall_bottom_id,scene)->state.get();
@@ -106,8 +102,7 @@
 		BodyContainer::iterator bi = scene->bodies->begin();
 		BodyContainer::iterator biEnd = scene->bodies->end();
 		spheresVolume = 0;
-		for ( ; bi!=biEnd; ++bi )
-		{
+		for ( ; bi!=biEnd; ++bi ) {
 			if((*bi)->isClump()) continue;
 			const shared_ptr<Body>& b = *bi;
 			if ( b->isDynamic() || b->isClumpMember() ) {
@@ -134,9 +129,7 @@
 	if (scene->iter % stiffnessUpdateInterval == 0 || scene->iter<100) updateStiffness();
 	bool isARadiusControlIteration = (scene->iter % radiusControlInterval == 0);
 
-	if (scene->iter % computeStressStrainInterval == 0 ||
-		 (internalCompaction && isARadiusControlIteration) )
-		computeStressStrain();
+	if (scene->iter % computeStressStrainInterval == 0 || (internalCompaction && isARadiusControlIteration) ) computeStressStrain();
 
 	if (!internalCompaction) {
 		Vector3r wallForce (0, goal2*width*depth, 0);
@@ -169,8 +162,7 @@
 			else p_front->vel[2] += (-normal[wall_front][2]*0.5*goal3*depth -p_front->vel[2])*(1-strainDamping);
 		} else p_front->vel=Vector3r::Zero();
 	}
-	else //if internal compaction
-	{
+	else { //if internal compaction
 		p_bottom->vel=Vector3r::Zero(); p_top->vel=Vector3r::Zero(); p_left->vel=Vector3r::Zero(); p_right->vel=Vector3r::Zero(); p_back->vel=Vector3r::Zero(); p_front->vel=Vector3r::Zero();
 		if (isARadiusControlIteration) {
 			Real sigma_iso_ = bool(stressMask & 1)*goal1 +  bool(stressMask & 2)*goal2 +  bool(stressMask & 4)*goal3;
@@ -189,8 +181,7 @@
 	}
 }
 
-void TriaxialStressController::computeStressStrain()
-{
+void TriaxialStressController::computeStressStrain() {
 	scene->forces.sync();
 	State* p_bottom=Body::byId(wall_bottom_id,scene)->state.get();
 	State* p_top=Body::byId(wall_top_id,scene)->state.get();
@@ -199,9 +190,9 @@
 	State* p_front=Body::byId(wall_front_id,scene)->state.get();
 	State* p_back=Body::byId(wall_back_id,scene)->state.get();
 
- 	height = p_top->se3.position.y() - p_bottom->se3.position.y() - thickness;
- 	width = p_right->se3.position.x() - p_left->se3.position.x() - thickness;
- 	depth = p_front->se3.position.z() - p_back->se3.position.z() - thickness;
+	height = p_top->se3.position.y() - p_bottom->se3.position.y() - thickness;
+	width = p_right->se3.position.x() - p_left->se3.position.x() - thickness;
+	depth = p_front->se3.position.z() - p_back->se3.position.z() - thickness;
 
 	meanStress = 0;
 	if (height0 == 0) height0 = height;
@@ -216,36 +207,31 @@
 	Real invYSurface = 1.f/(width*depth);
 	Real invZSurface = 1.f/(width*height);
 
- 	force[wall_bottom]=getForce(scene,wall_id[wall_bottom]); stress[wall_bottom]=force[wall_bottom]*invYSurface;
+	force[wall_bottom]=getForce(scene,wall_id[wall_bottom]); stress[wall_bottom]=force[wall_bottom]*invYSurface;
 	force[wall_top]=   getForce(scene,wall_id[wall_top]);    stress[wall_top]=force[wall_top]*invYSurface;
 	force[wall_left]=  getForce(scene,wall_id[wall_left]);   stress[wall_left]=force[wall_left]*invXSurface;
 	force[wall_right]= getForce(scene,wall_id[wall_right]);  stress[wall_right]= force[wall_right]*invXSurface;
 	force[wall_front]= getForce(scene,wall_id[wall_front]);  stress[wall_front]=force[wall_front]*invZSurface;
-        force[wall_back]=  getForce(scene,wall_id[wall_back]);   stress[wall_back]= force[wall_back]*invZSurface;
+	force[wall_back]=  getForce(scene,wall_id[wall_back]);   stress[wall_back]= force[wall_back]*invZSurface;
 
 	for (int i=0; i<6; i++) meanStress-=stress[i].dot(normal[i]);
 	meanStress/=6.;
 }
 
-void TriaxialStressController::controlInternalStress ( Real multiplier )
-{
+void TriaxialStressController::controlInternalStress ( Real multiplier ) {
 	spheresVolume *= pow ( multiplier,3 );
 	BodyContainer::iterator bi    = scene->bodies->begin();
 	BodyContainer::iterator biEnd = scene->bodies->end();
-	for ( ; bi!=biEnd ; ++bi )
-	{
-		if ( ( *bi )->isDynamic() )
-		{
+	for ( ; bi!=biEnd ; ++bi ) {
+		if ( ( *bi )->isDynamic() ) {
 			( static_cast<Sphere*> ( ( *bi )->shape.get() ) )->radius *= multiplier;
-				(*bi)->state->mass*=pow(multiplier,3);
-				(*bi)->state->inertia*=pow(multiplier,5);
-
+			(*bi)->state->mass*=pow(multiplier,3);
+			(*bi)->state->inertia*=pow(multiplier,5);
 		}
 	}
 	InteractionContainer::iterator ii    = scene->interactions->begin();
 	InteractionContainer::iterator iiEnd = scene->interactions->end();
-	for (; ii!=iiEnd ; ++ii)
-	{
+	for (; ii!=iiEnd ; ++ii) {
 		if ((*ii)->isReal()) {
 			ScGeom* contact = static_cast<ScGeom*>((*ii)->geom.get());
 			if ((*(scene->bodies))[(*ii)->getId1()]->isDynamic())
@@ -262,5 +248,3 @@
     \fn TriaxialStressController::ComputeUnbalancedForce( bool maxUnbalanced)
  */
 Real TriaxialStressController::ComputeUnbalancedForce( bool maxUnbalanced) {return Shop::unbalancedForce(maxUnbalanced,scene);}
-
-

=== modified file 'pkg/dem/TriaxialStressController.hpp'
--- pkg/dem/TriaxialStressController.hpp	2014-05-23 13:05:19 +0000
+++ pkg/dem/TriaxialStressController.hpp	2014-07-24 07:33:43 +0000
@@ -18,11 +18,12 @@
 class State;
 
 
-/*! \brief Controls the stress on the boundaries of a box and compute strain-like and stress-like quantities for the packing. The algorithms used have been developed initialy for simulations reported in [Chareyre2002a] and [Chareyre2005]. They have been ported to Yade in a second step and used in e.g. [Kozicki2008],[Scholtes2009b],[Jerier2010b].
+/*! \brief Controls the stress on the boundaries of a box and compute strain-like and stress-like quantities for the packing.
+           The algorithms used have been developed initialy for simulations reported in [Chareyre2002a] and [Chareyre2005].
+           They have been ported to Yade in a second step and used in e.g. [Kozicki2008],[Scholtes2009b],[Jerier2010b].
 */
 
-class TriaxialStressController : public BoundaryController
-{
+class TriaxialStressController : public BoundaryController {
 	private :
 		bool first;
 		inline const Vector3r getForce(Scene* rb, Body::id_t id){ return rb->forces.getForce(id); /* needs sync, which is done at the beginning of action */ }
@@ -69,20 +70,24 @@
 		//! Compute stresses on walls as "Vector3r stress[6]", compute meanStress, strain[3] and mean strain
 		void computeStressStrain();
 		//! Compute the mean/max unbalanced force in the assembly (normalized by mean contact force)
-    		Real ComputeUnbalancedForce(bool maxUnbalanced=false);
+		Real ComputeUnbalancedForce(bool maxUnbalanced=false);
 		///! Getter for stress and rates in python
 		Vector3r getStress(int boundId);
 		Vector3r getStrainRate();
 
 		YADE_CLASS_BASE_DOC_ATTRS_DEPREC_INIT_CTOR_PY(TriaxialStressController,BoundaryController,
-		"An engine maintaining constant stresses or constant strain rates on some boundaries of a parallepipedic packing. The stress/strain control is defined for each axis using :yref:`TriaxialStressController::stressMask` (a bitMask) and target values are defined by goal1,goal2, and goal3. sigmaIso has to be defined during growing phases."
-		"\n\n.. note::\n\t The algorithms used have been developed initialy for simulations reported in [Chareyre2002a]_ and [Chareyre2005]_. They have been ported to Yade in a second step and used in e.g. [Kozicki2008]_,[Scholtes2009b]_,[Jerier2010b]."
+		"An engine maintaining constant stresses or constant strain rates on some boundaries of a parallepipedic packing. \
+		The stress/strain control is defined for each axis using :yref:`TriaxialStressController::stressMask` (a bitMask) \
+		and target values are defined by goal1,goal2, and goal3. sigmaIso has to be defined during growing phases."
+		"\n\n.. note::\n\t The algorithms used have been developed initialy for simulations reported in [Chareyre2002a]_ and [Chareyre2005]_. \
+		They have been ported to Yade in a second step and used in e.g. [Kozicki2008]_,[Scholtes2009b]_,[Jerier2010b]."
 		,
-   		((unsigned int,stiffnessUpdateInterval,10,,"target strain rate (./s)"))
-   		((unsigned int,radiusControlInterval,10,,""))
+		((unsigned int,stiffnessUpdateInterval,10,,"target strain rate (./s)"))
+		((unsigned int,radiusControlInterval,10,,""))
 		((unsigned int,computeStressStrainInterval,10,,""))
 		((Real,stressDamping,0.25,,"wall damping coefficient for the stress control - wallDamping=0 implies a (theoretical) perfect control, wallDamping=1 means no movement"))
-		((Real,strainDamping,0.99,,"coefficient used for smoother transitions in the strain rate. The rate reaches the target value like $d^n$ reaches 0, where $d$ is the damping coefficient and $n$ is the number of steps"))
+		((Real,strainDamping,0.99,,"coefficient used for smoother transitions in the strain rate. \
+		The rate reaches the target value like $d^n$ reaches 0, where $d$ is the damping coefficient and $n$ is the number of steps"))
 		((Real,thickness,-1,,"thickness of boxes (needed by some functions)"))
 		((int,wall_bottom_id,2,,"id of boundary ; coordinate 1- (default value is ok if aabbWalls are appended BEFORE spheres.)"))
 		((int,wall_top_id,3,,"id of boundary ; coordinate 1+ (default value is ok if aabbWalls are appended BEFORE spheres.)"))
@@ -106,10 +111,14 @@
 		((Real,goal1,0,,"prescribed stress/strain rate on axis 1, as defined by :yref:`TriaxialStressController::stressMask` (see also :yref:`TriaxialStressController::isAxisymetric`)"))
 		((Real,goal2,0,,"prescribed stress/strain rate on axis 2, as defined by :yref:`TriaxialStressController::stressMask` (see also :yref:`TriaxialStressController::isAxisymetric`)"))
 		((Real,goal3,0,,"prescribed stress/strain rate on axis 3, as defined by :yref:`TriaxialStressController::stressMask` (see also :yref:`TriaxialStressController::isAxisymetric`)"))
-		((unsigned int,stressMask,7,,"Bitmask determining if the components of :yref:`TriaxialStressController::goal` are stress (1) or strain (0). 0 for none, 7 for all, 1 for sigma1, etc."))
+		((unsigned int,stressMask,7,,"Bitmask determining if the components of :yref:`TriaxialStressController::goal` are stress (1) or strain (0). \
+		0 for none ($0*2^0 + 0*2^1 + 0*2^2 = 0$), 7 for all ($1*2^0 + 1*2^1 + 1*2^2$ = 7), 1 for sigma1 ($1*2^0 + 0*2^1 + 0*2^2$ = 1), etc."))
 		((Real,maxMultiplier,1.001,,"max multiplier of diameters during internal compaction (initial fast increase - :yref:`TriaxialStressController::finalMaxMultiplier` is used in a second stage)"))
 		((Real,finalMaxMultiplier,1.00001,,"max multiplier of diameters during internal compaction (secondary precise adjustment - :yref:`TriaxialStressController::maxMultiplier` is used in the initial stage)"))
-		((Real,max_vel,1,,"Maximum allowed walls velocity [m/s]. This value superseeds the one assigned by the stress controller if the later is higher. max_vel can be set to infinity in many cases, but sometimes helps stabilizing packings. Based on this value, different maxima are computed for each axis based on the dimensions of the sample, so that if each boundary moves at its maximum velocity, the strain rate will be isotropic (see e.g. :yref:`TriaxialStressController::max_vel1`)."))
+		((Real,max_vel,1,,"Maximum allowed walls velocity [m/s]. This value superseeds the one assigned by the stress controller \
+		if the later is higher. max_vel can be set to infinity in many cases, but sometimes helps stabilizing packings. \
+		Based on this value, different maxima are computed for each axis based on the dimensions of the sample, so that if \
+		each boundary moves at its maximum velocity, the strain rate will be isotropic (see e.g. :yref:`TriaxialStressController::max_vel1`)."))
 		((Real,previousStress,0,Attr::readonly,"|yupdate|"))
 		((Real,previousMultiplier,1,Attr::readonly,"|yupdate|"))
 		((bool,internalCompaction,true,,"Switch between 'external' (walls) and 'internal' (growth of particles) compaction."))
@@ -125,8 +134,8 @@
 		,
 		/* extra initializers */
 		,
-   		/* constructor */
-   		first = true;
+		/* constructor */
+		first = true;
 		stiffness.resize(6);
 		previousTranslation.assign(Vector3r::Zero());
 		for (int i=0; i<6; ++i){normal[i]=stress[i]=force[i]=Vector3r::Zero();stiffness[i]=0;}
@@ -140,9 +149,9 @@
 		,
 		.def_readonly("strain",&TriaxialStressController::strain,"Current strain in a vector (exx,eyy,ezz). The values reflect true (logarithmic) strain.")
 		.def_readonly("strainRate",&TriaxialStressController::getStrainRate,"Current strain rate in a vector d/dt(exx,eyy,ezz).")
- 		.def_readonly("porosity",&TriaxialStressController::porosity,"Porosity of the packing.")
+		.def_readonly("porosity",&TriaxialStressController::porosity,"Porosity of the packing.")
 		.def_readonly("boxVolume",&TriaxialStressController::boxVolume,"Total packing volume.")
-		.def_readonly("spheresVolume",&TriaxialStressController::spheresVolume,"Total volume pf spheres.")
+		.def_readonly("spheresVolume",&TriaxialStressController::spheresVolume,"Total volume of spheres.")
 		.def_readonly("max_vel1",&TriaxialStressController::max_vel1,"see :yref:`TriaxialStressController::max_vel` |ycomp|")
 		.def_readonly("max_vel2",&TriaxialStressController::max_vel2,"see :yref:`TriaxialStressController::max_vel` |ycomp|")
 		.def_readonly("max_vel3",&TriaxialStressController::max_vel3,"see :yref:`TriaxialStressController::max_vel` |ycomp|")


Follow ups