Selecting DOFs on a patch of cells

39 views
Skip to first unread message

Sudip Kunda

unread,
Jul 30, 2025, 7:25:56 PM7/30/25
to deal.II User Group
Hello all,

I am trying to figure out the correct way to use the function DoFTools::get_dofs_on_patch documented here. I have attached a bit of code to this message (test.cc) showing a simple version of what I am attempting.

In test.cc, I am making a 2D unit square domain divided into 4 equal cells. I am trying to select the DOFs of the two cells in the domain whose centers lie to the left of the line x=0.5. I have set up a scalar FE system. When working correctly, this code should select 6 DOFs.

My understanding of the error message is that the type of element in the std::vector I am passing to get_dofs_on_patch does not match the type of elements the function is expecting. Could someone please point out the mistake I am making when creating the patch of cells ?

Best Regards,
Sudip Kunda
test.cc

Wolfgang Bangerth

unread,
Jul 30, 2025, 8:06:56 PM7/30/25
to dea...@googlegroups.com
On 7/30/25 17:25, Sudip Kunda wrote:
>
> My understanding of the error message is that the type of element in the
> std::vector I am passing to get_dofs_on_patch does not match the type of
> elements the function is expecting. Could someone please point out the mistake
> I am making when creating the patch of cells ?

Can you also post what the error message is?
Best
W.

Sudip Kunda

unread,
Jul 30, 2025, 10:14:17 PM7/30/25
to deal.II User Group
The following is a screenshot of the error message

Error_message.png

Wolfgang Bangerth

unread,
Jul 30, 2025, 10:19:53 PM7/30/25
to dea...@googlegroups.com
On 7/30/25 20:14, Sudip Kunda wrote:
> **
>
> The following is a screenshot of the error message

Ah yes, the key is that it says
couldn't deduce template parameter 'dim'

C++ says that in some contexts, the compiler can figure out what 'dim' (and
here, 'spacedim') are based on the arguments you pass to a function. In some
other contexts, that's not possible, and yours is one of these cases. That
means that you have to provide the template arguments yourself by writing
DoFTools::get_dofs_on_patch<dim>(patch)

Best
W.

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


Sudip Kunda

unread,
Jul 30, 2025, 10:37:47 PM7/30/25
to deal.II User Group
Yes, that was the issue. Thank you !
Reply all
Reply to author
Forward
0 new messages