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

Importing multiple P3D grid files into Pointwise

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 24, 2017, 11:28
Default Importing multiple P3D grid files into Pointwise
  #1
gsh
New Member
 
Greg
Join Date: Aug 2015
Posts: 4
Rep Power: 10
gsh is on a distinguished road
Hello All,

I have separated a single domain into 48 blocks for parallel processing and I want to bring them back into Pointwise for grid refinement. I was wondering if there is a built-in means of importing multiple P3D grid files at a single time so that all of the grids are imported (rather than having to manually import each file). Or if there is no built-in function in Pointwise how do i go about writing a code to do so?

Thank you for the assistance with this issue,
gsh
gsh is offline   Reply With Quote

Old   January 24, 2017, 19:45
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
Nope. A script is your best bet.
dgarlisch is offline   Reply With Quote

Old   January 27, 2017, 16:56
Default
  #3
gsh
New Member
 
Greg
Join Date: Aug 2015
Posts: 4
Rep Power: 10
gsh is on a distinguished road
Well I tried to do the journal file route: make a journal file, change the journal file code so it fits my purpose (hard coded), use re-appropriated journal/glyph file. However, since I have not found an explicit set of pointwise instructions on importing any file type; I have not been able to get the glyph to work. I put the code that I have been trying to use below.

Any insight would be appreciated.


----
package require PWI_Glyph

# X is the number of multi-blocks to import
# -----------------------------------------------
set x 48
set i 1

while {$i <= $x} {

# grid is the location and file
set grid_file "/home/split-on-hub/ast.b$i.x"
set _TMP(mode_1) [pw::Application begin GridImport]
$_TMP(mode_1) initialize -type Automatic {$grid_file}
$_TMP(mode_1) read
$_TMP(mode_1) convert
$_TMP(mode_1) end
unset _TMP(mode_1)
incr i
}
----
gsh is offline   Reply With Quote

Old   January 27, 2017, 17:28
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
Since you changed the literal file name in the journal from {/path/to/the/filename.x} to a variable, you don't want the {} any more.

So change:
$_TMP(mode_1) initialize -type Automatic {$grid_file}
to
$_TMP(mode_1) initialize -type Automatic $grid_file

Also, since you know the actual file type, you can change Automatic to PLOT3D.


FINAL SCRIPT:

Code:
package require PWI_Glyph

# $numFiles is the number of multi-blocks to import
# -------------------------------------------------
set numFiles 48

# Only need to create mode once and reuse it
set ioGrid [pw::Application begin GridImport]

for {set i 1} {$i <= $numFiles} {incr i} {
  # use ${i} embedded inside string to make variable name explicit.
  # otherwise parser might think the var name is $i.x
  $ioGrid initialize -type PLOT3D "/home/split-on-hub/ast.b${i}.x"
  $ioGrid read
  $ioGrid convert
}

# Now we are done with mode.
# Using "end" will make all changes permanent.
# Using "abort" will throw away all changes made since mode was created.
$ioGrid end
unset ioGrid


Why?

In Glyph (Tcl) anything inside {} is NOT expanded with variable substitution. So your code was trying to import a file actually named {$grid_file}.


A little trick:

Code:
# capture the script folder
set scriptDir [file dirname [info script]]

# construct full path and filename
set fullFileName [file join $scriptDir "filename.x"]

# $fullFileName is something like:
#    /path/to/script/folder/filename.x
dgarlisch is offline   Reply With Quote

Old   January 27, 2017, 17:58
Default
  #5
gsh
New Member
 
Greg
Join Date: Aug 2015
Posts: 4
Rep Power: 10
gsh is on a distinguished road
Thank you I very much appreciate the help, that worked perfectly!

Now that i have a working example I think I will try to write a script to export blocks into Plot3D files after manipulating the number of blocks.

Thanks again!
gsh is offline   Reply With Quote

Old   January 27, 2017, 18:13
Default
  #6
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
Slightly more advanced script with error checking and progress output...

Code:
package require PWI_Glyph

# $numFiles is the number of multi-blocks to import
# -------------------------------------------------
set numFiles 48

# Only need to create mode once and reuse it
set ioGrid [pw::Application begin GridImport]

for {set i 1} {$i <= $numFiles} {incr i} {
  # use ${i} embedded inside string to make variable name explicit.
  # otherwise parser might think the var name is $i.x
  set xFile "/home/split-on-hub/ast.b${i}.x"
  puts "loading $i of $numFiles: $xFile"
  if { [catch {$ioGrid initialize -type PLOT3D $xFile} err] } {
    puts "  Could not initialize $xFile"
    puts "  $err"
    continue
  }
  $ioGrid read
  $ioGrid convert
}

# Now we are done with mode.
# Using "end" will make all changes permanent.
# Using "abort" will throw away all changes made since mode was created.
$ioGrid end
unset ioGrid

puts "grid: [pw::Grid getAll -type pw::Block]"
dgarlisch is offline   Reply With Quote

Old   January 27, 2017, 18:34
Default
  #7
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
And another version that uses pattern matching...

See Full Glyph script documentation.
See Full Tcl documentation.


Code:
package require PWI_Glyph

set xFileDir "/home/split-on-hub"
set pattern "ast.b*.x"

# find all files in $xFileDir matching $pattern
set xFiles [glob -nocomplain -directory $xFileDir -- $pattern]

# Only need to create mode once and reuse it
set ioGrid [pw::Application begin GridImport]

set i 0
set numFiles [llength $xFiles]
foreach xFile $xFiles {
  puts [format "Loading file %3d of %d: %s" [incr i] $numFiles $xFile]
  if { [catch {$ioGrid initialize -type PLOT3D $xFile} err] } {
    puts "  Could not initialize $xFile"
    puts "  $err"
    continue
  }
  $ioGrid read
  $ioGrid convert
}

# Now we are done with mode.
# Using "end" will make all changes permanent.
# Using "abort" will throw away all changes made since mode was created.
$ioGrid end
unset ioGrid

set blks [pw::Grid getAll -type pw::Block]
puts {}
puts "[llength $blks] blocks imported:"
foreach blk $blks {
  puts "  [$blk getName] ($blk)"
}
dgarlisch is offline   Reply With Quote

Reply

Tags
grid, multi blocks, pointwise


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
how to set periodic boundary conditions Ganesh FLUENT 15 November 18, 2020 06:09
17.3 Pointwise can NOT import CGNS mesh with Multiple nodes swm Pointwise & Gridgen 3 January 24, 2017 10:48
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 03:01
Grid Independent Solution Chuck Leakeas Main CFD Forum 2 May 26, 2000 11:18


All times are GMT -4. The time now is 09:43.