project_boundary_values for components

40 views
Skip to first unread message

Anton

unread,
Apr 5, 2019, 1:25:53 PM4/5/19
to deal.II User Group
Hello,
I need to apply a boundary condition (discontinuous function) to a few components of a dof_handler only.  I am currently using 

void VectorTools::interpolate_boundary_values (const DoFHandlerType< dim, spacedim > &dof, const types::boundary_id boundary_component, const Function< spacedim, number > &boundary_function, ConstraintMatrix &constraints, const ComponentMask &component_mask=ComponentMask())

for this purpose, but because of the discontinuity I get unwanted effects near the discontinuity - that is even when the discontinuity is aligned with the mesh, and even though I am using discontinuous elements (FE_FaceQ), I get unwanted effects because the interpolation point falls exactly between the elements.  Is there a way of applying project_boundary_values instead to fix this issue?  Basically I cannot seem to find support for component selection in connection with project_boundary_values.
Sincerely,
/Anton

Wolfgang Bangerth

unread,
Apr 6, 2019, 11:11:09 AM4/6/19
to dea...@googlegroups.com
On 4/5/19 11:25 AM, Anton wrote:
> I need to apply a boundary condition (discontinuous function) to a few
> components of a dof_handler only.  I am currently using
>
> |
> voidVectorTools::interpolate_boundary_values
> <https://dealii.org/current/doxygen/deal.II/group__constraints.html#ga2376b9a282a2b62be5c55ab62a11a132>(constDoFHandlerType<dim,spacedim
> >&dof,consttypes::boundary_id
> <https://dealii.org/current/doxygen/deal.II/namespacetypes.html#aaf4eb6ec214fa642dfd956f11a9cd2d7>boundary_component,constFunction
> <https://dealii.org/current/doxygen/deal.II/classFunction.html><spacedim,number >&boundary_function,ConstraintMatrix
> <https://dealii.org/current/doxygen/deal.II/classConstraintMatrix.html>&constraints,constComponentMask
> <https://dealii.org/current/doxygen/deal.II/classComponentMask.html>&component_mask=ComponentMask
> <https://dealii.org/current/doxygen/deal.II/classComponentMask.html>())
> |
>
> for this purpose, but because of the discontinuity I get unwanted effects near
> the discontinuity - that is even when the discontinuity is aligned with the
> mesh, and even though I am using discontinuous elements (FE_FaceQ), I get
> unwanted effects because the interpolation point falls exactly between the
> elements.  Is there a way of applying project_boundary_values instead to fix
> this issue?  Basically I cannot seem to find support for component selection
> in connection with project_boundary_values.

Can you explain what these unwanted effects are, for example in a picture?

You're right that the project_b_v() function (currently) doesn't support
selecting individual components. But you can just project onto all components
into a separate object, and then you only transfer those elements that
correspond to the components you care about.

Best
Wolfgang

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

Anton

unread,
Apr 6, 2019, 2:29:18 PM4/6/19
to deal.II User Group
Thank you Wolfgang.

Basically if I interpolate a step function (which can be exactly presented in for example DGQ1 space if the discontinuity is at the node) I get a 1-element wide transition.  In ASCII pictures, I expect  ___----  but I get ___/---  instead :)

So if I understand you correctly, one would need to (1) obtain ConstraintMatrix from project_boundary_values; (2) go over each row of the constraint matrix and check which component it is; (3) if it is the "right" component  then copy the row.  Could I ask how does one figure out the component number from the row number in the ConstraintMatrix - I cannot immediately figure this out from DoFHandler interface?

/Anton

Wolfgang Bangerth

unread,
Apr 7, 2019, 6:11:19 PM4/7/19
to dea...@googlegroups.com
On 4/6/19 12:29 PM, Anton wrote:
>
> Basically if I interpolate a step function (which can be exactly presented in
> for example DGQ1 space if the discontinuity is at the node) I get a 1-element
> wide transition.  In ASCII pictures, I expect  ___----  but I get ___/---
> instead :)

Ah, yes -- ASCII art to the fore! Yes, the problem is that the DGQ(k) elements
have support (interpolation) points at the vertices, and so you'll get the
same value for both cells at these vertices. That's unavoidable. Projection is
the solution.


> So if I understand you correctly, one would need to (1) obtain
> ConstraintMatrix from project_boundary_values; (2) go over each row of the
> constraint matrix and check which component it is; (3) if it is the "right"
> component  then copy the row.  Could I ask how does one figure out the
> component number from the row number in the ConstraintMatrix - I cannot
> immediately figure this out from DoFHandler interface?

You can't do it this way, but there are functions in DoFTools that allow you
to extract *all* DoF indices for a particular component from a DoFHandler, and
then you can cross-check the two objects.

Best
W.

Anton

unread,
Apr 9, 2019, 4:23:04 AM4/9/19
to deal.II User Group
Wolfgang,

Thank you for the help.  I think I have it working in the non-distributed case, but project_boundary_values segfaults on me without any explanations (compiled in debug mode) when run with a distributed triangulation.  Is this "normal"?  

/Anton

Wolfgang Bangerth

unread,
Apr 9, 2019, 11:21:37 AM4/9/19
to dea...@googlegroups.com
On 4/9/19 2:23 AM, Anton wrote:
>
> Thank you for the help.  I think I have it working in the non-distributed
> case, but project_boundary_values segfaults on me without any explanations
> (compiled in debug mode) when run with a distributed triangulation.  Is this
> "normal"?

Ah, good point. The function may not be intended (so far) for the parallel
case. Do you think you can come up with a minimal example that shows the segfault?

The root of the issue is that you are using a DG element. For those elements,
the projection is local on each face, and I think it would probably not be
terribly difficult to implement by hand given that there is no function right
now that does what you want. Have you thought about doing that? It may be
useful to then put that into the library.
Reply all
Reply to author
Forward
0 new messages