Tony S Yu | 12 Jul 02:08

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()
(Continue reading)

Jonathan Guyer | 14 Jul 16:50

Re: faceVariable missing copy method


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

(Continue reading)


Gmane