glvis icon indicating copy to clipboard operation
glvis copied to clipboard

Shaper mini app, not copying attributes to new mesh

Open JonLangdon opened this issue 4 months ago • 4 comments

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.

JonLangdon avatar Oct 13 '24 14:10 JonLangdon