CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Pointwise & Gridgen (https://www.cfd-online.com/Forums/pointwise/)
-   -   How to count the number of cells of some selected domains? (https://www.cfd-online.com/Forums/pointwise/145661-how-count-number-cells-some-selected-domains.html)

xq712000 December 10, 2014 03:06

How to count the number of cells of some selected domains?
 
It's seems pointwise only provide total cell count...but what if I want to know the cell number of some specific domains ?

tcarrigan December 10, 2014 09:49

Hello,

You can accomplish this easily using a Glyph script. To get the cell count of an initialized structured or unstructured domain, use the following code:

Code:

package require PWI_Glyph

set sm [pw::Display createSelectionMask -requireDomain {Defined}]
pw::Display getSelectedEntities -selectionmask $sm ents

foreach ent $ents(Domains) {
    puts "[$ent getName] cell count: [$ent getCellCount]"
}

Be sure to save this as a .glf script. You'll need to be running Pointwise V17.2R2 to take advantage of the new getSelectedEntities command.

Travis

jrhoads December 10, 2014 12:29

This information is also available (and sortable) in the List panel. Click the arrow beside Domains. There are columns for the number of points (nodes) and cells for each domain. Clicking the column header will sort by that field; useful for finding very small domains.

If you want a cumulative count of several domains though, scripting is the way to go as Travis pointed out.

vic April 9, 2015 09:44

Hi,
sorry bui I'd want to know the total amount of cells instead, while using your script it shows a list of the selected domains with the related number of cells,
without computing the sum.
Could you help me ?
Thanks
Victor
PS I'm fairly new at pw.

dgarlisch April 10, 2015 09:56

use the Grid / Cell count... menu

or if you want the total cell count for the selected domains, you can change the script to:

Code:

package require PWI_Glyph

set sm [pw::Display createSelectionMask -requireDomain {Defined}]
pw::Display getSelectedEntities -selectionmask $sm ents

set dash "-----------------------------------------------"
set fmt "| %-20.20s | %8.8s |"

set totalCellCount 0
puts "Cell counts:"
puts [format $fmt {Entity name} {Count}]
puts [format $fmt $dash $dash]
foreach ent $ents(Domains) {
    set domCellCount [$ent getCellCount]
    puts [format $fmt [$ent getName] $domCellCount]
    incr totalCellCount $domCellCount
}
puts [format $fmt $dash $dash]
puts [format $fmt {Total} $totalCellCount]

Generates something like:

Code:

Script: Cell counts:
Script: | Entity name          |    Count |
Script: | -------------------- | -------- |
Script: | dom-15              |        4 |
Script: | dom-2                |        4 |
Script: | dom-5                |        4 |
Script: | dom-9                |        4 |
Script: | dom-33              |        8 |
Script: | dom-4                |        4 |
Script: | -------------------- | -------- |
Script: | Total                |      28 |


vic April 11, 2015 03:27

Thank you for the quick and exhaustive response.
Regards
Victor


All times are GMT -4. The time now is 16:06.