Nektar++
Functions
ExtractCriticalLayerFunctions.cpp File Reference
#include <cstdio>
#include <MultiRegions/ExpList.h>

Go to the source code of this file.

Functions

void Computestreakpositions (MultiRegions::ExpListSharedPtr &streak, Array< OneD, NekDouble > &xc, Array< OneD, NekDouble > &yc, NekDouble cr, NekDouble trans)
 

Function Documentation

◆ Computestreakpositions()

void Computestreakpositions ( MultiRegions::ExpListSharedPtr streak,
Array< OneD, NekDouble > &  xc,
Array< OneD, NekDouble > &  yc,
NekDouble  cr,
NekDouble  trans 
)

Definition at line 42 of file ExtractCriticalLayerFunctions.cpp.

46{
47 int i;
48 int npts = xc.size();
49
50 int nq = streak->GetTotPoints();
51 Array<OneD, NekDouble> derstreak(nq);
54 streak->GetCoords(x, y);
55
56 streak->BwdTrans(streak->GetCoeffs(), streak->UpdatePhys());
57 streak->PhysDeriv(MultiRegions::eY, streak->GetPhys(), derstreak);
58
59 // set intiial xc to be equispaced over mesh and yc to be zero
60 NekDouble x_max = Vmath::Vmax(nq, x, 1);
61 NekDouble x_min = Vmath::Vmin(nq, x, 1);
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;
70 NekDouble U, dU;
71 NekDouble F;
72 NekDouble ConvTol = 1e-9;
73 NekDouble CoordTol = 1e-5;
74 int maxiter = 100;
76
77 // Do Newton iteration on y direction
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 // output to interface file
115 FILE *fp = fopen("interfacedat.geo", "w");
116
117 NekDouble y_max = Vmath::Vmax(nq, y, 1);
118 NekDouble y_min = Vmath::Vmin(nq, y, 1);
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 // output to interface_up file as bend of vertical shift and 45 degrees
139 // shift
140 fp = fopen("interfacedat_up.geo", "w");
141
142 NekDouble nx, ny, norm;
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 // output to interface_up file as bend of vertical shift and 45 degrees
162 // shift
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)
Definition: ErrorUtil.hpp:208
static const NekDouble kNekUnsetDouble
double NekDouble
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
Definition: Vmath.hpp:725
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
Definition: Vmath.hpp:644
scalarT< T > abs(scalarT< T > in)
Definition: scalar.hpp:298
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294

References tinysimd::abs(), ASSERTL0, Nektar::MultiRegions::eY, Nektar::NekConstants::kNekUnsetDouble, tinysimd::sqrt(), Vmath::Vmax(), and Vmath::Vmin().

Referenced by GetStreakLocation(), and main().