27 lines = [
"NCASES %d" % len(CASES)]
28 for kind, ang, off, ratio
in CASES:
29 c = M.Case(N, ang, off, ratio, 1.0, kind)
30 M.build(c,
"sharp",
"fit")
32 C, mixed, te, de, xall, m = L[
"C"], L[
"mixed"], L[
"tauexpr"], L[
"dnnexpr"], L[
"xall"], L[
"mac"]
34 lines.append(
"CASE %d %.17g %.17g %.17g %.17g %.17g %.17g %.17g %.17g %.17g %d" % (
35 N, c.n[0], c.n[1], c.t[0], c.t[1], c.c[0], c.c[1], c.s, c.muA, c.muB, kind ==
"general"))
36 cells = [(i, j)
for i
in range(-1, N + 1)
for j
in range(-1, N + 1)
if mixed[i + 1, j + 1]]
39 xc, yc = (i + 0.5) * h, (j + 0.5) * h
40 cbu = c.frac_line(xc, yc, np.array([0.0, 1.0]),
"box")
41 cbv = c.frac_line(xc, yc, np.array([1.0, 0.0]),
"box")
42 tau = sum(v * xall[k]
for k, v
in te[(i, j)].items())
if (i, j)
in te
else 0.0
43 dnn = sum(v * xall[k]
for k, v
in de[(i, j)].items())
if (i, j)
in de
else 0.0
44 rows.append(
"%d %d %.17g %.17g %.17g %d %.17g %.17g" % (i, j, C[i + 1, j + 1], cbu, cbv,
45 (i, j)
in te, tau, dnn))
46 lines.append(
"NCELL %d" % len(rows))
48 mx =
lambda i, j: 0 <= i <= N - 1
and 0 <= j <= N - 1
and mixed[i + 1, j + 1]
50 for i
in range(0, N + 1):
51 for j
in range(0, N + 1):
52 if not any(mx(i - di, j - dj)
for di
in (0, 1)
for dj
in (0, 1)):
54 fu = c.frac_line(i * h, j * h, np.array([1.0, 0.0]),
"box")
55 fv = c.frac_line(i * h, j * h, np.array([0.0, 1.0]),
"box")
56 thy = c.frac_line(i * h, j * h, np.array([0.0, 1.0]),
"hat")
57 thx = c.frac_line(i * h, j * h, np.array([1.0, 0.0]),
"hat")
58 rows.append(
"%d %d %.17g %.17g %.17g %.17g" % (i, j, fu, fv, thy, thx))
59 lines.append(
"NNODE %d" % len(rows))
61 near =
lambda i, j: any(abs(i - p) <= 3
and abs(j - q) <= 3
for (p, q)
in cells)
62 ru = [
"%d %d %.17g" % (i, j, xall[m.iu(i, j)])
for i
in range(N + 1)
for j
in range(-1, N + 1)
64 rv = [
"%d %d %.17g" % (i, j, xall[m.iv(i, j)])
for i
in range(-1, N + 1)
for j
in range(N + 1)
66 lines.append(
"NU %d" % len(ru))
68 lines.append(
"NV %d" % len(rv))
70 open(out,
"w").write(
"\n".join(lines) +
"\n")
71 print(
"wrote %d cases to %s" % (len(CASES), out))