On Jul 11, 2008, at 8:11 PM, Tony S Yu wrote:

I think `faceVariable` may be missing a `copy` method. I've included a patch below, which is basically a copy of `cellVariable`'s `copy` method (minus it's `hasOld` attribute and changing the rename from + '_old' to + '_copy').

We've never needed it, which is why it never got written, but I don't see that it's harmful in anyway.

Also, the patch includes a fix for matplotlib2DViewer.py, which has changed since I originally submitted the patch.

Thanks for that.

Both of these are committed as r2670.



In case you're curious about a use case: I wanted to set *almost* all of the exterior faces to a no flux boundary condition. So I naturally I tried

>>> no_flux_faces = mesh.getExteriorFaces()
>>> no_flux_faces.setValue(array[False], where=faces_with_other_BC)

But it turns out the above commands change the faces that the mesh recognizes as exterior

I would have implemented this as

>>> no_flux_faces = mesh.getExteriorFaces() & ~faces_with_other_BC




(`getExteriorFaces` doesn't automatically copy; for performance reasons, maybe?).

Yes. I have it on my to-do list to re-implement a great many things like `getExteriorFaces()` with read-only descriptors.

But, `faceVariable`'s `copy` method defaults to `Variable`'s `copy` method. As a result, the copied variable doesn't have a `mesh` attribute.

That's certainly no good.



Reply via email to