← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3977: TwoPhaseFlowEngine: better integration of fluid clusters

 

------------------------------------------------------------
revno: 3977
committer: bchareyre <bruno.chareyre@xxxxxxxxxxxxxxx>
timestamp: Wed 2016-11-23 11:43:14 +0100
message:
  TwoPhaseFlowEngine: better integration of fluid clusters
modified:
  pkg/pfv/TwoPhaseFlowEngine.cpp
  pkg/pfv/TwoPhaseFlowEngine.hpp
  pkg/pfv/UnsaturatedEngine.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/pfv/TwoPhaseFlowEngine.cpp'
--- pkg/pfv/TwoPhaseFlowEngine.cpp	2016-11-22 17:29:15 +0000
+++ pkg/pfv/TwoPhaseFlowEngine.cpp	2016-11-23 10:43:14 +0000
@@ -125,47 +125,12 @@
 	r3 = sqrt(cell -> vertex(3) -> point().weight());	
 	
 	//Fill coefficient matrix
-	M(0,0) = 0.0;
-	M(1,0) = d01;
-	M(2,0) = d02;
-	M(3,0) = d03;
-	M(4,0) = pow((r0+Rin),2);
-	M(5,0) = 1.0;
-	
-	M(0,1) = d01;
-	M(1,1) = 0.0;
-	M(2,1) = d12;
-	M(3,1) = d13;
-	M(4,1) = pow((r1+Rin),2);
-	M(5,1) = 1.0;
-	
-	M(0,2) = d02; 
-	M(1,2) = d12;
-	M(2,2) = 0.0;
-	M(3,2) = d23;
-	M(4,2) = pow((r2+Rin),2);
-	M(5,2) = 1.0;
-	
-	M(0,3) = d03;
-	M(1,3) = d13;
-	M(2,3) = d23;
-	M(3,3) = 0.0;
-	M(4,3) = pow((r3+Rin),2);
-	M(5,3) = 1.0;
-	
-	M(0,4) = pow((r0+Rin),2);
-	M(1,4) = pow((r1+Rin),2);
-	M(2,4) = pow((r2+Rin),2);
-	M(3,4) = pow((r3+Rin),2);
-	M(4,4) = 0.0;
-	M(5,4) = 1.0;
-	
-	M(0,5) = 1.0;
-	M(1,5) = 1.0;
-	M(2,5) = 1.0;
-	M(3,5) = 1.0;
-	M(4,5) = 1.0;
-	M(5,5) = 0.0;
+	M(0,0) = 0.0; M(1,0) = d01; M(2,0) = d02; M(3,0) = d03; M(4,0) = pow((r0+Rin),2); M(5,0) = 1.0;
+	M(0,1) = d01; M(1,1) = 0.0; M(2,1) = d12; M(3,1) = d13; M(4,1) = pow((r1+Rin),2); M(5,1) = 1.0;
+	M(0,2) = d02; M(1,2) = d12; M(2,2) = 0.0; M(3,2) = d23; M(4,2) = pow((r2+Rin),2); M(5,2) = 1.0;
+	M(0,3) = d03; M(1,3) = d13; M(2,3) = d23; M(3,3) = 0.0; M(4,3) = pow((r3+Rin),2); M(5,3) = 1.0;
+	M(0,4) = pow((r0+Rin),2); M(1,4) = pow((r1+Rin),2); M(2,4) = pow((r2+Rin),2); M(3,4) = pow((r3+Rin),2); M(4,4) = 0.0; M(5,4) = 1.0;
+	M(0,5) = 1.0; M(1,5) = 1.0; M(2,5) = 1.0; M(3,5) = 1.0; M(4,5) = 1.0; M(5,5) = 0.0;
 	
 	i = 0;
 	check = false;
@@ -669,7 +634,8 @@
     FiniteCellsIterator cellEnd = tri.finite_cells_end();
     for ( FiniteCellsIterator cell = tri.finite_cells_begin(); cell != cellEnd; cell++ ) {
         if (cell->info().label==-1) {
-            updateSingleCellLabelRecursion(cell,currentLabel+1);
+	    clusters.push_back(shared_ptr<PhaseCluster>(new PhaseCluster));
+	    updateSingleCellLabelRecursion(cell,currentLabel+1,clusters.back()->pores);
             currentLabel++;
         }
     }
@@ -686,9 +652,10 @@
     return maxLabel;
 }
 
