CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSYS (https://www.cfd-online.com/Forums/ansys/)
-   -   Loop through timesteps in the command editor of CFD-Post and write evaluated function (https://www.cfd-online.com/Forums/ansys/132744-loop-through-timesteps-command-editor-cfd-post-write-evaluated-function.html)

eaysk April 5, 2014 12:00

Loop through timesteps in the command editor of CFD-Post and write evaluated function
 
Hello!

I am trying evaluate the volume averaged water volume fraction for each timestep I have run.
I have written these commands in the command editor of CFD-Post.

#************************************************* *********************

! open(OFH, " >> file.dat"); # writing to a file

# for loop start

! for ($i=100; $i <= 28000; $i=$i+100) {

COMMAND FILE:
CFX Post Version = 14.5.7
END

> load filename=C:\bcp4_3_v4_sr4_omg15_pw3\bcp4_3_v4_sr4_ omg15_pw3 (fi=0.9097)\bcp4_3_v4_sr4_omg15-13-00$i.dat
! $vff= volumeAve(Water.Volume Fraction, "Plane 1");
! printf (OFH "1.8f\n",$vff;
!}

! close(OFH);
#************************************************* *********

I get the error-
ERROR
CCL parser failed with message:
Perl Syntax errors detected:
syntax error at (eval 6235) line 11, at EOF

Could somebody tell me whether I am on the right track with the code? If yes, then how can I correct it?

Cheers.

eaysk April 7, 2014 06:29

I don't see the difference..

I have changed the code now. I get no errors, but nothing is written to file.txt, no matter what I do. Even the simplest of commands such as

!open(FH, '<file.txt');
!printf (FH, "Hello");
!close(FH);

does not print to file!

Here is my new code-

#*************************************************
COMMAND FILE:
CFX Post Version = 14.5.7
END
! my $file=file.txt;
! open(FH, '>$file'); # writing to a file

!$start = 200;
!$finish = 400;
! for ($i=$start; $i <= $finish; $i=$i+100) {

!if($i<1000){
> load filename=C:\bcp4_3_v4_sr4_omg15_pw3\bcp4_3_v4_sr4_ omg15_pw3 (fi=0.9097)\Data files\bcp4_3_v4_sr4_omg15-13-00$i.dat
!}
!elsif($i<10000){
> load filename=C:\bcp4_3_v4_sr4_omg15_pw3\bcp4_3_v4_sr4_ omg15_pw3 (fi=0.9097)\Data files\bcp4_3_v4_sr4_omg15-13-0$i.dat
!}
!else{
> load filename=C:\bcp4_3_v4_sr4_omg15_pw3\bcp4_3_v4_sr4_ omg15_pw3 (fi=0.9097)\Data files\bcp4_3_v4_sr4_omg15-13-$i.dat
!}
! $vol_frac_fluid= areaAve("Water.Volume Fraction", "Plane 1");
!printf(FH "1.8f\n",$vol_frac_fluid);

!}

! close(FH);
#************************************************* *********


All times are GMT -4. The time now is 14:07.