Then it is not MatCreate() causing your SEGV.<br><br> Matt<br><br><div class="gmail_quote">On Mon, Dec 21, 2009 at 5:11 PM, Umut Tabak <span dir="ltr"><<a href="mailto:u.tabak@tudelft.nl">u.tabak@tudelft.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Matthew Knepley wrote:<div class="im"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Mon, Dec 21, 2009 at 5:01 PM, Umut Tabak <<a href="mailto:u.tabak@tudelft.nl" target="_blank">u.tabak@tudelft.nl</a> <mailto:<a href="mailto:u.tabak@tudelft.nl" target="_blank">u.tabak@tudelft.nl</a>>> wrote:<br>
<br>
Dear all,<br>
<br>
I was trying to wrap around some Petsc code into a class, so that<br>
there is a neat interface and implementation, I got into a problem<br>
at the very beginning and did not understand the reason maybe some<br>
of you could help me to understand this.<br>
<br>
I have a Matrix A in the private section of my simple class.<br>
<br>
And I would like to create this matrix inside the class ctor.<br>
Whenever I call the MatCreate function I get a segmentation fault with<br>
<br>
<br>
Without seeing the code, we cannot say anything, but I bet you misdeclared A.<br>
<br>
<br>
</blockquote></div>
Dear Matthew,<br>
<br>
Here is my simple starter design,<br>
8 class petscMatrix<br>
9 {<br>
10 public:<br>
11 petscMatrix();<br>
12 petscMatrix(PetscInt, PetscInt, char) throw(std::runtime_error);<br>
13 Mat* assignSubMatrix();<br>
14 int createMatrix();<br>
15 private:<br>
16 Mat A; // Operation matrix<br>
17 PetscInt m,n; // the row and column count<br>
18 // of the matrix<br>
19 char matType;<br>
20<br>
21};<br>
<br>
<br>
And its implementation is:<br>
<br>
15 petscMatrix::petscMatrix(PetscInt rowSz, PetscInt colSz, char t) throw(runtime_error)<br>
16 {<br>
17 try{<br>
18 switch(t)<br>
19 {<br>
20 case('d'): // dense<br>
21 matType = t;<br>
22 m = rowSz;<br>
23 n = colSz;<br>
24 case('D'): // dense<br>
25 matType = t;<br>
26 m = rowSz;<br>
27 n = colSz;<br>
28 case('s'): //sparse<br>
29 matType = t;<br>
30 m = rowSz;<br>
31 n = colSz;<br>
32 MatCreate(MPI_COMM_SELF, &A);<br>
33 MatSetSizes(A, m, n, 0, 0);<br>
34 MatSetType(A,MATSEQAIJ);<br>
35 case('S'): //sparse<br>
36 matType = t;<br>
37 m = rowSz;<br>
38 n = colSz;<br>
39 default:<br>
40 throw runtime_error("Matrix type not recognized\nMatrix not initialized\nExiting...");<br>
41 }<br>
42 }<br>
43 catch(runtime_error &e)<br>
44 {<br>
45 cout << e.what() << endl;<br>
46 exit(1);<br>
47 }<br>
48 }<br>
<br>
Maybe I am too tired, most probably, there is sth easy that I am missing...<br>
</blockquote></div><br><br clear="all"><br>-- <br>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener<br>