Search code examples
python-2.7numpymeshfipynumpy-ufunc

Best way to address outer mesh surfaces of a cylinder by FiPy ,


Could I address outer mesh face centers by any FiPy or ... modules? For a cylinder by radius of 'R', related meshes are created O'grid sweep-like on it. As it seems, 'R' is greater than the most outer mesh face centers; so there is a difference between them (FIG.) and can not be addressed by "R" easily.

enter image description here

I need to mention all outer mesh face centers around the cylinder wall (not top and bottom wall). The mesh system are imported by "FiPy Gmsh" (FiPy version = 3.1 and Python 2.7). FiPy 'solver.mesh.getFaceCenters()' get an simple array for mesh face centers. I think the cylinder wall related outer faces of outer hexagonal mesh layer could be addressed by code such below:

reduce(numpy.logical_and, (FORMULAs))               # where FORMULAs are specifying mesh face center coordinates limits

I tried to use the following codes, but it will need some changes for segment '> R', if the FORMULA be applicable.

x,y,z = solver.mesh.getFaceCenters()
np.sqrt(x ** 2 + y  ** 2) > R       #  as FORMULAs

I would be very appreciated if anyone could help me to overcome this issue. I think the best way must be using FiPy and numpy modules.


Solution

  • This is discussed in the documentation for Gmsh2D.

    Although it is possible to define such faces parametrically, it is necessary to allow some error in position due to the finite resolution of the discretized mesh. Far better to define the faces you want in the abstract geometry definition and refer to them directly, e.g., your GEO file in Gmsh would have something like

    Physical Volume("FORMULA") = {5, 6, 7};
    

    and then your FiPy script would access them with

    formula_faces = solver.mesh.physicalFaces["FORUMULA"]