|
[Sponsors] |
December 13, 2017, 07:09 |
sampleDict output for transient simulation
|
#1 |
New Member
Andrea
Join Date: Sep 2017
Posts: 12
Rep Power: 8 |
Dear All,
I have been looking for an answer to my simple question but I failed, so I am sure that you can help me. I want to use the sampleDict dictionary to do some post-pro after the simulation is done Openfoam 4.X). My simulation is transient and I want to check and plot some point values, so I'd like to have a .csv or .txt file including all my saved timesteps for a given point, like the utility Probes does. Is that possible? Thank you for your help, Wishes Andrea |
|
December 14, 2017, 06:20 |
|
#2 |
New Member
Join Date: Oct 2017
Location: Germany
Posts: 26
Rep Power: 8 |
Hi Andrea,
Try "Plot selection over time" Filter in Paraview and then export the graph in .csv file. Regards, Rajan |
|
December 14, 2017, 06:55 |
|
#3 |
New Member
Andrea
Join Date: Sep 2017
Posts: 12
Rep Power: 8 |
Dear Rajan,
Thank for your reply. Yes, I tried to locate some points and use that, but the fact is that I cannot chose the coordinates of the points, just guess their position manually. |
|
December 14, 2017, 08:01 |
|
#4 |
New Member
Join Date: Oct 2017
Location: Germany
Posts: 26
Rep Power: 8 |
Ahh....okay I am just a beginner in this topic. So the way I figured out to solve it is not so sophisticated (maybe experts know how to do it in a decent way).
Use "Extract location" to select the desired node and then by observing this node, you can use "Plot selection over time" filter to select the closest node. I hope it was helpful. Regards, Rajan |
|
December 14, 2017, 10:42 |
|
#5 |
New Member
Andrea
Join Date: Sep 2017
Posts: 12
Rep Power: 8 |
I am a begginner too, and I found your advice really usefull. Basically you search for a given point and then manually allocate a sampling point as close as possible to it, right?
Many thanks for you reply, if I find a different method I will keep you updated. Kind regards Andrea |
|
December 15, 2017, 02:06 |
|
#6 |
New Member
Join Date: Oct 2017
Location: Germany
Posts: 26
Rep Power: 8 |
Hi Andrea,
You're welcome. Yes, that's exactly what I meant. Regards, Rajan |
|
December 15, 2017, 10:56 |
Python to the rescue
|
#7 |
Member
Bruno Lebon
Join Date: Dec 2012
Posts: 33
Rep Power: 13 |
I wrote a Python script for that and it works like a charm:
Code:
from __future__ import print_function, division from os import getcwd, environ, path, getenv, makedirs import sys import numpy as np import pandas as pd environ['PARAVIEWDIR']=getenv('HOME') + '/OpenFOAM/ThirdParty-4.1/build/linux64Gcc/ParaView-5.0.1' environ['PYTHONPATH']=getenv('PARAVIEWDIR') + r';' + getenv('PARAVIEWDIR') + '/lib;' + getenv('PARAVIEWDIR') + '/lib/site-packages;' for i in [getenv('PARAVIEWDIR'), getenv('PARAVIEWDIR') + '/lib', getenv('PARAVIEWDIR') + '/lib/site-packages']: if i not in sys.path: sys.path.append(i) from paraview.simple import * from paraview.numpy_support import vtk_to_numpy SOURCE = OpenFOAMReader(FileName="case.foam") SOURCE.MeshRegions = ['internalMesh'] probe = ProbeLocation(SOURCE, ProbeType = "Fixed Radius Point Source") probe.ProbeType.Center = [0, 0, -0.06] # probe location [x,y,z] <-- use coordinate you need to extract from here # Loop through the files probeResults = [] variable = 'p' # name of the array <-- use name of the variable to extract here times = SOURCE.TimestepValues # animationScene1.GoToFirst() for time in times: print(time) #SOURCE.UpdatePipelineInformation() probe.UpdatePipeline(time) data = servermanager.Fetch(probe) probeResults.append(ns.vtk_to_numpy(data.GetPointData().GetArray(variable))) # animationScene1.GoToNext() f = open('data.csv', 'w') f.write('t (s), p (Pa)\n') for i in range(len(times)): f.write("{0:10.5e},{1:10.5e}\n".format(times[i], probeResults[i][0])) f.close() |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using output parameter as input parameter within the same simulation | jjfm20 | FLUENT | 11 | November 6, 2017 08:53 |
How Coorectly Run sampleDict | FlyBob91 | OpenFOAM Post-Processing | 5 | September 13, 2017 04:01 |
restarting paused transient simulation using reactingFoam | JMDag2004 | OpenFOAM Running, Solving & CFD | 1 | August 10, 2015 10:15 |
Flow Simulation output control | joaopffg | FloEFD, FloWorks & FloTHERM | 5 | February 11, 2015 10:07 |
9.4 version...is it possible to analyse the output of a 9.3 simulation?? | sdr | FLOW-3D | 6 | February 12, 2010 04:57 |