Trunc boolean function to keep elements


When you use the trunc function to keep elements from a mesh using a boolean function, you keep a element of the mesh if, at all vertices, the function is true. I need to do the oposite. I need to keep a element on the mesh if, at one of the vertex, the function is true, even if it is false on the other vertices. Is there a way to do this? I also tried to use labels to each element region label but I don´t know a way to change the region label of a single element at a time, using something like:


Thank you.

You can try


That is what I’m trying to do but i don’t know a way to change region labels of the elements of the mesh. Is there some function to change them directly (one element at a time) or by using a global change of the labels? All i found on the documentation is a way to change the already existings label to a different label but I could not find a way to split different element with the same label into having 2 different labels.

The simple way is introduction a P1 finite element function ok

ok = 1 if vertex ok
ok =1 if vertex is not ok.

mesh Th1=trunc(Th,ok>0); // remove all triangle if the 3 vertices are not ok
mesh Th1=trunc(Th,ok>0.9999); // remove all triangle if one of 3 vertex are not ok. 

Thank you, that works (I think that you wanted to use ok = 0 if vertex is not ok).

By your answer, I understand there is no way to change the label of the elements or that that is hard to do.