Changeset 4394


Ignore:
Timestamp:
Jun 18, 2014 11:08:12 AM (7 years ago)
Author:
ldelgass
Message:

Fix test for number of field values: check that number of values is divisible by
the number of components per tuple, also when field association is celldata,
check number of tuples against number of cells, not number of points.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/field.tcl

    r4390 r4394  
    15561556        }
    15571557        set numFieldValues [$v length]
    1558         set numComponentsPerPoint [numComponents $cname]
    1559         set numPoints [$mesh numpoints]
    1560         set numExpectedPoints [expr $numPoints * $numComponentsPerPoint]
    1561         if { $numExpectedPoints != $numFieldValues } {
    1562             puts stderr "ERROR: Number of points in mesh ($numExpectedPoints) and number of field values ($numFieldValues) don't agree"
     1558        set numComponentsPerTuple [numComponents $cname]
     1559        if { [expr $numFieldValues % $numComponentsPerTuple] != 0 } {
     1560            puts stderr "ERROR: Number of field values ($numFieldValues) not divisble by elemsize ($numComponentsPerTuple)"
    15631561            return 0
    15641562        }
    1565 
     1563        set numFieldTuples [expr $numFieldValues / $numComponentsPerTuple]
     1564        if { $_comp2assoc($cname) == "pointdata" } {
     1565            set numPoints [$mesh numpoints]
     1566            if { $numPoints != $numFieldTuples } {
     1567                puts stderr "ERROR: Number of points in mesh ($numPoints) and number of field tuples ($numFieldTuples) don't agree"
     1568                return 0
     1569            }
     1570        } elseif { $_comp2assoc($cname) == "celldata" } {
     1571            set numCells [$mesh numcells]
     1572            if { $numCells != $numFieldTuples } {
     1573                puts stderr "ERROR: Number of cells in mesh ($numCells) and number of field tuples ($numFieldTuples) don't agree"
     1574                return 0
     1575            }
     1576        }
    15661577        set _comp2dims($cname) "[$mesh dimensions]D"
    15671578        set _comp2mesh($cname) [list $mesh $v]
     
    15921603        }
    15931604        set numFieldValues [$v length]
    1594         set numComponentsPerPoint [numComponents $cname]
    1595         set numPoints [$mesh numpoints]
    1596         set numExpectedPoints [expr $numPoints * $numComponentsPerPoint]
    1597         if { $numExpectedPoints != $numFieldValues } {
    1598             puts stderr "ERROR: Number of points in mesh ($numExpectedPoints) and number of field values ($numFieldValues) don't agree"
     1605        set numComponentsPerTuple [numComponents $cname]
     1606        if { [expr $numFieldValues % $numComponentsPerTuple] != 0 } {
     1607            puts stderr "ERROR: Number of field values ($numFieldValues) not divisble by elemsize ($numComponentsPerTuple)"
    15991608            return 0
     1609        }
     1610        set numFieldTuples [expr $numFieldValues / $numComponentsPerTuple]
     1611        if { $_comp2assoc($cname) == "pointdata" } {
     1612            set numPoints [$mesh numpoints]
     1613            if { $numPoints != $numFieldTuples } {
     1614                puts stderr "ERROR: Number of points in mesh ($numPoints) and number of field tuples ($numFieldTuples) don't agree"
     1615                return 0
     1616            }
     1617        } elseif { $_comp2assoc($cname) == "celldata" } {
     1618            set numCells [$mesh numcells]
     1619            if { $numCells != $numFieldTuples } {
     1620                puts stderr "ERROR: Number of cells in mesh ($numCells) and number of field tuples ($numFieldTuples) don't agree"
     1621                return 0
     1622            }
    16001623        }
    16011624        set _comp2dims($cname) "[$mesh dimensions]D"
Note: See TracChangeset for help on using the changeset viewer.