[cig-commits] [commit] rajesh-petsc,rajesh-petsc-schur: fixed some bugs; started replacing VecGetOwnershipRange with VecGetArray (6c6619f)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Nov 5 19:02:41 PST 2014


Repository : https://github.com/geodynamics/citcoms

On branches: rajesh-petsc,rajesh-petsc-schur
Link       : https://github.com/geodynamics/citcoms/compare/464e1b32299b15819f93efd98d969cddb84dfe51...f97ae655a50bdbd6dac1923a3471ee4dae178fbd

>---------------------------------------------------------------

commit 6c6619fe28b3921761bbc0a0ccd3ef06ccc61354
Author: Rajesh Kommu <rajesh.kommu at gmail.com>
Date:   Wed Aug 20 12:35:06 2014 -0700

    fixed some bugs; started replacing VecGetOwnershipRange with VecGetArray


>---------------------------------------------------------------

6c6619fe28b3921761bbc0a0ccd3ef06ccc61354
 .../input.sample => bin/regional_input.sample      | 30 ++++++++--------
 lib/Drive_solvers.c                                | 24 ++++++-------
 lib/Petsc_citcoms.c                                | 40 +++++++++++++++++-----
 3 files changed, 59 insertions(+), 35 deletions(-)

diff --git a/examples/Regional/input.sample b/bin/regional_input.sample
similarity index 94%
copy from examples/Regional/input.sample
copy to bin/regional_input.sample
index d961bf3..f50352f 100644
--- a/examples/Regional/input.sample
+++ b/bin/regional_input.sample
@@ -1,5 +1,8 @@
+use_petsc=on
+petsc_schur=off
+
 # specify output files
-datadir="/scratch"
+datadir="/home/rkk/scratch"
 datafile="regtest"
 
 output_format=ascii
@@ -27,16 +30,16 @@ tracer_file=""
 
 # processors, mesh grid information
 nproc_surf=1
-nprocx=2
-nprocy=2
+nprocx=1
+nprocy=1
 nprocz=1
-nodex=17
-nodey=17
+nodex=9
+nodey=9
 nodez=9
-mgunitx=8
-mgunity=8
-mgunitz=8
-levels=1
+mgunitx=4
+mgunity=4
+mgunitz=4
+levels=2
 
 
 # the calculation region definition
@@ -60,8 +63,8 @@ zero_elapsed_time=1
 
 # timestepping information
 minstep=1
-maxstep=71
-maxtotstep=71
+maxstep=1
+maxtotstep=1
 storage_spacing=10
 cpu_limits_in_seconds=360000000
 
@@ -121,8 +124,7 @@ z_cmb=0.439			#     depth of another phase change
 
 
 # Viscosity Information
-Viscosity=system
-rheol=3
+rheol=1
 visc_smooth_method=3
 
 VISC_UPDATE=on
@@ -198,7 +200,7 @@ density_below=6600.0
 # Data input and program debugging
 DESCRIBE=off
 BEGINNER=off
-VERBOSE=on
+VERBOSE=off
 
 verbose=off
 see_convergence=1
diff --git a/lib/Drive_solvers.c b/lib/Drive_solvers.c
index 016b481..89fcc32 100644
--- a/lib/Drive_solvers.c
+++ b/lib/Drive_solvers.c
@@ -67,8 +67,8 @@ void general_stokes_solver_setup(struct All_variables *E)
 
   E->mtx_grad_p.E = E;
   E->mtx_grad_p.level = E->mesh.levmax;
-  E->mtx_grad_p.iSize = E->lmesh.neq;
-  E->mtx_grad_p.oSize = E->lmesh.nel;
+  E->mtx_grad_p.iSize = E->lmesh.nel;
+  E->mtx_grad_p.oSize = E->lmesh.neq;
   
   E->mtx_div_u.E = E;
   E->mtx_div_u.level = E->mesh.levmax;
@@ -86,16 +86,16 @@ void general_stokes_solver_setup(struct All_variables *E)
   E->pcshell_ctx.acc = 1e-6;
   E->pcshell_ctx.level = lev;
 
-  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_del2_u.iData[i] );
-  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_del2_u.oData[i] );
-  PetscMalloc( (nel+1)*sizeof(double), &E->mtx_grad_p.iData[i] );
-  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_grad_p.oData[i] );
-  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_div_u.iData[i] );
-  PetscMalloc( (nel+1)*sizeof(double), &E->mtx_div_u.oData[i] );
-  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_div_rho_u.iData[i] );
-  PetscMalloc( (npno+1)*sizeof(double), &E->mtx_div_rho_u.oData[i] );
-  PetscMalloc( (E->lmesh.NEQ[lev])*sizeof(double), &E->pcshell_ctx.V[i] );
-  PetscMalloc( (E->lmesh.NEQ[lev])*sizeof(double), &E->pcshell_ctx.RR[i] );
+  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_del2_u.iData[1] );
+  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_del2_u.oData[1] );
+  PetscMalloc( (nel+1)*sizeof(double), &E->mtx_grad_p.iData[1] );
+  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_grad_p.oData[1] );
+  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_div_u.iData[1] );
+  PetscMalloc( (nel+1)*sizeof(double), &E->mtx_div_u.oData[1] );
+  PetscMalloc( (neq+1)*sizeof(double), &E->mtx_div_rho_u.iData[1] );
+  PetscMalloc( (npno+1)*sizeof(double), &E->mtx_div_rho_u.oData[1] );
+  PetscMalloc( (E->lmesh.NEQ[lev])*sizeof(double), &E->pcshell_ctx.V[1] );
+  PetscMalloc( (E->lmesh.NEQ[lev])*sizeof(double), &E->pcshell_ctx.RR[1] );
 
   // Create a Matrix shell for the K matrix
   MatCreateShell( PETSC_COMM_WORLD, 
diff --git a/lib/Petsc_citcoms.c b/lib/Petsc_citcoms.c
index 560d03a..282eba5 100644
--- a/lib/Petsc_citcoms.c
+++ b/lib/Petsc_citcoms.c
@@ -229,12 +229,13 @@ PetscErrorCode MatShellMult_del2_u( Mat K, Vec U, Vec KU )
   // K is (neq+1) x (neq+1)
   // U is (neq+1)
   // KU is (neq+1)
-  int i, j, neq, nel;
+  int i, j, neq;
   PetscErrorCode ierr;
+  PetscScalar *KData, *KUData;
   struct MatMultShell *ctx;
   MatShellGetContext( K, (void **)&ctx );
-  neq = ctx->iSize;
-  nel = ctx->oSize;
+  neq = ctx->iSize; // ctx->iSize SHOULD be the same as ctx->oSize
+#if 0
   int low, high;
 
   VecAssemblyBegin(U);
@@ -247,10 +248,18 @@ PetscErrorCode MatShellMult_del2_u( Mat K, Vec U, Vec KU )
       CHKERRQ( ierr );
     }
   }
-
+#endif
+  ierr = VecGetArray(K, &KData); CHKERRQ(ierr);
+  for(j = 0; j <=neq; j++)
+    ctx->iData[1][j] = KData[j];
+  ierr = VecRestoreArray(K, &KData); CHKERRQ(ierr);
   // actual CitcomS operation
   assemble_del2_u( ctx->E, ctx->iData, ctx->oData, ctx->level, 1 );
-  
+  ierr = VecGetArray(KU, &KUData); CHKERRQ(ierr);
+  for(j = 0; j <= neq; j++)
+    KUData[j] = ctx->oData[1][j];
+  ierr = VecRestoreArray(KU, &KUData); CHKERRQ(ierr);
+#if 0 
   VecGetOwnershipRange( KU, &low, &high );
   for( i=1; i <= ctx->E->sphere.caps_per_proc; ++i ) {
     for( j = 0; j <= neq; j++ ) {
@@ -260,7 +269,7 @@ PetscErrorCode MatShellMult_del2_u( Mat K, Vec U, Vec KU )
   }
   VecAssemblyBegin( KU );
   VecAssemblyEnd( KU );
-
+#endif
   PetscFunctionReturn(0);
 }
 
@@ -271,12 +280,14 @@ PetscErrorCode MatShellMult_grad_p( Mat G, Vec P, Vec GP )
   // GP is (neq+1) x 1 of which first neq entries (0:neq-1) are actual values
   int i, j, neq, nel;
   PetscErrorCode ierr;
+  PetscScalar *PData, *GPData;
   struct MatMultShell *ctx;
   MatShellGetContext( G, (void **)&ctx );
-  neq = ctx->iSize;
   nel = ctx->iSize;
-
+  neq = ctx->oSize;
+#if 0  
   int low, high;
+
   VecGetOwnershipRange( P, &low, &high );
 
   VecAssemblyBegin( P );
@@ -288,10 +299,21 @@ PetscErrorCode MatShellMult_grad_p( Mat G, Vec P, Vec GP )
       CHKERRQ( ierr );
     }
   }
+#endif
+  ierr = VecGetArray(P, &PData); CHKERRQ(ierr);
+  for(j = 0; j < nel; j++)
+    ctx->iData[1][j+1] = PData[j];
+  ierr = VecRestoreArray(P, &PData); CHKERRQ(ierr);
+
 
   // actual CitcomS operation
   assemble_grad_p( ctx->E, ctx->iData, ctx->oData, ctx->level );
 
+  ierr = VecGetArray(GP, &GPData); CHKERRQ(ierr);
+  for(j = 0; j < neq; j++)
+    GPData[j] = ctx->oData[1][j];
+  ierr = VecRestoreArray(GP, &GPData); CHKERRQ(ierr);
+#if 0
   VecGetOwnershipRange( GP, &low, &high );
   for( i = 1; i <= ctx->E->sphere.caps_per_proc; i++ ) {
     for( j = 0; j < neq; j++ ) {
@@ -301,7 +323,7 @@ PetscErrorCode MatShellMult_grad_p( Mat G, Vec P, Vec GP )
   }
   VecAssemblyBegin( GP );
   VecAssemblyEnd( GP );
-
+#endif
   PetscFunctionReturn(0);
 }
 



More information about the CIG-COMMITS mailing list