46{
47 int i;
48 int npts = xc.size();
49
50 int nq = streak->GetTotPoints();
54 streak->GetCoords(x, y);
55
56 streak->BwdTrans(streak->GetCoeffs(), streak->UpdatePhys());
58
59
62
63 for (i = 0; i < npts; ++i)
64 {
65 xc[i] = x_min + (x_max - x_min) * i / ((
NekDouble)(npts - 1));
66 yc[i] = 0.0;
67 }
68
69 int elmtid, offset, cnt;
74 int maxiter = 100;
76
77
78 cerr << "[";
79 for (int e = 0; e < npts; e++)
80 {
81 coord[0] = xc[e];
82 coord[1] = yc[e];
83
84 if (!(e % 10))
85 {
86 cerr << ".";
87 }
88
89 F = 1000;
90 cnt = 0;
91 while ((
abs(F) > ConvTol) && (cnt < maxiter))
92 {
93 elmtid = streak->GetExpIndex(coord, CoordTol);
94 offset = streak->GetPhys_Offset(elmtid);
95
96 U = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() +
97 offset);
98 dU =
99 streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
100
101 coord[1] = coord[1] - (U - cr) / dU;
102
103 F = U - cr;
104 cnt++;
105 }
106 ASSERTL0(cnt < maxiter,
"Failed to converge Newton iteration");
107
108 yc[e] = coord[1];
109 }
110 cerr << "]" << endl;
111
113 {
114
115 FILE *fp = fopen("interfacedat.geo", "w");
116
119
120 cnt = 1;
121 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++, x_min,
122 y_min);
123 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++, x_max,
124 y_min);
125 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++, x_max,
126 y_max);
127 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++, x_min,
128 y_max);
129
130 for (i = 0; i < npts; ++i)
131 {
132 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++,
133 xc[i], yc[i]);
134 }
135
136 fclose(fp);
137
138
139
140 fp = fopen("interfacedat_up.geo", "w");
141
143
144 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++, xc[0],
145 yc[0] + trans);
146
147 for (i = 1; i < npts - 1; ++i)
148 {
149 norm =
sqrt((xc[i + 1] - xc[i - 1]) * (xc[i + 1] - xc[i - 1]) +
150 (yc[i + 1] - yc[i - 1]) * (yc[i + 1] - yc[i - 1]));
151 nx = (yc[i - 1] - yc[i + 1]) / norm;
152 ny = (xc[i + 1] - xc[i - 1]) / norm;
153
154 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++,
155 xc[i] + nx * trans, yc[i] + ny * trans);
156 }
157
158 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++,
159 xc[npts - 1], yc[npts - 1] + trans);
160
161
162
163 fp = fopen("interfacedat_dn.geo", "w");
164
165 trans = -trans;
166
167 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++, xc[0],
168 yc[0] + trans);
169
170 for (i = 1; i < npts - 1; ++i)
171 {
172 norm =
sqrt((xc[i + 1] - xc[i - 1]) * (xc[i + 1] - xc[i - 1]) +
173 (yc[i + 1] - yc[i - 1]) * (yc[i + 1] - yc[i - 1]));
174 nx = (yc[i - 1] - yc[i + 1]) / norm;
175 ny = (xc[i + 1] - xc[i - 1]) / norm;
176
177 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++,
178 xc[i] + nx * trans, yc[i] + ny * trans);
179 }
180
181 fprintf(fp, "Point(%d)={%12.10lf,%12.10lf,0,1.0}; \n", cnt++,
182 xc[npts - 1], yc[npts - 1] + trans);
183 }
184}
#define ASSERTL0(condition, msg)
static const NekDouble kNekUnsetDouble
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
scalarT< T > abs(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)