-void TwoPhaseFlowEngine:: updateSingleCellLabelRecursion(CellHandle cell, int label)
+void TwoPhaseFlowEngine:: updateSingleCellLabelRecursion(CellHandle cell, int label, std::vector<CellHandle> *outputVector)
 {
     cell->info().label=label;
+    if (outputVector) outputVector->push_back(cell);
     for (int facet = 0; facet < 4; facet ++) {
         CellHandle nCell = cell->neighbor(facet);
         if (solver->T[solver->currentTes].Triangulation().is_infinite(nCell)) continue;
@@ -696,7 +663,7 @@
 //         if ( (nCell->info().isFictious) && (!isInvadeBoundary) ) continue;
         //TODO:the following condition may relax to relate to nCell->info().hasInterface
         if ( (nCell->info().saturation==cell->info().saturation) && (nCell->info().label!=cell->info().label) )
-            updateSingleCellLabelRecursion(nCell,label);
+            updateSingleCellLabelRecursion(nCell,label,outputVector);
     }
 }
 

=== modified file 'pkg/pfv/TwoPhaseFlowEngine.hpp'
--- pkg/pfv/TwoPhaseFlowEngine.hpp	2016-11-22 17:29:15 +0000
+++ pkg/pfv/TwoPhaseFlowEngine.hpp	2016-11-23 10:43:14 +0000
@@ -58,10 +58,33 @@
 typedef TemplateFlowEngine_TwoPhaseFlowEngineT<TwoPhaseCellInfo,TwoPhaseVertexInfo> TwoPhaseFlowEngineT;
 REGISTER_SERIALIZABLE(TwoPhaseFlowEngineT);
 
+// A class to represent isolated single-phase cluster (main application in convective drying at the moment)
+class PhaseCluster : public Serializable
+{
+		double totalCellVolume;
+	public :
+		virtual ~PhaseCluster();
+		vector<TwoPhaseFlowEngineT::CellHandle>* pores;
+		TwoPhaseFlowEngineT::RTriangulation* tri;
+		YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(PhaseCluster,Serializable,"Preliminary.",
+		((int,label,-1,,"Unique label of this cluster, should be reflected in pores of this cluster."))
+		((double,volume,0,,"cumulated volume of all pores."))
+		((double,entryPc,0,,"smallest entry capillary pressure."))
+		((int,entryPore,0,,"the pore of the cluster incident to the throat with smallest entry Pc."))
+		((double,interfacialArea,0,,"interfacial area of the cluster"))
+		,,,
+		)
+};
+REGISTER_SERIALIZABLE(PhaseCluster);
+YADE_PLUGIN((PhaseCluster));
+PhaseCluster::~PhaseCluster(){}
+
 class TwoPhaseFlowEngine : public TwoPhaseFlowEngineT
 {
-		double totalCellVolume;
 	public :
+	double totalCellVolume;
+	vector<shared_ptr<PhaseCluster> > clusters; // the list of clusters
+
 	//We can overload every functions of the base engine to make it behave differently
 	//if we overload action() like this, this engine is doing nothing in a standard timestep, it can still have useful functions
 	virtual void action() {};
@@ -103,7 +126,7 @@
 	void checkTrap(double pressure);
 	void updateReservoirLabel();
 	void updateCellLabel();
-	void updateSingleCellLabelRecursion(CellHandle cell, int label);
+	void updateSingleCellLabelRecursion(CellHandle cell, int label, std::vector<CellHandle> *outputVector=NULL);
 	int getMaxCellLabel();
 
 	void invasion2();//without-trap

=== modified file 'pkg/pfv/UnsaturatedEngine.cpp'
--- pkg/pfv/UnsaturatedEngine.cpp	2016-11-22 17:45:57 +0000
+++ pkg/pfv/UnsaturatedEngine.cpp	2016-11-23 10:43:14 +0000
@@ -13,13 +13,13 @@
 //when you want it compiled, you can pass -DTWOPHASEFLOW to cmake, or just uncomment the following line
 #ifdef TWOPHASEFLOW
 
+
+
+
 class UnsaturatedEngine : public TwoPhaseFlowEngine
 {
+	public :
 		double totalCellVolume;
-	protected:
-// 		void initialization();		
-
-	public :
 		double computeCellInterfacialArea(CellHandle cell, int j, double rC);
 
 // 		void computeSolidLine();
@@ -37,6 +37,24 @@
 		double getSpecificInterfacialArea();
 
 		void printSomething();
+
+		boost::python::list getPotentialPendularSpheresPair() {
+			RTriangulation& Tri = solver->T[solver->currentTes].Triangulation();
+			boost::python::list bridgeIds;
+			FiniteEdgesIterator ed_it = Tri.finite_edges_begin();
+			for ( ; ed_it!=Tri.finite_edges_end(); ed_it++ ) {
+			  if (detectBridge(ed_it)==true) {
+			    const VertexInfo& vi1=(ed_it->first)->vertex(ed_it->second)->info();
+			    const VertexInfo& vi2=(ed_it->first)->vertex(ed_it->third)->info();
+			    const int& id1 = vi1.id();
+			    const int& id2 = vi2.id();
+			    bridgeIds.append(boost::python::make_tuple(id1,id2));}}
+			    return bridgeIds;}
+  		bool detectBridge(RTriangulation::Finite_edges_iterator& edge);
+		
+		boost::python::list pyClusters() { boost::python::list ret;
+			for(vector<shared_ptr<PhaseCluster> >::iterator it=clusters.begin(); it!=clusters.end(); ++it) ret.append(*it);
+			return ret;}
 				
 		virtual ~UnsaturatedEngine();
 
@@ -56,6 +74,8 @@
 		.def("getWindowsSaturation",&UnsaturatedEngine::getWindowsSaturation,(boost::python::arg("windowsID"),boost::python::arg("isSideBoundaryIncluded")), "get saturation of subdomain with windowsID. If isSideBoundaryIncluded=false (default), the pores of side boundary are excluded in saturation calculating; if isSideBoundaryIncluded=true (only in isInvadeBoundary=true drainage mode), the pores of side boundary are included in saturation calculating.")
 		.def("initializeCellWindowsID",&UnsaturatedEngine::initializeCellWindowsID,"Initialize cell windows index. A temporary function for comparison with experiments, will delete soon")
 		.def("printSomething",&UnsaturatedEngine::printSomething,"print debug.")
+		.def("getPotentialPendularSpheresPair",&UnsaturatedEngine::getPotentialPendularSpheresPair,"Get the list of sphere ID pairs of potential pendular liquid bridge.")
+		.def("getClusters",&UnsaturatedEngine::pyClusters/*,(boost::python::arg("folder")="./VTK")*/,"Get the list of clusters.")
 		)
 		DECLARE_LOGGER;
 };
