Welcome, Guest
Username: Password: Remember me

TOPIC: How to get informations from a mesh with BlueKenue to a txt file

How to get informations from a mesh with BlueKenue to a txt file 10 years 10 months ago #11669

  • special_20
  • special_20's Avatar
Dear all,

I would like to select some points in a mesh and save informations like coordinates and number node into a txt file that would look like :

X Y n°
1.3 3.14 5
5.2 2.7 8
3.4 3.4 15

Is it possible ? And if so how to do this ?

Thanks
The administrator has disabled public write access.

How to get informations from a mesh with BlueKenue to a txt file 10 years 10 months ago #11677

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

You can write a small python script using the python tools we have developed -- something like the following should work:
#!/usr/bin/env python
import sys
sys.path.append( "c:\\opentelemac\\v6p3\\scripts\\python27\\" )
from parsers.parserSELAFIN import SELAFIN
from utils.files import putFileContent

slf = SELAFIN('input.slf')
out = ['X Y N']
for i in range(slf.NPOIN2):
   out.append(str(slf.MESHX[i])+' '+str(slf.MESHY[i])+' '+str(i))

putFileContent( 'outfile.xyn',out)

You have to put the correct path, and the correct file names. You can also improve this simple trial.

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

How to get informations from a mesh with BlueKenue to a txt file 10 years 10 months ago #11685

  • Serrer
  • Serrer's Avatar
  • OFFLINE
  • Moderator
  • Posts: 720
  • Thank you received: 304
Hi Special_20,

As a response I'll say it depends on what you are trying to achieve.

In addition to the native t3s format, you can save a mesh to a
number of different ASCII file formats. (See File->SaveCopyAs"
(SMS,ADCIRC,TRIGRID,Tecplot,xyz)
Some of these formats include the node number.

Using "Tools->Extract Points" or "Tools->T3Mesh->Extract Subset"
you can extract nodes or a submesh that lie within a polygon.

Hope this helps... Martin
The administrator has disabled public write access.
The following user(s) said Thank You: special_20

How to get informations from a mesh with BlueKenue to a txt file 10 years 9 months ago #11732

  • harryyao
  • harryyao's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 190
  • Thank you received: 3
Dear Serrer,

I also have a question, Can The Blue Kenue import the data directly from AutoCAD ? for examples, Import the river boundary conditions from AutoCAD.
The administrator has disabled public write access.

How to get informations from a mesh with BlueKenue to a txt file 10 years 9 months ago #11808

  • special_20
  • special_20's Avatar
I must say thank you Serrer for your answer, I applied it this day and I must say that this is exactly what I was looking for :woohoo:

Now, what I should have done by hand, node by node, in a week will just take me about a few hours. So thanks again :woohoo: :woohoo:
The administrator has disabled public write access.

How to get informations from a mesh with BlueKenue to a txt file 10 years 9 months ago #12112

  • ogr013
  • ogr013's Avatar
Hi,
Thanks for the lines of code to read selafin files into python.

from runSELAFIN import *
slf = scanSELAFIN(infile).slf
z = slf.getVALUES(0)

I want to map some new data points onto a geometry file.
i = np.argwhere(z < -20)
z[ i ] = -20

How can I put the modified data 'z' back into the slf object? To then save as a new file

slf.putContent(outfile) ...?

Thanks,
Julian
The administrator has disabled public write access.

How to get informations from a mesh with BlueKenue to a txt file 10 years 9 months ago #11722

  • special_20
  • special_20's Avatar
Thank you Sebourban and Serrer for your answers.

Sebourban : I don't know how to code in Python but I must say that your solution looks interesting. It is written in your code : "for i in range(slf.NPOIN2)", this implies that each node is identified by a node number in a slf file ?
The administrator has disabled public write access.

How to get informations from a mesh with BlueKenue to a txt file 10 years 9 months ago #11726

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

In python MESHX[ i ] and MESHY[ i ] are the coordinates of node i
Same for the Fortran with different variable names (and brackets' style)

Do try python -- it is fun to learn and so efficient

Hope this help,
Sébastien.
The administrator has disabled public write access.

How to get informations from a mesh with BlueKenue to a txt file 10 years 9 months ago #11728

  • special_20
  • special_20's Avatar
I am supposed to learn Python soon at my lab. But I think I will not wait and learn by myself.
The administrator has disabled public write access.

How to get informations from a mesh with BlueKenue to a txt file 10 years 8 months ago #12224

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

you can try something like this (assuming your variable is first of the list):
slf.fole.update({ 'hook': open('outputfile.slf','wb') })
   slf.appendHeaderSLF()
   # ~~> Time stepping
   for t in range(len(slf.tags['times'])):
      slf.appendCoreTimeSLF(t) # Time stamps
      vars = slf.getVALUES(t)
      vars[0][np.argwhere(vars[0] < -20)] = -20
      slf.appendCoreVarsSLF(vars)
   slf.fole['hook'].close()

Hope this helps,
Sébastien.
The administrator has disabled public write access.
The following user(s) said Thank You: ogr013
Moderators: Serrer, a.barton

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