[petsc-users] Question about KSPSolve

John Yawney jyawney123 at gmail.com
Fri Aug 2 12:27:10 CDT 2013


Good Afternoon Everyone,

I'm using PETSc to solve some linear systems in my ocean model. Currently
I'm using the KSPSolve environment with 4 MPI processors. I've established
the matrix A and the RHS b and confirmed that everything looks correct
using VecView and MatView. Here are some code snippets that show the basic
steps I took.

-------------------------------------------------------------------------
*Assembling A:*
MatConvert(matLaplacianX, MATSAME, MAT_INITIAL_MATRIX, &matLaplacian);
MatAssemblyBegin(matLaplacian, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(matLaplacian, MAT_FINAL_ASSEMBLY);

MatAXPY(matLaplacian, 1.0, matLaplacianY, DIFFERENT_NONZERO_PATTERN);
MatAssemblyBegin(matLaplacian, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(matLaplacian, MAT_FINAL_ASSEMBLY);

MatAXPY(matLaplacian, 1.0, matLaplacianZ, DIFFERENT_NONZERO_PATTERN);
MatAssemblyBegin(matLaplacian, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(matLaplacian, MAT_FINAL_ASSEMBLY);

*Defining KSP environment:*
KSPCreate(MPI_COMM_WORLD, &m_inksp);
KSPSetOperators(m_inksp, matLaplacian, matLaplacian,
DIFFERENT_NONZERO_PATTERN);
KSPSetType(m_inksp, KSPGMRES);
KSPSetInitialGuessNonzero(m_inksp,PETSC_TRUE);
KSPSetFromOptions(m_inksp);
KSPSetUp(m_inksp);

*Defining RHS vector:*
VecCreateMPI(MPI_COMM_WORLD, nLocalElements, nGlobalElements, &m_vecRHS);

*Solving the linear system:*
VecAssemblyBegin(m_vecRHS);
VecAssemblyEnd(m_vecRHS);
KSPSolve(m_inksp, m_vecRHS, m_vecPressure);
-------------------------------------------------------------------------

If I modify my problem to consider a 2D (x-z) domain with flat bottom
topography and I set the initial velocity fields to 0 and a constant
density of 1025 throughout, then if I compute a number of time steps I get
computational artifacts at the beginning and end locations of each block. I
should also mention I'm only splitting up the domain into sub-blocks in the
x direction currently. After about 10 time steps, the min density is off by
about 1E-8 but only at these locations. I've attached a figure to
demonstrate the errors.

Are there ways for me to remove these errors? Should I be looking at the DM
manual pages?

Thanks for any help and suggestions.

All the best,
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130802/ba64a1c6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MPICommError - TimeStep10.jpg
Type: image/jpeg
Size: 74936 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130802/ba64a1c6/attachment-0001.jpg>


More information about the petsc-users mailing list