How to watch the variable of BlockVector type?

19 views
Skip to first unread message

Michael Lee

unread,
Aug 18, 2021, 9:18:24 PM8/18/21
to deal.II User Group
I want to check if I have system_rhs assembled correctly. Is there an easy way to watch the contents of this BlockVector during debugging?

          BlockVector<double> & system_rhs;
          system_rhs.reinit(dofs_per_block);

For normal vectors, I can use *((double(*)[10]) v.begin()), but it does not work for BlockVector. I'm using VS code.

Best,
Michael

Michael Li

unread,
Aug 18, 2021, 9:21:07 PM8/18/21
to dea...@googlegroups.com

Sorry, it seems to work using *((double(*)[20])residual.begin()).

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/9db1415e-812b-4825-8f73-eb7ed3866c17n%40googlegroups.com.

 

Wolfgang Bangerth

unread,
Aug 18, 2021, 10:37:19 PM8/18/21
to dea...@googlegroups.com
On 8/18/21 7:18 PM, Michael Lee wrote:
>
>           BlockVector<double> & system_rhs;
>           system_rhs.reinit(dofs_per_block);
>
> For normal vectors, I can use *((double(*)[10]) v.begin()), but it does not
> work for BlockVector. I'm using VS code.

Try *( (double(*)[10]) v.block(0).begin())

Best
W.


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

Michael Li

unread,
Aug 18, 2021, 10:47:33 PM8/18/21
to dea...@googlegroups.com

Yeah! .block(0) is essential. Without this, the data obtained is garbage!

 

Thanks for this great hint!

--

The deal.II project is located at http://www.dealii.org/

For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en

---

You received this message because you are subscribed to the Google Groups "deal.II User Group" group.

To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages