CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

sampleDict output for transient simulation

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By rajan19us
  • 1 Post By blebon

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 13, 2017, 07:09
Default sampleDict output for transient simulation
  #1
New Member
 
Andrea
Join Date: Sep 2017
Posts: 12
Rep Power: 8
ab2484 is on a distinguished road
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
ab2484 is offline   Reply With Quote

Old   December 14, 2017, 06:20
Default
  #2
New Member
 
Join Date: Oct 2017
Location: Germany
Posts: 26
Rep Power: 8
rajan19us is on a distinguished road
Hi Andrea,

Try "Plot selection over time" Filter in Paraview and then export the graph in .csv file.


Regards,
Rajan
rajan19us is offline   Reply With Quote

Old   December 14, 2017, 06:55
Default
  #3
New Member
 
Andrea
Join Date: Sep 2017
Posts: 12
Rep Power: 8
ab2484 is on a distinguished road
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.
ab2484 is offline   Reply With Quote

Old   December 14, 2017, 08:01
Default
  #4
New Member
 
Join Date: Oct 2017
Location: Germany
Posts: 26
Rep Power: 8
rajan19us is on a distinguished road
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
parthigcar likes this.
rajan19us is offline   Reply With Quote

Old   December 14, 2017, 10:42
Default
  #5
New Member
 
Andrea
Join Date: Sep 2017
Posts: 12
Rep Power: 8
ab2484 is on a distinguished road
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
ab2484 is offline   Reply With Quote

Old   December 15, 2017, 02:06
Smile
  #6
New Member
 
Join Date: Oct 2017
Location: Germany
Posts: 26
Rep Power: 8
rajan19us is on a distinguished road
Hi Andrea,

You're welcome.

Yes, that's exactly what I meant.

Regards,
Rajan
rajan19us is offline   Reply With Quote

Old   December 15, 2017, 10:56
Default Python to the rescue
  #7
Member
 
Bruno Lebon
Join Date: Dec 2012
Posts: 33
Rep Power: 13
blebon is on a distinguished road
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()
parthigcar likes this.
blebon is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 00:27.