Ignore:
Timestamp:
May 29, 2015 7:22:49 PM (9 years ago)
Author:
ldelgass
Message:

add structured grid example/test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/zoo/mesh/mesh.tcl

    r5630 r5634  
    2121$xv seq 0 1 50
    2222
     23set hide no
     24
    2325switch -- $meshtype {
    2426    "cloud" {
    25         set mesh output.mesh
    26 
    27         $driver put $mesh.about.label "cloud in unstructured mesh"
    28         $driver put $mesh.dim  2
    29         $driver put $mesh.units "m"
    30         $driver put $mesh.hide "yes"
    31 
    32         set points {}
    33         foreach y [$xv range 0 end] {
    34             foreach x [$xv range 0 end] {
    35                 append points "$x $y\n"
    36             }
    37         }
    38         $driver put $mesh.unstructured.points $points
    39         $driver put $mesh.unstructured.celltypes ""
     27        set mesh output.mesh
     28
     29        $driver put $mesh.about.label "cloud in unstructured mesh"
     30        $driver put $mesh.dim  2
     31        $driver put $mesh.units "m"
     32        $driver put $mesh.hide $hide
     33
     34        set points {}
     35        foreach y [$xv range 0 end] {
     36            foreach x [$xv range 0 end] {
     37                append points "$x $y\n"
     38            }
     39        }
     40        $driver put $mesh.unstructured.points $points
     41        $driver put $mesh.unstructured.celltypes ""
    4042    }
    4143    "regular" {
    42         set mesh output.mesh
    43 
    44         $driver put $mesh.about.label "uniform grid mesh"
    45         $driver put $mesh.dim  2
    46         $driver put $mesh.units "m"
    47         $driver put $mesh.hide "yes"
    48 
    49         $driver put $mesh.grid.xaxis.min 0.0
    50         $driver put $mesh.grid.xaxis.max 1.0
    51         $driver put $mesh.grid.xaxis.numpoints 50
    52         $driver put $mesh.grid.yaxis.min 0.0
    53         $driver put $mesh.grid.yaxis.max 1.0
    54         $driver put $mesh.grid.yaxis.numpoints 50
     44        set mesh output.mesh
     45
     46        $driver put $mesh.about.label "uniform grid mesh"
     47        $driver put $mesh.dim  2
     48        $driver put $mesh.units "m"
     49        $driver put $mesh.hide $hide
     50
     51        $driver put $mesh.grid.xaxis.min 0.0
     52        $driver put $mesh.grid.xaxis.max 1.0
     53        $driver put $mesh.grid.xaxis.numpoints 50
     54        $driver put $mesh.grid.yaxis.min 0.0
     55        $driver put $mesh.grid.yaxis.max 1.0
     56        $driver put $mesh.grid.yaxis.numpoints 50
    5557    }
    5658    "irregular" {
    57         set mesh output.mesh
    58 
    59         $driver put $mesh.about.label "irregular grid mesh"
    60         $driver put $mesh.dim  2
    61         $driver put $mesh.units "m"
    62         $driver put $mesh.hide "yes"
    63 
    64         $driver put $mesh.grid.xcoords [$xv range 0 end]
    65         $driver put $mesh.grid.ycoords [$xv range 0 end]
     59        set mesh output.mesh
     60
     61        $driver put $mesh.about.label "irregular rectilinear grid mesh"
     62        $driver put $mesh.dim  2
     63        $driver put $mesh.units "m"
     64        $driver put $mesh.hide $hide
     65
     66        $driver put $mesh.grid.xcoords [$xv range 0 end]
     67        $driver put $mesh.grid.ycoords [$xv range 0 end]
    6668    }
    6769    "hybrid" {
    68         set mesh output.mesh
    69 
    70         $driver put $mesh.about.label "hybrid regular and irregular grid mesh"
    71         $driver put $mesh.dim  2
    72         $driver put $mesh.units "m"
    73         $driver put $mesh.hide "yes"
    74 
    75         $driver put $mesh.units "m"
    76         $driver put $mesh.grid.xcoords [$xv range 0 end]
    77         $driver put $mesh.grid.yaxis.min 0.0
    78         $driver put $mesh.grid.yaxis.max 1.0
    79         $driver put $mesh.grid.yaxis.numpoints 50
     70        set mesh output.mesh
     71
     72        $driver put $mesh.about.label "hybrid regular and irregular rectilinear grid mesh"
     73        $driver put $mesh.dim  2
     74        $driver put $mesh.units "m"
     75        $driver put $mesh.hide $hide
     76
     77        $driver put $mesh.grid.xcoords [$xv range 0 end]
     78        $driver put $mesh.grid.yaxis.min 0.0
     79        $driver put $mesh.grid.yaxis.max 1.0
     80        $driver put $mesh.grid.yaxis.numpoints 50
     81    }
     82    "structured" {
     83        set mesh output.mesh
     84
     85        $driver put $mesh.about.label "Structured (Curvilinear) Grid"
     86        $driver put $mesh.dim  2
     87        $driver put $mesh.units "m"
     88        $driver put $mesh.hide $hide
     89
     90        $driver put $mesh.grid.xdim 50
     91        $driver put $mesh.grid.ydim 50
     92        set points {}
     93        foreach y [$xv range 0 end] {
     94            foreach x [$xv range 0 end] {
     95                append points "$x $y\n"
     96            }
     97        }
     98        $driver put $mesh.grid.points $points
    8099    }
    81100    "triangular" {
    82         set mesh output.mesh
    83 
    84         $driver put $mesh.about.label "triangles in unstructured mesh"
    85         $driver put $mesh.dim  2
    86         $driver put $mesh.units "m"
    87         $driver put $mesh.hide "yes"
    88        
    89         $driver put -type file -compress no $mesh.unstructured.points \
    90             points.txt
    91         $driver put -type file -compress no $mesh.unstructured.triangles \
    92             triangles.txt
     101        set mesh output.mesh
     102
     103        $driver put $mesh.about.label "triangles in unstructured mesh"
     104        $driver put $mesh.dim  2
     105        $driver put $mesh.units "m"
     106        $driver put $mesh.hide $hide
     107       
     108        $driver put -type file -compress no $mesh.unstructured.points \
     109            points.txt
     110        $driver put -type file -compress no $mesh.unstructured.triangles \
     111            triangles.txt
    93112    }
    94113    "generic" {
    95         set mesh output.mesh
    96 
    97         $driver put $mesh.about.label "nodes and elements mesh"
    98         $driver put $mesh.dim  2
    99         $driver put $mesh.units "m"
    100         $driver put $mesh.hide "yes"
    101 
    102         set count 0
    103         set f [open "points.txt" "r"]
    104         set points [read $f]
    105         close $f
    106         foreach { x y } $points {
    107             $driver put $mesh.node($count) "$x $y"
    108             incr count
    109         }
    110         set count 0
    111         set f [open "triangles.txt" "r"]
    112         set triangles [read $f]
    113         close $f
    114         foreach { a b c } $triangles {
    115             $driver put $mesh.element($count).nodes "$a $b $c"
    116             incr count
    117         }
     114        set mesh output.mesh
     115
     116        $driver put $mesh.about.label "nodes and elements mesh"
     117        $driver put $mesh.dim  2
     118        $driver put $mesh.units "m"
     119        $driver put $mesh.hide $hide
     120
     121        set count 0
     122        set f [open "points.txt" "r"]
     123        set points [read $f]
     124        close $f
     125        foreach { x y } $points {
     126            $driver put $mesh.node($count) "$x $y"
     127            incr count
     128        }
     129        set count 0
     130        set f [open "triangles.txt" "r"]
     131        set triangles [read $f]
     132        close $f
     133        foreach { a b c } $triangles {
     134            $driver put $mesh.element($count).nodes "$a $b $c"
     135            incr count
     136        }
    118137    }
    119138    "unstructured" {
    120         set mesh output.mesh
    121 
    122         $driver put $mesh.about.label "Unstructured Grid"
    123         $driver put $mesh.dim  2
    124         $driver put $mesh.units "m"
    125         $driver put $mesh.hide "yes"
    126 
    127         $driver put -type file -compress no $mesh.unstructured.points points.txt
    128         set cells {}
    129         set f [open "triangles.txt" "r"]
    130         set triangles [read $f]
    131         close $f
    132         foreach { a b c } $triangles {
    133             append cells "$a $b $c\n"
    134         }
    135         $driver put $mesh.unstructured.cells $cells
    136         $driver put $mesh.unstructured.celltypes "triangle"
     139        set mesh output.mesh
     140
     141        $driver put $mesh.about.label "Unstructured Grid"
     142        $driver put $mesh.dim  2
     143        $driver put $mesh.units "m"
     144        $driver put $mesh.hide $hide
     145
     146        $driver put -type file -compress no $mesh.unstructured.points points.txt
     147        set cells {}
     148        set f [open "triangles.txt" "r"]
     149        set triangles [read $f]
     150        close $f
     151        foreach { a b c } $triangles {
     152            append cells "$a $b $c\n"
     153        }
     154        $driver put $mesh.unstructured.cells $cells
     155        $driver put $mesh.unstructured.celltypes "triangle"
    137156    }
    138157    "cells" {
    139         set mesh output.mesh
    140 
    141         $driver put $mesh.about.label \
    142             "Unstructured Grid with Heterogeneous Cells"
    143         $driver put $mesh.dim  2
    144         $driver put $mesh.units "m"
    145         $driver put $mesh.hide "yes"
    146 
    147         set celltypes {}
    148         set f [open "triangles.txt" "r"]
    149         set triangles [read $f]
    150         close $f
    151         foreach { a b c } $triangles {
    152             append cells "$a $b $c\n"
    153             append celltypes "triangle\n"
    154         }
    155         $driver put -type file -compress no $mesh.unstructured.points points.txt
    156         $driver put $mesh.unstructured.celltypes $celltypes
    157         $driver put $mesh.unstructured.cells $cells
     158        set mesh output.mesh
     159
     160        $driver put $mesh.about.label \
     161            "Unstructured Grid with Heterogeneous Cells"
     162        $driver put $mesh.dim  2
     163        $driver put $mesh.units "m"
     164        $driver put $mesh.hide $hide
     165
     166        set celltypes {}
     167        set f [open "triangles.txt" "r"]
     168        set triangles [read $f]
     169        close $f
     170        foreach { a b c } $triangles {
     171            append cells "$a $b $c\n"
     172            append celltypes "triangle\n"
     173        }
     174        $driver put -type file -compress no $mesh.unstructured.points points.txt
     175        $driver put $mesh.unstructured.celltypes $celltypes
     176        $driver put $mesh.unstructured.cells $cells
    158177    }
    159178    "vtkmesh" {
    160         set mesh output.mesh
    161 
    162         $driver put $mesh.about.label "vtk mesh"
    163         $driver put $mesh.dim  2
    164         $driver put $mesh.units "m"
    165         $driver put $mesh.hide "yes"
    166         $driver put -type file -compress no $mesh.vtk mesh.vtk
     179        set mesh output.mesh
     180
     181        $driver put $mesh.about.label "vtk mesh"
     182        $driver put $mesh.dim  2
     183        $driver put $mesh.units "m"
     184        $driver put $mesh.hide $hide
     185        $driver put -type file -compress no $mesh.vtk mesh.vtk
    167186    }
    168187    "vtkfield" {
    169188
    170         $driver put output.field(substrate).about.label "Substrate Surface"
    171         $driver put -type file -compress no \
    172             output.field(substrate).component.vtk file.vtk
     189        $driver put output.field(substrate).about.label "Substrate Surface"
     190        $driver put -type file -compress no \
     191            output.field(substrate).component.vtk file.vtk
    173192        $driver put output.string.current ""
    174         Rappture::result $driver
    175         exit 0
     193        Rappture::result $driver
     194        exit 0
    176195    }
    177196    default {
    178         error "unknown mesh type \"$meshtype\""
     197        error "unknown mesh type \"$meshtype\""
    179198    }
    180199}
Note: See TracChangeset for help on using the changeset viewer.