<div><br><div class="gmail_quote"><div>On Sun, 28 May 2017 at 08:31, leejearl <<a href="mailto:leejearl@126.com">leejearl@126.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, PETSc developer:<br>
<br>
I need to create a PetscSection with a struct. The struct is<br>
defined as follow,<br>
<br>
typedef struct<br>
{<br>
PetscReal x;<br>
PetscInt id;<br>
} testStruct;<br>
<br>
When I run the program, I got a wrong output as follow,<br>
<br>
Vec Object: 1 MPI processes<br>
type: seq<br>
2.<br>
4.94066e-324<br>
2.<br>
4.94066e-324<br>
2.<br>
4.94066e-324<br>
2.<br>
4.94066e-324<br>
2.<br>
4.94066e-324<br>
2.<br>
4.94066e-324<br>
2.<br>
4.94066e-324<br>
2.<br>
4.94066e-324<br>
<br>
But when I defined the struct as<br>
<br>
typedef struct<br>
{<br>
PetscReal x;<br>
PetscReal id;<br>
} testStruct;<br>
<br>
The output is ok. It seems that there is some wrong with the memories<br>
when I define the "id" as a PetscInt type.</blockquote><div><br></div><div>Yep.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
I can not find out the reasons, and any one can help me with it?</blockquote><div><br></div><div>The Vec object can only store quantities of type PetscScalar. It cannot store PetscInt's and it definitely cannot represent a mixture of PetscReal's and PetscInt's.</div><div><br></div><div><br></div><div>Thanks,</div><div> Dave</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> The<br>
source file "test.c" is attached.<br>
<br>
<br>
Thanks,<br>
<br>
leejearl<br>
<br>
</blockquote></div></div>