Dear Alex, 

if you send me your github user, I’ll give you access to a code that does 
exactly what you are trying to do, so that you can get some inspiration on how 
to assemble the coupling matrices.

There is an open PR (the review has been stalling for some time on that) 
https://github.com/dealii/dealii/pull/15773 that tackle exactly this use case. 

Let me know if you need some assistance. 

L.

> On 8 Nov 2023, at 05:02, Wolfgang Bangerth <[email protected]> wrote:
> 
> 
> Alex:
> 
> > [...]
> 
> I think everything up to this point looks reasonable.
> 
>> From what I can see, the system_matrix looks right with n_blocks = 2 and   
>> start_indices = {0, 24, 72}, as expected.
>> Next, I run through the Assemble_System() to create a local cell matrix. I 
>> start with the Solid elements and cell_matrix_sld. I'm skipping the 
>> calculation of the cell matrix for brevity's sake.
>> for (const auto &cell : dof_handler_sld.active_cell_iterators())
>>     {
>>     // *** Placeholder for calculating cell_matrix_sld, a 24x24 matrix ***
>>     cell->get_dof_indices(local_dof_indices_sld);
>>     // Add the cell matrix to the system matrix
>>     for (unsigned int i = 0; i < dofs_per_cell_sld; ++i)
>>           for (unsigned int j = 0; j < dofs_per_cell_sld; ++j)
>>             system_matrix.add(local_dof_indices_sld[i],
>>                               local_dof_indices_sld[j],
>>                               cell_matrix_sld(i, j));
>>     }  // end of cell loop
>> The bit of code 'system_matrix.add(...)' works for when i=0 and j=0, but 
>> fails on the next loop when j=1.  I get this error:
> 
> The issue here is that you're indexing into the *global* matrix with the 
> indices of only one of the DoFHandler objects. That can't go well. It 
> *should* work if you do the indexing only in the matrix block that 
> corresponds to dof_handler_sld:
> 
>            system_matrix.block(block_index_sld, block_index_sld)
>                         .add(local_dof_indices_sld[i],
>                              local_dof_indices_sld[j],
>                              cell_matrix_sld(i, j));
> 
> where you define block_index_sld somewhere to either be zero or one.
> 
> In your case, this won't work yet because you hadn't built the sparsity 
> pattern yet. You can do that the same way:
> 
>  DoFTools::make_sparsity_pattern(dof_handler_sld,
>                           block_dsp.block(block_index_sld, block_index_sld));
> 
> Best
> W.
> 
> -- 
> ------------------------------------------------------------------------
> Wolfgang Bangerth          email:                 [email protected]
>                           www: http://www.math.colostate.edu/~bangerth/
> 
> 
> -- 
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/dealii/9a890d55-91f6-ec16-98be-acdb730919d3%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/8FA5C3E5-1317-43A0-B1CB-C30CBDA3E786%40gmail.com.

Reply via email to