Note that PETSc is designed to hide the details of the implementations from you (It's in C, but uses the techniques of Object-Oriented programming that you might be more familiar with in C++), so normal use would never require the user to know anything about the way PETSc objects represent data. In cases cases where access to lower-level representations of the data is useful, there is an interface provided to do this, as with Vec[Get/Set]Array (see the tutorials included in the src/ tree for many examples - if you look at the bottom of the link Anton provided, you'll see a handy list of links to ones that use that particular function).

The definitions of the functions in VecOps will depend on the implementation of Vec being used, and this is in general only known at runtime (which is a great advantage, as you can use command line arguments to change which implementation is used without recompiling anything). The various function definitions should be found in src/vec/vec/impls and subdirectories.

So, while it is possible to access the data stored in an object and print it and so on, you'd have to include a private header and it'd be a bit ugly. Perhaps a better way to poke around is to use a debugger like gdb or lldb (or something else built into your IDE if you're using one) - that should be quicker, and not require to you to spend time recompiling things.




On 9/28/14 1:57 PM, Parvathi M.K wrote:
I want to access the data stored in the vec object directly without using any functions. Is this possible?

I tried using something like p->hdr._ in a printf statement (where p is a vector). I wish to know which element of the _p_Vec structure stores the data.

On Sun, Sep 28, 2014 at 4:45 PM, Parvathi M.K <[email protected] <mailto:[email protected]>> wrote:

    Hey,
    I am fairly new to PetSc. I was just curious as to how you can
    directly access the data stored in a Petsc object, say a vector
    without using VecGetValues().

    I've gone through the header files, petscimpl.h and vecimpl.h
    which contain the definitions of the PetscObject and Vec
    structures. I cannot figure out which member of the struct holds
    the Vector data entered using VecSet(). Also, I could not find the
    definitions of the functions in VecOps. Could someone tell me
    where I can find these function definitions?

    Thank you :)

    Parvathi



Reply via email to