Rahul,

I was responsible for starting the discussion regarding Gmsh meshes and
subdomain_ids() earlier this week .... :) . I confirm that things work with
Gmsh meshes.

You could try the following code to the example ex3.C, right after you call
mesh.print_info(); It essentially does what Derek mentioned in the previous
post to print the subdomain ids of an element, and the boundary ids of any
of its sides that are part of a boundary.

======================================================
for ( ; el != end_el; ++el)
  {
    const Elem* elem = *el;
    const unsigned int sbd_id = elem->subdomain_id();
    std::cout << std::endl << "Element subdomain id = " << sbd_id <<
std::endl;
    std::cout << "Sides are :" << std::endl;

    for (unsigned int side =0 ; side < elem->n_sides(); side++)
    {
    short int bc_id = mesh.boundary_info->boundary_id (elem,side);
    if (bc_id != BoundaryInfo::invalid_id)
        std::cout << "Side : " << side << "belongs to bdy" << bc_id <<
std::endl;
    else
        std::cout << "Side : " << side << "belongs to the interior." <<
std::endl;

    }

   }
==========================================================

Try it on the attached file .msh file (which was generated using the
attached
.geo file). The ids 300 and 400 refer to nodes that I have tagged in the
.geo file.

Regards

Arvind


On Fri, Oct 30, 2009 at 8:05 PM, Derek Gaston <[email protected]> wrote:

> Rahul,
>
> What type of boundary condition (Dirichlet or Neumann)?  Are you
> planning on enforcing Dirichlet conditions using a penalty (as all of
> the libMesh examples do)?
>
> In general in libMesh we don't operate on _nodes_ for boundary
> conditions.... we operate on sides.  The reason for this is that we
> integrate the boundary condition over the side.  Also... working with
> nodes is precarious with adaptivity.... because new nodes are always
> getting generated so the book-keeping is a pain.  As you can see in
> the examples (like ex3) one way to achieve this is to look for NULL
> neighbors... then you know you're on a boundary side so you can
> integrate your boundary condition over that side.
>
> Now... if you want to do something more sophisticated than looking for
> NULL neighbors you need to interact with the BoundaryInfo object for
> the mesh (mesh->boundary_info).  With this object you can associate
> sides (and their associated elements) with an id.  Then you can get
> back a list of elements, sides and ids by calling "build_side_list".
> You can then loop over this list to integrate your boundary conditions.
>
> Another option other than using "build_side_list" is to go ahead and
> check for NULL neighbors... and when you find one ask the
> boundary_info object for teh boundary_id() associated with that
> element and side.  Then key off of that to know which boundary
> condition to apply.
>
> Finally... some mesh formats will automatically add side set info to
> the boundary_info object when the mesh is read from a file.  I know
> for a fact that the Exodus reader does this... and there was some
> discussion on this capability for GMSH earlier this week (although I
> don't know if it works yet).  Another option is to have a preprocessor
> built using libMesh that reads the format of your choice... adds sides
> to the boundary info object and then writes out an xda/xdr mesh file
> that will contain the boundary info.  One other thing: the internal
> mesh generators inside libMesh usually try to assign boundary info to
> the sides.  For instance the build_square() routine will assign
> boundaries 0,1,2,3 to the different flat sides of the square.
>
> Hope that helps,
> Derek
>
> On Oct 30, 2009, at 7:35 AM, Rahul Sampath wrote:
>
> > Hi:
> >
> > I would like to know how to tag nodes with different boundary ids for
> > possibly different sets of boundary conditions and loop over the
> > subset of elements that contain nodes of a particular boundary id. I
> > would also be able to do this in parallel. Could someone kindly tell
> > me how to do this?
> >
> > Thank you very much.
> >
> > Regards,
> >
> > Rahul
> >
> >
> ------------------------------------------------------------------------------
> > Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> > is the only developer event you need to attend this year. Jumpstart
> > your
> > developing skills, take BlackBerry mobile applications to market and
> > stay
> > ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> > http://p.sf.net/sfu/devconference
> > _______________________________________________
> > Libmesh-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/libmesh-users
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Libmesh-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libmesh-users
>
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libmesh-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to