|
[Sponsors] |
how to export every data w.r.t time to txt file |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 6, 2014, 14:49 |
|
#81 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
I am not sure but it seems illogical to me to name the output like a usual variable. Just name it FH and try again.
|
|
April 6, 2014, 15:21 |
|
#82 |
New Member
Sagar
Join Date: Apr 2014
Posts: 10
Rep Power: 12 |
Did you mean that I rename $vol_frac_fluid to $FH?
I did that but its still not working. |
|
April 6, 2014, 15:58 |
|
#83 |
New Member
Sagar
Join Date: Apr 2014
Posts: 10
Rep Power: 12 |
Even the simplest of file writing commands don't seem to work for me.
I tried this- COMMAND FILE: CFX Post Version = 14.5.7 END ! open($FH, ">data.txt"); ! printf($FH ,100); ! close($FH); But it wrote nothing in data.txt |
|
April 6, 2014, 17:31 |
|
#84 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
! open(FH, ">data.txt");
! printf(FH ,100); ! close(FH); |
|
April 6, 2014, 17:46 |
|
#85 |
New Member
Sagar
Join Date: Apr 2014
Posts: 10
Rep Power: 12 |
I get an error now-
ERROR CCL parser failed with message: Perl Syntax errors detected: No comma allowed after filehandle at (eval 5707) line 6. |
|
April 6, 2014, 18:12 |
|
#86 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
! open (MYFILE, '>>data.txt');
! print MYFILE "Bob\n"; ! close (MYFILE); |
|
April 7, 2014, 06:38 |
|
#87 |
New Member
Sagar
Join Date: Apr 2014
Posts: 10
Rep Power: 12 |
That isn't working either.
Is it necessary to include any perl libraries into the code? What I mean is that in C, when printf is used, it becomes necessary to include the standard input-output library using #include<stdio.h>. When other input-output functions cin and cout are used, we write #include<iostream.h>... I have also created a file called file.txt or data.txt in the folder where I saved my data files 'bcp4_3_v4_sr4_omg15-13-00200' to 'bcp4_3_v4_sr4_omg15-13-28000' and the state file for 'Plane 1' before I ran the code. But nothing is written into the files! Not even for simple commands like- ! open (MYFILE, '>>data.txt'); ! print MYFILE "Bob\n"; ! close (MYFILE); But I don't get any errors either.. Note that I am able to load my datafiles, I am just not able to write to file. |
|
April 7, 2014, 06:48 |
|
#88 |
Senior Member
Matthias Voß
Join Date: Mar 2009
Location: Berlin, Germany
Posts: 449
Rep Power: 20 |
Try to do a search on the created file "data.txt" in your system. If there is no error, then the task was completed. And at least an empty data.txt was created somewhere.
|
|
April 7, 2014, 07:18 |
|
#89 |
Senior Member
Lance
Join Date: Mar 2009
Posts: 669
Rep Power: 22 |
Check that the current directory is where you think it is.
Code:
!use Cwd; !print cwd(); |
|
April 7, 2014, 07:37 |
|
#90 |
New Member
Sagar
Join Date: Apr 2014
Posts: 10
Rep Power: 12 |
There is no empty text file created. I thought that there should already be an existing file in the working directory with the name of the file that would contain the output.. So I created a text file in the working directory and then run the code. But it makes no difference whatever method I do. I can load the files but not write to files.
Should I be using the Command Editor of CFD-Post to process my code? Because I don't understand where a print function would display the output.. So I can't print the current working directory anywhere. |
|
April 7, 2014, 08:09 |
|
#91 |
Senior Member
Lance
Join Date: Mar 2009
Posts: 669
Rep Power: 22 |
Yes, use the command editor. I run CFX under linux and get the output to the terminal window. But I think that if you start cfd-post in stand alone there's an output window (think DOS-style) as well?
|
|
April 7, 2014, 09:14 |
|
#92 |
Senior Member
Bruno
Join Date: Mar 2009
Location: Brazil
Posts: 277
Rep Power: 21 |
If printing the average volfrac at a plane is all you want to do, why not just use the built in chart from Post?
Anyway, try using the complete file path to the file you want to write. That might make things easier: Code:
! open(OUT, ">E:/TEMP/test.txt"); ! print OUT "testing:\n"; ! printf(OUT "%.8e\n", 1.23); ! close(OUT); Code:
COMMAND FILE: CFX Post Version = 14.5.7 END ! my $file="C:/file.txt"; ! open(FH, ">$file"); ! ! $start = 200; ! $finish = 28000; ! $basename = "C:/bcp4_3_v4_sr4_omg15_pw3/bcp4_3_v4_sr4_ omg15_pw3 (fi=0.9097)/Data files/bcp4_3_v4_sr4_omg15-13"; ! for ($i=$start; $i <= $finish; $i=$i+100) ! { ! if($i<1000) { > load filename=$basename-00$i.dat ! } ! elsif($i<10000) { > load filename=$basename-0$i.dat ! } ! else { > load filename=$basename-$i.dat ! } ! ! $vol_frac_fluid = areaAve("Water.Volume Fraction", "Plane 1"); ! printf(FH "1.8f\n", $vol_frac_fluid); ! } ! close(FH); |
|
April 7, 2014, 10:18 |
|
#93 |
New Member
Sagar
Join Date: Apr 2014
Posts: 10
Rep Power: 12 |
Thank you so much Bruno!
There were was wrong syntax i.e. backlash instead of frontslash, in the file specification.. It works file now The basename suggestion doesn't work because the string gets formatted whenever \b comes up in the file name Is it possible to make a chart for water.volumefraction vs. timestep directly using Post tools? |
|
April 7, 2014, 10:58 |
|
#94 |
Senior Member
Bruno
Join Date: Mar 2009
Location: Brazil
Posts: 277
Rep Power: 21 |
Use slashes (/), not backslashes (\). A slash won't cause you problems. I tested it here and it worked fine.
And yes, it's possible to generate what you want using a chart in Post. You just need to create an expression with what you want to plot. One of the tutorials from CFX covers that. Look for the ones that use a transient setup or take a look at the documentation for charts in CFD-Post. |
|
August 25, 2015, 10:45 |
|
#95 |
New Member
Join Date: Aug 2015
Posts: 1
Rep Power: 0 |
Hey Guys,
I know this thread is quite old, but I have a question I can not solve by myself and hope somebody can help me. I have ran a simulation and do have 2000 .trn files. From these files I want to extract the pressure and the velocity. I am already able to do this, however I have to import ever .trn file before I can run my script otherwise I get 2000 .csv files with the same value. I hope somebody can help me! here is my script: COMMAND FILE: CFX Post Version = 16.0 END DATA READER: Clear All Objects = false Append Results = false Edit Case Names = false Open to Compare = false Multi Configuration File Load Option = Last Case Open in New View = true Keep Camera Position = true Load Particle Tracks = true Files to Compare = Construct Variables From Fourier Coefficients = True END DATA READER: Domains to Load= END > load filename = /file.res , \ force_reload=true ! use strict; ! use warnings; ! my $trn; ! for ($trn = 6001; $trn <= 6007; $trn ++ ){ ! print "$trn\n "; > load timestep = $trn > addtimestep filename=path/$trn.trn,\ case=file.res , ignoreduplicates=true EXPORT: ANSYS Export Data = Element Heat Flux ANSYS File Format = ANSYS ANSYS Reference Temperature = 0.0 [K] ANSYS Specify Reference Temperature = Off ANSYS Supplemental HTC = 0.0 [W m^-2 K^-1] Additional Variable List = BC Profile Type = Inlet Velocity Export Connectivity = Off Export Coord Frame = Global Export File =/path/plane$trn.csv Export Geometry = On Export Location Aliases = Export Node Numbers = Off Export Null Data = On Export Type = Generic Export Units System = Current Export Variable Type = Current External Export Data = None Include File Information = Off Include Header = On Location = inlet Location List = /PLANE:Plane 1 Null Token = null Overwrite = On Precision = 10 Separator = ", " Spatial Variables = X,Y,Z Variable List = Pressure, Velocity u, Velocity v, Velocity w Vector Brackets = () Vector Display = Scalar END >export ! }; |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] swak4foam building problem | GGerber | OpenFOAM Community Contributions | 54 | April 24, 2015 17:02 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 07:20 |
OpenFOAM on MinGW crosscompiler hosted on Linux | allenzhao | OpenFOAM Installation | 127 | January 30, 2009 20:08 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |
Could anybody help me see this error and give help | liugx212 | OpenFOAM Running, Solving & CFD | 3 | January 4, 2006 19:07 |