On Sun, 28 May 2017 at 08:31, leejearl <leeje...@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.


Thanks,
 Dave

The
> source file "test.c" is attached.
>
>
> Thanks,
>
> leejearl
>
>

Reply via email to