← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2694: - make Cell.size read/write for faster hSize setting.

 

------------------------------------------------------------
revno: 2694
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
branch nick: yade
timestamp: Sun 2011-01-30 19:03:29 +0100
message:
  - make Cell.size read/write for faster hSize setting.
  - improve and simplify documentation (the older method is no longer documented)
modified:
  core/Cell.hpp
  doc/sphinx/formulation.rst


--
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/Cell.hpp'
--- core/Cell.hpp	2011-01-30 15:43:18 +0000
+++ core/Cell.hpp	2011-01-30 18:03:29 +0000
@@ -19,8 +19,10 @@
 
 class Cell: public Serializable{
 	public:
-	//! Get current size (refSize × normal strain)
+	//! Get current size
 	const Vector3r& getSize() const { return _size; }
+	
+	void setSize(const Vector3r& s){for (int k=0;k<3;k++) hSize.col(k)*=s[k]/hSize.col(k).norm(); postLoad(*this);}
 	//! Return copy of the current size (used only by the python wrapper)
 	Vector3r getSize_copy() const { return _size; }
 	//! return vector of consines of skew angle in yz, xz, xy planes between respective transformed base vectors
@@ -91,9 +93,12 @@
 	// return body velocity while taking away mean field velocity (coming from velGrad) if the mean field velocity is applied on velocity
 	Vector3r bodyFluctuationVel(const Vector3r& pos, const Vector3r& vel) const { if(homoDeform==HOMO_VEL || homoDeform==HOMO_VEL_2ND) return (vel-velGrad*pos); return vel; }
 
+
+	
+
 	// get/set mechanically undeformed shape; setting resets trsf to identity
 	Matrix3r getHSize() const { return hSize; }
-	void setHSize(const Matrix3r& m){ hSize=refHSize=m; trsf=Matrix3r::Identity(); postLoad(*this); }
+	void setHSize(const Matrix3r& m){ hSize=refHSize=m; trsf=Matrix3r::Identity(); postLoad(*this); }	
 	// set current transformation; has no influence on current configuration (hSize); sets display refHSize as side-effect
 	Matrix3r getTrsf() const { return trsf; }
 	void setTrsf(const Matrix3r& m){ refHSize=hSize; trsf=m; postLoad(*this); }
@@ -139,8 +144,8 @@
 		.add_property("refSize",&Cell::getRefSize,&Cell::setRefSize,"Reference size of the cell (lengths of initial cell vectors, i.e. column norms of :yref:`hSize<Cell.hSize>`).\n\n.. note:: Modifying this value is deprecated, use :yref:`setBox<Cell.setBox>` instead.\n\n")
 		.add_property("trsf",&Cell::getTrsf,&Cell::setTrsf,"Current transformation matrix of the cell with regards to the initial configuration.")
 		// useful properties
-		.add_property("hSize0",&Cell::getHSize0,"Value of untransformed hSize, with respect to current :yref:`trsf<Cell.trsf>` (computed as :yref:`trsf<Cell.trsf>`⁻¹ × :yref:`hSize<Cell.hSize>`.")
-		.def_readonly("size",&Cell::getSize_copy,"Current size of the cell, i.e. lengths of the 3 cell lateral vectors contained in :yref:`Cell.hSize` columns. Updated automatically at every step.")
+		.add_property("hSize0",&Cell::getHSize0,"Value of untransformed hSize, with respect to current :yref:`trsf<Cell.trsf>` (computed as :yref:`invTrsf<Cell.invTrsf>` × :yref:`hSize<Cell.hSize>`.")
+		.add_property("size",&Cell::getSize_copy,&Cell::setSize,"Current size of the cell, i.e. lengths of the 3 cell lateral vectors contained in :yref:`Cell.hSize` columns. Updated automatically at every step.")
 		.add_property("volume",&Cell::getVolume,"Current volume of the cell.")
 		// functions
 		.def("setBox",&Cell::setBox,"Set :yref:`Cell` shape to be rectangular, with dimensions along axes specified by given argument. Shorthand for assigning diagonal matrix with respective entries to :yref:`hSize<Cell.hSize>`.")

=== modified file 'doc/sphinx/formulation.rst'
--- doc/sphinx/formulation.rst	2011-01-21 19:55:58 +0000
+++ doc/sphinx/formulation.rst	2011-01-30 18:03:29 +0000
@@ -837,25 +837,18 @@
 ============================
 While most DEM simulations happen in $R^3$ space, it is frequently useful to avoid boundary effects by using periodic space instead. In order to satisfy periodicity conditions, periodic space is created by repetition of parallelepiped-shaped cell. In Yade, periodic space is implemented in the :yref:`Cell` class. The geometry of the cell in the reference coordinates system is defined by three edges of the parallepiped. The corresponding base vectors are stored in the columns of matrix :yref:`Cell.hSize`.
 
-The initial :yref:`Cell.hSize` can be explicitely defined as a 3x3 matrix at the begining of the simulation. There are no restricitions on the possible shapes: any parallelepiped is accepted as the initial undeformed period.
+The initial :yref:`Cell.hSize` can be explicitely defined as a 3x3 matrix at the begining of the simulation. There are no restricitions on the possible shapes: any parallelepiped is accepted as the initial undeformed period. If the base vectors are axis-aligned, defining the sizes of the cell along each axis can be more conveninent than defining the full hSize matrix; in that case one can simply define the vector :yref:`Cell.sizes`, reprensenting the lenghts of base vectors.
 
-The deformation of the period over time is defined via a matrix representing the gradient of an homogeneous velocity field $\nabla \vec{v}$ (:yref:`Cell.velGrad`). This gradient represents arbitrary combinations of rotations and stretches. It can be imposed externaly or updated by periodic engines in order to reach target strain values or to maintain some prescribed stress.
+The deformation of the cell over time is defined via a matrix representing the gradient of an homogeneous velocity field $\nabla \vec{v}$ (:yref:`Cell.velGrad`). This gradient represents arbitrary combinations of rotations and stretches. It can be imposed externaly or updated by engines (see :yref:`PeriTriaxController` or :yref:`Peri3dController`) in order to reach target strain values or to maintain some prescribed stress.
 The velocity gradient is integrated automatically over time, and the cumulated transformation is reflected in the transformation matrix $\mat{F}$ (:yref:`Cell.trsf`). :yref:`Cell.hSize` will also be updated. The  update reads (it is similar for hSize), with $I$ the identity matrix:
 
 .. math:: \next{\mat{F}}=(I+\nabla \vec{v} \Dt)\curr{\mat{F}}.
 
-There is an alternative way to define the initial period geometry, using:
-
-* \ the reference size $\vec{s}$ (:yref:`Cell.refSize`), defining the dimensions or a rectangular parallelepiped with corners $(0,0,0)$ and $\vec{s}$;
-* \ the transformation matrix $\mat{F}$ (:yref:`Cell.trsf`).
-
-For instance, if :yref:`Cell.refSize` is set equal to the unit vector and if :yref:`Cell.trsf` is defined as a rotation matrix, the initial period will be an inclined cube. This method and the previous one (direct assignement of hSize) are not exactly equivalent: assigning hSize keeps the transformation :yref:`Cell.trsf` unaffected, hence the simulation will start with a null deformation (:yref:`Cell.trsf` =I); inversely, if the period geometry is defined using :yref:`Cell.trsf`$=m$, then the initial value will be $m$.
-
-It is believed that the first method is generally more convenient, since it will let  :yref:`Cell.trsf` reflect only the transformation produced during the simulation, independently of the initial period geometry.
-
-In all cases, the period geometry should not be modified during a simulation, be it via hSize, trsf, or refSize. The velocity gradient :yref:`Cell.velGrad` is the only variable that let the period deformation be correctly accounted for in constitutive laws and Newton integrator (:yref:`NewtonIntegrator`).
-
-Along with the automatic integration of cell transformation, there is an option to homothetically displace all particles so that $\nabla \vec{v}$ is applied over the whole simulation (enabled via :yref:`Cell.homoDeform`). This avoids all boundary effects coming from change of the transformation.
+$\mat{F}$ can be set back to identity at any point in simulations in order to define the current state as reference for strains definition. It is done with the function :yref:`Cell.resetTrsf`.
+
+The cell's geometry should not be modified during a simulation, be it via hSize or size. The velocity gradient :yref:`Cell.velGrad` is the only variable that let the period deformation be correctly accounted for in constitutive laws and Newton integrator (:yref:`NewtonIntegrator`).
+
+Along with the automatic integration of cell transformation, there is an option to homothetically displace all particles so that $\nabla \vec{v}$ is applied over the whole simulation (enabled via :yref:`Cell.homoDeform`). This avoids all boundary effects coming from change of the velocity gradient.
 
 Collision detection in periodic cell
 ------------------------------------