[petsc-users] Question about KSPSolve
Matthew Knepley
knepley at gmail.com
Fri Aug 2 15:28:36 CDT 2013
On Sat, Aug 3, 2013 at 1:27 AM, John Yawney <jyawney123 at gmail.com> wrote:
> 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?
>
The above looks correct, so I assume there is a problem with the definition
of the system. I would try putting
in an exact solution, or comparing a serial and parallel run.
Thanks,
Matt
> Thanks for any help and suggestions.
>
> All the best,
> John
>
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130803/76d76ebb/attachment.html>
More information about the petsc-users
mailing list