1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 | void make_direct_coord_field(void)
{
SAF_Unit umeter; /* Handle to the units for the coordinates. */
SAF_FieldTmpl coord_d0_ftmpl, /* Handle to the coordinate field field
* template on domain0. */
coord_d0_ctmpl, /* Handle to the coordinate field component
* template on domain0. */
coord_d1_ftmpl, /* Handle to the coordinate field field
* template on domain1. */
coord_d1_ctmpl, /* Handle to the coordinate field component
* template on domain1. */
tmp_ftmpl[3]; /* temporarly field template handles for
* component fields. */
/* Coordinate values. */
float domain0_Xcoords[] = { 0., 1., 1., 0., 0., 1., 1., 0. },
domain0_Ycoords[] = { 0., 0., 0., 0., 1., 1., 1., 1. },
domain0_Zcoords[] = { 0., 0., 1., 1., 0., 0., 1., 1. },
domain1_Xcoords[] = { 1., 2., 2., 1., 1., 2., 2., 1. },
domain1_Ycoords[] = { 0., 0., 0., 0., 1., 1., 1., 1. },
domain1_Zcoords[] = { 0., 0., 1., 1., 0., 0., 1., 1. };
void *domain0_coords[3],
*domain1_coords[3];
domain0_coords[0] = domain0_Xcoords;
domain0_coords[1] = domain0_Ycoords;
domain0_coords[2] = domain0_Zcoords;
domain1_coords[0] = domain1_Xcoords;
domain1_coords[1] = domain1_Ycoords;
domain1_coords[2] = domain1_Zcoords;
/*
---------------------------------------------------------------------------
* DECLARE FIELD TEMPLATES
---------------------------------------------------------------------------
*/
/* for domain0 */
saf_declare_field_tmpl(SAF_ALL, db, "coords_on_d0_ctmpl", SAF_ALGTYPE_SCALAR,
SAF_CARTESIAN, SAF_QLENGTH, 1,
NULL, &coord_d0_ctmpl);
tmp_ftmpl[0] = coord_d0_ctmpl;
tmp_ftmpl[1] = coord_d0_ctmpl;
tmp_ftmpl[2] = coord_d0_ctmpl;
saf_declare_field_tmpl(SAF_ALL, db, "coords_on_d0_ctmpl", SAF_ALGTYPE_VECTOR,
SAF_CARTESIAN, SAF_QLENGTH, 3,
tmp_ftmpl, &coord_d0_ftmpl);
/* for domain1 */
saf_declare_field_tmpl(SAF_ALL, db, "coords_on_d1_ctmpl", SAF_ALGTYPE_SCALAR,
SAF_CARTESIAN, SAF_QLENGTH, 1,
NULL, &coord_d1_ctmpl);
tmp_ftmpl[0] = coord_d1_ctmpl;
tmp_ftmpl[1] = coord_d1_ctmpl;
tmp_ftmpl[2] = coord_d1_ctmpl;
saf_declare_field_tmpl(SAF_ALL, db, "coords_on_d1_tmpl", SAF_ALGTYPE_VECTOR,
SAF_CARTESIAN, SAF_QLENGTH, 3,
tmp_ftmpl, &coord_d1_ftmpl);
/*
---------------------------------------------------------------------------
* DECLARE AND WRITE FIELDS
---------------------------------------------------------------------------
*/
/* Get a handle to the units for this field. */
saf_find_one_unit(db, "meter", &umeter);
/* Declare the fields on domain0. */
saf_declare_field(SAF_ALL, db, &coord_d0_ctmpl, "X", &domain0, &umeter, SAF_SELF(db),
SAF_NODAL(&nodes, &zones), SAF_FLOAT,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
&(coord_d0_compon[0]));
saf_declare_field(SAF_ALL, db, &coord_d0_ctmpl, "Y", &domain0, &umeter, SAF_SELF(db),
SAF_NODAL(&nodes, &zones), SAF_FLOAT,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
&(coord_d0_compon[1]));
saf_declare_field(SAF_ALL, db, &coord_d0_ctmpl, "Z", &domain0, &umeter, SAF_SELF(db),
SAF_NODAL(&nodes, &zones), SAF_FLOAT,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
&(coord_d0_compon[2]));
saf_declare_field(SAF_ALL, db, &coord_d0_ftmpl, "coords", &domain0, &umeter, SAF_SELF(db),
SAF_NODAL(&nodes, &zones), SAF_FLOAT,
coord_d0_compon, SAF_BLOCKED, SAF_IDENTITY, NULL,
&coords_d0);
/* Write the field on domain0. */
saf_write_field(SAF_ALL, &coords_d0, SAF_WHOLE_FIELD, 3, H5I_INVALID_HID,
domain0_coords, db);
/* specify that it is a coordinate field */
saf_declare_coords(SAF_ALL, &coords_d0);
saf_declare_default_coords(SAF_ALL,&domain0,&coords_d0);
/* Declare the fields on domain1. */
saf_declare_field(SAF_ALL, db, &coord_d1_ctmpl, "X", &domain1, &umeter, SAF_SELF(db),
SAF_NODAL(&nodes, &zones), SAF_FLOAT,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
&(coord_d1_compon[0]));
saf_declare_field(SAF_ALL, db, &coord_d1_ctmpl, "Y", &domain1, &umeter, SAF_SELF(db),
SAF_NODAL(&nodes, &zones), SAF_FLOAT,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
&(coord_d1_compon[1]));
saf_declare_field(SAF_ALL, db, &coord_d1_ctmpl, "Z", &domain1, &umeter, SAF_SELF(db),
SAF_NODAL(&nodes, &zones), SAF_FLOAT,
NULL, SAF_INTERLEAVE_NONE, SAF_IDENTITY, NULL,
&(coord_d1_compon[2]));
saf_declare_field(SAF_ALL, db, &coord_d1_ftmpl, "coords", &domain1, &umeter, SAF_SELF(db),
SAF_NODAL(&nodes, &zones), SAF_FLOAT,
coord_d1_compon, SAF_BLOCKED, SAF_IDENTITY, NULL,
&coords_d1);
/* Write the fields on domain1. */
saf_write_field(SAF_ALL, &coords_d1, SAF_WHOLE_FIELD, 3, H5I_INVALID_HID,
domain1_coords, db);
/* specify that it is a coordinate field */
saf_declare_coords(SAF_ALL, &coords_d1);
saf_declare_default_coords(SAF_ALL,&domain1,&coords_d1);
return;
}
|