[petsc-users] How to pass the parameters for KSP
vedaprakash subramanian
vedaprakashsubramanian at gmail.com
Wed Oct 6 21:26:13 CDT 2010
Can anyone tell me whether the concept I understood is correct or not.
If I am having a MATLAB function func(Matrix A, Vector x, Vector b, Matrix
Q, Matrix M, int max_it, int tol, Vec* sol, int* err, int* iter, int* flag)
to be converted into a KSP solver, then I have to do these following
steps.
1. In KSPSetUp_func(KSP ksp), initialize KSPDefaultGetWork(ksp,11); //
This tells the KSP that it is going to take 11 arguments
2. In KSPSolve_func(KSP ksp), declare
Mat A, Q, M;
Vec x, b, *sol;
PetscInt max_it, *flag, *iter;
PetscScalar tol, *err;
A = ksp->work[0];
x = ksp->work[1];
b = ksp->work[2];
Q = ksp->work[3];
M = ksp->work[4];
max_it = ksp->work[5];
tol = ksp->work[6];
*sol = ksp->work[7];
*err = ksp->work[8];
*iter = ksp->work[9];
*flag = ksp->work[10];
------------------------------
Is the above said is correct. Is that the way to get the arguments of the
KSPSolve.
Moreover, I have a doubt. What are these variables that are been used in
cg.c
stored_max_it = ksp->max_it;
X = ksp->vec_sol;
B = ksp->vec_rhs;
Where are these variables (ksp->max_it, ksp->vec_sol and ksp->vec_rhs)
getting initialized.
-Vedaprakash
On Wed, Oct 6, 2010 at 7:56 PM, vedaprakash subramanian <
vedaprakashsubramanian at gmail.com> wrote:
> I need my KSP to take in Tolerence, flag, err, 3 matrices, right hand side
> vector. How can I make it to take all the parameters.
>
> On Mon, Sep 20, 2010 at 11:00 AM, <petsc-users-request at mcs.anl.gov> wrote:
>
>> Send petsc-users mailing list submissions to
>> petsc-users at mcs.anl.gov
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>> https://lists.mcs.anl.gov/mailman/listinfo/petsc-users
>> or, via email, send a message with subject or body 'help' to
>> petsc-users-request at mcs.anl.gov
>>
>> You can reach the person managing the list at
>> petsc-users-owner at mcs.anl.gov
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of petsc-users digest..."
>>
>>
>> Today's Topics:
>>
>> 1. How to pass the parameters for KSP (vedaprakash subramanian)
>> 2. Re: How to pass the parameters for KSP (Barry Smith)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Sun, 19 Sep 2010 19:05:48 -0600
>> From: vedaprakash subramanian <vedaprakashsubramanian at gmail.com>
>> Subject: [petsc-users] How to pass the parameters for KSP
>> To: petsc-users at mcs.anl.gov
>> Message-ID:
>> <AANLkTinjiGMTMVB1yVx6JEvPhjGi_=T+QY6HK7wnHgOa at mail.gmail.com<T%2BQY6HK7wnHgOa at mail.gmail.com>
>> >
>> Content-Type: text/plain; charset="iso-8859-1"
>>
>> I am converting a MATLAB function into a KSP solver. I am doing it similar
>> to BiCGStab. But I wanted to know how to pass the arguments of the
>> function
>> into KSP solver.
>>
>> Thanks,
>> Vedaprakash
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <
>> http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100919/9d902e74/attachment-0001.htm
>> >
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Sun, 19 Sep 2010 21:49:47 -0500
>> From: Barry Smith <bsmith at mcs.anl.gov>
>> Subject: Re: [petsc-users] How to pass the parameters for KSP
>> To: PETSc users list <petsc-users at mcs.anl.gov>
>> Message-ID: <27B820EF-3A6A-424B-8A43-2A43E82089B3 at mcs.anl.gov>
>> Content-Type: text/plain; charset=us-ascii
>>
>>
>> What arguments? Do you mean the right hand side x and the matrix? Or do
>> you mean parameters like the relative tolerance in convergence?
>>
>> See src/ksp/ksp/examples/tutorials/ex1.c for a simple example.
>>
>> Barry
>>
>> On Sep 19, 2010, at 8:05 PM, vedaprakash subramanian wrote:
>>
>> > I am converting a MATLAB function into a KSP solver. I am doing it
>> similar to BiCGStab. But I wanted to know how to pass the arguments of the
>> function into KSP solver.
>> >
>> > Thanks,
>> > Vedaprakash
>>
>>
>>
>> ------------------------------
>>
>> _______________________________________________
>> petsc-users mailing list
>> petsc-users at mcs.anl.gov
>> https://lists.mcs.anl.gov/mailman/listinfo/petsc-users
>>
>>
>> End of petsc-users Digest, Vol 21, Issue 32
>> *******************************************
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101006/b35bcdb0/attachment.htm>
More information about the petsc-users
mailing list