/
ref_inflate_test.c
152 lines (133 loc) · 3.99 KB
/
ref_inflate_test.c
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* Copyright 2006, 2014, 2021 United States Government as represented
* by the Administrator of the National Aeronautics and Space
* Administration. No copyright is claimed in the United States under
* Title 17, U.S. Code. All Other Rights Reserved.
*
* The refine version 3 unstructured grid adaptation platform is
* licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include "ref_inflate.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ref_adj.h"
#include "ref_cell.h"
#include "ref_dict.h"
#include "ref_edge.h"
#include "ref_export.h"
#include "ref_grid.h"
#include "ref_import.h"
#include "ref_list.h"
#include "ref_math.h"
#include "ref_matrix.h"
#include "ref_mpi.h"
#include "ref_node.h"
#include "ref_sort.h"
int main() {
{
REF_DBL H, h0, rate;
REF_INT n;
H = 10.0;
h0 = 1.0;
n = 10;
RSS(ref_inflate_rate(n, h0, H, &rate), "rate");
RWDS(1.0, rate, 1.0e-8, "uniform");
}
{
REF_DBL H, h0, rate;
REF_INT n;
H = 10.0;
h0 = 0.5;
n = 10;
RSS(ref_inflate_rate(n, h0, H, &rate), "rate");
RWDS(1.1469, rate, 1.0e-3, "growth");
}
/*
SKIP_BLOCK("intel compiler") {
REF_DBL H, h0, rate;
REF_INT n;
H = 0.1;
h0 = 0.01;
n = 10;
RSS(ref_inflate_rate(n, h0, H, &rate), "rate");
RWDS(1.0, rate, 1.0e-6, "growth");
}
*/
{
REF_DBL H, h0, rate;
REF_INT n;
h0 = 0.5;
n = 10;
rate = 1.1469;
RSS(ref_inflate_total_thickness(n, h0, rate, &H), "total");
RWDS(10.0, H, 1.0e-3, "not total");
}
{
REF_DBL dHdr, h0, rate;
REF_INT n;
REF_DBL tol = 1.0e-6, fd, Hp, Hm;
h0 = 0.5;
n = 10;
rate = 1.1469;
RSS(ref_inflate_total_thickness(n, h0, rate + tol, &Hp), "total+");
RSS(ref_inflate_total_thickness(n, h0, rate - tol, &Hm), "total-");
fd = (Hp - Hm) / 2.0 / tol;
RSS(ref_inflate_dthickness(n, h0, rate, &dHdr), "deriv");
RWDS(fd, dHdr, 1.0e-8, "not total");
}
{
char file[] = "ref_inflate_test.mapbc";
char family[] = "cigar";
REF_INT bc = 3;
FILE *f;
REF_DICT ref_dict;
REF_INT id, type;
f = fopen(file, "w");
fprintf(f, "#\n#\n#\n#\n");
fprintf(f, "1219 3 3 0 0 SURFACE. \n");
fprintf(f, "1220 4 4 0 0 SURFACE. \n");
fprintf(f, "1221 2 2 0 0 cigar \n");
fprintf(f, "1222 0 0 0 0 cigar \n");
fprintf(f, "1223 3 3 0 0 cigar\n");
fprintf(f, "1224 3 3 0 0 cigar \n");
fclose(f);
RSS(ref_dict_create(&ref_dict), "create");
RSS(ref_inflate_read_usm3d_mapbc(ref_dict, file, family, bc), "read mapbc");
REIS(2, ref_dict_n(ref_dict), "lines");
id = 1223;
RSS(ref_dict_value(ref_dict, id, &type), "retrieve");
REIS(REF_EMPTY, type, "type");
id = 1224;
RSS(ref_dict_value(ref_dict, id, &type), "retrieve");
REIS(REF_EMPTY, type, "type");
RSS(ref_dict_free(ref_dict), "free");
REIS(0, remove(file), "test clean up");
}
{ /* compact 2 same */
REF_INT n = 2;
REF_DBL x[] = {0, 0};
REF_DBL yz[] = {10, 20, 10, 20};
REF_DBL phi[] = {30, 30};
RSS(ref_inflate_compact_rail(&n, x, yz, phi), "compact");
REIS(1, n, "unique");
}
{ /* compact 2 different */
REF_INT n = 2;
REF_DBL x[] = {0, 1};
REF_DBL yz[] = {10, 20, 11, 21};
REF_DBL phi[] = {30, 31};
RSS(ref_inflate_compact_rail(&n, x, yz, phi), "compact");
REIS(2, n, "unique");
}
return 0;
}