|
[Sponsors] |
How to Extract Data at Specific Coordinates in Non-Cubic Meshes Using Python |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 15, 2024, 08:16 |
How to Extract Data at Specific Coordinates in Non-Cubic Meshes Using Python
|
#1 |
New Member
Lucas Liu
Join Date: Nov 2023
Posts: 4
Rep Power: 3 |
Hi everyone,
I'm new to OpenFOAM and currently facing a challenge that I hope to get some guidance on. I am working on a project where I need to extract velocity data (U) at specific coordinates from my simulation results. However, the challenge arises because my mesh is not of a standard cubic form. Instead, it consists of various special shapes, making it difficult to directly use mesh coordinates for data extraction. I am considering using Python for this task, but I am unsure about the best approach to locate the specific coordinates within my complex mesh and retrieve the corresponding U data. Here are some specifics about my situation: 1. The mesh geometry is complex and does not follow a regular pattern. 2. I have a list of specific coordinates (x, y, z) where I need to find the U data. 3. I am looking for a Python-based solution that can accurately map these coordinates to the mesh and extract the needed data. I would greatly appreciate any advice, code snippets, or references to tools/libraries within the OpenFOAM ecosystem that could help with this task. Additionally, if anyone has experience with similar challenges or can suggest best practices for dealing with non-cubic meshes in OpenFOAM, I would be very thankful for your insights. Thank you in advance for your time and help! Best regards, |
|
February 15, 2024, 18:29 |
|
#2 |
Member
Shravan
Join Date: Mar 2017
Posts: 75
Rep Power: 9 |
Hello,
If your simulation is already over and you want to extract some data at specific points you can use the "Probe Location" filter in Paraview. https://docs.paraview.org/en/latest/...ata.html#probe If you want to automate it you can look at other posts in the forum:Probe location in a script Now, if you still did not start your simulation you can use the "Probes" functionality in OpenFOAM. https://doc.cfd.direct/openfoam/user...phs-monitoring https://www.openfoam.com/documentati...8H_source.html With this you can specify your required coordinates and your velocity data over time will be printed out. This is the most effective way if you already know what points to probe and you have to do it for many such simulations. Good luck |
|
February 16, 2024, 08:10 |
|
#3 | |
New Member
Lucas Liu
Join Date: Nov 2023
Posts: 4
Rep Power: 3 |
Quote:
Thank you for your reply. I believe I may not have clearly described my situation earlier. I have already completed my simulation and obtained the results. What I need now is for Python to output the U data in [u, v, w] format when I input the specific simulation time and coordinates. Is it possible? Thank you once again. |
||
February 16, 2024, 12:52 |
|
#4 |
Member
Shravan
Join Date: Mar 2017
Posts: 75
Rep Power: 9 |
Hello,
I now understand it better. I think the best way then is to use a Python macro in Paraview Did you see the code given in this thread? Probe location in a script For your case, you have a single file I guess (see the files variable), then add your coordinates similar to how it is shown HTML Code:
probe.ProbeType.Center = [0,0,0] # probe location [x,y,z] You can then save it as a Python macro and simply run the macro in Paraview. Since as you mention that the points that you would like to probe are not located at the cell centres, interpolation is needed. So, using Python in Paraview could be a good option and you can let Paraview do the interpolation for you. Exporting your data directly from OpenFOAM to Python will be really expensive and slow to load. On top of that you also have to do interpolation which might be cumbersome. Thanks |
|
March 29, 2024, 02:26 |
|
#5 |
New Member
Lucas Liu
Join Date: Nov 2023
Posts: 4
Rep Power: 3 |
Hi,
Thank you for your response. I've implemented the method you suggested, and it was successful. However, I'm now looking to use my simulation results to train a reinforcement learning model, which requires probing data millions of times at various times and locations. I've found that using macros in Paraview isn't very efficient for this purpose. Do you have any alternative suggestions? Alternatively, is there a way to convert vtk data into a database format that can efficiently output velocity data in the [u, v, w] format when given specific simulation times and coordinates? |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Extract data at a specific depth | reespanau | OpenFOAM Post-Processing | 1 | May 15, 2023 07:45 |
How to extract data from a specific layer of the grid? | reespanau | Main CFD Forum | 1 | January 10, 2023 22:47 |
[OpenFOAM] Get cell center coordinates in a python script | francois | ParaView | 2 | June 3, 2017 09:20 |
[General] 2 datas on one plot | Akuji | ParaView | 46 | December 1, 2013 15:06 |
Two-Phase Buoyant Flow Issue | Miguel Baritto | CFX | 4 | August 31, 2006 13:02 |