Accessing a particular boundary in one-dimensional case

17 views
Skip to first unread message

Krishnakumar Gopalakrishnan

unread,
Mar 13, 2020, 7:34:31 PM3/13/20
to deal.II User Group
For a one-dimensional unit domain (0,1), if one needs to set non-homogenous Neumann BC at a particular end of the domain (say the left end, x=0),

Looking at step-7 and adapting it a little bit, does the following code look reasonable to mark the boundary ID of the left edge as '1' for later setting its flux?

for (const auto &cell : triangulation.cell_iterators())
    for (const auto &face : cell->face_iterators())
    {
         const auto center = face->center();
         if (std::fabs(center(0)) < 1e-12)
         face->set_boundary_id(1);
    }


This is based on my assumption that center(0) method of a face iterator shall return the actual co-ordinate itself (since in the 1D case, the face degenerates to a single point and its center is the same). On a related note, when we use the arrow operator, under which page should I look up the documentation. Searching for center() returns a whole lot of results in doxygen.

Wolfgang Bangerth

unread,
Mar 13, 2020, 7:47:44 PM3/13/20
to dea...@googlegroups.com
On 3/13/20 5:34 PM, Krishnakumar Gopalakrishnan wrote:
>
> Looking at step-7 and adapting it a little bit, does the following code look
> reasonable to mark the boundary ID of the left edge as '1' for later setting
> its flux?
>
> for (const auto &cell : triangulation.cell_iterators
> <https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdealii.org%2Fdeveloper%2Fdoxygen%2Fdeal.II%2Fgroup__CPP11.html%23ga7295c669f32e78c45446ddc236f19136&data=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7C78a1855a0a7a4b3ac25608d7c7a716c5%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637197392773455746&sdata=c5HWHjdx99F5AhA4Si5Zesfqc3krTMVywMf6E7nso2Y%3D&reserved=0>())
> for (const auto &face : cell->face_iterators())
>     {
> const auto center = face->center();
> if (std::fabs(center(0)) < 1e-12)
>          face->set_boundary_id(1);
>     }
>
>
> This is based on my assumption that center(0) method of a face iterator shall
> return the actual co-ordinate itself (since in the 1D case, the face
> degenerates to a single point and its center is the same).

Have you tried this? I think it should work, but it will be faster for you
(and for us) if you just played with stuff and tried whether it actually works :-)


> On a related note,
> when we use the arrow operator, under which page should I look up the
> documentation. Searching for center() returns a whole lot of results in doxygen.

The class in question is TriaAccessor.

Best
WB

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

Krishnakumar Gopalakrishnan

unread,
Mar 15, 2020, 3:47:28 PM3/15/20
to dea...@googlegroups.com
Have you tried this? I think it should work, but it will be faster for you  (and for us) if you just played with stuff and tried whether it actually works :-)
  • Yay! That actually worked. Thank you all the help. I now have some working code to start with.
Regards,
Krishna


--
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 a topic in the Google Groups "deal.II User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dealii/fbWdIUNF-SI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/f8095857-cb3a-360c-34e9-a54ba561b27c%40colostate.edu.
Reply all
Reply to author
Forward
0 new messages