[petsc-users] Best way to solve eqns for Runge Kutta 3rd order schemes
TAY wee-beng
zonexo at gmail.com
Fri Jul 1 17:19:37 CDT 2011
Hi,
I need to solve the momentum eqns of my CFD code which uses the RK3 scheme.
I need to solve the x and y momentum eqns 3 times per time step.
Hence, for each sub time step, I have 2 linear eqns for x and y, which I
solve using PETSc.
The off-diagonal elements of the matrix are different for each substep.
But the off-diagonal elements for the same substep is the same for
different time. ie
Off-diagonal elements (total 4) of the matrix of substep 1 at t=1 is the
same as that of substep 1 at t=2,3....
Similarly, off-diagonal elements of the matrix of substep 2 at t=1 is
the same as that of substep 2 at t=2,3....
Moreover, the off-diagonal elements of the matrix of substep 1,2 and 3
differs by a fixed factor ie
if not considering the diagonal elements, matrix A(substep 1) ==
k1*A(substep 2) = k2*A(substep 3), where k1, k2 are constants
However, the diagonal elements of the matrix changes all the time,
between substeps and between time steps.
The RHS vector also changes all the time.
I am not too sure what is the best way (most efficient, fastest) to
solve these linear equations.
Currently, I write in the matrix at each substep. I doubt this is the
best. I am thinking of:
1. Instead of creating 2 matrices for x and y, I create 6, 2 for each
substep. The off-diagonal elements are always the same. I only use
MatDiagonalSet to change the diagonal elements for each matrix at
different time steps
or
2. I only create 2 matrices. At each substep, I multiply the matrices by
a constant, so that off-diagonal elements at one substep is equal to
that of another. Then I use MatDiagonalSet to do the same as above.
Which is a better mtd? Or is there other better mtds?
My main concern is to save time.
Moreover, how often do I have to do call:
call KSPCreate(MPI_COMM_WORLD,ksp_semi_x,ierr)
call KSPGetPC(ksp_semi_x,pc_semi_x,ierr)
ksptype=KSPBCGS
call KSPSetType(ksp_semi_x,ksptype,ierr)
call KSPSetFromOptions(ksp_semi_x,ierr)
tol=1.e-5
call
KSPSetTolerances(ksp_semi_x,tol,PETSC_DEFAULT_DOUBLE_PRECISION,PETSC_DEFAULT_DOUBLE_PRECISION,PETSC_DEFAULT_INTEGER,ierr)
Thank you very much for the help!
--
Yours sincerely,
TAY wee-beng
More information about the petsc-users
mailing list