← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 4189: porosity() function infers now a volume value for non-periodic cases, rather than throwing an err...

 

------------------------------------------------------------
revno: 4189
committer: jduriez <jerome.duriez@xxxxxxxxxxx>
timestamp: Wed 2014-10-08 14:07:22 -0600
message:
  porosity() function infers now a volume value for non-periodic cases, rather than throwing an error. Positiv volume values eventually passed as argument override this inferred value
modified:
  pkg/dem/Shop_01.cpp


--
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/Shop_01.cpp'
--- pkg/dem/Shop_01.cpp	2014-07-19 19:52:41 +0000
+++ pkg/dem/Shop_01.cpp	2014-10-08 20:07:22 +0000
@@ -42,6 +42,9 @@
 	#include"yade/pkg/common/Gl1_NormPhys.hpp"
 #endif
 
+#include"yade/py/_utils.cpp"
+
+
 CREATE_LOGGER(Shop);
 
 /*! Flip periodic cell by given number of cells.
@@ -320,8 +323,12 @@
 	const shared_ptr<Scene> scene=(_scene?_scene:Omega::instance().getScene());
 	Real V;
 	if(!scene->isPeriodic){
-		if(_volume<=0) throw std::invalid_argument("utils.porosity must be given (positive) *volume* for aperiodic simulations.");
-		V=_volume;
+		if(_volume<=0){// throw std::invalid_argument("utils.porosity must be given (positive) *volume* for aperiodic simulations.");
+		  py::tuple extrema = aabbExtrema(); //aabbExtrema() defined in _utils.cpp
+		  V = py::extract<Real>( (extrema[1][0] - extrema[0][0])*(extrema[1][1] - extrema[0][1])*(extrema[1][2] - extrema[0][2]) );
+		}
+		else
+		  V=_volume;
 	} else {
 		V=scene->cell->getVolume();
 	}


Follow ups