~ubuntu-branches/ubuntu/trusty/silo-llnl/trusty

« back to all changes in this revision

Viewing changes to tests/polyzl.c

  • Committer: Bazaar Package Importer
  • Author(s): Alastair McKinstry
  • Date: 2011-01-02 00:03:01 UTC
  • Revision ID: james.westby@ubuntu.com-20110102000301-9s2hfsjrkguz6h4r
Tags: upstream-4.8
ImportĀ upstreamĀ versionĀ 4.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 1994 - 2010, Lawrence Livermore National Security, LLC.
 
3
LLNL-CODE-425250.
 
4
All rights reserved.
 
5
 
 
6
This file is part of Silo. For details, see silo.llnl.gov.
 
7
 
 
8
Redistribution and use in source and binary forms, with or without
 
9
modification, are permitted provided that the following conditions
 
10
are met:
 
11
 
 
12
   * Redistributions of source code must retain the above copyright
 
13
     notice, this list of conditions and the disclaimer below.
 
14
   * Redistributions in binary form must reproduce the above copyright
 
15
     notice, this list of conditions and the disclaimer (as noted
 
16
     below) in the documentation and/or other materials provided with
 
17
     the distribution.
 
18
   * Neither the name of the LLNS/LLNL nor the names of its
 
19
     contributors may be used to endorse or promote products derived
 
20
     from this software without specific prior written permission.
 
21
 
 
22
THIS SOFTWARE  IS PROVIDED BY  THE COPYRIGHT HOLDERS  AND CONTRIBUTORS
 
23
"AS  IS" AND  ANY EXPRESS  OR IMPLIED  WARRANTIES, INCLUDING,  BUT NOT
 
24
LIMITED TO, THE IMPLIED  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
25
A  PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN  NO  EVENT SHALL  LAWRENCE
 
26
LIVERMORE  NATIONAL SECURITY, LLC,  THE U.S.  DEPARTMENT OF  ENERGY OR
 
