Welcome, Guest
Username: Password: Remember me

TOPIC: How to contribute Python Suggestions and Code?

How to contribute Python Suggestions and Code? 11 years 8 months ago #7856

  • j_floyd
  • j_floyd's Avatar
I cannot find any information on how to contribute.

For example I have used the python selafin module to help me assemble the the geometry and bathymetry data for model runs. The grid was generated from the opensource gmesh package which I had been using for FVCOM grid generation.

To make this work efficiently I needed to enhance/replace the getEdgesSLF, so that I could get edges quickly and also create the boundary edges simply. The one routine also generates the cell neighbours.

Cheers
John
The administrator has disabled public write access.

How to contribute Python Suggestions and Code? 11 years 8 months ago #7901

  • sebourban
  • sebourban's Avatar
  • OFFLINE
  • Administrator
  • Principal Scientist
  • Posts: 814
  • Thank you received: 219
Hello,

That is a good thing. If in small dose, just e-mail your code to me This email address is being protected from spambots. You need JavaScript enabled to view it..

If you think you can contribute much more, we can create a branch from the main trunk for you, so yo ucan commit changes and use that version as your own until your changes are validated by the consortium and merged back to the main trunk.

With respect to finding edges and a few other things, we have much improved these processes since v6p2 (coming for v6p3) and for example for edges we now call on the matplotlib cpp get_cpp_triangulation function. Here is the new code with only 2 lines if you have matplotlib.tri installed. Of course, we'd be happy to take in any improvements.
def getEdgesSLF(IKLE,MESHX,MESHY):

   try:
      from matplotlib.tri import Triangulation
      edges = Triangulation(MESHX,MESHY,IKLE).get_cpp_triangulation().get_edges()
   except:
      #print '... you are in bad luck !'
      #print '       ~>  without matplotlib based on python 2.7, this operation takes ages'
      edges = []
      ibar = 0; pbar = ProgressBar(maxval=len(IKLE)).start()
      for e in IKLE:
         pbar.update(ibar); ibar += 1
         if [e[0],e[1]] not in edges: edges.append([e[1],e[0]])
         if [e[1],e[2]] not in edges: edges.append([e[2],e[1]])
         if [e[2],e[0]] not in edges: edges.append([e[0],e[2]])
      pbar.finish()

   return edges

Hope this helps,
Sébastien.
The administrator has disabled public write access.
Moderators: borisb

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.