<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
Thanks for your kind replies. I will give a result after the test.<br>
<br>
<div class="moz-cite-prefix">On 2017年05月28日 19:32, Matthew Knepley
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAMYG4GmC8Wx5cxGUDe5OxPQ8RDdU1TvrCGJ_Z0HjkETfEkg8vw@mail.gmail.com">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Sun, May 28, 2017 at 1:49 AM, Dave
May <span dir="ltr"><<a
href="mailto:dave.mayhem23@gmail.com" target="_blank"
moz-do-not-send="true">dave.mayhem23@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><br>
<div class="gmail_quote">
<div>
<div class="h5">
<div>On Sun, 28 May 2017 at 08:31, leejearl <<a
href="mailto:leejearl@126.com" target="_blank"
moz-do-not-send="true">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>
</div>
<div>Yep.</div>
<span class="">
<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>
</span>
<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>
</div>
</blockquote>
<div><br>
</div>
<div>Dave is correct. However this usage completely misses
the point of Section. Section is a device for storing
indices into</div>
<div>ANY storage, not just Vec and IS. I would manage an
array of the structs that I allocate, and use the Section
to index into.</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div class="gmail_quote">
<div><br>
</div>
<div>Thanks,</div>
<div> Dave</div>
<span class="">
<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>
</span></div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div>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</div>
<div><br>
</div>
<div><a href="http://www.caam.rice.edu/%7Emk51/"
target="_blank" moz-do-not-send="true">http://www.caam.rice.edu/~mk51/</a><br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
李季
西北工业大学航空学院流体力学系
Phone: 17792092487
QQ: 188524324
</pre>
</body>
</html>