Skip to content

Make Smith domains from named mfem AttributeSets - #1679

Open
gabsillis wants to merge 6 commits into
developfrom
gabsillis/domain_mfem_attr_sets
Open

gabsillis wants to merge 6 commits into
developfrom
gabsillis/domain_mfem_attr_sets

Conversation

@gabsillis

Copy link
Copy Markdown

MFEM added the ability to create named collections of attributes, some of which get automatically imported when reading a mesh from file. These are convenience methods to create a Smith domain by querying that name. I was using this to define domains from gmsh physical groups.

@chapman39 chapman39 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lc-hubcast approve

@ebchin ebchin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gabsillis, this is a great addition! Just a few small comments to address.

template <int d>
Domain from_boundary_element_attribute_set(const mesh_t& mesh, std::string_view attribute_set_name)
{
assert(mesh.SpaceDimension() == d);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert(mesh.SpaceDimension() == d);
assert(mesh.Dimension() == d);

In case mesh is embedded in a higher dimensional space.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain_of_boundary_elems through the Domain::ofBoundaryElements would still break the embedded case through a similar assertion. Since d is the dimensionality of the coordinates in the node-search predicate, should this be SpaceDimension and the domain dimension constructed in domain_of_boundary_elems be mesh.Dimension() - 1?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gianni, I think you are correct, but this does raise a question I'd be interested in having answered: does Smith eventually plan to support shell/membrane-like domains or other domain elements of a lower dimension than the spatial dimension (to Eric's point)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to support them eventually. We need to check the status of the support of lower-dimensional elements in MFEM.

Comment thread src/smith/numerics/functional/domain.cpp Outdated
Comment thread src/smith/numerics/functional/domain.hpp Outdated
Comment thread src/smith/numerics/functional/domain.hpp Outdated
Comment thread src/smith/numerics/functional/domain.hpp Outdated
Comment thread src/smith/numerics/functional/domain.cpp

// predicate for domain from the attribute list
auto by_attr_list = [&attr_list](std::vector<tensor<double, d>>, int attr) {
return std::ranges::find(attr_list, attr) != attr_list.end();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add #include <algorithm> at the top of the header

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively/equivalently, return attr_list.Find(attr) != -1; using mfem::Array::Find() would avoid the extra header inclusion, but this may be more a matter of taste. I'd be interested to know if the team has a preference one way or another?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with the mfem::Array::Find() to be more lightweight for now but I'm open to changing it back if there's a preference.

Comment thread src/smith/numerics/functional/domain.cpp

@brian-giffin brian-giffin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! My comments are mostly aesthetic, and at your discretion to address (or not).

Comment thread src/smith/numerics/functional/domain.hpp Outdated
Comment thread src/smith/numerics/functional/domain.cpp Outdated

// predicate for domain from the attribute list
auto by_attr_list = [&attr_list](std::vector<tensor<double, d>>, int attr) {
return std::ranges::find(attr_list, attr) != attr_list.end();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively/equivalently, return attr_list.Find(attr) != -1; using mfem::Array::Find() would avoid the extra header inclusion, but this may be more a matter of taste. I'd be interested to know if the team has a preference one way or another?

template <int d>
Domain from_boundary_element_attribute_set(const mesh_t& mesh, std::string_view attribute_set_name)
{
assert(mesh.SpaceDimension() == d);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gianni, I think you are correct, but this does raise a question I'd be interested in having answered: does Smith eventually plan to support shell/membrane-like domains or other domain elements of a lower dimension than the spatial dimension (to Eric's point)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants