Hi Jon, Thank you. It works perfectly.
Best, Zhekai On Sun, May 21, 2017 at 12:13 PM, Guyer, Jonathan E. Dr. (Fed) < [email protected]> wrote: > Zhekai - > > Thank you for the explanation. You're right, I answered a much simpler > question than you were asking. > > The following should do what you want: > > velocityVector = fp.FaceVariable(mesh=mesh, rank=1) > topFaces = fp.numerix.unique(mesh.cellFaceIDs[..., > mesh.physicalCells["top"].value].flatten().filled()) > velocityVector[0, topFaces] = velocityX_Top[..., topFaces] > velocityVector[1, topFaces] = velocityY_Top[..., topFaces] > > This obtains all of the faces that surround each of the cells in "top", > rearranges them into a long list, removes any empty values (different cells > can have different numbers of faces), and then removes duplicates. The > result is a list of the faceIDs for all the faces that bound all of the > cells in "top". > > > Alternatively, > > topFaces = (mesh.physicalCells["top"].faceValue != 0.).value > > This obtains the face-evaluated average of whether a cell is in "top". > This relies on the fact that True and False can be treated pretty > interchangeably with 1. and 0.. The result is a boolean mask which is True > for all the faces that bound all of the cells in "top". > > - Jon > > > On May 12, 2017, at 12:13 PM, Zhekai Deng <zhekaideng2014@u. > northwestern.edu> wrote: > > > > Hi Jon, > > > > Thanks for answering that. However, I am afraid I am not fully > understand how "physicalFaces" field for gmsh mesh could help me resolve > this one. > > > > The "physicalFaces" field, If I understand correctly, is giving me the > Physical Line (not Physical Surface) that I specified in gmsh. Thus, this > is giving me the faces index on that specific line I specified in gmsh. > What I want to achieve is that is there any function that takes sub-domain > name as input (in my case "Physical Surface("top")) give me all the faces > in this domain (not just faces on one line). > > > > If I just use mesh.physicalFaces["Top"], it will just return error > because "Top" in my case is a "Physical Surface" not a "Physical Line". > > > > Any help will be appreciated. Thanks. > > > > Zhekai > > > > On Fri, May 12, 2017 at 8:54 AM, Guyer, Jonathan E. Dr. (Fed) < > [email protected]> wrote: > > There is also a .physicalFaces field defined for a gmsh mesh. > > > > > On May 11, 2017, at 6:39 PM, Zhekai Deng <zhekaideng2014@u. > northwestern.edu> wrote: > > > > > > Hi All, > > > > > > I wonder is there any way to specify the FaceVariable based on the > naming from gmsh ? For example, I name my sub domain in gmsh as "top" and > "bottom". In Fipy, I would like to do something similar to following: > > > > > > velocityX_Top = (1-Epsilon*Epsilon)/(Epsilon*Epsilon)*(yFace + > Epsilon*np.sqrt(1-xFace*xFace)) > > > velocityY_Top = (1-Epsilon*Epsilon)/Epsilon*( > xFace*yFace)/(np.sqrt(1-xFace*xFace)) > > > velocityX_Bottom = yFace > > > velocityY_Bottom = -xFace > > > > > > velocityVector = FaceVariable(mesh=mesh.physicalCells["top"], rank=1) > > > velocityVector[0] = velocityX_Top > > > velocityVector[1] = velocityY_Top > > > > > > velocityVector = FaceVariable(mesh=mesh.physicalCells["bottom"], > rank=1) > > > velocityVector[0] = velocityX_Bottom > > > velocityVector[1] = velocityY_Bottom > > > > > > I think it gives me error because the mesh.physicalCells is cell > index, not face index. But is there any way I could do get all face index > using sub domain ID? > > > > > > I have attached the complete and minimal code to demonstrate what I > try to achieve. > > > > > > Thanks! > > > > > > Zhekai > > > > > > <example.py>_______________________________________________ > > > fipy mailing list > > > [email protected] > > > http://www.ctcms.nist.gov/fipy > > > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] > > > > > > _______________________________________________ > > fipy mailing list > > [email protected] > > http://www.ctcms.nist.gov/fipy > > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] > > > > _______________________________________________ > > fipy mailing list > > [email protected] > > http://www.ctcms.nist.gov/fipy > > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] > > > _______________________________________________ > fipy mailing list > [email protected] > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] >
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
