Tony S Yu | 12 Jul 02:08
Favicon

faceVariable missing copy method

Hi,

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').

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

Cheers,
-Tony

Attachment (add_facevar_copy.diff): application/octet-stream, 1356 bytes

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 (`getExteriorFaces` doesn't automatically copy;  
for performance reasons, maybe?). So I just tried to copy before  
modifying:

 >>> exterior = mesh.getExteriorFaces()
 >>> no_flux_faces = exterior.copy()

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

Gmane