[cig-commits] [commit] rajesh-petsc: Added general_stokes_solver_teardown() method for PETSc related cleanup (8969fe9)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Mon Sep 8 11:08:41 PDT 2014
Repository : https://github.com/geodynamics/citcoms
On branch : rajesh-petsc
Link : https://github.com/geodynamics/citcoms/compare/23c90a718846823e34ce57607763b0f1d4489c7c...cbfba74b3be02b34963818a3f901604436fb8111
>---------------------------------------------------------------
commit 8969fe9f76a7f903d63b5e01fa372cac8803dba1
Author: Rajesh Kommu <rajesh.kommu at gmail.com>
Date: Mon Sep 8 09:48:58 2014 -0700
Added general_stokes_solver_teardown() method for PETSc related cleanup
>---------------------------------------------------------------
8969fe9f76a7f903d63b5e01fa372cac8803dba1
bin/Citcom.c | 22 ++++++++++++++++++++++
lib/Drive_solvers.c | 23 +++++++++++++++++++++++
lib/prototypes.h | 3 +++
3 files changed, 48 insertions(+)
diff --git a/bin/Citcom.c b/bin/Citcom.c
index 84fe2da..f2bdb1a 100644
--- a/bin/Citcom.c
+++ b/bin/Citcom.c
@@ -137,6 +137,14 @@ int main(argc,argv)
post_processing(E);
(E->problem_output)(E, E->monitor.solution_cycles);
+#ifdef USE_PETSC
+ /*
+ * cleanup all the PETSc related initializations done in
+ * general_stokes_solver_setup()
+ */
+ general_stokes_solver_teardown(E);
+#endif
+
citcom_finalize(E, 0);
}
@@ -180,6 +188,13 @@ int main(argc,argv)
if(E->control.tracer==1)
tracer_advection(E);
(E->problem_output)(E, E->monitor.solution_cycles);
+#ifdef USE_PETSC
+ /*
+ * cleanup all the PETSc related initializations done in
+ * general_stokes_solver_setup()
+ */
+ general_stokes_solver_teardown(E);
+#endif
citcom_finalize(E, 0);
}
@@ -295,6 +310,13 @@ int main(argc,argv)
fprintf(E->fp,"Average cpu time taken for velocity step = %f\n",
cpu_time_on_vp_it/((float)(E->monitor.solution_cycles-E->control.restart)));
}
+#ifdef USE_PETSC
+ /*
+ * cleanup all the PETSc related initializations done in
+ * general_stokes_solver_setup()
+ */
+ general_stokes_solver_teardown(E);
+#endif
citcom_finalize(E, 0);
return(0);
diff --git a/lib/Drive_solvers.c b/lib/Drive_solvers.c
index d85b1e5..c66ed45 100644
--- a/lib/Drive_solvers.c
+++ b/lib/Drive_solvers.c
@@ -156,6 +156,29 @@ void general_stokes_solver_setup(struct All_variables *E)
#endif
}
+#ifdef USE_PETSC
+void general_stokes_solver_teardown(struct All_variables *E)
+{
+ KSPDestroy(&E->ksp);
+
+ MatDestroy(&E->K);
+ MatDestroy(&E->G);
+ MatDestroy(&E->D);
+ MatDestroy(&E->DC);
+
+ PetscFree( E->mtx_del2_u.iData[1] );
+ PetscFree( E->mtx_del2_u.oData[1] );
+ PetscFree( E->mtx_grad_p.iData[1] );
+ PetscFree( E->mtx_grad_p.oData[1] );
+ PetscFree( E->mtx_div_u.iData[1] );
+ PetscFree( E->mtx_div_u.oData[1] );
+ PetscFree( E->mtx_div_rho_u.iData[1] );
+ PetscFree( E->mtx_div_rho_u.oData[1] );
+ PetscFree( E->pcshell_ctx.V[1] );
+ PetscFree( E->pcshell_ctx.RR[1] );
+}
+#endif
+
void general_stokes_solver(struct All_variables *E)
{
void solve_constrained_flow_iterative();
diff --git a/lib/prototypes.h b/lib/prototypes.h
index 6ad3948..9559d47 100644
--- a/lib/prototypes.h
+++ b/lib/prototypes.h
@@ -97,6 +97,9 @@ void hc_ludcmp_3x3(double [3][3], int, int *);
void hc_lubksb_3x3(double [3][3], int, int *, double *);
/* Drive_solvers.c */
void general_stokes_solver_setup(struct All_variables *);
+#ifdef USE_PETSC
+void general_stokes_solver_teardown(struct All_variables *);
+#endif
void general_stokes_solver(struct All_variables *);
int need_visc_update(struct All_variables *);
int need_to_iterate(struct All_variables *);
More information about the CIG-COMMITS
mailing list