You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the shaper mini app to fit a mesh to an object with 2 materials. Unfortunately, the attribute numbers for the materials do not appear in the output file where it shows all the elements are set to attribute 1. I believe the intended behavior is for the element attributes to equal the return value of the "material" function: int material(Vector &x, Vector &xmin, Vector &xmax). In the example, this returns a value of 1 or 2.
Debugging, I noticed that the values were correctly set when checking mesh->GetElement(i).attribute. So, the error appears to be in the "Printer" function used to save the mesh. It turns out that the output of shaper is a "non-conforming mesh". Therefore, the mesh is saved using the NCMesh type. It appears that the element attributes are not being copied to the elements in mesh to those in NCMesh. I added the following code to my copy of mesh.cpp within the Mesh::Printer after the if(Nonconforming) statement:
for (int i = 0; i < this->GetNE(); i++)
{
ncmesh->elements[i].attribute = this->elements[i]->GetAttribute();
}
This results in an output file with the attributes written into the elements. I don't know enough about your software to be sure this will produce the intended result (properly labelling the materials in the mesh), but at least, two material types do appear in the output file now.
The text was updated successfully, but these errors were encountered:
This looks like a bug to me. It is hard to believe this would go undetected for so long, but my guess is that this does happen in normal usage of NCMesh. In shaper, the attributes are set at the end, right before printing. Normally, attributes are set in a Mesh, which is then converted to NCMesh and adaptively refined with correct inheritance of attributes. If it is just this case of setting attributes in Mesh that is not supported, it should be an easy fix. I will work on an MFEM PR for this.
@JonLangdon can you please let us know if branch ncmesh-attr works for you? This sets the element attributes in NCMesh. Since this is an MFEM bug, not glvis, you should only need to rebuild MFEM, not glvis. mfem/mfem#4539
Hi developers,
I am using the shaper mini app to fit a mesh to an object with 2 materials. Unfortunately, the attribute numbers for the materials do not appear in the output file where it shows all the elements are set to attribute 1. I believe the intended behavior is for the element attributes to equal the return value of the "material" function: int material(Vector &x, Vector &xmin, Vector &xmax). In the example, this returns a value of 1 or 2.
Debugging, I noticed that the values were correctly set when checking mesh->GetElement(i).attribute. So, the error appears to be in the "Printer" function used to save the mesh. It turns out that the output of shaper is a "non-conforming mesh". Therefore, the mesh is saved using the NCMesh type. It appears that the element attributes are not being copied to the elements in mesh to those in NCMesh. I added the following code to my copy of mesh.cpp within the Mesh::Printer after the if(Nonconforming) statement:
for (int i = 0; i < this->GetNE(); i++)
{
ncmesh->elements[i].attribute = this->elements[i]->GetAttribute();
}
This results in an output file with the attributes written into the elements. I don't know enough about your software to be sure this will produce the intended result (properly labelling the materials in the mesh), but at least, two material types do appear in the output file now.
The text was updated successfully, but these errors were encountered: