Setting block ID when generating a mesh

161 views
Skip to first unread message

Benjamin Spencer

unread,
Jun 18, 2015, 1:13:25 PM6/18/15
to moose-users
I'm trying to create my own generated mesh with MOOSE, and can't figure out how to set the element block ID for the elements that I'm creating. I need to create two blocks of different element types, so they can't be in the same block.  Is that possible, and if so, how do you do it?

-Ben

Wang (Non-US), Yaqi

unread,
Jun 18, 2015, 1:24:42 PM6/18/15
to moose-users
Ben,

Not sure if you have access to Yak. There is one generator derived from GeneratedMesh https://hpcgitlab.inl.gov/idaholab/yak/blob/devel/src/common/mesh/GeneratedBIDMesh.C.

It has an extra parameter specifying the block IDs of all elements, then in its buildMesh(), the following is there:
  MeshBase & my_mesh = getMesh();
  for (unsigned int e=0; e<my_mesh.n_elem(); e++)
    my_mesh.elem(e)->subdomain_id() = _bids[e];

Yaqi

On Thu, Jun 18, 2015 at 11:13 AM, Benjamin Spencer <benjamin...@inl.gov> wrote:
I'm trying to create my own generated mesh with MOOSE, and can't figure out how to set the element block ID for the elements that I'm creating. I need to create two blocks of different element types, so they can't be in the same block.  Is that possible, and if so, how do you do it?

-Ben

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at http://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/CANcsQPfAyEfztmbbpM7K_N-TZgkyt1QNujMEs59g1f36H-agHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Wang (Non-US), Yaqi

unread,
Jun 18, 2015, 1:30:40 PM6/18/15
to moose-users
Oh, I was not looking your post carefully. You are asking for a mesh with mixed types of elements. Maybe we can create a mesh modifier to change the element types of a particular block.

On Thu, Jun 18, 2015 at 11:13 AM, Benjamin Spencer <benjamin...@inl.gov> wrote:
I'm trying to create my own generated mesh with MOOSE, and can't figure out how to set the element block ID for the elements that I'm creating. I need to create two blocks of different element types, so they can't be in the same block.  Is that possible, and if so, how do you do it?

-Ben

Cody Permann

unread,
Jun 18, 2015, 2:27:25 PM6/18/15
to moose-users
Exodus is the limitation here not libMesh. You can only have one element type per block so using Yaqi's code to set the subdomain intelligently should work fine. Now generating the elements is a different story. You can certainly build elements from scratch and glue them altogether. I did this in he prismatic reactor generator in Yak. Are you just trying to glue together two blocks of different types? Can you guarantee conformity?

Benjamin Spencer

unread,
Jun 18, 2015, 3:59:40 PM6/18/15
to moose-users
I think Yaqi's suggestion is exactly what I need. In my case the two blocks aren't even contiguous.  Thanks.

-Ben


Peterson, JW

unread,
Jun 29, 2015, 11:15:52 AM6/29/15
to moose-users
On Thu, Jun 18, 2015 at 11:24 AM, Wang (Non-US), Yaqi <yaqi...@inl.gov> wrote:
Ben,

Not sure if you have access to Yak. There is one generator derived from GeneratedMesh https://hpcgitlab.inl.gov/idaholab/yak/blob/devel/src/common/mesh/GeneratedBIDMesh.C.

It has an extra parameter specifying the block IDs of all elements, then in its buildMesh(), the following is there:
  MeshBase & my_mesh = getMesh();
  for (unsigned int e=0; e<my_mesh.n_elem(); e++)
    my_mesh.elem(e)->subdomain_id() = _bids[e];

Please use element_iterators to loop over the elements of a Mesh, your code above only works if the element numbering is contiguous.  That's guaranteed for GeneratedMesh but not for meshes generated by Cubit, etc.


MeshBase::element_iterator       el     = mesh.elements_begin();
const MeshBase::element_iterator end_el = mesh.elements_end();
for ( ; el != end_el; ++el)
  {
    Elem* elem = *el;
    elem->subdomain_id() = _bids[elem->id()];
  }



--
John
Reply all
Reply to author
Forward
0 new messages