← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3809: Use enum instead of string to keep capyllar type.

 

------------------------------------------------------------
revno: 3809
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Thu 2014-01-30 09:09:44 +0100
message:
  Use enum instead of string to keep capyllar type.
modified:
  pkg/dem/ViscoelasticCapillarPM.cpp
  pkg/dem/ViscoelasticPM.cpp
  pkg/dem/ViscoelasticPM.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/ViscoelasticCapillarPM.cpp'
--- pkg/dem/ViscoelasticCapillarPM.cpp	2014-01-29 16:26:55 +0000
+++ pkg/dem/ViscoelasticCapillarPM.cpp	2014-01-30 08:09:44 +0000
@@ -15,7 +15,7 @@
     * 
     */
      
-  if (phys.CapillarType  == "Weigert") {
+  if (phys.CapillarType == Weigert) {
       /* Capillar model from [Weigert1999]
        */
         Real R = phys.R;
@@ -44,7 +44,7 @@
         fC = M_PI/4.0*pow((2.0*R),2.0)*pow(sin(beta),2.0)*Pk +
              phys.gamma*M_PI*2.0*R*sin(beta)*sin(beta+phys.theta);                                // [Weigert1999], equation (21)
         
-      } else if (phys.CapillarType  == "Willett_numeric") {
+      } else if (phys.CapillarType == Willett_numeric) {
       
         /* Capillar model from [Willett2000]
          */ 
@@ -85,7 +85,7 @@
         Real FS = exp(lnFS);
         
         fC = FS * 2.0 * M_PI* R * Gamma;
-      } else if (phys.CapillarType  == "Willett_analytic") {
+      } else if (phys.CapillarType == Willett_analytic) {
         /* Capillar model from Willet [Willett2000] (analytical solution), but 
          * used also in the work of Herminghaus [Herminghaus2005]
          */
@@ -106,7 +106,7 @@
         Real f_star = cos(phys.theta)/(1 + 2.1*sPl + 10.0 * pow(sPl, 2.0));                 // [Willett2000], equation (12)
         fC = f_star * (2*M_PI*R*Gamma);                                                     // [Willett2000], equation (13), against F
         
-      } else if ((phys.CapillarType  == "Rabinovich") or (phys.CapillarType  == "Lambert")) {
+      } else if ((phys.CapillarType  == Rabinovich) or (phys.CapillarType  == Lambert)) {
         /* 
          * Capillar model from Rabinovich [Rabinov2005]
          *
@@ -125,14 +125,14 @@
           dsp = H/2.0*(-1.0 + sqrt(1.0 + 2.0*V/(M_PI*R*H*H)));                            // [Rabinov2005], equation (20)
           fC = -(2*M_PI*R*Gamma*cos(phys.theta))/(1+(H/(2*dsp)));                         // [Lambert2008], equation (65), taken from [Rabinov2005]
           
-          if (phys.CapillarType  == "Rabinovich") {
+          if (phys.CapillarType  == Rabinovich) {
             const Real alpha = sqrt(H/R*(-1+ sqrt(1 + 2.0*V/(M_PI*R*H*H))));              // [Rabinov2005], equation (A3)
             fC -= 2*M_PI*R*Gamma*sin(alpha)*sin(phys.theta + alpha);                      // [Rabinov2005], equation (19)
           }
         } else {
-          
           fC = -(2*M_PI*R*Gamma*cos(phys.theta));
-          if (phys.CapillarType  == "Rabinovich") {
+          
+          if (phys.CapillarType == Rabinovich) {
             const Real alpha = 0.0;
             fC -= 2*M_PI*R*Gamma*sin(alpha)*sin(phys.theta + alpha);                      // [Rabinov2005], equation (19)
           }

=== modified file 'pkg/dem/ViscoelasticPM.cpp'
--- pkg/dem/ViscoelasticPM.cpp	2014-01-09 07:12:14 +0000
+++ pkg/dem/ViscoelasticPM.cpp	2014-01-30 08:09:44 +0000
@@ -99,8 +99,15 @@
 		} else {
 			throw runtime_error("Theta should be equal for both particles!.");
 		}
+		
 		if (mat1->CapillarType == mat2->CapillarType and mat2->CapillarType != ""){
-			phys->CapillarType = mat1->CapillarType;
+			
+			if      (mat1->CapillarType == "Willett_numeric")  phys->CapillarType = Willett_numeric;
+			else if (mat1->CapillarType == "Willett_analytic") phys->CapillarType = Willett_analytic;
+			else if (mat1->CapillarType == "Weigert")          phys->CapillarType = Weigert;
+			else if (mat1->CapillarType == "Rabinovich")       phys->CapillarType = Rabinovich;
+			else if (mat1->CapillarType == "Lambert")          phys->CapillarType = Lambert;
+			else                                               phys->CapillarType = None_Capillar;
 		} else {
 			throw runtime_error("CapillarType should be equal for both particles!.");
 		}

=== modified file 'pkg/dem/ViscoelasticPM.hpp'
--- pkg/dem/ViscoelasticPM.hpp	2014-01-29 16:26:55 +0000
+++ pkg/dem/ViscoelasticPM.hpp	2014-01-30 08:09:44 +0000
@@ -37,6 +37,7 @@
 REGISTER_SERIALIZABLE(ViscElMat);
 
 /// Interaction physics
+enum CapType {None_Capillar, Willett_numeric, Willett_analytic, Weigert, Rabinovich, Lambert};
 class ViscElPhys : public FrictPhys{
 	public:
 		virtual ~ViscElPhys();
@@ -52,7 +53,7 @@
 		((Real,Vb,NaN,,"Liquid bridge volume [m^3]"))
 		((Real,gamma,NaN,,"Surface tension [N/m]"))
 		((Real,theta,NaN,,"Contact angle [rad]"))
-		((std::string,CapillarType,"",,"Different types of capillar interaction: Willett_numeric, Willett_analytic, Weigert, Rabinovich")),
+		((CapType,CapillarType,None_Capillar,,"Different types of capillar interaction: Willett_numeric, Willett_analytic, Weigert, Rabinovich, Lambert")),
 		createIndex();
 	)
 	REGISTER_CLASS_INDEX(ViscElPhys,FrictPhys);