CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Mesh Generation & Pre-Processing Software > Pointwise & Gridgen

Script to export each domain separately

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 27, 2019, 04:02
Default Script to export each domain separately
  #1
New Member
 
Join Date: May 2017
Posts: 3
Rep Power: 9
natan is on a distinguished road
Hello,


I need to export each domain in my mesh as a PLOT3D file separately. With many domains this can be a really cumbersome task. Is there a script I could run for this?
natan is offline   Reply With Quote

Old   March 27, 2019, 18:29
Default
  #2
Senior Member
 
David Garlisch
Join Date: Jan 2013
Location: Fidelity Pointwise, Cadence Design Systems (Fort Worth, Texas Office)
Posts: 307
Rep Power: 14
dgarlisch is on a distinguished road
you can create your own script.

As a guide, export one or two domains by hand with journaling.

Script, Begin Journaling...
Export one or two domains to Plot3D by hand.
Script, End Journaling

Using this journal as a guide, you can write a script that will grab all domains in model and then export them one by one.

See Glyph docs here.

Example Glyph scripts here.

See also pw::Grid getAll -type pw::DomainStructured to capture structured domains.
dgarlisch is offline   Reply With Quote

Old   March 28, 2019, 03:28
Default
  #3
New Member
 
Join Date: May 2017
Posts: 3
Rep Power: 9
natan is on a distinguished road
Thank you. I have consulted those sources and created a script based on the journal. Is there a for loop or something similar so that I can loop through all structured domains instead of changing the domain name every time? Also, is there a way to set a variable so that I can save a file based on the domain name?
natan is offline   Reply With Quote

Old   March 28, 2019, 10:06
Default
  #4
Senior Member
 
David Garlisch
Join Date: Jan 2013
Location: Fidelity Pointwise, Cadence Design Systems (Fort Worth, Texas Office)
Posts: 307
Rep Power: 14
dgarlisch is on a distinguished road
I have attached a skeleton script that you can edit. It loops over all the structured domains in a grid.

I also added a few personal "best practices" to the script for your consideration.

Good luck.

Code:
# Load the Pointwise Glyph library
package require PWI_Glyph


#============================================================================
# Set up the global environment
#============================================================================

# Capture the directory in which the is located
set scriptDir [file dirname [info script]]

if { ![info exists argv] } {
    # must be running from the Pointwise GUI
    set argc 0
    set argv[list]
}


#============================================================================
# Define procs
#============================================================================


#-----------------------------------------------------------------------------
proc main { argv } {
  # if run from the command line, you can pass arguments
  processArgs $argv

  # Capture a list of all structured domains in the current grid
  set allStrDoms [pw::Grid getAll -type pw::DomainStructured]

  # loop through domains and export one at a time
  foreach strDom $allStrDoms {
    doExport $strDom
  }
}


#-----------------------------------------------------------------------------
proc processArgs { argv } {
  # Add command line processing here if needed

  # for now, just print all args to console
  if { 0 == [llength $argv] } {
    puts "No command line arguments found."
  } else {
    puts "argv:"
    foreach arg $argv {
      puts "  '$arg'"
    }
  }
}


#-----------------------------------------------------------------------------
proc doExport { strDom } {
  set domName [$strDom getName]

  # Be careful. The domain name MUST be only contain valid filename chars or the
  # export will fail!

  # The filename is in the same folder as the script.
  set filename [file join $::scriptDir "$domName.x"]

  puts "Exporting $filename ..."

  #####
  ##### put grid export code here
  #####
}


#============================================================================
# Invoke main AFTER all data and procs have been defined.
#============================================================================

main $argv


#============================================================================
# NOTE:
# Calling main as the starting point of a script is a personal preference.
# It is not required by Glyph or Tcl. You could also just put the code from main
# here at the end. I just like having main as the first proc in a script.
#============================================================================
Attached Files
File Type: zip domain-loop.zip (1,010 Bytes, 2 views)
dgarlisch is offline   Reply With Quote

Reply

Tags
domain, export, pointwise, script, separately


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
script for export particle information archetype CFX 2 August 8, 2017 09:57
Periodic Pressure drop cfd_begin CFX 10 May 25, 2017 07:09
Export Solid Domain Autogrid5 karwendel Fidelity CFD 2 March 29, 2017 03:52
Closed Domain Buoyancy Flow Problem Madhatter92 CFX 6 June 20, 2016 21:05
Monte Carlo Simulation: H-Energy is not convergating & high Incident Radiation volleyHC CFX 5 April 3, 2016 05:41


All times are GMT -4. The time now is 20:01.