Timo,

" What I have done in several codes (and what is used in ASPECT), is to 
always create block matrices and vectors but to put all DoFs into a single 
block when a direct solver is used. This decision can be made at rintime. 
Inside the solve routine you can just access block_matrix.block(0,0), which 
is a SparseMatrix. Same for the vector. This way, there are no different 
code paths, different types, or copies involved. "

In terms of readability, this sounds like the best solution. 

My motivation to use block structures even for direct solvers is to compute
norms of the pressure or the velocity, if we talk about the Stokes system.
Or in general, having access to the individual blocks to write them to 
files,...

If I am not mistaken, you create a nested finite element system with one 
block

FESystem<3>    feVelocity( FE_Q<3>(degree), 3 );
FE_DGQ<3>       fePressure(degree-1);
FESystem<3>    nestedFE ( feVelocity, 1, fePressure, 1 ); 

resulting in a 1x1 block system.
But it is not clear to me how to compute the norms of velocity and pressure 
in that case.
So far, I used a Block indices object as returned by 
DoFTools::count_dofs_per_fe_block()
since I compute the l2-norm only of the unconstrained DoFs. 

That said, how do you access the velocity and pressure block when working 
with direct solvers?

Thank you,
Simon
Timo Heister schrieb am Dienstag, 19. Dezember 2023 um 20:02:30 UTC+1:

> What I have done in several codes (and what is used in ASPECT), is to 
> always create block matrices and vectors but to put all DoFs into a single 
> block when a direct solver is used. This decision can be made at rintime. 
> Inside the solve routine you can just access block_matrix.block(0,0), which 
> is a SparseMatrix. Same for the vector. This way, there are no different 
> code paths, different types, or copies involved.
>
> --
> Timo Heister
> http://www.math.clemson.edu/~heister/
> ------------------------------
> *From:* dea...@googlegroups.com <dea...@googlegroups.com> on behalf of 
> Wolfgang Bangerth <bang...@colostate.edu>
> *Sent:* Monday, December 18, 2023 4:37:34 PM
> *To:* dea...@googlegroups.com <dea...@googlegroups.com>
> *Subject:* Re: [deal.II] construct TrilinosWrappers::SparseMatrix from 
> TrilinosWrappers::BlockSparseMatrix to use Amesos direct solver 
>  
> This Message Is From An External Sender: Use caution when opening links or 
> attachments if you do not recognize the sender.
>
>
> On 12/18/23 12:44, Simon wrote:
> >
> > I use a BlockSolver for the solution and right hand side of the
> > linear system to compute the various norms (non-linear solver) of the
> > the individual blocks. For a direct solver, I would now use a
> > SparseMatrix as matrix type and a BlockVector as vector type. At each
> > solve, I convert the BlockVector to a standard Vector, which I guess
> > is not too expensive. This mix (SparseMatrix and BlockVector) should
> > not cause any undue problems, right? Or would you not recommend
> > this?
> No. This seems like a reasonable approach to me.
> Best
>   W.
>
> --
> The deal.II project is located at 
> https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.dealii.org%2F&data=05%7C02%7Cheister%40clemson.edu%7Cb26c1543ea3f4a770d1a08dc00118fcd%7C0c9bf8f6ccad4b87818d49026938aa97%7C0%7C0%7C638385322953674220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=FCQhyskq54Y%2B9Uc7oyauIeXMsI5CLzO12RE%2FCDG1w3Y%3D&reserved=0
>  
> <http://www.dealii.org/>
> For mailing list/forum options, see 
> https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fforum%2Fdealii%3Fhl%3Den&data=05%7C02%7Cheister%40clemson.edu%7Cb26c1543ea3f4a770d1a08dc00118fcd%7C0c9bf8f6ccad4b87818d49026938aa97%7C0%7C0%7C638385322953674220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=QKshKRkLcezx3WBxZW4FajigvudlynOE6GClmS9nNnY%3D&reserved=0
>  
> <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://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdealii%2F15994792-761a-4899-b7e6-af2fc6ba2932%2540colostate.edu&data=05%7C02%7Cheister%40clemson.edu%7Cb26c1543ea3f4a770d1a08dc00118fcd%7C0c9bf8f6ccad4b87818d49026938aa97%7C0%7C0%7C638385322953674220%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=Lmjub869SyEbNQ5DTAN4RNnzG41%2B2XEWpPs6s97c9OU%3D&reserved=0
>  
> <https://groups.google.com/d/msgid/dealii/15994792-761a-4899-b7e6-af2fc6ba2932%40colostate.edu>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/e5655ba8-e55f-4995-9adf-3c41badeac80n%40googlegroups.com.

Reply via email to