[cig-commits] [commit] rajesh-petsc, rajesh-petsc-schur: Added velocity and pressure vector initialization to solve_Ahat_p_fhat_PETSc_Schur (9f568ea)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Nov 5 19:02:47 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 9f568ea33c03b53ec3e9a9aa6c1dd0b6cddfa180
Author: Rajesh Kommu <rajesh.kommu at gmail.com>
Date: Wed Aug 20 12:36:33 2014 -0700
Added velocity and pressure vector initialization to solve_Ahat_p_fhat_PETSc_Schur
>---------------------------------------------------------------
9f568ea33c03b53ec3e9a9aa6c1dd0b6cddfa180
bin/regional_input.sample | 4 ++--
lib/Stokes_flow_Incomp.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/bin/regional_input.sample b/bin/regional_input.sample
index 4834ddf..5c7e236 100644
--- a/bin/regional_input.sample
+++ b/bin/regional_input.sample
@@ -1,5 +1,5 @@
-use_petsc=off
-petsc_schur=off
+use_petsc=on
+petsc_schur=on
# specify output files
datadir="/home/rkk/scratch"
diff --git a/lib/Stokes_flow_Incomp.c b/lib/Stokes_flow_Incomp.c
index defeb0a..037346b 100644
--- a/lib/Stokes_flow_Incomp.c
+++ b/lib/Stokes_flow_Incomp.c
@@ -222,12 +222,58 @@ static void solve_Ahat_p_fhat(struct All_variables *E,
static PetscErrorCode solve_Ahat_p_fhat_PETSc_Schur(struct All_variables *E,
double **V, double **P, double **F, double imp, int *steps_max)
{
+ int i, npno, neq, lev, nel;
PetscErrorCode ierr;
Mat S;
+ Vec FF, PVec, VVec;
+ PetscReal *P_data, *V_data;
+
+ nel = E->lmesh.nel;
+ npno = E->lmesh.npno;
+ neq = E->lmesh.neq;
+ lev = E->mesh.levmax;
+
+ // Create the force Vec
+ ierr = VecCreateMPI( PETSC_COMM_WORLD, neq+1, PETSC_DECIDE, &FF );
+ CHKERRQ(ierr);
+ double *FF_data;
+ ierr = VecGetArray( FF, &FF_data ); CHKERRQ( ierr );
+ for( i = 0; i < neq; i++ )
+ FF_data[i] = F[1][i];
+ ierr = VecRestoreArray( FF, &FF_data ); CHKERRQ( ierr );
+
+
+ // create the pressure vector and initialize it to zero
+ ierr = VecCreateMPI( PETSC_COMM_WORLD, nel, PETSC_DECIDE, &PVec );
+ CHKERRQ(ierr);
+ ierr = VecSet( PVec, 0.0 ); CHKERRQ( ierr );
+
+ // create the velocity vector and copy contents of V into it
+ ierr = VecCreateMPI( PETSC_COMM_WORLD, neq+1, PETSC_DECIDE, &VVec );
+ CHKERRQ(ierr);
+ ierr = VecGetArray( VVec, &V_data ); CHKERRQ( ierr );
+ for( i = 0; i <= neq; i++ )
+ V_data[i] = V[1][i];
+ ierr = VecRestoreArray( VVec, &V_data ); CHKERRQ( ierr );
+
+ /* Create the Schur complement */
ierr = MatCreateSchurComplement(E->K,E->K,E->G,E->D,PETSC_NULL, &S);
CHKERRQ(ierr);
+ /* carry out the actual solution */
+
+ // copy the values of VVec and PVec into V and P
+ ierr = VecGetArray( VVec, &V_data ); CHKERRQ( ierr );
+ for( i = 0; i <= neq; i++ )
+ V[1][i] = V_data[i];
+ ierr = VecRestoreArray( VVec, &V_data ); CHKERRQ( ierr );
+
+ ierr = VecGetArray( PVec, &P_data ); CHKERRQ( ierr );
+ for( i = 0; i < nel; i++ )
+ P[1][i+1] = P_data[i];
+ ierr = VecRestoreArray( PVec, &P_data ); CHKERRQ( ierr );
+
PetscFunctionReturn(0);
}
More information about the CIG-COMMITS
mailing list