Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.
Fluids

Fluids

Topics related to Fluent, CFX, Turbogrid and more.

Offscreen rendering of “playback” scenarios

    • Holzmann
      Subscriber

      Hey everybody,

      I have a bunch of animations created for a larger case and need to create the single images for each frame. Hence, I am trying to search a way to do all the work in a batch-mode (offscreen) scenario. I guess I need a journal file for that. However, the question still arises if it is possible to do the following:

      • Loop through all cxa files
      • Save each frame of the cxa animation as *png file
      • Go on to the next cxa file


    • DrAmine
      Ansys Employee
      You can try using TUI commands to do that and launch Fluent in batch but with graphics support (-gu -driver null). The journal file needs to read the cxa file, generate pictures and then go to the next one You might loop here using Scheme.
    • Holzmann
      Subscriber
      Hi Amine well, I checked it out already and the problem is that I need to read the *.hsf files in the TUI. I am solving that problem by creating a bash script which creates the journal file for me. As I am not very familiar with the journal file-stuff (programming) it is the easiest way for me.
      Just to clarify, the bash script will read all *.cxa files and create for each *.cxa file one *.jou file that inherits all single TUI commands to create the single frames. The main key here is the loop through the *.hsf files:
      /display/hsf-file xy-0001.hsf
      /display/re-render
      /display/save-picture
      ... Do it thousands of times :)

      Thanks for your comment.

    • DrAmine
      Ansys Employee
      Okay you saved in hsf file: next time save directly in the right picture format.
      There is nothing special about TUI journals: just start journal and search with the Command searcher after the right TUI command and only the right commands will be stored in the journal.
      You do not need to read hsf file you just need to read the cxa referring to all of these hsf files.
    • Holzmann
      Subscriber
      Okay, where can I find the "command searcher". I did not find anything helpful to read the *.cxa file and save it.
      By the way. I am always having the problem that the "colors" of the rendered images seems that the "lightning" are still set to on even though, I turned it off. It is an interesting phenomenon because it seems that deactivating the "lightning" via TUI will not change the scene in terms of coloring (re-render is not helpful too). The only way is to "mouse-click" the "lighting" checkbox in the GUI but the TUI command is not working (at least it seems to not work for me).
      I don┬┤t want to save the animation into an appropriate picture-formate as I am not able to move the perspective anymore (and that is bad if you run a calculation 2 weeks)
      What I have until now is:

      /display/views read-views "viewPosition.vw"

      /display/hsf-file "animation-settling-standard-feuchte_0000.hsf"
      /display/set/lights headlight-on no
      /display/set/lights lights-on no
      /display/views restore-view view-0
      /display/set/picture/driver png
      /display/save-picture "animation-settling-standard-feuchte_0000"

      /display/hsf-file "animation-settling-standard-feuchte_0001.hsf"
      /display/set/lights headlight-on no
      /display/set/lights lights-on no
      /display/views restore-view view-0
      /display/set/picture/driver png
      /display/save-picture "animation-settling-standard-feuchte_0001"

      ####### Repeat until we reached the end-frame
      So my bash-script is done and the journal file is written correctly. However - still the "lighting" problem exists. Any idea.
    • DrAmine
      Ansys Employee
      Top Right "Quick Search".
    • DrAmine
      Ansys Employee
      You might disable the lighting under Preferences globally. There are some options which you can make them default for all cases
    • Holzmann
      Subscriber
      I want to post my solution here as it has some nice benefits (at least for me).
      I built a bash script that reads all *.cxa files at the current directory and built a corresponding journal file for each *.cxa file
      Based on two input-parameters, it sets the view (camera)
      Furthermore, it deactivates the "lightning" and "headlights"
      The nice thing is, that one can use the "cat *.jou \> executeAllJournals.jou" command to combine each single journal file to one single guy which will create all the pictures for all *.cxa files.
      The bash script is given as follows (you might adapt it to your needs)...

      #!/bin/bash
      #==============================================================================
      #
      # A bash script that creates a journal file for creating single frames of an
      # animation to be used for a batch-mode-generation of the frames
      #
      # 16.07.2021
      # Tobias Holzmann
      #
      # Usage:
      #a) Copy this script into your folder in which the cxa files are located
      #b) Simply provide the viewFile and the viewName for the animations
      #Create these data in Fluent GUI
      #c) Finally, define which *.cxa file should be used. If the cxaFile="*.cxa"
      #each cxa File is analyzed and a corresponding journal file is written
      #d) Execute the bash script in a terminal by typing
      #./fluentAnimationJournalGeneration
      #e) After the journal files are created, you start fluent in batch-mode
      #fluent211 -gu -driver null -t11 3ddp
      #
      #-t11 tells fluent to start with 11 processors (parallel)
      #3ddp := start fluent in 3d and double precision
      #3d:= start fluent in 3d and single precision
      #
      #f) Load the journal file:
      #> file/read-journal "myJournalFile.jou"
      #
      #Note: if the cxaFile="*.cxa" each animation has the same view port
      #
      #Note: If you have more journal files you can simply copy-paste the
      #data of each file into one large file and execute only one journal
      #file that does all the jop. Alternative one command:
      #cat *.jou > myNewJournalFile.jou
      #
      #==============================================================================

      viewFile="viewPosition.vw"
      viewName="view-0"
      cxaFiles="*.cxa"

      #==============================================================================
      clear

      for i in `ls $cxaFiles`
      do
      echo "Analyzing the files $i"
      echo \
      "
      ;==============================================================================
      ; A script that does a batch-mode-rendering job
      ; 16.07.2021
      ; Tobias Holzmann
      ;==============================================================================

      /display/views read-views \"$viewFile\"
      " > ${i::-4}.jou


      # Now read the cxa file, take the *hsf files and create the commands in the
      # journal file to save each single frame
      while IFS= read -r line
      do
      if [ "$(echo $line | grep -c "hsf")" -eq 1 ]
      then
      frameName=$(echo $line | xargs | cut -d' ' -f4)
      echo \
      "
      /display/hsf-file \"$frameName\"
      /display/set/lights headlight-on no
      /display/set/lights lights-on no
      /display/views restore-view $viewName
      /display/set/picture/driver png
      /display/save-picture \"${frameName::-4}\"" >> ${i::-4}.jou
      fi

      done < "$i"

      echo "${i::-4}.jou created sucessfully..."
      done

      echo "-------------------------------------------------------"
      echo "Open fluent in batch mode by providing the journal file"
      echo "fluent211 -gu -driver null -t10"
      echo "After that load 3d or 3ddp and read the journal file in the TUI"
      echo ">file/read-journal \"yourFile.jou\""
      echo "Note: t10 means -> parallel execution using 10 cores"



    • DrAmine
      Ansys Employee
      Thanks for posting your solution. I allowed myself to remove your last statement.
Viewing 8 reply threads
  • The topic ‘Offscreen rendering of “playback” scenarios’ is closed to new replies.
[bingo_chatbox]