Fail to set up a custom pretty-printing for TrilinosWrappers::MPI::BlockVector

28 views
Skip to first unread message

Qing Yin

unread,
Sep 1, 2017, 3:08:54 AM9/1/17
to deal.II User Group
Dear all,

I use the deal.II pretty-printers and it works well for template types. But I found it can’t print some kinds of vectors in deall.II,
for example, TrilinosWrappers::MPI::BlockVector stokes_solution in step-31. I think the reason is that regular expression in deal.py is only used for template types.

In order to print readable format of this type, I try to create a python file just like the deal.py file.
I don’t known how to print the value of vectors for that type. But for test, I try to print the n_blocks(number of blocks).
So I change the regular expression and modify a class named BlockVectorPrinter.

Then I put test.py in ~/.gdbscripts, and add import test in .gdbinit. And I use info pretty-printer to check it.

However, when I debug the step-31 program, gdb doesn’t print the variable stokes_solution with pretty-printing. At the same time, the deal.II pretty-printer still works well. It confused me.

There are my questions:

  1. What’s wrong with my test pretty-printing file?
  2. How can we print the vectors of that type (TrilinosWrappers::MPI::BlockVector)?
  3. Inferior values that are strctures of some class can be accessed using the Python dictionary syntax, and how can we know the dictionary of a particular deal.II class?
  4. Is there any way to debug this GDB’s Python API?

The commands and results are as follows.

gdb ./build/step-31
b 1749
r

Then print the variables.

(gdb) print local_rhs
$1 = double[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}
(gdb) print local_dof_indices
$2 = std::vector of length 9, capacity 9 = {0, 0, 0, 0, 0, 0, 0, 0, 0}
(gdb) print stokes_solution
$3 = {
  <dealii::BlockVectorBase<dealii::TrilinosWrappers::MPI::Vector>> = {
    <dealii::Subscriptor> = {
      _vptr.Subscriptor = 0x7ffff7cf5e58 <vtable for dealii::TrilinosWrappers::MPI::BlockVector+16>,
      counter = 0,
      counter_map = std::map with 0 elements,
      object_info = 0x0
    },
    members of dealii::BlockVectorBase<dealii::TrilinosWrappers::MPI::Vector>:
    static supports_distributed_data = <optimized out>,
    components = std::vector of length 2, capacity 2 = {{
        <dealii::TrilinosWrappers::VectorBase> = {
          <dealii::Subscriptor> = {
            _vptr.Subscriptor = 0x7ffff7cf8d18 <vtable for dealii::TrilinosWrappers::MPI::Vector+16>,
            counter = 0,
            counter_map = std::map with 0 elements,
            object_info = 0x0
          },
          members of dealii::TrilinosWrappers::VectorBase:
          last_action = Zero,
          compressed = true,
---Type <return> to continue, or q <return> to quit---q
Quit

Any help or advise would be appreciated. Thank you!

Best,

Qing

mytest.py

Wolfgang Bangerth

unread,
Sep 1, 2017, 7:52:48 PM9/1/17
to dea...@googlegroups.com

Qing,

> I use the deal.II pretty-printers
> <http://www.dealii.org/developer/users/gdb.html> and it works well for
> template types. But I found it can’t print some kinds of vectors in
> deall.II,
> for example, |TrilinosWrappers::MPI::BlockVector stokes_solution| in
> step-31. I think the reason is that regular expression in |deal.py| is
> only used for template types.
>
> In order to print readable format of this type, I try to create a python
> file just like the |deal.py| file.
> I don’t known how to print the value of vectors for that type. But for
> test, I try to print the |n_blocks|(number of blocks).
> So I change the regular expression and modify a class named
> |BlockVectorPrinter|.
>
> Then I put |test.py| in ~/.gdbscripts, and add |import test| in
> |.gdbinit|. And I use |info pretty-printer| to check it.
>
> However, when I debug the step-31 program, gdb doesn’t print the
> variable |stokes_solution| with pretty-printing. At the same time, the
> deal.II pretty-printer still works well. It confused me.
>
> There are my questions:
>
> 1. What’s wrong with my test pretty-printing file?
> 2. How can we print the vectors of that type
> (TrilinosWrappers::MPI::BlockVector)?
> 3. Inferior values that are strctures of some class can be accessed
> using the Python |dictionary| syntax, and how can we know the
> |dictionary| of a particular deal.II class?
> 4. Is there any way to debug this GDB’s Python API?

I think that at the moment, we simply don't have pretty-printers for any
of the Trilinos wrappers. In order to write one, you'd have to know how
Trilinos stores the elements of such vectors -- which I'm not sure any
of us know, or even want to know (we like to treat Trilinos as a black
box). Any pretty printer for these classes would require knowing

I've found it difficult to debug the GDB pretty printers -- if you do
something wrong, you just get some non-descript error message on the GDB
console. There may be smarter approaches that I don't know; have you
tried searching the internet for ideas?

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Qing Yin

unread,
Sep 6, 2017, 11:39:03 AM9/6/17
to deal.II User Group, bang...@colostate.edu
Dear Dr. Bangerth,

Thanks for your reply. I also didn't find a good way to debug it.

Best,

Qing


在 2017年9月1日星期五 UTC-6下午5:52:48,Wolfgang Bangerth写道:
Reply all
Reply to author
Forward
0 new messages