@@ -356,62 +376,5 @@
 
 //--------------end of comparison with experiment----------------------------
 
-
-//#########################################################
-//         CONVECTIVE DRYING EXTENSION
-//#########################################################
-
-class PhaseCluster : public Serializable
-{
-  		double totalCellVolume;
-	public :
-
-				
-		virtual ~PhaseCluster();
-		vector<TwoPhaseFlowEngine::CellHandle> pores;
-		TwoPhaseFlowEngine::RTriangulation* tri;
-
-		
-		YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(PhaseCluster,Serializable,"Preliminary.",
-		((int,label,-1,,"Unique label of this cluster, should be reflected in pores of this cluster."))
-		((double,volume,0,,"cumulated volume of all pores."))
-		((double,entryPc,0,,"smallest entry capillary pressure."))
-		((int,entryPore,0,,"the pore of the cluster incident to the throat with smallest entry Pc."))
-		((double,interfacialArea,0,,"interfacial area of the cluster"))
-					,,,
-		)
-};
-
-REGISTER_SERIALIZABLE(PhaseCluster);
-YADE_PLUGIN((PhaseCluster));
-
-PhaseCluster::~PhaseCluster(){}
-
-
-class DryingEngine : public UnsaturatedEngine
-{
-	public :
-		virtual ~DryingEngine();
-		vector<shared_ptr<PhaseCluster> > clusters;
-		
-		boost::python::list pyClusters() {
-			boost::python::list ret;
-			for(vector<shared_ptr<PhaseCluster> >::iterator it=clusters.begin(); it!=clusters.end(); ++it) ret.append(*it);
-			return ret;}
-	
-		YADE_CLASS_BASE_DOC_ATTRS_INIT_CTOR_PY(DryingEngine,UnsaturatedEngine,"Extended TwoPhaseFlowEngine for application to convective drying.",
-// 		((shared_ptr<PhaseCluster> , cluster,new PhaseCluster,,"The list of clusters"))
-					,,,
-		.def("getClusters",&DryingEngine::pyClusters/*,(boost::python::arg("folder")="./VTK")*/,"Save pressure field in vtk format. Specify a folder name for output.")
-		)
-		DECLARE_LOGGER;
-};
-
-DryingEngine::~DryingEngine(){};
-
-REGISTER_SERIALIZABLE(DryingEngine);
-YADE_PLUGIN((DryingEngine));
-
-
 #endif //TWOPHASEFLOW
 #endif //FLOW_ENGINE