← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3985: fix fluidForce=0 after remeshing + allow constant positions for DFNFlowEngine

 

------------------------------------------------------------
revno: 3985
committer: Bruno Chareyre <bruno.chareyre@xxxxxxxxxxxxxxx>
timestamp: Tue 2014-05-27 01:23:29 +0200
message:
  fix fluidForce=0 after remeshing + allow constant positions for DFNFlowEngine
modified:
  lib/triangulation/FlowBoundingSphere.hpp
  lib/triangulation/FlowBoundingSphere.ipp
  pkg/pfv/DFNFlow.cpp
  pkg/pfv/FlowEngine.hpp
  pkg/pfv/FlowEngine.ipp


--
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 'lib/triangulation/FlowBoundingSphere.hpp'
--- lib/triangulation/FlowBoundingSphere.hpp	2014-04-24 21:37:44 +0000
+++ lib/triangulation/FlowBoundingSphere.hpp	2014-05-26 23:23:29 +0000
@@ -154,7 +154,7 @@
 		void measurePressureProfile(double WallUpy, double WallDowny);
 		double averageSlicePressure(double Y);
 		double averagePressure();
-		double getCell (double X,double Y,double Z);
+		int getCell (double X,double Y,double Z);
 		double boundaryFlux(unsigned int boundaryId);
 		
 		vector<Real> averageFluidVelocityOnSphere(unsigned int Id_sph);

=== modified file 'lib/triangulation/FlowBoundingSphere.ipp'
--- lib/triangulation/FlowBoundingSphere.ipp	2014-04-24 21:37:44 +0000
+++ lib/triangulation/FlowBoundingSphere.ipp	2014-05-26 23:23:29 +0000
@@ -217,9 +217,9 @@
 }
 
 template <class Tesselation>
-double FlowBoundingSphere<Tesselation>::getCell (double X, double Y, double Z)
+int FlowBoundingSphere<Tesselation>::getCell (double X, double Y, double Z)
 {
-	if (noCache) {cerr<<"Triangulation does not exist. Waht did you do?!"<<endl; return -1;}
+	if (noCache) {cout<<"Triangulation does not exist. Waht did you do?!"<<endl; return -1;}
 	RTriangulation& Tri = T[noCache?(!currentTes):currentTes].Triangulation();
 	CellHandle cell = Tri.locate(Point(X,Y,Z));
 	return cell->info().id;
@@ -348,8 +348,9 @@
 			}
 		}
 		noCache=false;//cache should always be defined after execution of this function
+	}
 		if (onlyCache) return;
-	} else {//use cached values
+// 	} else {//use cached values
 		#ifndef parallel_forces
 		for (FiniteCellsIterator cell = Tri.finite_cells_begin(); cell != cellEnd; cell++) {
 			for (int yy=0;yy<4;yy++) cell->vertex(yy)->info().forces = cell->vertex(yy)->info().forces + cell->info().unitForceVectors[yy]*cell->info().p();}
@@ -367,7 +368,7 @@
 			v->info().forces = tf;
 		}
 		#endif
-	}
+// 	}
 	if (debugOut) {
 		CVector totalForce = nullVect;
 		for (FiniteVerticesIterator v = Tri.finite_vertices_begin(); v != Tri.finite_vertices_end(); ++v)	{

=== modified file 'pkg/pfv/DFNFlow.cpp'
--- pkg/pfv/DFNFlow.cpp	2014-04-03 16:44:33 +0000
+++ pkg/pfv/DFNFlow.cpp	2014-05-26 23:23:29 +0000
@@ -41,6 +41,7 @@
 
 	YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(DFNFlowEngine,DFNFlowEngineT,"documentation here",
 	((Real, myNewAttribute, 0,,"useless example"))
+	((bool, updatePositions, False,,"update particles positions when rebuilding the mesh (experimental)"))
 	,/*DFNFlowEngineT()*/,
 	,
 	)
@@ -48,6 +49,26 @@
 };
 REGISTER_SERIALIZABLE(DFNFlowEngine);
 YADE_PLUGIN((DFNFlowEngine));
+//In this version, we never update positions when !updatePositions, i.e. keep triangulating the same positions
+void DFNFlowEngine::setPositionsBuffer(bool current)
+{
+	vector<posData>& buffer = current? positionBufferCurrent : positionBufferParallel;
+	if (!updatePositions && buffer.size()>0) return;
+	buffer.clear();
+	buffer.resize(scene->bodies->size());
+	shared_ptr<Sphere> sph ( new Sphere );
+        const int Sph_Index = sph->getClassIndexStatic();
+	FOREACH ( const shared_ptr<Body>& b, *scene->bodies ) {
+                if (!b || ignoredBody==b->getId()) continue;
+                posData& dat = buffer[b->getId()];
+		dat.id=b->getId();
+		dat.pos=b->state->pos;
+		dat.isSphere= (b->shape->getClassIndex() ==  Sph_Index);
+		if (dat.isSphere) dat.radius = YADE_CAST<Sphere*>(b->shape.get())->radius;
+		dat.exists=true;
+	}
+}
+
 
 void DFNFlowEngine::trickPermeability (RTriangulation::Facet_circulator& facet, Real somethingBig)
 {

=== modified file 'pkg/pfv/FlowEngine.hpp'
--- pkg/pfv/FlowEngine.hpp	2014-05-23 13:05:19 +0000
+++ pkg/pfv/FlowEngine.hpp	2014-05-26 23:23:29 +0000
@@ -79,7 +79,7 @@
 		typedef typename RTriangulation::Triangulation_data_structure::Cell::Info       CellInfo;
 		typedef typename RTriangulation::Triangulation_data_structure::Vertex::Info     VertexInfo;
 		
-	protected:
+// 	protected:
 		shared_ptr<FlowSolver> solver;
 		shared_ptr<FlowSolver> backgroundSolver;
 		volatile bool backgroundCompleted;

=== modified file 'pkg/pfv/FlowEngine.ipp'
--- pkg/pfv/FlowEngine.ipp	2014-05-07 10:28:20 +0000
+++ pkg/pfv/FlowEngine.ipp	2014-05-26 23:23:29 +0000
@@ -249,10 +249,7 @@
 void TemplateFlowEngine<_CellInfo,_VertexInfo,_Tesselation,solverT>::buildTriangulation ( double pZero, Solver& flow )
 {
  	if (first) flow.currentTes=0;
-        else {
-                flow.currentTes=!flow.currentTes;
-                if (debug) cout << "--------RETRIANGULATION-----------" << endl;
-        }
+        else {  flow.currentTes=!flow.currentTes; if (debug) cout << "--------RETRIANGULATION-----------" << endl;}
 	flow.resetNetwork();
 	initSolver(flow);