<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 1/10/2012 4:39 PM, Jed Brown wrote:<br>
</div>
<blockquote
cite="mid:CAM9tzSnCCvDuK5g4K74Lmt4V8kP3U_z3e101T1QcZfEYPUroMQ@mail.gmail.com"
type="cite">MatSetValues() inserts logically dense blocks. You are
thinking of it as inserting a bunch of arbitrary (row,col,value)
but that's not how it works. Read the man page and look at any of
the examples.<br>
</blockquote>
<br>
If that's the case, is the 1st method I used the best way to insert
the matrix?<br>
<br>
In other words, I already have the A matrix and b vector in Fortran
matrix, used for solving Ax = b.<br>
<br>
Is there a better or more efficient way of inserting the Fortran
matrix into PETSC's matrix?<br>
<br>
Thanks<br>
<blockquote
cite="mid:CAM9tzSnCCvDuK5g4K74Lmt4V8kP3U_z3e101T1QcZfEYPUroMQ@mail.gmail.com"
type="cite"><br>
<div class="gmail_quote">
On Mon, Oct 1, 2012 at 10:36 AM, TAY wee-beng <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:zonexo@gmail.com"
target="_blank">zonexo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Hi,<br>
<br>
I'm trying to insert values into my PETSc matrix using
MatSetValues.<br>
<br>
I tried using:<br>
<br>
<i>do ijk=ijk_xyz_sta,ijk_xyz_end</i><i><br>
</i><i><br>
</i><i> II = ijk - 1 !Fortran shift to 0-based</i><i><br>
</i><i> </i><i><br>
</i><i> call
MatSetValues(A_semi_xyz,1,II,7,int_semi_xyz(ijk,1:7),semi_mat_xyz(ijk,1:7),INSERT_VALUES,ierr)</i><i><br>
</i><i><br>
</i><i>end do</i><br>
<br>
where ijk_xyz_sta/ijk_xyz_end are the starting/end index<br>
<br>
int_semi_xyz(ijk,1:7) stores the 7 column global indices<br>
<br>
semi_mat_xyz has the corresponding values.<br>
<br>
This work well but I'm trying to call MatSetValues in 1
statement, it failed. I tried:<br>
<br>
<i>do ijk = 1,ijk_xyz_end-ijk_xyz_sta</i><i><br>
</i><i><br>
</i><i> rows(ijk) = ijk_xyz_sta + ijk - 1</i><i> !to
get row's global indices<br>
</i><i> </i><i><br>
</i><i>end do</i><i><br>
</i><i><br>
</i><i>call
MatSetValues(A_semi_xyz,ijk_xyz_end-ijk_xyz_sta,rows,7,int_semi_xyz(ijk_xyz_sta+1:ijk_xyz_end,1:7),semi_mat_xyz(ijk_xyz_sta+1:ijk_xyz_end,1:7),INSERT_VALUES,ierr)</i><br>
<br>
but when I use MatView, the values are in the wrong
locations.<br>
<br>
May I know what's wrong?<br>
<br>
Thanks<span class="HOEnZb"><font color="#888888"><br>
<pre cols="72">--
Yours sincerely,
TAY wee-beng</pre>
</font></span></div>
</blockquote>
</div>
<br>
</blockquote>
<br>
</body>
</html>