Fri, 29 Jun 2007 17:12:52 -0400 (EDT), Jonathan Guyer <[EMAIL PROTECTED]>:
> This is because z is shaped like all the faces in the mesh, but the
> result of getFacesBottom() is much smaller. Instead, you can do
>
> >>> z = mesh.getFacesBottom().getCenters()[...,2]
> >>> mesh.getFacesBottom().where(z < 2)
> FaceIterator(mesh=UniformGrid3D(dx=1.0, dy=1.0, dz=1.0, nx=1,
> ny=1, nz=3), ids=array([4, 6]))
>
> Alternatively, you can write
>
> >>> y = mesh.getFaceCenters()[...,1]
> >>> z = mesh.getFaceCenters()[...,2]
> >>> mesh.getFaces().where((y == 0) & (z < 2))
> FaceIterator(mesh=UniformGrid3D(dx=1.0, dy=1.0, dz=1.0, nx=1,
> ny=1, nz=3), ids=array([4, 6]))
Jonathan,
Your reply was really helpful. Now I understood, that
* FixedValue() and FixedFlux() need a FaceIterator object to be given
* This FaceIterator should iterate over only exterior faces
* FaceIterator might be constructed manually
I liked your last example, but decided to go with more generic
selectFaces() function:
{{{
from fipy.meshes.meshIterator import FaceIterator
def selectFaces(mesh, selector):
"""
mesh: a mesh to get faces from
selector([x,y,z]): a function that returns True for faces to be selected
"""
faces=mesh.getExteriorFaces()
filtered=filter(lambda f:selector(f[1]),zip(faces,faces.getCenters()))
ids=map(lambda f:f[0],filtered)
return FaceIterator(mesh=mesh,ids=ids)
}}}
then it can be used this way:
{{{
# for example, select faces where y==0 and abs(z-zsize/2) < width
faces=selectFaces(mesh,lambda p: (p[1]==0) and (abs(p[2]-zsize/2)<width))
BCs=(FixedValue(faces=faces,value=1.0))
}}}
This way arbitrary selection rule might be implemented.
Thank you for response.
Best regards,
Sergey