Lisandro Dalcin avatar Lisandro Dalcin committed e17c189

Fix whitespace and petsc-3.3 compat in demo

Comments (0)

Files changed (1)

demo/TwoPhaseTwoComponent.c

 #undef __FUNCT__
 #define __FUNCT__ "EquationOfState"
 void EquationOfState(PetscInt dim,PetscScalar Pl,PetscScalar Pl_t,PetscScalar rholh,PetscScalar rholh_t,PetscScalar *rholh_x,
-		     PetscScalar *Sl,PetscScalar *Sl_t,PetscScalar *krl,PetscScalar *krg,
-		     PetscScalar *rhogh,PetscScalar *rhogh_t,PetscScalar *Pg_x,AppCtx *user)
+                     PetscScalar *Sl,PetscScalar *Sl_t,PetscScalar *krl,PetscScalar *krg,
+                     PetscScalar *rhogh,PetscScalar *rhogh_t,PetscScalar *Pg_x,AppCtx *user)
 {
   // VanGenuchten, Henry
   PetscScalar R     = 8.314e-5; // [J/(K-mol)]
   *krl     = sqrt(Sle)*pow(1.-pow(1.-pow(Sle,1./m),m),2);
   *krg     = sqrt(1.-Sle)*pow(1.-pow(Sle,1./m),2*m);
   *rhogh_t = rholh_t/(R*T*H);
-  *rhogh   = rholh  /(R*T*H); 
+  *rhogh   = rholh  /(R*T*H);
   PetscInt i;
-  for(i=0;i<dim;i++) Pg_x[i] = rholh_x[i]/Mh*H; 
+  for(i=0;i<dim;i++) Pg_x[i] = rholh_x[i]/Mh*H;
   return;
 }
 
 #undef  __FUNCT__
 #define __FUNCT__ "LeftInjectionResidual"
 PetscErrorCode LeftInjectionResidual(IGAPoint p,PetscReal dt,
-				     PetscReal shift,const PetscScalar *V,
-				     PetscReal t,const PetscScalar *U,
-				     PetscScalar *R,void *ctx)
+                                     PetscReal shift,const PetscScalar *V,
+                                     PetscReal t,const PetscScalar *U,
+                                     PetscScalar *R,void *ctx)
 {
   PetscInt a,nen;
   IGAPointGetSizes(p,&nen,0,0);
 #undef  __FUNCT__
 #define __FUNCT__ "Residual"
 PetscErrorCode Residual(IGAPoint p,PetscReal dt,
-			PetscReal shift,const PetscScalar *V,
-			PetscReal t,const PetscScalar *U,
-			PetscScalar *R,void *ctx)
+                        PetscReal shift,const PetscScalar *V,
+                        PetscReal t,const PetscScalar *U,
+                        PetscScalar *R,void *ctx)
 {
   if (p->atboundary)
     return LeftInjectionResidual(p,dt,shift,V,t,U,R,ctx);
 
   AppCtx *user = (AppCtx *)ctx;
-  PetscScalar rholw = user->rholw; 
-  PetscScalar porosity = user->porosity; 
+  PetscScalar rholw = user->rholw;
+  PetscScalar porosity = user->porosity;
   PetscScalar mul = user->mul;
   PetscScalar mug = user->mug;
   PetscScalar Mh  = user->Mh;
   PetscScalar Mw  = user->Mw;
   PetscScalar Dlh = user->Dlh;
-  PetscScalar k   = user->k; 
+  PetscScalar k   = user->k;
 
   PetscInt a,i,nen,dim;
   IGAPointGetSizes(p,&nen,0,0);
   IGAPointGetShapeFuns(p,1,(const PetscReal**)&N1);
 
   PetscScalar  Pl      = sol[0];    // liquid pressure
-  PetscScalar  Pl_t    = sol_t[0];    
-  PetscScalar *Pl_x    = sol_x[0];    
+  PetscScalar  Pl_t    = sol_t[0];
+  PetscScalar *Pl_x    = sol_x[0];
   PetscScalar  rholh   = sol[1];    // dissolved hydrogen
-  PetscScalar  rholh_t = sol_t[1]; 
+  PetscScalar  rholh_t = sol_t[1];
   PetscScalar *rholh_x = sol_x[1];
 
   PetscScalar Sl,Sl_t,krl,krg,rhogh,rhogh_t,Pg_x[dim];
   EquationOfState(dim,Pl,Pl_t,rholh,rholh_t,rholh_x,&Sl,&Sl_t,&krl,&krg,&rhogh,&rhogh_t,Pg_x,user);
   PetscScalar Sg = 1.-Sl, Sg_t = -Sl_t;
   PetscScalar cl = Sl*(rholh/Mh+rholw/Mw);
-  
+
   PetscScalar den = rholh/Mh+rholw/Mw;
   PetscScalar jlw[dim],ql[dim],qg[dim],g=0;
   for(i=0;i<dim;i++) {
 #undef  __FUNCT__
 #define __FUNCT__ "LeftInjectionJacobian"
 PetscErrorCode LeftInjectionJacobian(IGAPoint p,PetscReal dt,
-				     PetscReal shift,const PetscScalar *V,
-				     PetscReal t,const PetscScalar *U,
-				     PetscScalar *J,void *ctx)
+                                     PetscReal shift,const PetscScalar *V,
+                                     PetscReal t,const PetscScalar *U,
+                                     PetscScalar *J,void *ctx)
 {
   // for now use the option -snes_fd_color for the Jacobian
   return 0;
 #undef  __FUNCT__
 #define __FUNCT__ "Jacobian"
 PetscErrorCode Jacobian(IGAPoint p,PetscReal dt,
-			PetscReal shift,const PetscScalar *V,
-			PetscReal t,const PetscScalar *U,
-			PetscScalar *J,void *ctx)
+                        PetscReal shift,const PetscScalar *V,
+                        PetscReal t,const PetscScalar *U,
+                        PetscScalar *J,void *ctx)
 {
   if (p->atboundary)
     return LeftInjectionJacobian(p,dt,shift,V,t,U,J,ctx);
   for(i=info.xs;i<info.xs+info.xm;i++){
     for(j=info.ys;j<info.ys+info.ym;j++){
       u[j][i].Pl    = 10.;
-      u[j][i].rholh = 0; 
+      u[j][i].rholh = 0;
     }
   }
-  ierr = DMDAVecRestoreArray(da,U,&u);CHKERRQ(ierr); 
-  ierr = DMDestroy(&da);;CHKERRQ(ierr); 
-  PetscFunctionReturn(0); 
+  ierr = DMDAVecRestoreArray(da,U,&u);CHKERRQ(ierr);
+  ierr = DMDestroy(&da);;CHKERRQ(ierr);
+  PetscFunctionReturn(0);
 }
 
 #undef __FUNCT__
 {
   PetscErrorCode ierr;
   PetscFunctionBegin;
-  AppCtx *user = (AppCtx *)mctx; 
+  AppCtx *user = (AppCtx *)mctx;
   IGA      iga = user->iga;
   PetscInt dim = iga->dim;
-  
+
   if(step == 0){
     PetscPrintf(PETSC_COMM_WORLD,"#%11s %12s %12s %12s %12s %12s %12s\n","Time","dt","Pl(xL)","Pg(xL)","Sg(xL)","fluxw(xR)","fluxh(xR)");
   }
-  
-  // Pl,Pg,Sg computed at left middle  
+
+  // Pl,Pg,Sg computed at left middle
   PetscReal   point[2] = {0,10};
   PetscScalar sol[2];
   ierr = IGAInterpolate(iga,U,point,sol,NULL);CHKERRQ(ierr);
   user.Slr      = 0.4;
   user.Sgr      = 0.;
   user.T        = 303;
-  user.H        = 0.765; 
+  user.H        = 0.765;
   user.Mw       = 1e-2;
   user.Mh       = 2e-3;
   user.mul      = 1e-8/SEC_PER_YEAR;
   user.mug      = 9e-11/SEC_PER_YEAR;
   user.Dlh      = 3e-9*SEC_PER_YEAR;
-  user.k        = 5e-20; 
+  user.k        = 5e-20;
   PetscInt dim = 2, p = 1, N = 200, L = 200;
   ierr = PetscOptionsBegin(PETSC_COMM_WORLD,"r_","2c2p Options","2c2p");CHKERRQ(ierr);
   ierr = PetscOptionsEnd();CHKERRQ(ierr);
   ierr = IGAGetAxis(iga,1,&axis);CHKERRQ(ierr);
   ierr = IGAAxisSetDegree(axis,p);CHKERRQ(ierr);
   ierr = IGAAxisInitUniform(axis,N/10,0.0,0.1*L,0);CHKERRQ(ierr);
-  
+
   ierr = IGASetFromOptions(iga);CHKERRQ(ierr);
   ierr = IGASetUp(iga);CHKERRQ(ierr);
   user.iga = iga;
   ierr = TSSetTimeStep(ts,10.0);CHKERRQ(ierr);
   ierr = TSSetType(ts,TSALPHA);CHKERRQ(ierr);
   ierr = TSAlphaSetRadius(ts,0.95);CHKERRQ(ierr);
-  ierr = TSAlphaSetAdapt(ts,GeometricAdaptivity,NULL);CHKERRQ(ierr); 
+  ierr = TSAlphaSetAdapt(ts,GeometricAdaptivity,NULL);CHKERRQ(ierr);
   ierr = TSMonitorSet(ts,Monitor,&user,NULL);CHKERRQ(ierr);
   ierr = TSSetFromOptions(ts);CHKERRQ(ierr);
 
   Vec       U;
   ierr = IGACreateVec(iga,&U);CHKERRQ(ierr);
   ierr = InitialCondition(iga,U,&user);CHKERRQ(ierr);
+#if PETSC_VERSION_LE(3,3,0)
+  ierr = TSSolve(ts,U,NULL);CHKERRQ(ierr);
+#else
   ierr = TSSolve(ts,U);CHKERRQ(ierr);
+#endif
 
   ierr = IGAWrite(iga,"iga.dat");CHKERRQ(ierr);
   ierr = IGAWriteVec(iga,U,"ss.dat");CHKERRQ(ierr);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.