[petsc-users] a question about PetscSectionCreate

leejearl leejearl at 126.com
Sun May 28 21:57:05 CDT 2017


Thanks for your kind replies. I will give a result after the test.

On 2017年05月28日 19:32, Matthew Knepley wrote:
> On Sun, May 28, 2017 at 1:49 AM, Dave May <dave.mayhem23 at gmail.com 
> <mailto:dave.mayhem23 at gmail.com>> wrote:
>
>
>     On Sun, 28 May 2017 at 08:31, leejearl <leejearl at 126.com
>     <mailto:leejearl at 126.com>> wrote:
>
>         Hi, PETSc developer:
>
>              I need to create a PetscSection with a struct. The struct is
>         defined as follow,
>
>             typedef struct
>             {
>                PetscReal x;
>                PetscInt id;
>             } testStruct;
>
>             When I run the program, I got a wrong output as follow,
>
>             Vec Object: 1 MPI processes
>            type: seq
>         2.
>         4.94066e-324
>         2.
>         4.94066e-324
>         2.
>         4.94066e-324
>         2.
>         4.94066e-324
>         2.
>         4.94066e-324
>         2.
>         4.94066e-324
>         2.
>         4.94066e-324
>         2.
>         4.94066e-324
>
>         But when I defined the struct as
>
>             typedef struct
>             {
>                PetscReal x;
>                PetscReal id;
>             } testStruct;
>
>         The output is ok. It seems that  there is some wrong with the
>         memories
>         when I define the "id" as a PetscInt type.
>
>
>     Yep.
>
>
>
>         I can not find out the reasons, and any one can help me with it?
>
>
>     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.
>
>
> Dave is correct. However this usage completely misses the point of 
> Section. Section is a device for storing indices into
> 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.
>
>    Matt
>
>
>     Thanks,
>      Dave
>
>         The
>         source file "test.c" is attached.
>
>
>         Thanks,
>
>         leejearl
>
>
>
>
> -- 
> What most experimenters take for granted before they begin their 
> experiments is infinitely more interesting than any results to which 
> their experiments lead.
> -- Norbert Wiener
>
> http://www.caam.rice.edu/~mk51/ <http://www.caam.rice.edu/%7Emk51/>

-- 
李季
西北工业大学航空学院流体力学系
Phone: 17792092487
QQ: 188524324

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170529/bb28b1eb/attachment.html>


More information about the petsc-users mailing list