27
CONTRIBUTORS BE LIABLE FOR  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 
28
EXEMPLARY, OR  CONSEQUENTIAL DAMAGES  (INCLUDING, BUT NOT  LIMITED TO,
 
29
PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS  OF USE,  DATA, OR
 
30
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 
31
LIABILITY, WHETHER  IN CONTRACT, STRICT LIABILITY,  OR TORT (INCLUDING
 
32
NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT  OF THE USE  OF THIS
 
33
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
34
 
 
35
This work was produced at Lawrence Livermore National Laboratory under
 
36
Contract No.  DE-AC52-07NA27344 with the DOE.
 
37
 
 
38
Neither the  United States Government nor  Lawrence Livermore National
 
39
Security, LLC nor any of  their employees, makes any warranty, express
 
40
or  implied,  or  assumes  any  liability or  responsibility  for  the
 
41
accuracy, completeness,  or usefulness of  any information, apparatus,
 
42
product, or  process disclosed, or  represents that its use  would not
 
43
infringe privately-owned rights.
 
44
 
 
45
Any reference herein to  any specific commercial products, process, or
 
46
services by trade name,  trademark, manufacturer or otherwise does not
 
47
necessarily  constitute or imply  its endorsement,  recommendation, or
 
48
favoring  by  the  United  States  Government  or  Lawrence  Livermore
 
49
National Security,  LLC. The views  and opinions of  authors expressed
 
50
herein do not necessarily state  or reflect those of the United States
 
51
Government or Lawrence Livermore National Security, LLC, and shall not
 
52
be used for advertising or product endorsement purposes.
 
53
*/
 
54
 
 
55
#include "silo.h"               /*include public silo           */
 
56
 
 
57
#include <math.h>
 
58
#include <string.h>
 
59
#include <std.c>
 
60
 
 
61
#define NNODES 12
 
62
#define NZONES 2
 
63
#define NFACES 11
 
64
 
 
65
 
 
66
/*-------------------------------------------------------------------------
 
67
 * Function:        main
 
68
 *
 
69
 * Purpose:        Test writing a polyhedral zonelist
 
70
 *
 
71
 *                 Writes two hexes sharing a common face using a 
 
72
 *                 polyhedral zonelist
 
73
 *
 
74
 * Return:        0
 
75
 *
 
76
 * Programmer:        Mark C. Miller, July 27, 2004
 
77
 *
 
78
 *-------------------------------------------------------------------------
 
79
 */
 
80
int
 
81
main(int argc, char *argv[])
 
82
{
 
83
    
 
84
    int            i, driver=DB_PDB;
 
85
    char          *filename="polyzl.pdb";
 
86
    DBfile        *dbfile;
 
87
 
 
88
    DBoptlist     *optlist;
 
89
 
 
90
    char *xname = "xcoords";
 
91
    char *yname = "ycoords";
 
92
    char *zname = "zcoords";
 
93
 
 
94
    float x[NNODES] = {0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0};
 
95
    float y[NNODES] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
 
96
    float z[NNODES] = {0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0};
 
97
 
 
98
    int nodecnt[NFACES] = {4,4,4,4,4,4,4,4,4,4,4};
 
99
    int lnodelist = 4 * NFACES;
 
100
    int nodelist[4*NFACES] = {0,1,7,6,    1,2,8,7,    1,0,3,4,
 
101
                              2,1,4,5,    4,3,9,10,   5,4,10,11, 
 
102
                              6,7,10,9,   7,8,11,10,  0,6,9,3,
 
103
                              1,7,10,4,   2,5,11,8};
 
104
 
 
105
    int facecnt[NZONES] = {6,6};
 
106
    int lfacelist = 6 * NZONES;
 
107
    int facelist[6*NZONES] = {0,2,4,6,8,-9,   1,3,5,7,9,10};
 
108
 
 
109
    float *coords[3];
 
110
    char *coordnames[3];
 
111
    int show_all_errors = FALSE;
 
112
 
 
113
    coords[0] = x;
 
114
    coords[1] = y;
 
115
    coords[2] = z;
 
116
 
 
117
    coordnames[0] = xname;
 
118
    coordnames[1] = yname;
 
119
    coordnames[2] = zname;
 
120
 
 
121
    /* Parse command-line */
 
122
    for (i=1; i<argc; i++) {
 
123
        if (!strncmp(argv[i], "DB_PDB", 6)) {
 
124
            driver = StringToDriver(argv[i]);
 
125
            filename = "polyzl.pdb";
 
126
        } else if (!strncmp(argv[i], "DB_HDF5", 7)) {
 
127
            driver = StringToDriver(argv[i]);
 
128
            filename = "polyzl.h5";
 
129
        } else if (!strcmp(argv[i], "show-all-errors")) {
 
130
            show_all_errors = 1;
 
131
        } else if (argv[i][0] != '\0') {
 
132
            fprintf(stderr, "%s: ignored argument `%s'\n", argv[0], argv[i]);
 
133
        }
 
134
    }
 
135
    
 
136
    DBShowErrors(show_all_errors?DB_ALL_AND_DRVR:DB_TOP, NULL);
 
137
    DBForceSingle(1);
 
138
 
 
139
    /*
 
140
     * Create a file that contains a simple mesh of 2 hexes 
 
141
     */
 
142
    printf("Creating file: `%s'\n", filename);
 
143
    dbfile = DBCreate(filename,0,DB_LOCAL,"Polyhedral Zonelist Test",driver);
 
144
 
 
145
    optlist = DBMakeOptlist(3);
 
146
    DBAddOption(optlist, DBOPT_PHZONELIST, "polyzl");
 
147
 
 
148
    DBPutUcdmesh(dbfile, "ucdmesh", 3, coordnames, coords, NNODES, NZONES,
 
149
        NULL, NULL, DB_FLOAT, optlist);
 
150
 
 
151
    DBPutPHZonelist(dbfile, "polyzl",
 
152
        NFACES, nodecnt, lnodelist, nodelist, NULL,
 
153
        NZONES, facecnt, lfacelist, facelist, 
 
154
        0, 0, NZONES-1, NULL);
 
155
 
 
156
    DBClose(dbfile);
 
157
 
 
158
    CleanupDriverStuff();
 
159
    return 0;
 
160
 
 
161
}