CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Writing surface report to a file using journal file

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2021, 11:53
Default Writing surface report to a file using journal file
  #1
New Member
 
Join Date: Apr 2021
Posts: 4
Rep Power: 5
eccc is on a distinguished road
Hi
I'm currently attempting something that should be relatively straightforward: I want to take an area-weighted average on a surface, and write that value to a file using a journal command. I want to do this from an existing data file, not as I'm running my calculation.

This is easily achievable through the GUI by simply going through the report interface and clicking 'write' after I've calculated my average. However, I can't seem to find an equivalent journal command. (The report/surface-integrals tree doesn't have a write option, and the file tree doesn't seem to have a surface-integrals option)

(The reason I'm doing this is simply that I have a large number of data files that I'd like to loop through and take the report from each of them)
eccc is offline   Reply With Quote

Old   April 15, 2021, 22:33
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
you don't need journal file to do that
it is possible to write to file integrals vs time:
solution -> report-definition -> new -> surface-report -> area-weight average -> select variable and face -> OK

now create output file:
solution-> monitors -> report Files -> new -> select your variable -> define file name -> OK
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   April 16, 2021, 05:10
Default
  #3
New Member
 
Join Date: Apr 2021
Posts: 4
Rep Power: 5
eccc is on a distinguished road
Thanks for your response. Unfortunately I'm not sure its applicable to my case, as I already have the solution data files and I don't want to rerun the simulation.
I'm looking instead to write the value from a journal file as I already have a script to loop through the existing data files and perform the journal operations on them. I'd rather not go through each one manually writing out the value.
eccc is offline   Reply With Quote

Old   April 19, 2021, 01:30
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
to write output at the end of file:
Code:
(ti-menu-load-string (format #f " report surface-integrals area-weighted-avg *surface_name* () *variable* yes *filename.srp*  "))
change *surface_name*, *variable*, *filename.srp* according to your needs, * is not needed

output will look like this
Quote:
"Surface Integral Report"

Area-Weighted Average
Static Temperature (k)
----------------------------------------------------
surface_name 299.99997
or you can get only value:
Code:
(pick-a-real  (format #f "report surface-integrals area-weighted-avg *surface_name* () *variable* no"))
in that case you should organize writing to file using scheme language

Code:
;;;write to file
(define call-with-output-file
	  (lambda (filename proc)
		(let ((p (open-output-file filename "a"))) ;;; a means my_append
		  (let ((v (proc p)))
			(close-output-port p)
			v)))
)
;;;write to file in format: Filename | Data (as a list)
(define (write_this filename data)
	(call-with-output-file filename
	  (lambda (p)
		(let f ((ls data))
			(if (not (null? ls))
				(begin
					(write (car ls) p)
					(write #\tab p)
					(f (cdr ls))
				)
				(newline p)
			))))
)
;;;convert list from pairs
(define (flatten x)
	(cond 
		((null? x) x)
		((and (pair? x) 
			  (not (pair? (car x))))
		 (cond 
		   ((null? (car x)) (flatten (cdr x)))
		   (else (cons (car x) (flatten (cdr x))))))
		((and (pair? x)
			  (pair? (car x)))
		 (flatten (cons (caar x) 
						(cons (cdar x) (cdr x)))))
		(else (cons x '())))
)
;;; put face name inside " " | example (get_surface_avg "surface_name")
(define (get_surface_avg surface_name)
	(pick-a-real  (format #f "report surface-integrals area-weighted-avg ~a () *variable* no" surface_name))
)
;;; run this to execute
(write_this "_surface_avg" (flatten (get_surface_avg "surface_name")))
so you will need to put last line (write_this "_surface_avg" (flatten (get_surface_avg "surface_name"))) inside loop over data files
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   April 19, 2021, 07:29
Default
  #5
New Member
 
Join Date: Apr 2021
Posts: 4
Rep Power: 5
eccc is on a distinguished road
Thanks so much for this - although actually I realise now that the option to write to file was always there under report and I simply wasn't going far enough to find it. Incidentally, I'm having a hard time finding much documentation on the scheme language. Do you have any good source of info on it?
eccc is offline   Reply With Quote

Old   April 20, 2021, 01:07
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
https://www.researchgate.net/publica..._Dokumentation

there you can find literature list, but in German:
Quote:
Leider gibt es außer diesem Dokument keine Literatur, die speziell auf Fluent-Scheme eingeht. DaScheme eine sehr mächtige Sprache ist, mit der anspruchsvolle Anwendungen wie KünstlicheIntelligenz realisiert werden können, gehen die meisten Scheme-Bücher viel weiter in die Tiefe, alses für Fluent notwendig ist. Ich verwende das Buch:R. Kent Dybvig, The Scheme Programming Language, Second Edition, 1996 Prentice Hall PTR.Online Version: http://www.scheme.com/tspl2d/index.html [http://www.scheme.com/tspl2d/index.html]Fluent empfielt folgende Scheme-Links im Web:http://www.swiss.ai.mit.edu/projects/scheme [http://www.swiss.ai.mit.edu/projects....schemers.org/ [http://www.schemers.org/]Einige Scheme-Beispiele zu FLUENT sind mittlerweile im FLUENT User Service Center im „OnlineTechnical Support“ zu finden:http://www.fluentusers.com/ [http://www.fluentusers.com/]Überblick über Online-Scheme Literatur im Netz:http://library.readscheme.org/page2.html [http://library.readscheme.org/page2.html]
there was english version somewhere, you may try to find it
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ 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
[swak4Foam] Installation Problem with OF 6 version Aurel OpenFOAM Community Contributions 14 November 18, 2020 16:18
OpenFoam "Permission denied" and "command not found" problems. iyidaniel@yahoo.co.uk OpenFOAM Running, Solving & CFD 11 January 2, 2018 06:47
Trouble compiling utilities using source-built OpenFOAM Artur OpenFOAM Programming & Development 14 October 29, 2013 10:59
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 01:41
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 11:44


All times are GMT -4. The time now is 18:39.