0

In the example from the fipy documentation the following code is used to "create a Viewer to see the mesh":

viewer = None
if __name__ == '__main__':
    try:
        viewer = Viewer(vars=phi, datamin=-1, datamax=1.)
        viewer.plotMesh()
        input("Irregular circular mesh. Press <return> to proceed...") # doctest: +GMSH
    except:
        print("Unable to create a viewer for an irregular mesh (try Matplotlib2DViewer or MayaviViewer)"

Could someone explain to me why this way is chosen over the simplified version of:

viewer = Viewer(vars=T, datamin=T0, datamax=Tu)
viewer.plotMesh()
input("Irregular circular mesh. Press <return> to proceed")

I guess it links to the question if the code is in the main program or if things got imported but i do not quite understand the advantage/disadvantage yet and would appreciate to clarify someone helping me:)

mcghgb
  • 25
  • 1
  • 5

1 Answers1

1

No good reason. That bit was originally (14 years ago) hard-coded to use a particular plotting library which, at the time, was the only one capable of displaying irregular meshes. We didn't want the example to fall over just because that particular plotting library wasn't installed.

That restriction is no longer true and, in fact, we don't even support that plotting library anymore, but we never noticed that the try-except was no longer needed as the code got revised over the years.

Thanks for reporting this issue (#688).

jeguyer
  • 2,379
  • 1
  • 11
  • 15