50#include <boost/lexical_cast.hpp>
111 int edge,
int npedge);
171 int Npoints,
string s_alp,
176int main(
int argc,
char *argv[])
182 if (argc > 6 || argc < 5)
184 fprintf(stderr,
"Usage: ./MoveMesh meshfile fieldfile changefile "
185 "alpha cr(optional)\n");
192 LibUtilities::SessionReader::CreateInstance(2, argv);
194 SpatialDomains::MeshGraphIO::Read(vSession);
197 if (argc == 6 && vSession->DefinesSolverInfo(
"INTERFACE") &&
198 vSession->GetSolverInfo(
"INTERFACE") ==
"phase")
200 cr = std::stod(argv[argc - 1]);
208 vSession, graphShPt);
218 string changefile(argv[argc - 2]);
222 string charalp(argv[argc - 1]);
224 cout <<
"read alpha=" << charalp << endl;
228 string fieldfile(argv[argc - 3]);
229 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
230 vector<vector<NekDouble>> fielddata;
235 vSession, graphShPt,
"w",
true);
239 for (
int i = 0; i < fielddata.size(); i++)
241 streak->ExtractDataToCoeffs(fielddef[i], fielddata[i],
242 fielddef[i]->m_fields[0],
243 streak->UpdateCoeffs());
245 streak->BwdTrans(streak->GetCoeffs(), streak->UpdatePhys());
251 int nIregions, lastIregion = 0;
253 streak->GetBndConditions();
257 int nbnd = bndConditions.size();
258 for (
int r = 0; r < nbnd; r++)
260 if (bndConditions[r]->GetUserDefined() ==
"CalcBC")
269 "there is any boundary region with the tag USERDEFINEDTYPE="
272 cout <<
"nIregions=" << nIregions << endl;
275 streak->GetBndCondExpansions();
278 int nedges = bndfieldx[lastIregion]->GetExpSize();
279 int nvertl = nedges + 1;
293 ((bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
296 vertex0->GetCoords(x0, y0, z0);
299 cout <<
"WARNING x0=" << x0 << endl;
304 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion - 1], Vids_low, v1,
305 v2, x_connect, lastedge, xold_low, yold_low);
306 ASSERTL0(Vids_low[v2] != -10,
"Vids_low[v2] is wrong");
308 graphShPt->GetVertex(Vids_low[v2]);
311 cout <<
"x_conn=" << x_connect <<
" yt=" << yt <<
" zt=" << zt
312 <<
" vid=" << Vids_low[v2] << endl;
313 vertex->GetCoords(x_connect, yt, zt);
319 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion - 1], Vids_low,
320 v1, v2, x_connect, lastedge, xold_low, yold_low);
322 graphShPt->GetVertex(Vids_low[v1]);
324 vertex->GetCoords(x_connect, yt, zt);
336 vertex0 = graphShPt->GetVertex(
337 ((bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
340 vertex0->GetCoords(x0, y0, z0);
343 cout <<
"WARNING x0=" << x0 << endl;
350 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion - 2], Vids_up, v1,
351 v2, x_connect, lastedge, xold_up, yold_up);
353 graphShPt->GetVertex(Vids_up[v2]);
354 vertexU->GetCoords(x_connect, yt, zt);
360 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion - 2], Vids_up,
361 v1, v2, x_connect, lastedge, xold_up, yold_up);
363 graphShPt->GetVertex(Vids_up[v1]);
366 vertex->GetCoords(x_connect, yt, zt);
378 vertex0 = graphShPt->GetVertex(
379 ((bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
382 vertex0->GetCoords(x0, y0, z0);
385 cout <<
"WARNING x0=" << x0 << endl;
393 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion], Vids_c, v1, v2,
394 x_connect, lastedge, xold_c, yold_c);
396 graphShPt->GetVertex(Vids_c[v2]);
399 vertexc->GetCoords(x_connect, yt, zt);
405 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion], Vids_c, v1, v2,
406 x_connect, lastedge, xold_c, yold_c);
408 graphShPt->GetVertex(Vids_c[v1]);
411 vertex->GetCoords(x_connect, yt, zt);
420 for (
int r = 0; r < nvertl; r++)
425 Deltaup[r] = yold_up[r] - yold_c[r];
426 Deltalow[r] = yold_c[r] - yold_low[r];
428 "distance between upper and layer curve is not positive");
430 "distance between lower and layer curve is not positive");
441 vSession, *(bregions.find(lastIregion)->second), graphShPt,
true);
452 if (vSession->DefinesParameter(
"npedge"))
454 npedge = (int)vSession->GetParameter(
"npedge");
463 int nq = streak->GetTotPoints();
466 streak->GetCoords(x, y);
474 xold_c, yold_c, x_c, y_c, cr,
true);
477 for (
int q = 0;
q < nvertl;
q++)
479 if (y_c[
q] < yold_c[
q])
484 Delta_c[
q] =
abs(yold_c[
q] - y_c[
q]);
487 cout << x_c[
q] <<
" " << y_c[
q] << endl;
492 cout <<
"Warning: the critical layer is stationary" << endl;
513 for (
int r = 0; r < nedges; r++)
518 Eid = (bndSegExp->GetGeom1D())->GetGlobalID();
519 id1 = (bndSegExp->GetGeom1D())->GetVid(0);
520 id2 = (bndSegExp->GetGeom1D())->GetVid(1);
521 vertex1 = graphShPt->GetVertex(id1);
522 vertex2 = graphShPt->GetVertex(id2);
524 vertex2->GetCoords(x2, y2, z2);
527 cout <<
"edge=" << r <<
" x1=" << x1 <<
" y1=" << y1 <<
" x2=" << x2
528 <<
" y2=" << y2 << endl;
531 Cpointsx[r] = x1 + (x2 - x1) / 2;
535 if (Cpointsx[r] > x2 || Cpointsx[r] < x1)
537 Cpointsx[r] = -Cpointsx[r];
539 for (
int w = 0;
w < npedge - 2;
w++)
542 Addpointsx[r * (npedge - 2) +
w] =
543 x1 + ((x2 - x1) / (npedge - 1)) * (
w + 1);
544 if (Addpointsx[r * (npedge - 2) +
w] > x2 ||
545 Addpointsx[r * (npedge - 2) +
w] < x1)
547 Addpointsx[r * (npedge - 2) +
w] =
548 -Addpointsx[r * (npedge - 2) +
w];
551 Addpointsy[r * (npedge - 2) +
w] =
552 y_c[r] + ((y_c[r + 1] - y_c[r]) / (x_c[r + 1] - x_c[r])) *
553 (Addpointsx[r * (npedge - 2) +
w] - x1);
557 Addpointsy[r * (npedge - 2) +
w],
558 Addpointsx[r * (npedge - 2) +
w],
559 Addpointsy[r * (npedge - 2) +
w],
573 Cpointsx[r] = x2 + (x1 - x2) / 2;
575 if (Cpointsx[r] > x1 || Cpointsx[r] < x2)
577 Cpointsx[r] = -Cpointsx[r];
579 for (
int w = 0;
w < npedge - 2;
w++)
581 Addpointsx[r * (npedge - 2) +
w] =
582 x2 + ((x1 - x2) / (npedge - 1)) * (
w + 1);
583 if (Addpointsx[r * (npedge - 2) +
w] > x1 ||
584 Addpointsx[r * (npedge - 2) +
w] < x2)
586 Addpointsx[r * (npedge - 2) +
w] =
587 -Addpointsx[r * (npedge - 2) +
w];
591 Addpointsy[r * (npedge - 2) +
w] =
593 ((y_c[r] - y_c[r + 1]) / (x_c[r] - x_c[r + 1])) *
594 (Addpointsx[r * (npedge - 2) +
w] - x2);
599 Addpointsy[r * (npedge - 2) +
w],
600 Addpointsx[r * (npedge - 2) +
w],
601 Addpointsy[r * (npedge - 2) +
w],
614 ASSERTL0(
false,
"point not generated");
632 for (
int a = 0; a < nedges; a++)
635 xcPhys[a * npedge + 0] = x_c[a];
636 ycPhys[a * npedge + 0] = y_c[a];
638 xcPhys[a * npedge + npedge - 1] = x_c[a + 1];
639 ycPhys[a * npedge + npedge - 1] = y_c[a + 1];
641 for (
int b = 0; b < npedge - 2; b++)
643 xcPhys[a * npedge + b + 1] = Addpointsx[a * (npedge - 2) + b];
644 ycPhys[a * npedge + b + 1] = Addpointsy[a * (npedge - 2) + b];
648 cout <<
"xc,yc before tanevaluate" << endl;
649 for (
int v = 0; v < xcPhys.size(); v++)
651 cout << xcPhys[v] <<
" " << ycPhys[v] << endl;
664 MappingEVids(xold_up, yold_up, xold_low, yold_low, xold_c, yold_c, Vids_c,
665 graphShPt, streak, V1, V2, nlays, lay_Eids, lay_Vids);
667 cout <<
"nlays=" << nlays << endl;
671 for (
int g = 0; g < nlays; g++)
682 if (vSession->DefinesParameter(
"Delta"))
684 Delta0 = vSession->GetParameter(
"Delta");
696 int nVertTot = graphShPt->GetNvertices();
712 for (
int i = 0; i < nVertTot; i++)
714 bool mvpoint =
false;
717 vertex->GetCoords(x, y,
z);
726 if (x == 0 && y < yold_low[0] && y > bleft)
731 if (x == xold_c[nvertl - 1] && y > yold_up[nvertl - 1] && y < tright)
736 if (x == xold_c[nvertl - 1] && y < yold_low[nvertl - 1] && y > bright)
741 if (x == 0 && y > yold_up[0] && y < tleft)
746 for (
int j = 0; j < nvertl; j++)
748 if ((xold_up[j] == x) && (yold_up[j] == y))
752 ynew[i] = y_c[j] + Delta0;
756 if ((xold_low[j] == x) && (yold_low[j] == y))
760 ynew[i] = y_c[j] - Delta0;
764 if ((xold_c[j] == x) && (yold_c[j] == y))
770 if (mvpoint ==
false)
775 for (
int k = 0; k < nvertl; k++)
777 if (
abs(x - xold_up[k]) < diff)
779 diff =
abs(x - xold_up[k]);
783 if (y > yold_up[qp_closer] && y < 1)
793 ynew[i] = y_c[qp_closer] + (y - yold_c[qp_closer]) *
794 (1 - y_c[qp_closer]) /
795 (1 - yold_c[qp_closer]);
798 else if (y < yold_low[qp_closer] && y > -1)
808 ynew[i] = y_c[qp_closer] + (y - yold_c[qp_closer]) *
809 (-1 - y_c[qp_closer]) /
810 (-1 - yold_c[qp_closer]);
813 else if (y > yold_c[qp_closer] && y < yold_up[qp_closer])
823 else if (y < yold_c[qp_closer] && y > yold_low[qp_closer])
833 else if (y == 1 || y == -1)
841 if ((ynew[i] > 1 || ynew[i] < -1) &&
842 (y > yold_up[qp_closer] || y < yold_low[qp_closer]))
844 cout <<
"point x=" << xnew[i] <<
" y=" << y
845 <<
" closer x=" << xold_up[qp_closer]
846 <<
" ynew=" << ynew[i] << endl;
847 ASSERTL0(
false,
"shifting out of range");
852 int nqedge = streak->GetExp(0)->GetNumPoints(0);
853 int nquad_lay = (nvertl - 1) * nqedge;
856 bool curv_lay =
true;
857 bool move_norm =
true;
858 int np_lay = (nvertl - 1) * npedge;
868 if (move_norm ==
true)
880 cout <<
"nquad per edge=" << nqedge << endl;
881 for (
int l = 0; l < 2; l++)
883 Edge_newcoords[l] = bndfieldx[lastIregion]
907 bndfieldx[lastIregion]->GetCoords(xcQ, ycQ, zcQ);
916 for (
int l = 0; l < xcQ.size(); l++)
930 Vmath::Vcopy(nquad_lay, ycQ, 1, Cont_y->UpdatePhys(), 1);
933 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffsy);
934 Cont_y->BwdTrans(coeffsy, Cont_y->UpdatePhys());
937 cout <<
"xcQ, ycQ" << endl;
938 for (
int s = 0; s < xcQ.size(); s++)
940 cout << xcQ[s] <<
" " << ycQ[s] << endl;
943 bool evaluatetan =
false;
947 for (
int k = 0; k < nedges; k++)
949 Vmath::Vcopy(nqedge, &xcQ[k * nqedge], 1, &xcedgeQ[0], 1);
950 Vmath::Vcopy(nqedge, &ycQ[k * nqedge], 1, &ycedgeQ[0], 1);
952 Edge_newcoords[0]->StdPhysDeriv(xcedgeQ, txedgeQ);
953 Edge_newcoords[1]->StdPhysDeriv(ycedgeQ, tyedgeQ);
955 Vmath::Vmul(nqedge, txedgeQ, 1, txedgeQ, 1, normsQ, 1);
957 Vmath::Vvtvp(nqedge, tyedgeQ, 1, tyedgeQ, 1, normsQ, 1, normsQ, 1);
962 Vmath::Vmul(nqedge, txedgeQ, 1, normsQ, 1, txedgeQ, 1);
963 Vmath::Vmul(nqedge, tyedgeQ, 1, normsQ, 1, tyedgeQ, 1);
968 for (
int u = 0; u < nqedge - 1; u++)
970 incratio = (ycedgeQ[u + 1] - ycedgeQ[u]) /
971 (xcedgeQ[u + 1] - xcedgeQ[u]);
972 cout <<
"incratio=" << incratio << endl;
973 if (
abs(incratio) > 4.0 && evaluatetan ==
false)
975 cout <<
"wrong=" << wrong << endl;
977 ASSERTL0(wrong < 2,
"number edges to change is too high!!");
978 edgeinterp[wrong] = k;
985 cout <<
"tan bef" << endl;
986 for (
int e = 0; e < nqedge; e++)
988 cout << xcedgeQ[e] <<
" " << ycedgeQ[e] <<
" "
989 << txedgeQ[e] << endl;
997 Vmath::Vcopy(npedge, &xcPhysMOD[k * npedge + 0], 1, &xPedges[0],
999 Vmath::Vcopy(npedge, &ycPhysMOD[k * npedge + 0], 1, &yPedges[0],
1002 PolyFit(polyorder, nqedge, xcedgeQ, ycedgeQ, coeffsinterp,
1003 xPedges, yPedges, npedge);
1005 Vmath::Vcopy(npedge, &xPedges[0], 1, &xcPhysMOD[k * npedge + 0],
1007 Vmath::Vcopy(npedge, &yPedges[0], 1, &ycPhysMOD[k * npedge + 0],
1014 Vmath::Vcopy(nqedge, &(txedgeQ[0]), 1, &(txQ[nqedge * k]), 1);
1015 Vmath::Vcopy(nqedge, &(tyedgeQ[0]), 1, &(tyQ[nqedge * k]), 1);
1020 for (
int w = 0;
w < fz.size();
w++)
1022 txQ[
w] = cos(atan(fz[
w]));
1023 tyQ[
w] = sin(atan(fz[
w]));
1024 cout << xcQ[
w] <<
" " << ycQ[
w] <<
" " << fz[
w] << endl;
1029 Vmath::Vcopy(nquad_lay, txQ, 1, Cont_y->UpdatePhys(), 1);
1030 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffsy);
1031 Cont_y->BwdTrans(coeffsy, Cont_y->UpdatePhys());
1034 Vmath::Vcopy(nquad_lay, tyQ, 1, Cont_y->UpdatePhys(), 1);
1035 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffsy);
1036 Cont_y->BwdTrans(coeffsy, Cont_y->UpdatePhys());
1047 for (
int q = 0;
q < 2;
q++)
1049 edgebef = edgeinterp[
q] - 1;
1051 (txQ[edgebef * nqedge + nqedge - 1] - txQ[edgebef * nqedge]) /
1052 (xcQ[edgebef * nqedge + nqedge - 1] - xcQ[edgebef * nqedge]);
1053 inc = (txQ[edgeinterp[
q] * nqedge + nqedge - 1] -
1054 txQ[edgeinterp[
q] * nqedge]) /
1055 (xcQ[edgeinterp[
q] * nqedge + nqedge - 1] -
1056 xcQ[edgeinterp[
q] * nqedge]);
1057 int npoints = 2 * nqedge;
1063 cout <<
"inc=" << inc <<
" incbef=" << incbefore << endl;
1064 if ((inc / incbefore) > 0.)
1066 cout <<
"before!!" << edgebef << endl;
1078 PolyFit(polyorder, npoints, xQedges, txQedges, coeffsinterp,
1079 xQedges, txQedges, npoints);
1083 &txQ[edgebef * nqedge + 0], 1);
1085 PolyFit(polyorder, npoints, xQedges, tyQedges, coeffsinterp,
1086 xQedges, tyQedges, npoints);
1090 &tyQ[edgebef * nqedge + 0], 1);
1094 cout <<
"after!!" << endl;
1106 PolyFit(polyorder, npoints, xQedges, txQedges, coeffsinterp,
1107 xQedges, txQedges, npoints);
1111 &txQ[edgeinterp[
q] * nqedge + 0], 1);
1113 PolyFit(polyorder, npoints, xQedges, tyQedges, coeffsinterp,
1114 xQedges, tyQedges, npoints);
1118 &tyQ[edgeinterp[
q] * nqedge + 0], 1);
1123 Vmath::Vcopy(nquad_lay, tyQ, 1, Cont_y->UpdatePhys(), 1);
1124 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffstmp);
1125 Cont_y->BwdTrans(coeffstmp, Cont_y->UpdatePhys());
1128 Vmath::Vcopy(nquad_lay, txQ, 1, Cont_y->UpdatePhys(), 1);
1129 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffstmp);
1130 Cont_y->BwdTrans(coeffstmp, Cont_y->UpdatePhys());
1133 for (
int k = 0; k < nedges; k++)
1140 Vmath::Vcopy(nqedge, &(txQ[nqedge * k]), 1, &(txedgeQ[0]), 1);
1141 Vmath::Vcopy(nqedge, &(tyQ[nqedge * k]), 1, &(tyedgeQ[0]), 1);
1143 Vmath::Vdiv(nqedge, txedgeQ, 1, tyedgeQ, 1, tx_tyedgeQ, 1);
1144 Vmath::Vmul(nqedge, tx_tyedgeQ, 1, tx_tyedgeQ, 1, tx_tyedgeQ, 1);
1145 Vmath::Sadd(nqedge, 1.0, tx_tyedgeQ, 1, nxedgeQ, 1);
1149 Vmath::Smul(nqedge, -1.0, nxedgeQ, 1, nxedgeQ, 1);
1150 Vmath::Vcopy(nqedge, &(nxedgeQ[0]), 1, &(nxQ[nqedge * k]), 1);
1152 Vmath::Vmul(nqedge, nxedgeQ, 1, nxedgeQ, 1, nyedgeQ, 1);
1153 Vmath::Smul(nqedge, -1.0, nyedgeQ, 1, nyedgeQ, 1);
1157 Vmath::Smul(nqedge, -1.0, nyedgeQ, 1, nyedgeQ, 1);
1158 Vmath::Vcopy(nqedge, &(nyedgeQ[0]), 1, &(nyQ[nqedge * k]), 1);
1160 cout <<
"edge:" << k << endl;
1161 cout <<
"tan/normal" << endl;
1162 for (
int r = 0; r < nqedge; r++)
1164 cout << xcQ[k * nqedge + r] <<
" " << txedgeQ[r] <<
" "
1165 << tyedgeQ[r] <<
" " << nxedgeQ[r] <<
" "
1166 << nyedgeQ[r] << endl;
1172 Vmath::Vcopy(nquad_lay, nyQ, 1, Cont_y->UpdatePhys(), 1);
1174 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffstmp);
1175 Cont_y->BwdTrans(coeffstmp, Cont_y->UpdatePhys());
1179 Vmath::Zero(Cont_y->GetNcoeffs(), Cont_y->UpdateCoeffs(), 1);
1180 Vmath::Vcopy(nquad_lay, nxQ, 1, Cont_y->UpdatePhys(), 1);
1181 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffstmp);
1182 Cont_y->BwdTrans(coeffstmp, Cont_y->UpdatePhys());
1186 for (
int k = 0; k < nedges; k++)
1192 nyQ[(k - 1) * nqedge + nqedge - 1] = nyQ[k * nqedge + 0];
1196 nxQ[(k - 1) * nqedge + nqedge - 1] = nxQ[k * nqedge + 0];
1204 cout <<
"nx,yQbefore" << endl;
1205 for (
int u = 0; u < xcQ.size(); u++)
1207 cout << xcQ[u] <<
" " << nyQ[u] <<
" " << txQ[u] << endl;
1213 cout <<
"nx,yQ" << endl;
1214 for (
int u = 0; u < x_tmpQ.size(); u++)
1216 cout << x_tmpQ[u] <<
" " << tmpnyQ[u] << endl;
1220 for (
int k = 0; k < nedges; k++)
1223 for (
int a = 0; a < npedge; a++)
1227 nxPhys[k * npedge + a] = nxQ[k * nqedge + 0];
1228 nyPhys[k * npedge + a] = nyQ[k * nqedge + 0];
1230 else if (a == npedge - 1)
1232 nxPhys[k * npedge + a] = nxQ[k * nqedge + nqedge - 1];
1233 nyPhys[k * npedge + a] = nyQ[k * nqedge + nqedge - 1];
1248 Addpointsx[k * (npedge - 2) + a - 1], x_tmpQ);
1258 Addpointsx[k * (npedge - 2) + a - 1], 4, Pxinterp,
1269 nxPhys[k * npedge + a] = -
sqrt(
abs(
1270 1 - nyPhys[k * npedge + a] * nyPhys[k * npedge + a]));
1285 nyPhys[(k - 1) * npedge + npedge - 1] =
1286 nyPhys[k * npedge + 0];
1290 nxPhys[(k - 1) * npedge + npedge - 1] =
1291 nxPhys[k * npedge + 0];
1295 cout <<
"xcPhys,," << endl;
1296 for (
int s = 0; s < np_lay; s++)
1299 cout << xcPhysMOD[s] <<
" " << ycPhysMOD[s] <<
" "
1300 << nxPhys[s] <<
" " << nyPhys[s] << endl;
1312 for (
int m = 0; m < nlays; m++)
1319 delta[m] = -(cntlow + 1 - m) * Delta0 / (cntlow + 1);
1323 delta[m] = (m - (cntlow)) * Delta0 / (cntlow + 1);
1329 for (
int h = 0; h < nvertl; h++)
1337 if (move_norm ==
false)
1339 ynew[lay_Vids[m][h]] = y_c[h] + delta[m];
1340 xnew[lay_Vids[m][h]] = x_c[h];
1344 if (h == 0 || h == nvertl - 1)
1346 ynew[lay_Vids[m][h]] = y_c[h] + delta[m];
1347 xnew[lay_Vids[m][h]] = x_c[h];
1351 ynew[lay_Vids[m][h]] =
1352 y_c[h] + delta[m] *
abs(nyPhys[h * npedge + 0]);
1353 xnew[lay_Vids[m][h]] =
1354 x_c[h] + delta[m] *
abs(nxPhys[h * npedge + 0]);
1357 cout <<
"Vid x=" << xnew[lay_Vids[m][h]]
1358 <<
" y=" << ynew[lay_Vids[m][h]] << endl;
1363 cout <<
"edge==" << h << endl;
1367 nyPhys[(h - 1) * npedge + npedge - 1],
1370 nxPhys[(h - 1) * npedge + npedge - 1],
1373 if (move_norm ==
false)
1376 layers_y[m][h * npedge + 0] = y_c[h] + delta[m];
1377 layers_x[m][h * npedge + 0] = xnew[lay_Vids[m][h]];
1379 layers_y[m][h * npedge + npedge - 1] =
1380 y_c[h + 1] + delta[m];
1381 layers_x[m][h * npedge + npedge - 1] =
1382 xnew[lay_Vids[m][h + 1]];
1384 for (
int d = 0;
d < npedge - 2;
d++)
1386 layers_y[m][h * npedge +
d + 1] =
1387 ycPhysMOD[h * npedge +
d + 1] + delta[m];
1389 layers_x[m][h * npedge +
d + 1] =
1390 xcPhysMOD[h * npedge +
d + 1];
1399 tmpy_lay[h * npedge + 0] = y_c[h] + delta[m];
1400 tmpx_lay[h * npedge + 0] = xnew[lay_Vids[m][h]];
1402 tmpy_lay[h * npedge + npedge - 1] =
1404 delta[m] *
abs(nyPhys[h * npedge + npedge - 1]);
1405 tmpx_lay[h * npedge + npedge - 1] =
1407 delta[m] *
abs(nxPhys[h * npedge + npedge - 1]);
1409 else if (h == nedges - 1)
1412 tmpy_lay[h * npedge + 0] =
1413 y_c[h] + delta[m] *
abs(nyPhys[h * npedge + 0]);
1414 tmpx_lay[h * npedge + 0] =
1415 x_c[h] + delta[m] *
abs(nxPhys[h * npedge + 0]);
1417 tmpy_lay[h * npedge + npedge - 1] =
1418 y_c[h + 1] + delta[m];
1419 tmpx_lay[h * npedge + npedge - 1] =
1420 xnew[lay_Vids[m][h + 1]];
1425 tmpy_lay[h * npedge + 0] =
1426 y_c[h] + delta[m] *
abs(nyPhys[h * npedge + 0]);
1427 tmpx_lay[h * npedge + 0] =
1428 x_c[h] + delta[m] *
abs(nxPhys[h * npedge + 0]);
1430 tmpy_lay[h * npedge + npedge - 1] =
1432 delta[m] *
abs(nyPhys[h * npedge + npedge - 1]);
1433 tmpx_lay[h * npedge + npedge - 1] =
1435 delta[m] *
abs(nxPhys[h * npedge + npedge - 1]);
1439 for (
int d = 0;
d < npedge - 2;
d++)
1442 tmpy_lay[h * npedge +
d + 1] =
1443 ycPhysMOD[h * npedge +
d + 1] +
1444 delta[m] *
abs(nyPhys[h * npedge +
d + 1]);
1447 tmpx_lay[h * npedge +
d + 1] =
1448 xcPhysMOD[h * npedge +
d + 1] +
1449 delta[m] *
abs(nxPhys[h * npedge +
d + 1]);
1467 for (
int s = 0; s < np_lay; s++)
1469 cout << tmpx_lay[s] <<
" " << tmpy_lay[s] << endl;
1472 cout <<
"fisrt interp" << endl;
1473 for (
int s = 0; s < np_lay; s++)
1475 cout << tmpx_lay[s] <<
" " << tmpy_lay[s] << endl;
1487 NekDouble boundright = xcPhysMOD[np_lay - 1];
1488 bool outboundleft =
false;
1489 bool outboundright =
false;
1490 if (tmpx_lay[1] < boundleft)
1492 outboundleft =
true;
1494 if (tmpx_lay[np_lay - 2] > boundright)
1496 outboundright =
true;
1504 for (
int r = 0; r < nedges; r++)
1507 if (tmpx_lay[r * npedge + npedge - 1] < boundleft &&
1508 outboundleft ==
true)
1510 vertout[outvert] = r;
1516 if (tmpx_lay[(r + 1) * npedge + npedge - 1] > boundleft)
1518 for (
int s = 0; s < npedge - 2; s++)
1520 if (tmpx_lay[(r + 1) * npedge + s + 1] <
1530 if (tmpx_lay[r * npedge + 0] > boundright &&
1531 outboundright ==
true)
1533 vertout[outvert] = r;
1539 if (tmpx_lay[(r - 1) * npedge + 0] < boundright)
1541 for (
int s = 0; s < npedge - 2; s++)
1543 if (tmpx_lay[(r - 1) * npedge + s + 1] >
1555 outcount = outvert * npedge + 1 + outmiddle;
1557 int replacepointsfromindex = 0;
1558 for (
int c = 0; c < nedges; c++)
1561 if (xcPhysMOD[c * npedge + npedge - 1] <=
1562 tmpx_lay[c * (npedge - (npedge - 2)) + 2] &&
1563 outboundright ==
true)
1565 replacepointsfromindex = c * (npedge - (npedge - 2)) + 2;
1570 if (xcPhysMOD[(nedges - 1 - c) * npedge + 0] >=
1571 tmpx_lay[np_lay - 1 -
1572 (c * (npedge - (npedge - 2)) + 2)] &&
1573 outboundleft ==
true)
1575 replacepointsfromindex =
1576 np_lay - 1 - (c * (npedge - (npedge - 2)) + 2);
1592 if (outboundright ==
true)
1594 pstart = replacepointsfromindex;
1595 shift = np_lay - outcount;
1597 (xcPhysMOD[np_lay - outcount] - xcPhysMOD[pstart]) /
1599 outcount = outcount - 1;
1600 ASSERTL0(tmpx_lay[np_lay - outcount] >
1601 xcPhysMOD[(nedges - 1) * npedge + 0],
1602 "no middle points in the last edge");
1607 pstart = outcount - 1;
1608 increment = (xcPhysMOD[replacepointsfromindex] -
1609 xcPhysMOD[pstart]) /
1612 xcPhysMOD[0 * npedge + npedge - 1],
1613 "no middle points in the first edge");
1630 NekDouble xctmp, ycinterp, nxinterp, nyinterp;
1632 for (
int v = 0; v < outcount; v++)
1634 xctmp = xcPhysMOD[pstart] + (v + 1) * increment;
1648 nxinterp =
sqrt(
abs(1 - nyinterp * nyinterp));
1656 replace_x[v] = xctmp + delta[m] *
abs(nxinterp);
1657 replace_y[v] = ycinterp + delta[m] *
abs(nyinterp);
1658 tmpx_lay[v + shift] = replace_x[v];
1659 tmpy_lay[v + shift] = replace_y[v];
1679 int closepoints = 4;
1685 int pointscount = 0;
1686 for (
int q = 0;
q < np_lay;
q++)
1688 for (
int e = 0; e < nedges; e++)
1690 if (tmpx_lay[
q] <= x_c[e + 1] && tmpx_lay[
q] >= x_c[e])
1694 if (
q == e * npedge + npedge - 1 && pointscount != npedge)
1699 else if (
q == e * npedge + npedge - 1)
1720 lay_Vids[m], layers_x[m], layers_y[m], xnew,
1800 if (curv_lay ==
true)
1809 int npoints = npedge;
1812 for (
int f = 0; f < nedges; f++)
1823 PolyFit(polyorder, npoints, xPedges, yPedges, coeffsinterp,
1824 xPedges, yPedges, npoints);
1828 &layers_y[m][(f)*npedge + 0], 1);
1831 layers_y[m][f * npedge + 0] = ynew[lay_Vids[m][f]];
1832 layers_y[m][f * npedge + npedge - 1] = ynew[lay_Vids[m][f + 1]];
1835 cout <<
" xlay ylay lay:" << m << endl;
1836 for (
int l = 0; l < np_lay; l++)
1839 cout << std::setprecision(8) << layers_x[m][l] <<
" "
1840 << layers_y[m][l] << endl;
1876 cout <<
"lay=" << m << endl;
1879 " different layer ymin val");
1882 " different layer ymax val");
1885 " different layer xmin val");
1888 " different layer xmax val");
1898 npedge, graphShPt, xold_c, yold_c, xold_low, yold_low, xold_up,
1899 yold_up, layers_x[0], layers_y[0], layers_x[nlays - 1],
1900 layers_y[nlays - 1], nxPhys, nyPhys, xnew, ynew);
1981 Down, Up, xnew, ynew, layers_x, layers_y);
1991 cout << std::setprecision(8) <<
"xmin=" <<
Vmath::Vmin(nVertTot, xnew, 1)
1994 " different xmin val");
1996 " different ymin val");
1998 " different xmax val");
2000 " different ymax val");
2005 charalp, layers_x, layers_y, lay_Eids, curv_lay);
2014 int nvertl = nedges + 1;
2018 for (
int j = 0; j < nedges; j++)
2022 edge = (bndSegExplow->GetGeom1D())->GetGlobalID();
2024 for (
int k = 0; k < 2; k++)
2026 Vids_temp[j + k] = (bndSegExplow->GetGeom1D())->GetVid(k);
2028 graphShPt->GetVertex(Vids_temp[j + k]);
2030 vertex->GetCoords(x1, y1, z1);
2031 if (x1 == x_connect && edge != lastedge)
2034 if (x_connect == x0layer)
2036 Vids[v1] = Vids_temp[j + k];
2043 (bndSegExplow->GetGeom1D())->GetVid(1);
2044 Vids[v2] = Vids_temp[j + 1];
2046 graphShPt->GetVertex(Vids[v2]);
2048 vertex->GetCoords(x2, y2, z2);
2055 (bndSegExplow->GetGeom1D())->GetVid(0);
2056 Vids[v2] = Vids_temp[j + 0];
2058 graphShPt->GetVertex(Vids[v2]);
2060 vertex->GetCoords(x2, y2, z2);
2070 (bndSegExplow->GetGeom1D())->GetVid(1);
2071 Vids[v1] = Vids_temp[j + 1];
2073 graphShPt->GetVertex(Vids[v1]);
2075 vertex->GetCoords(x1, y1, z1);
2082 (bndSegExplow->GetGeom1D())->GetVid(0);
2083 Vids[v1] = Vids_temp[j + 0];
2085 graphShPt->GetVertex(Vids[v1]);
2087 vertex->GetCoords(x1, y1, z1);
2095 if (Vids[v1] != -10)
2114 cout <<
"Computestreakpositions" << endl;
2115 int nq = streak->GetTotPoints();
2129 Vmath::Vadd(xc.size(), yold_up, 1, yold_low, 1, yc, 1);
2143 for (
int e = 0; e < npoints; e++)
2148 elmtid = streak->GetExpIndex(coord, 0.00001);
2149 offset = streak->GetPhys_Offset(elmtid);
2155 while (
abs(F) > 0.000000001)
2158 elmtid = streak->GetExpIndex(coord, 0.00001);
2165 if ((
abs(coord[1]) > 1 || elmtid == -1) && attempt == 0 &&
2169 coord[1] = yold_c[e];
2172 else if ((
abs(coord[1]) > 1 || elmtid == -1))
2174 coord[1] = ytmp + 0.01;
2175 elmtid = streak->GetExpIndex(coord, 0.001);
2176 offset = streak->GetPhys_Offset(elmtid);
2177 NekDouble Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2178 coord, streak->GetPhys() + offset);
2179 NekDouble dUtmp = streak->GetExp(elmtid)->PhysEvaluate(
2180 coord, derstreak + offset);
2181 coord[1] = coord[1] - (Utmp - cr) / dUtmp;
2182 if ((
abs(Utmp - cr) >
abs(F)) || (
abs(coord[1]) > 1))
2184 coord[1] = ytmp - 0.01;
2191 ASSERTL0(
abs(coord[1]) <= 1,
" y value out of bound +/-1");
2193 offset = streak->GetPhys_Offset(elmtid);
2194 U = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() +
2197 streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2198 coord[1] = coord[1] - (U - cr) / dU;
2200 ASSERTL0(coord[0] == xc[e],
" x coordinate must remain the same");
2203 if (its > 200 &&
abs(F) < 0.00001)
2205 cout <<
"warning streak position obtained with precision:" << F
2209 else if (its > 1000 &&
abs(F) < 0.0001)
2211 cout <<
"warning streak position obtained with precision:" << F
2215 else if (its > 1000)
2217 ASSERTL0(
false,
"no convergence after 1000 iterations");
2220 yc[e] = coord[1] - (U - cr) / dU;
2221 ASSERTL0(U <= cr + tol,
"streak wrong+");
2222 ASSERTL0(U >= cr - tol,
"streak wrong-");
2225 cout <<
"result streakvert x=" << xc[e] <<
" y=" << yc[e]
2226 <<
" streak=" << U << endl;
2247 while (
abs(F) > 0.00000001)
2251 elmtid = function->GetExpIndex(coords, 0.01);
2253 cout <<
"gen newton xi=" << xi <<
" yi=" << coords[1]
2254 <<
" elmtid=" << elmtid <<
" F=" << F << endl;
2256 if ((
abs(coords[1]) > 1 || elmtid == -1))
2259 coords[1] = ytmp + 0.01;
2260 elmtid = function->GetExpIndex(coords, 0.01);
2261 offset = function->GetPhys_Offset(elmtid);
2262 NekDouble Utmp = function->GetExp(elmtid)->PhysEvaluate(
2263 coords, function->GetPhys() + offset);
2264 NekDouble dUtmp = function->GetExp(elmtid)->PhysEvaluate(
2265 coords, derfunction + offset);
2266 coords[1] = coords[1] - (Utmp - cr) / dUtmp;
2267 cout <<
"attempt:" << coords[1] << endl;
2268 if ((
abs(Utmp - cr) >
abs(F)) || (
abs(coords[1]) > 1.01))
2270 coords[1] = ytmp - 0.01;
2275 else if (
abs(coords[1]) < 1.01 && attempt == 0)
2282 ASSERTL0(
abs(coords[1]) <= 1.00,
" y value out of bound +/-1");
2284 offset = function->GetPhys_Offset(elmtid);
2285 U = function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() +
2287 dU = function->GetExp(elmtid)->PhysEvaluate(coords,
2288 derfunction + offset);
2289 coords[1] = coords[1] - (U - cr) / dU;
2290 cout << cr <<
"U-cr=" << U - cr <<
" tmp result y:" << coords[1]
2291 <<
" dU=" << dU << endl;
2295 if (its > 200 &&
abs(F) < 0.00001)
2297 cout <<
"warning streak position obtained with precision:" << F
2301 else if (its > 1000 &&
abs(F) < 0.0001)
2303 cout <<
"warning streak position obtained with precision:" << F
2307 else if (its > 1000)
2309 ASSERTL0(
false,
"no convergence after 1000 iterations");
2312 ASSERTL0(coords[0] == xi,
" x coordinate must remain the same");
2315 yout = coords[1] - (U - cr) / dU;
2316 cout <<
"NewtonIt result x=" << xout <<
" y=" << coords[1] <<
" U=" << U
2324 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D =
2326 int nel = exp2D->size();
2334 for (
int i = 0; i < nel; i++)
2336 if ((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
2338 for (
int j = 0; j < locQuadExp->GetNtraces(); ++j)
2340 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
2341 id = SegGeom->GetGlobalID();
2343 if (V1tmp[
id] == 10000)
2345 V1tmp[id] = SegGeom->GetVertex(0)->GetVid();
2346 V2tmp[id] = SegGeom->GetVertex(1)->GetVid();
2354 else if ((locTriExp = (*exp2D)[i]->as<LocalRegions::TriExp>()))
2356 for (
int j = 0; j < locTriExp->GetNtraces(); ++j)
2358 SegGeom = (locTriExp->GetGeom2D())->GetEdge(j);
2359 id = SegGeom->GetGlobalID();
2361 if (V1tmp[
id] == 10000)
2363 V1tmp[id] = SegGeom->GetVertex(0)->GetVid();
2364 V2tmp[id] = SegGeom->GetVertex(1)->GetVid();
2374 for (
int g = 0; g < cnt; g++)
2377 ASSERTL0(V1tmp[g] != 10000,
"V1 wrong");
2379 ASSERTL0(V2tmp[g] != 10000,
"V2 wrong");
2394 int nlay_Eids = xcold.size() - 1;
2395 int nlay_Vids = xcold.size();
2397 int nVertsTot = mesh->GetNvertices();
2398 cout <<
"nverttot=" << nVertsTot << endl;
2402 cout <<
"init nlays=" << nlays << endl;
2409 cout <<
"yoldup=" << yoldup[0] << endl;
2410 cout <<
"yolddown=" << yolddown[0] << endl;
2412 for (
int r = 0; r < nVertsTot; r++)
2417 vertex->GetCoords(x, y,
z);
2423 if (y <= yoldup[0] && y >= yolddown[0] && y != ycold[0])
2426 tmpVids0[nlays] = r;
2433 cout <<
"nlays=" << nlays << endl;
2445 for (
int w = 0;
w < nlays;
w++)
2448 tmpx0[
w] = tmpx[index];
2449 tmpy0[
w] = tmpf[index];
2450 tmpVids0[
w] = tmpV[index];
2451 tmpf[index] = max + 1000;
2457 for (
int m = 0; m < nlays; m++)
2468 NekDouble xtmp, ytmp, normnext = 0.0, xnext = 0.0, ynext = 0.0, diff;
2469 NekDouble Ubef = 0.0, Utmp = 0.0, Unext = 0.0;
2472 int nTotEdges = V1.size();
2474 for (
int m = 0; m < nlays; m++)
2476 for (
int g = 0; g < nlay_Eids; g++)
2480 for (
int h = 0; h < nTotEdges; h++)
2483 if (tmpVids0[m] == V1[h])
2486 mesh->GetVertex(V2[h]);
2488 vertex->GetCoords(x, y,
z);
2492 Vids_lay[m][0] = V1[h];
2493 Vids_lay[m][1] = V2[h];
2495 mesh->GetVertex(V1[h]);
2497 vertex1->GetCoords(x1, y1, z1);
2499 sqrt((y - y1) * (y - y1) + (x - x1) * (x - x1));
2504 elmtid = streak->GetExpIndex(coord, 0.00001);
2505 offset = streak->GetPhys_Offset(elmtid);
2506 Ubef = streak->GetExp(elmtid)->PhysEvaluate(
2507 coord, streak->GetPhys() + offset);
2510 if (tmpVids0[m] == V2[h])
2513 mesh->GetVertex(V1[h]);
2515 vertex->GetCoords(x, y,
z);
2519 Vids_lay[m][0] = V2[h];
2520 Vids_lay[m][1] = V1[h];
2522 mesh->GetVertex(V2[h]);
2525 sqrt((y - y2) * (y - y2) + (x - x2) * (x - x2));
2530 elmtid = streak->GetExpIndex(coord, 0.00001);
2531 offset = streak->GetPhys_Offset(elmtid);
2532 Ubef = streak->GetExp(elmtid)->PhysEvaluate(
2533 coord, streak->GetPhys() + offset);
2538 cout <<
"Eid=" << Eids_lay[m][0]
2539 <<
" Vids_lay0=" << Vids_lay[m][0]
2540 <<
" Vidslay1=" << Vids_lay[m][1] << endl;
2546 for (
int h = 0; h < nTotEdges; h++)
2550 if ((Vids_lay[m][g] == V1[h] || Vids_lay[m][g] == V2[h]) &&
2551 h != Eids_lay[m][g - 1])
2553 cout <<
"edgetmp=" << h << endl;
2554 ASSERTL0(cnt <= 6,
"wrong number of candidates");
2563 cout <<
"normbef=" << normbef << endl;
2564 cout <<
"Ubefcc=" << Ubef << endl;
2566 for (
int e = 0; e < cnt; e++)
2569 mesh->GetVertex(V1[edgestmp[e]]);
2571 vertex1->GetCoords(x1, y1, z1);
2573 mesh->GetVertex(V2[edgestmp[e]]);
2575 vertex2->GetCoords(x2, y2, z2);
2578 sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
2580 cout <<
"edgetmp1=" << edgestmp[e] << endl;
2581 cout <<
"V1 x1=" << x1 <<
" y1=" << y1 << endl;
2582 cout <<
"V2 x2=" << x2 <<
" y2=" << y2 << endl;
2583 if (Vids_lay[m][g] == V1[edgestmp[e]])
2590 elmtid = streak->GetExpIndex(coord, 0.00001);
2591 offset = streak->GetPhys_Offset(elmtid);
2592 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2593 coord, streak->GetPhys() + offset);
2594 diffarray[e] =
abs((xtmp * xbef + ytmp * ybef) /
2595 (normtmp * normbef) -
2597 diffUarray[e] =
abs(Ubef - Utmp);
2598 cout <<
" normtmp=" << normtmp << endl;
2599 cout <<
" Utmpcc=" << Utmp << endl;
2600 cout << xtmp <<
" ytmp=" << ytmp <<
" diff="
2601 <<
abs(((xtmp * xbef + ytmp * ybef) /
2602 (normtmp * normbef)) -
2605 if (
abs((xtmp * xbef + ytmp * ybef) /
2606 (normtmp * normbef) -
2608 y2 <= yoldup[g + 1] && y2 >= yolddown[g + 1] &&
2609 y1 <= yoldup[g] && y1 >= yolddown[g])
2612 Eids_lay[m][g] = edgestmp[e];
2613 Vids_lay[m][g + 1] = V2[edgestmp[e]];
2614 diff =
abs((xtmp * xbef + ytmp * ybef) /
2615 (normtmp * normbef) -
2623 else if (Vids_lay[m][g] == V2[edgestmp[e]])
2630 elmtid = streak->GetExpIndex(coord, 0.00001);
2631 offset = streak->GetPhys_Offset(elmtid);
2632 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2633 coord, streak->GetPhys() + offset);
2634 diffarray[e] =
abs((xtmp * xbef + ytmp * ybef) /
2635 (normtmp * normbef) -
2637 diffUarray[e] =
abs(Ubef - Utmp);
2638 cout <<
" normtmp=" << normtmp << endl;
2639 cout <<
" Utmpcc=" << Utmp << endl;
2640 cout << xtmp <<
" ytmp=" << ytmp <<
" diff="
2641 <<
abs(((xtmp * xbef + ytmp * ybef) /
2642 (normtmp * normbef)) -
2645 if (
abs((xtmp * xbef + ytmp * ybef) /
2646 (normtmp * normbef) -
2648 y2 <= yoldup[g] && y2 >= yolddown[g] &&
2649 y1 <= yoldup[g + 1] && y1 >= yolddown[g + 1])
2651 Eids_lay[m][g] = edgestmp[e];
2652 Vids_lay[m][g + 1] = V1[edgestmp[e]];
2653 diff =
abs((xtmp * xbef + ytmp * ybef) /
2654 (normtmp * normbef) -
2667 cout <<
"Eid before check=" << Eids_lay[m][g] << endl;
2668 for (
int q = 0;
q < cnt;
q++)
2670 cout <<
q <<
" diff" << diffarray[
q] << endl;
2674 if (m > 0 && m < nlays)
2677 Vids_lay[m][g + 1]);
2681 cout <<
"COMMON VERT" << endl;
2683 diffarray[eid] = 1000;
2687 mesh->GetVertex(V1[edgestmp[eid]]);
2689 vertex1->GetCoords(x1, y1, z1);
2691 mesh->GetVertex(V2[edgestmp[eid]]);
2693 vertex2->GetCoords(x2, y2, z2);
2696 sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
2698 Eids_lay[m][g] = edgestmp[eid];
2699 if (Vids_lay[m][g] == V1[edgestmp[eid]])
2703 elmtid = streak->GetExpIndex(coord, 0.00001);
2704 offset = streak->GetPhys_Offset(elmtid);
2705 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2706 coord, streak->GetPhys() + offset);
2707 Vids_lay[m][g + 1] = V2[edgestmp[eid]];
2714 if (Vids_lay[m][g] == V2[edgestmp[eid]])
2718 elmtid = streak->GetExpIndex(coord, 0.00001);
2719 offset = streak->GetPhys_Offset(elmtid);
2720 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2721 coord, streak->GetPhys() + offset);
2722 Vids_lay[m][g + 1] = V1[edgestmp[eid]];
2731 cout << m <<
"edge aft:" << Eids_lay[m][g]
2732 <<
" Vid=" << Vids_lay[m][g + 1] << endl;
2738 cout <<
"endelse" << normtmp << endl;
2745 for (
int w = 0;
w < nlays;
w++)
2747 for (
int f = 0; f < nlay_Eids; f++)
2749 cout <<
"check=" <<
w <<
" Eid:" << Eids_lay[
w][f] << endl;
2758 for (
int u = 0; u < Vids_laybefore.size(); u++)
2760 if (Vids_laybefore[u] == Vid || Vids_c[u] == Vid)
2764 cout << Vid <<
" Vert test=" << Vids_laybefore[u] << endl;
2774 int np_lay = inarray.size();
2775 ASSERTL0(inarray.size() % nedges == 0,
" something on number npedge");
2779 for (
int w = 0;
w < np_lay;
w++)
2784 if (inarray[
w] == inarray[
w + 1])
2789 outarray[cnt] = inarray[
w];
2793 ASSERTL0(cnt == np_lay - (nedges - 1),
"wrong cut");
2798 int npts = xArray.size();
2807 if (xArray[index] > x)
2820 ASSERTL0(neighpoints % 2 == 0,
"number of neighbour points should be even");
2821 int leftpoints = (neighpoints / 2) - 1;
2822 int rightpoints = neighpoints / 2;
2827 if (index - leftpoints < 0)
2830 diff = index - leftpoints;
2832 Vmath::Vcopy(neighpoints, &yArray[0], 1, &Neighbour_y[0], 1);
2833 Vmath::Vcopy(neighpoints, &xArray[0], 1, &Neighbour_x[0], 1);
2835 else if ((yArray.size() - 1) - index < rightpoints)
2838 int rpoints = (yArray.size() - 1) - index;
2839 diff = rightpoints - rpoints;
2841 start = index - leftpoints - diff;
2842 Vmath::Vcopy(neighpoints, &yArray[start], 1, &Neighbour_y[0], 1);
2843 Vmath::Vcopy(neighpoints, &xArray[start], 1, &Neighbour_x[0], 1);
2848 start = index - leftpoints;
2849 Vmath::Vcopy(neighpoints, &yArray[start], 1, &Neighbour_y[0], 1);
2850 Vmath::Vcopy(neighpoints, &xArray[start], 1, &Neighbour_x[0], 1);
2859 for (
int f = 1; f < neighpoints; f++)
2861 ASSERTL0(Neighbour_x[f] != Neighbour_x[f - 1],
2862 " repetition on NeighbourArrays");
2873 for (
int pt = 0; pt < npts; ++pt)
2877 for (
int j = 0; j < pt; ++j)
2879 h = h * (x - xpts[j]) / (xpts[pt] - xpts[j]);
2882 for (
int k = pt + 1; k < npts; ++k)
2884 h = h * (x - xpts[k]) / (xpts[pt] - xpts[k]);
2888 sum += funcvals[pt] * LagrangePoly;
2900 int np_pol = coeffsinterp.size();
2901 cout <<
"evaluatetan with " << np_pol << endl;
2907 for (
int q = 0;
q < npoints;
q++)
2909 polorder = np_pol - 1;
2910 derorder = np_pol - 2;
2912 for (
int d = 0;
d < np_pol - 1;
d++)
2914 yprime[
q] += (derorder + 1) * coeffsinterp[
d] *
2915 std::pow(xcQedge[
q], derorder);
2919 for (
int a = 0; a < np_pol; a++)
2921 yinterp[
q] += coeffsinterp[a] * std::pow(xcQedge[
q], polorder);
2929 for (
int n = 0; n < npoints; n++)
2933 txQedge[n] = cos((atan((yprime[n]))));
2934 tyQedge[n] = sin((atan((yprime[n]))));
2935 cout << xcQedge[n] <<
" " << yinterp[n] <<
" " << yprime[n]
2936 <<
" " << txQedge[n] <<
" " << tyQedge[n] << endl;
2943 int edge,
int npedge)
2945 int np_pol = xpol.size();
2951 for (
int e = 0; e < N; e++)
2954 for (
int w = 0;
w < N;
w++)
2956 A[N * e + row] = std::pow(xpol[
w], N - 1 - e);
2961 for (
int r = 0; r < np_pol; r++)
2975 std::string message =
2976 "ERROR: The " + std::to_string(-info) +
2977 "th parameter had an illegal parameter for dgetrf";
2982 std::string message =
"ERROR: Element u_" + std::to_string(info) +
2983 std::to_string(info) +
" is 0 from dgetrf";
2989 Lapack::Dgetrs(
'N', N, ncolumns_b,
A.get(), N, ipivot.get(), b.get(), N,
2993 std::string message =
2994 "ERROR: The " + std::to_string(-info) +
2995 "th parameter had an illegal parameter for dgetrf";
3000 std::string message =
"ERROR: Element u_" + std::to_string(info) +
3001 std::to_string(info) +
" is 0 from dgetrf";
3013 for (
int c = 0; c < npedge; c++)
3015 polorder = np_pol - 1;
3017 ycout[edge * (npedge) + c + 1] = 0;
3018 for (
int d = 0;
d < np_pol;
d++)
3020 ycout[edge * (npedge) + c + 1] +=
3021 b[
d] * std::pow(xcout[edge * (npedge) + c + 1], polorder);
3036 int N = polyorder + 1;
3039 cout << npoints << endl;
3040 for (
int u = 0; u < npoints; u++)
3042 cout <<
"c=" << xin[u] <<
" " << fin[u] << endl;
3046 for (
int e = 0; e < N; e++)
3049 for (
int row = 0; row < N; row++)
3051 for (
int w = 0;
w < npoints;
w++)
3053 A[N * e + row] += std::pow(xin[
w], e + row);
3058 for (
int row = 0; row < N; row++)
3060 for (
int h = 0; h < npoints; h++)
3062 b[row] += fin[h] * std::pow(xin[h], row);
3075 std::string message =
3076 "ERROR: The " + std::to_string(-info) +
3077 "th parameter had an illegal parameter for dgetrf";
3082 std::string message =
"ERROR: Element u_" + std::to_string(info) +
3083 std::to_string(info) +
" is 0 from dgetrf";
3088 Lapack::Dgetrs(
'N', N, ncolumns_b,
A.get(), N, ipivot.get(), b.get(), N,
3092 std::string message =
3093 "ERROR: The " + std::to_string(-info) +
3094 "th parameter had an illegal parameter for dgetrf";
3099 std::string message =
"ERROR: Element u_" + std::to_string(info) +
3100 std::to_string(info) +
" is 0 from dgetrf";
3109 for (
int j = 0; j < N; j++)
3111 b[j] = tmp[cnt - 1];
3115 for (
int h = 0; h < N; h++)
3117 cout <<
"coeff:" << b[h] << endl;
3122 for (
int c = 0; c < npout; c++)
3124 polorder = polyorder;
3127 for (
int d = 0;
d < N;
d++)
3130 fout[c] += b[
d] * std::pow(xout[c], polorder);
3153 for (
int w = 0;
w < tmpx.size();
w++)
3156 outarray_x[
w] = tmpx[index];
3157 outarray_y[
w] = tmpy[index];
3158 if (
w < tmpx.size() - 1)
3160 if (tmpx[index] == tmpx[index + 1])
3162 outarray_x[
w + 1] = tmpx[index + 1];
3163 outarray_y[
w + 1] = tmpy[index + 1];
3164 tmpx[index + 1] = max + 1000;
3180 tmpx[index] = max + 1000;
3193 int np_lay = layers_y[0].size();
3195 for (
int h = 1; h < nlays - 1; h++)
3198 for (
int s = 0; s < nvertl; s++)
3201 ASSERTL0(ynew[lay_Vids[h][s]] == -20,
"ynew layers not empty");
3205 ynew[lay_Vids[h][s]] =
3207 h *
abs(ynew[Down[s]] - yc[s]) / (cntlow + 1);
3209 xnew[lay_Vids[h][s]] = xc[s];
3213 layers_y[h][s] = ynew[lay_Vids[h][s]];
3214 layers_x[h][s] = xnew[lay_Vids[h][s]];
3219 ynew[lay_Vids[h][s]] = yc[s] + (h - cntlow) *
3220 abs(ynew[Up[s]] - yc[s]) /
3223 xnew[lay_Vids[h][s]] = xc[s];
3225 layers_y[h][s] = ynew[lay_Vids[h][s]];
3226 layers_x[h][s] = xnew[lay_Vids[h][s]];
3240 int np_lay = xcPhys.size();
3241 int nedges = nvertl - 1;
3248 int closepoints = 4;
3253 for (
int g = 0; g < nedges; g++)
3262 Pxinterp, Pyinterp);
3263 xnew[Vids[g]] = xcPhys[g * npedge + 0];
3264 ylay[g * npedge + 0] = ynew[Vids[g]];
3265 xlay[g * npedge + 0] = xnew[Vids[g]];
3275 xcPhys[g * npedge + npedge - 1], closepoints, Pxinterp, Pyinterp);
3276 xnew[Vids[g + 1]] = xcPhys[g * npedge + npedge - 1];
3277 ylay[g * npedge + npedge - 1] = ynew[Vids[g + 1]];
3278 xlay[g * npedge + npedge - 1] = xnew[Vids[g + 1]];
3281 for (
int r = 0; r < npedge - 2; r++)
3288 ASSERTL0(index <= tmpy.size() - 1,
" index wrong");
3294 xcPhys[g * npedge + r + 1], closepoints, Pxinterp, Pyinterp);
3296 xlay[g * npedge + r + 1] = xcPhys[g * npedge + r + 1];
3317 int np_lay = xcPhys.size();
3318 int nedges = nvertl - 1;
3326 int closepoints = 4;
3331 for (
int g = 0; g < nedges; g++)
3335 ynew[Vids[g]] = tmpy_lay[g * npedge + 0];
3336 xnew[Vids[g]] = tmpx_lay[g * npedge + 0];
3338 ylay[g * npedge + 0] = ynew[Vids[g]];
3339 xlay[g * npedge + 0] = xnew[Vids[g]];
3342 ynew[Vids[g + 1]] = tmpy_lay[g * npedge + npedge - 1];
3343 xnew[Vids[g + 1]] = tmpx_lay[g * npedge + npedge - 1];
3344 ylay[g * npedge + npedge - 1] = ynew[Vids[g + 1]];
3345 xlay[g * npedge + npedge - 1] = xnew[Vids[g + 1]];
3348 for (
int r = 0; r < npedge - 2; r++)
3350 x0 = xlay[g * npedge + 0];
3351 x1 = xlay[g * npedge + npedge - 1];
3352 xtmp = x0 + r * (x1 - x0) / (npedge - 1);
3357 ASSERTL0(index <= tmpy.size() - 1,
" index wrong");
3362 ylay[g * npedge + r + 1] =
3365 xlay[g * npedge + r + 1] = xtmp;
3382 int nvertl = ycold.size();
3383 int nVertTot = mesh->GetNvertices();
3384 for (
int n = 0; n < nVertTot; n++)
3389 vertex->GetCoords(x, y,
z);
3394 for (
int k = 0; k < nvertl; k++)
3396 if (
abs(x - xcold[k]) < tmp)
3398 tmp =
abs(x - xcold[k]);
3410 nplay_closer = (qp_closer - 1) * npedge + npedge - 1;
3413 if (y > yoldup[qp_closer] && y < 1)
3419 ratio = (1 - ylayup[nplay_closer]) / ((1 - yoldup[qp_closer]));
3421 ynew[n] = ylayup[nplay_closer] + (y - yoldup[qp_closer]) * ratio;
3424 else if (y < yolddown[qp_closer] && y > -1)
3427 ratio = (1 + ylaydown[nplay_closer]) / ((1 + yolddown[qp_closer]));
3430 ylaydown[nplay_closer] + (y - yolddown[qp_closer]) * ratio;
3448 int nvertl = xoldup.size();
3449 int nedges = nvertl - 1;
3458 for (
int a = 0; a < nedges; a++)
3463 xnew_down[a] = xlaydown[a * npedge + 0];
3464 ynew_down[a] = ylaydown[a * npedge + 0];
3465 xnew_up[a] = xlayup[a * npedge + 0];
3466 ynew_up[a] = ylayup[a * npedge + 0];
3467 nxvert[a] = nxPhys[a * npedge + 0];
3468 nyvert[a] = nyPhys[a * npedge + 0];
3470 xnew_down[a + 1] = xlaydown[a * npedge + npedge - 1];
3471 ynew_down[a + 1] = ylaydown[a * npedge + npedge - 1];
3472 xnew_up[a + 1] = xlayup[a * npedge + npedge - 1];
3473 ynew_up[a + 1] = ylayup[a * npedge + npedge - 1];
3474 nxvert[a + 1] = nxPhys[a * npedge + npedge - 1];
3475 nyvert[a + 1] = nyPhys[a * npedge + npedge - 1];
3480 xnew_down[a + 1] = xlaydown[a * npedge + npedge - 1];
3481 ynew_down[a + 1] = ylaydown[a * npedge + npedge - 1];
3482 xnew_up[a + 1] = xlayup[a * npedge + npedge - 1];
3483 ynew_up[a + 1] = ylayup[a * npedge + npedge - 1];
3484 nxvert[a + 1] = nxPhys[a * npedge + npedge - 1];
3485 nyvert[a + 1] = nyPhys[a * npedge + npedge - 1];
3496 int nVertTot = mesh->GetNvertices();
3497 for (
int n = 0; n < nVertTot; n++)
3502 vertex->GetCoords(x, y,
z);
3503 int qp_closeroldup = 0, qp_closerolddown = 0;
3509 for (
int k = 0; k < nvertl; k++)
3511 if (
abs(x - xolddown[k]) < diffdown)
3513 diffdown =
abs(x - xolddown[k]);
3514 qp_closerolddown = k;
3516 if (
abs(x - xoldup[k]) < diffup)
3518 diffup =
abs(x - xoldup[k]);
3527 int qp_closerup = 0, qp_closerdown = 0;
3529 for (
int f = 0; f < nvertl; f++)
3531 if (
abs(x - xnew_down[f]) < diffdown)
3533 diffdown =
abs(x - xnew_down[f]);
3536 if (
abs(x - xnew_up[f]) < diffup)
3538 diffup =
abs(x - xnew_up[f]);
3565 int qp_closernormup;
3574#pragma GCC diagnostic push
3575#if defined(__GNUC__) && (__GNUC__ > 12)
3576#pragma GCC diagnostic ignored "-Wstringop-overflow"
3580#pragma GCC diagnostic pop
3582 int qp_closernormdown;
3590 if (y > yoldup[qp_closeroldup] && y < 1)
3596 ratio = (1 - ynew_up[qp_closerup]) / ((1 - yoldup[qp_closeroldup]));
3602 ynew_up[qp_closerup] + (y - yoldup[qp_closeroldup]) * ratio;
3610 if (x > (xmax - xmin) / 2. && x < xmax)
3612 ratiox = (xmax - xnew_up[qp_closernormup]) /
3613 (xmax - xoldup[qp_closernormup]);
3614 if ((xmax - xoldup[qp_closernormup]) == 0)
3622 x +
abs(nxvert[qp_closernormup]) *
3623 (xnew_up[qp_closeroldup] - xoldup[qp_closeroldup]) *
3625 ASSERTL0(x > xmin,
" x value <xmin up second half");
3626 ASSERTL0(x < xmax, " x value >xmax up second half
");
3628 else if (x > xmin && x <= (xmax - xmin) / 2.)
3630 // cout<<"up close normold=
"<<qp_closernormoldup<<"
3632 ratiox = (xnew_up[qp_closernormup] - xmin) /
3633 ((xoldup[qp_closernormup] - xmin));
3634 if ((xoldup[qp_closernormup] - xmin) == 0)
3641 x +
abs(nxvert[qp_closernormup]) *
3642 (xnew_up[qp_closeroldup] - xoldup[qp_closeroldup]) *
3645 ASSERTL0(x > xmin,
" x value <xmin up first half");
3646 ASSERTL0(x < xmax, " x value >xmax up first half
");
3649 else if (y < yolddown[qp_closerolddown] && y > -1)
3652 ratio = (1 + ynew_down[qp_closerdown]) /
3653 ((1 + yolddown[qp_closerolddown]));
3655 // ratioy = (1-ynew_down[qp_closernormdown])/
3656 // ( (1-yolddown[qp_closernormolddown]) );
3658 // distance prop to layerlow
3659 ynew[n] = ynew_down[qp_closerdown] +
3660 (y - yolddown[qp_closerolddown]) * ratio;
3661 // ynew[n] = y +abs(nyvert[qp_closernormdown])*
3662 // (ynew_down[qp_closerolddown]-yolddown[qp_closerolddown])*ratioy;
3664 // 0.3*(ynew_down[qp_closerdown]-yolddown[qp_closerdown]); xnew[n] =
3666 // abs(nxvert[qp_closerolddown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown]);
3670 cout<<qp_closerolddown<<" nplaydown=
"<<qp_closerdown<<endl;
3671 cout<<"xolddown=
"<<xolddown[qp_closerolddown]<<"
3672 xnewdown=
"<<xnew_down[qp_closerdown]<<endl; cout<<"xold+
"<<x<<"
3673 xnew+
"<<xnew[n]<<endl;
3677 if (x > (xmax - xmin) / 2. && x < xmax)
3679 ratiox = (xmax - xnew_down[qp_closernormdown]) /
3680 ((xmax - xolddown[qp_closernormdown]));
3681 if ((xmax - xolddown[qp_closernormdown]) == 0)
3685 // xnew[n] = xnew_down[qp_closerdown]
3686 // + (x-xolddown[qp_closerolddown])*ratiox;
3687 xnew[n] = x + abs(nxvert[qp_closernormdown]) *
3688 (xnew_down[qp_closerolddown] -
3689 xolddown[qp_closerolddown]) *
3691 ASSERTL0(x > xmin, " x value <xmin down second half
");
3692 ASSERTL0(x < xmax, " x value >xmax down second half
");
3694 else if (x > xmin && x <= (xmax - xmin) / 2.)
3696 ratiox = (xnew_down[qp_closernormdown] - xmin) /
3697 ((xolddown[qp_closernormdown] - xmin));
3698 if ((xolddown[qp_closernormdown] - xmin) == 0)
3702 // xnew[n] = xnew_down[qp_closerdown]
3703 // + (x-xolddown[qp_closerolddown])*ratiox;
3704 xnew[n] = x + abs(nxvert[qp_closernormdown]) *
3705 (xnew_down[qp_closerolddown] -
3706 xolddown[qp_closerolddown]) *
3708 ASSERTL0(x > xmin, " x value <xmin down first half
");
3709 ASSERTL0(x < xmax, " x value >xmax down first half
");
3713 cout << "xold
" << x << " xnew=
" << xnew[n] << endl;
3714 ASSERTL0(xnew[n] >= xmin, "newx < xmin
");
3715 ASSERTL0(xnew[n] <= xmax, "newx > xmax
");
3720void CheckSingularQuads(MultiRegions::ExpListSharedPtr Exp, Array<OneD, int> V1,
3721 Array<OneD, int> V2, Array<OneD, NekDouble> &xnew,
3722 Array<OneD, NekDouble> &ynew)
3724 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D = Exp->GetExp();
3725 int nel = exp2D->size();
3726 LocalRegions::QuadExpSharedPtr locQuadExp;
3727 LocalRegions::TriExpSharedPtr locTriExp;
3728 SpatialDomains::Geometry1DSharedPtr SegGeom;
3730 NekDouble xV1, yV1, xV2, yV2;
3731 NekDouble slopebef = 0.0, slopenext = 0.0, slopenew = 0.0;
3732 Array<OneD, int> locEids(4);
3733 for (int i = 0; i < nel; i++)
3735 if ((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
3737 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(0);
3738 idbef = SegGeom->GetGlobalID();
3739 if (xnew[V1[idbef]] <= xnew[V2[idbef]])
3741 xV1 = xnew[V1[idbef]];
3742 yV1 = ynew[V1[idbef]];
3743 xV2 = xnew[V2[idbef]];
3744 yV2 = ynew[V2[idbef]];
3745 slopebef = (yV2 - yV1) / (xV2 - xV1);
3749 xV1 = xnew[V2[idbef]];
3750 yV1 = ynew[V2[idbef]];
3751 xV2 = xnew[V1[idbef]];
3752 yV2 = ynew[V1[idbef]];
3753 slopebef = (yV2 - yV1) / (xV2 - xV1);
3755 // cout<<"00 V1 x=
"<<xnew[ V1[idbef] ]<<" y=
"<<ynew[ V1[idbef]
3756 // ]<<endl; cout<<"00 V2 x=
"<<xnew[ V2[idbef] ]<<" y=
"<<ynew[
3757 // V2[idbef] ]<<endl;
3758 for (int j = 1; j < locQuadExp->GetNtraces(); ++j)
3760 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
3761 idnext = SegGeom->GetGlobalID();
3762 // cout<<"id=
"<<idnext<<" locid=
"<<j<<endl;
3763 // cout<<" V1 x=
"<<xnew[ V1[idnext] ]<<" y=
"<<ynew[
3764 // V1[idnext] ]<<endl; cout<<" V2 x=
"<<xnew[ V2[idnext] ]<<"
3766 if (xV1 == xnew[V1[idnext]] && yV1 == ynew[V1[idnext]])
3768 xV1 = xnew[V1[idnext]];
3769 yV1 = ynew[V1[idnext]];
3770 xV2 = xnew[V2[idnext]];
3771 yV2 = ynew[V2[idnext]];
3772 slopenext = (yV2 - yV1) / (xV2 - xV1);
3775 cout <<
"case1 x0=" << xV1 <<
" x1=" << xV2 << endl;
3776 cout << idnext <<
" 11slope bef =" << slopebef
3777 <<
" slopenext=" << slopenext << endl;
3780 if (slopebef / slopenext > 0.84 &&
3781 slopebef / slopenext < 1.18)
3783 xnew[V1[idnext]] = xnew[V1[idnext]] - 0.01;
3784 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3786 if (
abs(slopebef - slopenew) <
3787 abs(slopebef - slopenext))
3789 xnew[V1[idnext]] = xnew[V1[idnext]] + 0.02;
3790 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3792 slopenext = slopenew;
3793 cout <<
"slopenew=" << slopenew << endl;
3794 cout <<
"moved x=" << xnew[V1[idnext]] << endl;
3797 else if (xV2 == xnew[V2[idnext]] && yV2 == ynew[V2[idnext]])
3799 xV1 = xnew[V2[idnext]];
3800 yV1 = ynew[V2[idnext]];
3801 xV2 = xnew[V1[idnext]];
3802 yV2 = ynew[V1[idnext]];
3803 slopenext = (yV2 - yV1) / (xV2 - xV1);
3806 cout <<
"case2 x0=" << xV1 <<
" x1=" << xV2 << endl;
3807 cout << idnext <<
" 22slope bef =" << slopebef
3808 <<
" slopenext=" << slopenext << endl;
3811 if (slopebef / slopenext > 0.84 &&
3812 slopebef / slopenext < 1.18)
3814 xnew[V2[idnext]] = xnew[V2[idnext]] - 0.01;
3815 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3817 if (
abs(slopebef - slopenew) <
3818 abs(slopebef - slopenext))
3820 xnew[V2[idnext]] = xnew[V2[idnext]] + 0.02;
3821 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3823 slopenext = slopenew;
3824 cout <<
"slopenew=" << slopenew << endl;
3825 cout <<
"moved x=" << xnew[V2[idnext]] << endl;
3828 else if (xV1 == xnew[V2[idnext]] && yV1 == ynew[V2[idnext]])
3830 xV1 = xnew[V2[idnext]];
3831 yV1 = ynew[V2[idnext]];
3832 xV2 = xnew[V1[idnext]];
3833 yV2 = ynew[V1[idnext]];
3834 slopenext = (yV2 - yV1) / (xV2 - xV1);
3837 cout <<
"case3 x0=" << xV1 <<
" x1=" << xV2 << endl;
3838 cout << idnext <<
" 22slope bef =" << slopebef
3839 <<
" slopenext=" << slopenext << endl;
3842 if (slopebef / slopenext > 0.84 &&
3843 slopebef / slopenext < 1.18)
3845 xnew[V2[idnext]] = xnew[V2[idnext]] - 0.01;
3846 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3848 if (
abs(slopebef - slopenew) <
3849 abs(slopebef - slopenext))
3851 xnew[V2[idnext]] = xnew[V2[idnext]] + 0.02;
3852 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3854 slopenext = slopenew;
3855 cout <<
"slopenew=" << slopenew << endl;
3856 cout <<
"moved x=" << xnew[V2[idnext]] << endl;
3859 else if (xV2 == xnew[V1[idnext]] && yV2 == ynew[V1[idnext]])
3861 xV1 = xnew[V1[idnext]];
3862 yV1 = ynew[V1[idnext]];
3863 xV2 = xnew[V2[idnext]];
3864 yV2 = ynew[V2[idnext]];
3865 slopenext = (yV2 - yV1) / (xV2 - xV1);
3868 cout <<
"case4 x0=" << xV1 <<
" x1=" << xV2 << endl;
3869 cout << idnext <<
" 22slope bef =" << slopebef
3870 <<
" slopenext=" << slopenext << endl;
3873 if (slopebef / slopenext > 0.84 &&
3874 slopebef / slopenext < 1.18)
3876 xnew[V1[idnext]] = xnew[V1[idnext]] - 0.01;
3877 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3879 if (
abs(slopebef - slopenew) <
3880 abs(slopebef - slopenext))
3882 xnew[V1[idnext]] = xnew[V1[idnext]] + 0.02;
3883 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3885 slopenext = slopenew;
3886 cout <<
"slopenew=" << slopenew << endl;
3887 cout <<
"moved x=" << xnew[V1[idnext]] << endl;
3892 ASSERTL0(
false,
"edge not connected");
3894 slopebef = slopenext;
3903 int Npoints,
string s_alp,
3910 TiXmlDocument doc(filename);
3912 TiXmlElement *master = doc.FirstChildElement(
"NEKTAR");
3913 TiXmlElement *mesh = master->FirstChildElement(
"GEOMETRY");
3914 TiXmlElement *element = mesh->FirstChildElement(
"VERTEX");
3917 const char *xscal = element->Attribute(
"XSCALE");
3920 std::string xscalstr = xscal;
3922 xscale = expEvaluator.
Evaluate(expr_id);
3926 newfile = filename.substr(0, filename.find_last_of(
".")) +
"_moved.xml";
3927 doc.SaveFile(newfile);
3930 TiXmlDocument docnew(newfile);
3931 bool loadOkaynew = docnew.LoadFile();
3933 std::string errstr =
"Unable to load file: ";
3935 ASSERTL0(loadOkaynew, errstr.c_str());
3937 TiXmlHandle docHandlenew(&docnew);
3938 TiXmlElement *meshnew =
nullptr;
3939 TiXmlElement *masternew =
nullptr;
3940 TiXmlElement *condnew =
nullptr;
3941 TiXmlElement *Parsnew =
nullptr;
3942 TiXmlElement *parnew =
nullptr;
3946 masternew = docnew.FirstChildElement(
"NEKTAR");
3947 ASSERTL0(masternew,
"Unable to find NEKTAR tag in file.");
3951 condnew = masternew->FirstChildElement(
"CONDITIONS");
3952 Parsnew = condnew->FirstChildElement(
"PARAMETERS");
3953 cout <<
"alpha=" << s_alp << endl;
3954 parnew = Parsnew->FirstChildElement(
"P");
3957 TiXmlNode *node = parnew->FirstChild();
3961 std::string line = node->ToText()->Value();
3965 int beg = line.find_first_not_of(
" ");
3966 int end = line.find_first_of(
"=");
3973 if (end != line.find_last_of(
"="))
3978 if (end == std::string::npos)
3982 lhs = line.substr(line.find_first_not_of(
" "), end - beg);
3983 lhs = lhs.substr(0, lhs.find_last_not_of(
" ") + 1);
3989 boost::to_upper(lhs);
3992 alphastring =
"Alpha = " + s_alp;
3993 parnew->RemoveChild(node);
3994 parnew->LinkEndChild(
new TiXmlText(alphastring));
3998 parnew = parnew->NextSiblingElement(
"P");
4002 meshnew = masternew->FirstChildElement(
"GEOMETRY");
4004 ASSERTL0(meshnew,
"Unable to find GEOMETRY tag in file.");
4006 TiXmlElement *elementnew = meshnew->FirstChildElement(
"VERTEX");
4007 ASSERTL0(elementnew,
"Unable to find mesh VERTEX tag in file.");
4011 elementnew->SetAttribute(
"XSCALE", 1.0);
4013 TiXmlElement *vertexnew = elementnew->FirstChildElement(
"V");
4017 int nextVertexNumber = -1;
4023 TiXmlAttribute *vertexAttr = vertexnew->FirstAttribute();
4024 std::string attrName(vertexAttr->Name());
4026 (std::string(
"Unknown attribute name: ") + attrName).c_str());
4028 err = vertexAttr->QueryIntValue(&indx);
4029 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
4031 "Vertex IDs must begin with zero and be sequential.");
4033 std::string vertexBodyStr;
4035 TiXmlNode *vertexBody = vertexnew->FirstChild();
4037 if (vertexBody->Type() == TiXmlNode::TINYXML_TEXT)
4039 vertexBodyStr += vertexBody->ToText()->Value();
4040 vertexBodyStr +=
" ";
4043 "Vertex definitions must contain vertex data.");
4045 vertexnew->RemoveChild(vertexBody);
4052 s << std::scientific << std::setprecision(8) << newx[nextVertexNumber]
4053 <<
" " << newy[nextVertexNumber] <<
" " << 0.0;
4054 vertexnew->LinkEndChild(
new TiXmlText(s.str()));
4059 vertexnew = vertexnew->NextSiblingElement(
"V");
4063 TiXmlElement *curvednew = meshnew->FirstChildElement(
"CURVED");
4064 ASSERTL0(curvednew,
"Unable to find mesh CURVED tag in file.");
4065 TiXmlElement *edgenew = curvednew->FirstChildElement(
"E");
4068 std::string charindex;
4072 int neids_lay = lay_eids[0].size();
4079 TiXmlAttribute *edgeAttr = edgenew->FirstAttribute();
4080 std::string attrName(edgeAttr->Name());
4081 charindex = edgeAttr->Value();
4082 std::istringstream iss(charindex);
4083 iss >> std::dec >> index;
4085 edgenew->QueryIntAttribute(
"EDGEID", &eid);
4088 for (
int u = 0; u < Eids.size(); u++)
4098 curvednew->RemoveChild(edgenew);
4104 std::string edgeBodyStr;
4106 TiXmlNode *edgeBody = edgenew->FirstChild();
4107 if (edgeBody->Type() == TiXmlNode::TINYXML_TEXT)
4109 edgeBodyStr += edgeBody->ToText()->Value();
4113 "Edge definitions must contain edge data");
4115 edgenew->RemoveChild(edgeBody);
4122 err = edgenew->QueryIntAttribute(
"NUMPOINTS", &numPts);
4124 "Unable to read curve attribute NUMPOINTS.");
4127 edgenew->SetAttribute(
"NUMPOINTS", Npoints);
4128 for (
int u = 0; u < Npoints; u++)
4130 st << std::scientific << std::setprecision(8)
4131 << xcPhys[cnt * Npoints + u] <<
" "
4132 << ycPhys[cnt * Npoints + u] <<
" " << 0.000 <<
" ";
4135 edgenew->LinkEndChild(
new TiXmlText(st.str()));
4156 edgenew = edgenew->NextSiblingElement(
"E");
4160 if (curv_lay ==
true)
4162 cout <<
"write other curved edges" << endl;
4163 TiXmlElement *curved = meshnew->FirstChildElement(
"CURVED");
4165 int nlays = lay_eids.size();
4170 for (
int g = 0; g < nlays; ++g)
4172 for (
int p = 0;
p < neids_lay;
p++)
4175 TiXmlElement *e =
new TiXmlElement(
"E");
4176 e->SetAttribute(
"ID", idcnt++);
4177 e->SetAttribute(
"EDGEID", lay_eids[g][
p]);
4178 e->SetAttribute(
"NUMPOINTS", Npoints);
4179 e->SetAttribute(
"TYPE",
"PolyEvenlySpaced");
4180 for (
int c = 0; c < Npoints; c++)
4182 st << std::scientific << std::setprecision(8)
4183 << x_lay[g][
p * Npoints + c] <<
" "
4184 << y_lay[g][
p * Npoints + c] <<
" " << 0.000 <<
" ";
4187 TiXmlText *t0 =
new TiXmlText(st.str());
4188 e->LinkEndChild(t0);
4189 curved->LinkEndChild(e);
4194 docnew.SaveFile(newfile);
4196 cout <<
"new file: " << newfile << endl;
#define ASSERTL0(condition, msg)
void GenerateMapEidsv1v2(MultiRegions::ExpListSharedPtr field, Array< OneD, int > &V1, Array< OneD, int > &V2)
int main(int argc, char *argv[])
void MoveLayerNnormpos(int nvertl, int npedge, Array< OneD, NekDouble > xcPhys, Array< OneD, NekDouble > tmpx_lay, Array< OneD, NekDouble > tmpy_lay, Array< OneD, int > Vids, Array< OneD, NekDouble > &xlay, Array< OneD, NekDouble > &ylay, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void EvaluateTangent(int npoints, Array< OneD, NekDouble > xcQedge, Array< OneD, NekDouble > coeffsinterp, Array< OneD, NekDouble > &txQedge, Array< OneD, NekDouble > &tyQedge)
NekDouble LagrangeInterpolant(NekDouble x, int npts, Array< OneD, NekDouble > xpts, Array< OneD, NekDouble > funcvals)
void Computestreakpositions(int nvertl, MultiRegions::ExpListSharedPtr streak, Array< OneD, NekDouble > xold_up, Array< OneD, NekDouble > yold_up, Array< OneD, NekDouble > xold_low, Array< OneD, NekDouble > yold_low, Array< OneD, NekDouble > xold_c, Array< OneD, NekDouble > yold_c, Array< OneD, NekDouble > &xc, Array< OneD, NekDouble > &yc, NekDouble cr, bool verts)
void Cutrepetitions(int nedges, Array< OneD, NekDouble > inarray, Array< OneD, NekDouble > &outarray)
void MoveOutsidePointsNnormpos(int npedge, SpatialDomains::MeshGraphSharedPtr mesh, Array< OneD, NekDouble > xcold, Array< OneD, NekDouble > ycold, Array< OneD, NekDouble > xolddown, Array< OneD, NekDouble > yolddown, Array< OneD, NekDouble > xoldup, Array< OneD, NekDouble > yoldup, Array< OneD, NekDouble > xlaydown, Array< OneD, NekDouble > ylaydown, Array< OneD, NekDouble > xlayup, Array< OneD, NekDouble > ylayup, Array< OneD, NekDouble > nxPhys, Array< OneD, NekDouble > nyPhys, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void MappingEVids(Array< OneD, NekDouble > xoldup, Array< OneD, NekDouble > yoldup, Array< OneD, NekDouble > xolddown, Array< OneD, NekDouble > yolddown, Array< OneD, NekDouble > xcold, Array< OneD, NekDouble > ycold, Array< OneD, int > Vids_c, SpatialDomains::MeshGraphSharedPtr mesh, MultiRegions::ExpListSharedPtr streak, Array< OneD, int > V1, Array< OneD, int > V2, int &nlays, Array< OneD, Array< OneD, int > > &Eids_lay, Array< OneD, Array< OneD, int > > &Vids_lay)
void CheckSingularQuads(MultiRegions::ExpListSharedPtr Exp, Array< OneD, int > V1, Array< OneD, int > V2, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void Orderfunctionx(Array< OneD, NekDouble > inarray_x, Array< OneD, NekDouble > inarray_y, Array< OneD, NekDouble > &outarray_x, Array< OneD, NekDouble > &outarray_y)
void MoveLayerNfixedxpos(int nvertl, int npedge, Array< OneD, NekDouble > xcPhys, Array< OneD, NekDouble > tmpx_lay, Array< OneD, NekDouble > tmpy_lay, Array< OneD, int > Vids, Array< OneD, NekDouble > &xlay, Array< OneD, NekDouble > &ylay, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void Replacevertices(string filename, Array< OneD, NekDouble > newx, Array< OneD, NekDouble > newy, Array< OneD, NekDouble > xcPhys, Array< OneD, NekDouble > ycPhys, Array< OneD, int > Eids, int Npoints, string s_alp, Array< OneD, Array< OneD, NekDouble > > x_lay, Array< OneD, Array< OneD, NekDouble > > y_lay, Array< OneD, Array< OneD, int > > lay_eids, bool curv_lay)
void OrderVertices(int nedges, SpatialDomains::MeshGraphSharedPtr graphShPt, MultiRegions::ExpListSharedPtr &bndfield, Array< OneD, int > &Vids, int v1, int v2, NekDouble x_connect, int &lastedge, Array< OneD, NekDouble > &x, Array< OneD, NekDouble > &y)
void PolyFit(int polyorder, int npoints, Array< OneD, NekDouble > xin, Array< OneD, NekDouble > fin, Array< OneD, NekDouble > &coeffsinterp, Array< OneD, NekDouble > &xout, Array< OneD, NekDouble > &fout, int npout)
void GenerateAddPointsNewtonIt(NekDouble xi, NekDouble yi, NekDouble &xout, NekDouble &yout, MultiRegions::ExpListSharedPtr function, Array< OneD, NekDouble > derfunction, NekDouble cr)
void MoveLayersvertically(int nlays, int nvertl, int cntlow, int cntup, Array< OneD, Array< OneD, int > > lay_Vids, Array< OneD, NekDouble > xc, Array< OneD, NekDouble > yc, Array< OneD, int > Down, Array< OneD, int > Up, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew, Array< OneD, Array< OneD, NekDouble > > &layers_x, Array< OneD, Array< OneD, NekDouble > > &layers_y)
void GenerateNeighbourArrays(int index, int neighpoints, Array< OneD, NekDouble > xArray, Array< OneD, NekDouble > yArray, Array< OneD, NekDouble > &Neighbour_x, Array< OneD, NekDouble > &Neighbour_y)
bool checkcommonvert(Array< OneD, int > Vids_laybefore, Array< OneD, int > Vids_c, int Vid)
int DetermineclosePointxindex(NekDouble x, Array< OneD, NekDouble > xArray)
void MoveOutsidePointsfixedxpos(int npedge, SpatialDomains::MeshGraphSharedPtr mesh, Array< OneD, NekDouble > xcold, Array< OneD, NekDouble > ycold, Array< OneD, NekDouble > xolddown, Array< OneD, NekDouble > yolddown, Array< OneD, NekDouble > xoldup, Array< OneD, NekDouble > yoldup, Array< OneD, NekDouble > ylaydown, Array< OneD, NekDouble > ylayup, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void PolyInterp(Array< OneD, NekDouble > xpol, Array< OneD, NekDouble > ypol, Array< OneD, NekDouble > &coeffsinterp, Array< OneD, NekDouble > &xcout, Array< OneD, NekDouble > &ycout, int edge, int npedge)
Interpreter class for the evaluation of mathematical expressions.
int DefineFunction(const std::string &vlist, const std::string &expr)
Defines a function for the purposes of evaluation.
NekDouble Evaluate(const int id)
Evaluate a function which depends only on constants and/or parameters.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
const BoundaryRegionCollection & GetBoundaryRegions(void) const
void GetCoords(Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2=NullNekDouble1DArray, Array< OneD, NekDouble > &coords_3=NullNekDouble1DArray)
this function returns the physical coordinates of the quadrature points of the expansion
static void Dgetrf(const int &m, const int &n, double *a, const int &lda, int *ipiv, int &info)
General matrix LU factorisation.
static void Dgetrs(const char &trans, const int &n, const int &nrhs, const double *a, const int &lda, int *ipiv, double *b, const int &ldb, int &info)
General matrix LU backsolve.
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > &ElementIDs)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< QuadExp > QuadExpSharedPtr
std::shared_ptr< SegExp > SegExpSharedPtr
std::shared_ptr< TriExp > TriExpSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< ContField > ContFieldSharedPtr
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
std::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< PointGeom > PointGeomSharedPtr
std::shared_ptr< Geometry1D > Geometry1DSharedPtr
std::vector< double > w(NPUPPER)
std::vector< double > z(NPUPPER)
std::vector< double > d(NPUPPER *NPUPPER)
std::vector< double > q(NPUPPER *NPUPPER)
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |x|
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/x.
void Vdiv(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x/y.
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
void Zero(int n, T *x, const int incx)
Zero vector.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > abs(scalarT< T > in)
scalarT< T > sqrt(scalarT< T > in)