Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2018-12-03 14:39:34

MatthijsNL
Member
From: NL
Registered: 2018-11-21
Posts: 10

[SOLVED] Probe location at multiple points with ParaView

Hi everyone,

I'm trying to create a macro which outputs my stresses at a large number of locations and then saves this to a csv file.
I have been able to probe locations with my macro and write it to a csv file, however it only works for one location at a time.
The relevant part of my script is the following:

# create a new 'Probe Location'
probeLocation1 = ProbeLocation(Input=eLNOfieldToSurface1,
    ProbeType='Fixed Radius Point Source')

# Properties modified on probeLocation1.ProbeType
probeLocation1.ProbeType.NumberOfPoints = 3
for i in range(3):
    x=2.2*np.cos(i)
    y=2.5*np.sin(i)
    probeLocation1.ProbeType.Center = [x, y, 0.0]

The problem is that the 3 points that show up in the output table are all the exact same point, namely the last point of the range when i=2. Is there a way.
My question is: How can I change my code such that all locations are saved?

I put my full code in the attachment if you want to check it.

Help would be really appreciated!
Kind regards,

Matthijs

EDIT: If anyone knows a different/better way to extract data at these locations this would also be great!

Last edited by MatthijsNL (2018-12-05 11:16:53)


Attachments:
ProbeLocationMacro.py, Size: 3.72 KiB, Downloads: 125

Offline

#2 2018-12-05 11:16:35

MatthijsNL
Member
From: NL
Registered: 2018-11-21
Posts: 10

Re: [SOLVED] Probe location at multiple points with ParaView

Hi All,

After quite some struggling I was able to solve my problem!
I changed my macro script to the part shown below. I added some comments to explain what I did. If you copy this into your own macro then don't forget to add the numpy module as np.
I also added my entire macro code in the attachment in case you are interested in the entire thing.



# create a new 'Probe Location'
probeLocation1 = ProbeLocation(Input=eLNOfieldToSurface1,
    ProbeType='Fixed Radius Point Source')

N=5 #Specify number of points on which to find values
Stress2 = []
for i in range(N):
    x=i    #Select x-coordinate
    y=i+1  #Select y-coordinate
    # Properties modified on probeLocation1.ProbeType
    probeLocation1.ProbeType.Center = [x, y, 0.0]  #interpolates all data to a specific point
    polyData = servermanager.Fetch(probeLocation1) #Get data from the server side to the client side
    pointData = polyData.GetPointData()
    StressArray = pointData.GetArray('resnonl_SIGM_ELNO') #Select which data you want to extract
    Stress = StressArray.GetTuple(0)
    Coordinates = [x, y, 0]
    Stress1 = np.r_[Coordinates, Stress]#Combines the coordinates and stress values in one variable
    Stress2.append(Stress1)#Adds the next point to the array
    #print(Stress2)
#print(pointData) ##Print this (into the python shell) to see which data can be extracted into "StressArray"
np.savetxt(r"C:\Users\Matthijs\Documents\StressExtract2.txt" ,Stress2)#Save array to the desired file

Kind regards,

Matthijs

keywords: Paraview, Paravis, Data Extraction from coordinates, Data Extraction from analytical curve, probe location, interpolation


Attachments:
DataExtractor.py, Size: 3.47 KiB, Downloads: 127

Offline