41 #include <boost/core/ignore_unused.hpp>
51 #include <boost/lexical_cast.hpp>
112 int edge,
int npedge);
172 int Npoints,
string s_alp,
177 int main(
int argc,
char *argv[])
183 if (argc > 6 || argc < 5)
185 fprintf(stderr,
"Usage: ./MoveMesh meshfile fieldfile changefile "
186 "alpha cr(optional)\n");
193 LibUtilities::SessionReader::CreateInstance(2, argv);
195 SpatialDomains::MeshGraph::Read(vSession);
198 if (argc == 6 && vSession->DefinesSolverInfo(
"INTERFACE") &&
199 vSession->GetSolverInfo(
"INTERFACE") ==
"phase")
201 cr = boost::lexical_cast<NekDouble>(argv[argc - 1]);
209 vSession, graphShPt);
219 string changefile(argv[argc - 2]);
223 string charalp(argv[argc - 1]);
225 cout <<
"read alpha=" << charalp << endl;
229 string fieldfile(argv[argc - 3]);
230 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
231 vector<vector<NekDouble>> fielddata;
236 vSession, graphShPt,
"w",
true);
240 for (
int i = 0; i < fielddata.size(); i++)
242 streak->ExtractDataToCoeffs(fielddef[i], fielddata[i],
243 fielddef[i]->m_fields[0],
244 streak->UpdateCoeffs());
246 streak->BwdTrans(streak->GetCoeffs(), streak->UpdatePhys());
252 int nIregions, lastIregion = 0;
254 streak->GetBndConditions();
258 int nbnd = bndConditions.size();
259 for (
int r = 0; r < nbnd; r++)
261 if (bndConditions[r]->GetUserDefined() ==
"CalcBC")
270 "there is any boundary region with the tag USERDEFINEDTYPE="
273 cout <<
"nIregions=" << nIregions << endl;
276 streak->GetBndCondExpansions();
279 int nedges = bndfieldx[lastIregion]->GetExpSize();
280 int nvertl = nedges + 1;
294 ((bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
297 vertex0->GetCoords(x0, y0, z0);
300 cout <<
"WARNING x0=" << x0 << endl;
305 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion - 1], Vids_low, v1,
306 v2, x_connect, lastedge, xold_low, yold_low);
307 ASSERTL0(Vids_low[v2] != -10,
"Vids_low[v2] is wrong");
309 graphShPt->GetVertex(Vids_low[v2]);
312 cout <<
"x_conn=" << x_connect <<
" yt=" << yt <<
" zt=" << zt
313 <<
" vid=" << Vids_low[v2] << endl;
314 vertex->GetCoords(x_connect, yt, zt);
320 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion - 1], Vids_low,
321 v1, v2, x_connect, lastedge, xold_low, yold_low);
323 graphShPt->GetVertex(Vids_low[v1]);
325 vertex->GetCoords(x_connect, yt, zt);
337 vertex0 = graphShPt->GetVertex(
338 ((bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
341 vertex0->GetCoords(x0, y0, z0);
344 cout <<
"WARNING x0=" << x0 << endl;
351 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion - 2], Vids_up, v1,
352 v2, x_connect, lastedge, xold_up, yold_up);
354 graphShPt->GetVertex(Vids_up[v2]);
355 vertexU->GetCoords(x_connect, yt, zt);
361 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion - 2], Vids_up,
362 v1, v2, x_connect, lastedge, xold_up, yold_up);
364 graphShPt->GetVertex(Vids_up[v1]);
367 vertex->GetCoords(x_connect, yt, zt);
379 vertex0 = graphShPt->GetVertex(
380 ((bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
383 vertex0->GetCoords(x0, y0, z0);
386 cout <<
"WARNING x0=" << x0 << endl;
394 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion], Vids_c, v1, v2,
395 x_connect, lastedge, xold_c, yold_c);
397 graphShPt->GetVertex(Vids_c[v2]);
400 vertexc->GetCoords(x_connect, yt, zt);
406 OrderVertices(nedges, graphShPt, bndfieldx[lastIregion], Vids_c, v1, v2,
407 x_connect, lastedge, xold_c, yold_c);
409 graphShPt->GetVertex(Vids_c[v1]);
412 vertex->GetCoords(x_connect, yt, zt);
421 for (
int r = 0; r < nvertl; r++)
426 Deltaup[r] = yold_up[r] - yold_c[r];
427 Deltalow[r] = yold_c[r] - yold_low[r];
429 "distance between upper and layer curve is not positive");
431 "distance between lower and layer curve is not positive");
442 vSession, *(bregions.find(lastIregion)->second), graphShPt,
true);
453 if (vSession->DefinesParameter(
"npedge"))
455 npedge = (int)vSession->GetParameter(
"npedge");
464 int nq = streak->GetTotPoints();
467 streak->GetCoords(x, y);
475 xold_c, yold_c, x_c, y_c, cr,
true);
478 for (
int q = 0; q < nvertl; q++)
480 if (y_c[q] < yold_c[q])
485 Delta_c[q] =
abs(yold_c[q] - y_c[q]);
488 cout << x_c[q] <<
" " << y_c[q] << endl;
493 cout <<
"Warning: the critical layer is stationary" << endl;
514 for (
int r = 0; r < nedges; r++)
519 Eid = (bndSegExp->GetGeom1D())->GetGlobalID();
520 id1 = (bndSegExp->GetGeom1D())->GetVid(0);
521 id2 = (bndSegExp->GetGeom1D())->GetVid(1);
522 vertex1 = graphShPt->GetVertex(id1);
523 vertex2 = graphShPt->GetVertex(id2);
525 vertex2->GetCoords(x2, y2, z2);
528 cout <<
"edge=" << r <<
" x1=" << x1 <<
" y1=" << y1 <<
" x2=" << x2
529 <<
" y2=" << y2 << endl;
532 Cpointsx[r] = x1 + (x2 - x1) / 2;
536 if (Cpointsx[r] > x2 || Cpointsx[r] < x1)
538 Cpointsx[r] = -Cpointsx[r];
540 for (
int w = 0; w < npedge - 2; w++)
543 Addpointsx[r * (npedge - 2) + w] =
544 x1 + ((x2 - x1) / (npedge - 1)) * (w + 1);
545 if (Addpointsx[r * (npedge - 2) + w] > x2 ||
546 Addpointsx[r * (npedge - 2) + w] < x1)
548 Addpointsx[r * (npedge - 2) + w] =
549 -Addpointsx[r * (npedge - 2) + w];
552 Addpointsy[r * (npedge - 2) + w] =
553 y_c[r] + ((y_c[r + 1] - y_c[r]) / (x_c[r + 1] - x_c[r])) *
554 (Addpointsx[r * (npedge - 2) + w] - x1);
558 Addpointsy[r * (npedge - 2) + w],
559 Addpointsx[r * (npedge - 2) + w],
560 Addpointsy[r * (npedge - 2) + w],
574 Cpointsx[r] = x2 + (x1 - x2) / 2;
576 if (Cpointsx[r] > x1 || Cpointsx[r] < x2)
578 Cpointsx[r] = -Cpointsx[r];
580 for (
int w = 0; w < npedge - 2; w++)
582 Addpointsx[r * (npedge - 2) + w] =
583 x2 + ((x1 - x2) / (npedge - 1)) * (w + 1);
584 if (Addpointsx[r * (npedge - 2) + w] > x1 ||
585 Addpointsx[r * (npedge - 2) + w] < x2)
587 Addpointsx[r * (npedge - 2) + w] =
588 -Addpointsx[r * (npedge - 2) + w];
592 Addpointsy[r * (npedge - 2) + w] =
594 ((y_c[r] - y_c[r + 1]) / (x_c[r] - x_c[r + 1])) *
595 (Addpointsx[r * (npedge - 2) + w] - x2);
600 Addpointsy[r * (npedge - 2) + w],
601 Addpointsx[r * (npedge - 2) + w],
602 Addpointsy[r * (npedge - 2) + w],
615 ASSERTL0(
false,
"point not generated");
633 for (
int a = 0; a < nedges; a++)
636 xcPhys[a * npedge + 0] = x_c[a];
637 ycPhys[a * npedge + 0] = y_c[a];
639 xcPhys[a * npedge + npedge - 1] = x_c[a + 1];
640 ycPhys[a * npedge + npedge - 1] = y_c[a + 1];
642 for (
int b = 0; b < npedge - 2; b++)
644 xcPhys[a * npedge + b + 1] = Addpointsx[a * (npedge - 2) + b];
645 ycPhys[a * npedge + b + 1] = Addpointsy[a * (npedge - 2) + b];
649 cout <<
"xc,yc before tanevaluate" << endl;
650 for (
int v = 0; v < xcPhys.size(); v++)
652 cout << xcPhys[v] <<
" " << ycPhys[v] << endl;
665 MappingEVids(xold_up, yold_up, xold_low, yold_low, xold_c, yold_c, Vids_c,
666 graphShPt, streak, V1, V2, nlays, lay_Eids, lay_Vids);
668 cout <<
"nlays=" << nlays << endl;
672 for (
int g = 0; g < nlays; g++)
683 if (vSession->DefinesParameter(
"Delta"))
685 Delta0 = vSession->GetParameter(
"Delta");
697 int nVertTot = graphShPt->GetNvertices();
713 for (
int i = 0; i < nVertTot; i++)
715 bool mvpoint =
false;
718 vertex->GetCoords(x, y, z);
727 if (x == 0 && y < yold_low[0] && y > bleft)
732 if (x == xold_c[nvertl - 1] && y > yold_up[nvertl - 1] && y < tright)
737 if (x == xold_c[nvertl - 1] && y < yold_low[nvertl - 1] && y > bright)
742 if (x == 0 && y > yold_up[0] && y < tleft)
747 for (
int j = 0; j < nvertl; j++)
749 if ((xold_up[j] == x) && (yold_up[j] == y))
753 ynew[i] = y_c[j] + Delta0;
757 if ((xold_low[j] == x) && (yold_low[j] == y))
761 ynew[i] = y_c[j] - Delta0;
765 if ((xold_c[j] == x) && (yold_c[j] == y))
771 if (mvpoint ==
false)
776 for (
int k = 0; k < nvertl; k++)
778 if (
abs(x - xold_up[k]) < diff)
780 diff =
abs(x - xold_up[k]);
784 if (y > yold_up[qp_closer] && y < 1)
794 ynew[i] = y_c[qp_closer] + (y - yold_c[qp_closer]) *
795 (1 - y_c[qp_closer]) /
796 (1 - yold_c[qp_closer]);
799 else if (y < yold_low[qp_closer] && y > -1)
809 ynew[i] = y_c[qp_closer] + (y - yold_c[qp_closer]) *
810 (-1 - y_c[qp_closer]) /
811 (-1 - yold_c[qp_closer]);
814 else if (y > yold_c[qp_closer] && y < yold_up[qp_closer])
824 else if (y < yold_c[qp_closer] && y > yold_low[qp_closer])
834 else if (y == 1 || y == -1)
842 if ((ynew[i] > 1 || ynew[i] < -1) &&
843 (y > yold_up[qp_closer] || y < yold_low[qp_closer]))
845 cout <<
"point x=" << xnew[i] <<
" y=" << y
846 <<
" closer x=" << xold_up[qp_closer]
847 <<
" ynew=" << ynew[i] << endl;
848 ASSERTL0(
false,
"shifting out of range");
853 int nqedge = streak->GetExp(0)->GetNumPoints(0);
854 int nquad_lay = (nvertl - 1) * nqedge;
857 bool curv_lay =
true;
858 bool move_norm =
true;
859 int np_lay = (nvertl - 1) * npedge;
869 if (move_norm ==
true)
881 cout <<
"nquad per edge=" << nqedge << endl;
882 for (
int l = 0; l < 2; l++)
884 Edge_newcoords[l] = bndfieldx[lastIregion]
908 bndfieldx[lastIregion]->GetCoords(xcQ, ycQ, zcQ);
917 for (
int l = 0; l < xcQ.size(); l++)
931 Vmath::Vcopy(nquad_lay, ycQ, 1, Cont_y->UpdatePhys(), 1);
934 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffsy);
935 Cont_y->BwdTrans(coeffsy, Cont_y->UpdatePhys());
938 cout <<
"xcQ, ycQ" << endl;
939 for (
int s = 0; s < xcQ.size(); s++)
941 cout << xcQ[s] <<
" " << ycQ[s] << endl;
944 bool evaluatetan =
false;
948 for (
int k = 0; k < nedges; k++)
950 Vmath::Vcopy(nqedge, &xcQ[k * nqedge], 1, &xcedgeQ[0], 1);
951 Vmath::Vcopy(nqedge, &ycQ[k * nqedge], 1, &ycedgeQ[0], 1);
953 Edge_newcoords[0]->StdPhysDeriv(xcedgeQ, txedgeQ);
954 Edge_newcoords[1]->StdPhysDeriv(ycedgeQ, tyedgeQ);
956 Vmath::Vmul(nqedge, txedgeQ, 1, txedgeQ, 1, normsQ, 1);
958 Vmath::Vvtvp(nqedge, tyedgeQ, 1, tyedgeQ, 1, normsQ, 1, normsQ, 1);
963 Vmath::Vmul(nqedge, txedgeQ, 1, normsQ, 1, txedgeQ, 1);
964 Vmath::Vmul(nqedge, tyedgeQ, 1, normsQ, 1, tyedgeQ, 1);
969 for (
int u = 0; u < nqedge - 1; u++)
971 incratio = (ycedgeQ[u + 1] - ycedgeQ[u]) /
972 (xcedgeQ[u + 1] - xcedgeQ[u]);
973 cout <<
"incratio=" << incratio << endl;
974 if (
abs(incratio) > 4.0 && evaluatetan ==
false)
976 cout <<
"wrong=" << wrong << endl;
978 ASSERTL0(wrong < 2,
"number edges to change is too high!!");
979 edgeinterp[wrong] = k;
986 cout <<
"tan bef" << endl;
987 for (
int e = 0; e < nqedge; e++)
989 cout << xcedgeQ[e] <<
" " << ycedgeQ[e] <<
" "
990 << txedgeQ[e] << endl;
998 Vmath::Vcopy(npedge, &xcPhysMOD[k * npedge + 0], 1, &xPedges[0],
1000 Vmath::Vcopy(npedge, &ycPhysMOD[k * npedge + 0], 1, &yPedges[0],
1003 PolyFit(polyorder, nqedge, xcedgeQ, ycedgeQ, coeffsinterp,
1004 xPedges, yPedges, npedge);
1006 Vmath::Vcopy(npedge, &xPedges[0], 1, &xcPhysMOD[k * npedge + 0],
1008 Vmath::Vcopy(npedge, &yPedges[0], 1, &ycPhysMOD[k * npedge + 0],
1015 Vmath::Vcopy(nqedge, &(txedgeQ[0]), 1, &(txQ[nqedge * k]), 1);
1016 Vmath::Vcopy(nqedge, &(tyedgeQ[0]), 1, &(tyQ[nqedge * k]), 1);
1021 for (
int w = 0; w < fz.size(); w++)
1023 txQ[w] = cos(atan(fz[w]));
1024 tyQ[w] = sin(atan(fz[w]));
1025 cout << xcQ[w] <<
" " << ycQ[w] <<
" " << fz[w] << endl;
1030 Vmath::Vcopy(nquad_lay, txQ, 1, Cont_y->UpdatePhys(), 1);
1031 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffsy);
1032 Cont_y->BwdTrans(coeffsy, Cont_y->UpdatePhys());
1035 Vmath::Vcopy(nquad_lay, tyQ, 1, Cont_y->UpdatePhys(), 1);
1036 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffsy);
1037 Cont_y->BwdTrans(coeffsy, Cont_y->UpdatePhys());
1048 for (
int q = 0; q < 2; q++)
1050 edgebef = edgeinterp[q] - 1;
1052 (txQ[edgebef * nqedge + nqedge - 1] - txQ[edgebef * nqedge]) /
1053 (xcQ[edgebef * nqedge + nqedge - 1] - xcQ[edgebef * nqedge]);
1054 inc = (txQ[edgeinterp[q] * nqedge + nqedge - 1] -
1055 txQ[edgeinterp[q] * nqedge]) /
1056 (xcQ[edgeinterp[q] * nqedge + nqedge - 1] -
1057 xcQ[edgeinterp[q] * nqedge]);
1058 int npoints = 2 * nqedge;
1064 cout <<
"inc=" << inc <<
" incbef=" << incbefore << endl;
1065 if ((inc / incbefore) > 0.)
1067 cout <<
"before!!" << edgebef << endl;
1079 PolyFit(polyorder, npoints, xQedges, txQedges, coeffsinterp,
1080 xQedges, txQedges, npoints);
1084 &txQ[edgebef * nqedge + 0], 1);
1086 PolyFit(polyorder, npoints, xQedges, tyQedges, coeffsinterp,
1087 xQedges, tyQedges, npoints);
1091 &tyQ[edgebef * nqedge + 0], 1);
1095 cout <<
"after!!" << endl;
1098 Vmath::Vcopy(npoints, &xcQ[edgeinterp[q] * nqedge + 0], 1,
1100 Vmath::Vcopy(npoints, &ycQ[edgeinterp[q] * nqedge + 0], 1,
1102 Vmath::Vcopy(npoints, &txQ[edgeinterp[q] * nqedge + 0], 1,
1104 Vmath::Vcopy(npoints, &tyQ[edgeinterp[q] * nqedge + 0], 1,
1107 PolyFit(polyorder, npoints, xQedges, txQedges, coeffsinterp,
1108 xQedges, txQedges, npoints);
1112 &txQ[edgeinterp[q] * nqedge + 0], 1);
1114 PolyFit(polyorder, npoints, xQedges, tyQedges, coeffsinterp,
1115 xQedges, tyQedges, npoints);
1119 &tyQ[edgeinterp[q] * nqedge + 0], 1);
1124 Vmath::Vcopy(nquad_lay, tyQ, 1, Cont_y->UpdatePhys(), 1);
1125 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffstmp);
1126 Cont_y->BwdTrans(coeffstmp, Cont_y->UpdatePhys());
1129 Vmath::Vcopy(nquad_lay, txQ, 1, Cont_y->UpdatePhys(), 1);
1130 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffstmp);
1131 Cont_y->BwdTrans(coeffstmp, Cont_y->UpdatePhys());
1134 for (
int k = 0; k < nedges; k++)
1141 Vmath::Vcopy(nqedge, &(txQ[nqedge * k]), 1, &(txedgeQ[0]), 1);
1142 Vmath::Vcopy(nqedge, &(tyQ[nqedge * k]), 1, &(tyedgeQ[0]), 1);
1144 Vmath::Vdiv(nqedge, txedgeQ, 1, tyedgeQ, 1, tx_tyedgeQ, 1);
1145 Vmath::Vmul(nqedge, tx_tyedgeQ, 1, tx_tyedgeQ, 1, tx_tyedgeQ, 1);
1146 Vmath::Sadd(nqedge, 1.0, tx_tyedgeQ, 1, nxedgeQ, 1);
1150 Vmath::Smul(nqedge, -1.0, nxedgeQ, 1, nxedgeQ, 1);
1151 Vmath::Vcopy(nqedge, &(nxedgeQ[0]), 1, &(nxQ[nqedge * k]), 1);
1153 Vmath::Vmul(nqedge, nxedgeQ, 1, nxedgeQ, 1, nyedgeQ, 1);
1154 Vmath::Smul(nqedge, -1.0, nyedgeQ, 1, nyedgeQ, 1);
1158 Vmath::Smul(nqedge, -1.0, nyedgeQ, 1, nyedgeQ, 1);
1159 Vmath::Vcopy(nqedge, &(nyedgeQ[0]), 1, &(nyQ[nqedge * k]), 1);
1161 cout <<
"edge:" << k << endl;
1162 cout <<
"tan/normal" << endl;
1163 for (
int r = 0; r < nqedge; r++)
1165 cout << xcQ[k * nqedge + r] <<
" " << txedgeQ[r] <<
" "
1166 << tyedgeQ[r] <<
" " << nxedgeQ[r] <<
" "
1167 << nyedgeQ[r] << endl;
1173 Vmath::Vcopy(nquad_lay, nyQ, 1, Cont_y->UpdatePhys(), 1);
1175 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffstmp);
1176 Cont_y->BwdTrans(coeffstmp, Cont_y->UpdatePhys());
1180 Vmath::Zero(Cont_y->GetNcoeffs(), Cont_y->UpdateCoeffs(), 1);
1181 Vmath::Vcopy(nquad_lay, nxQ, 1, Cont_y->UpdatePhys(), 1);
1182 Cont_y->FwdTransLocalElmt(Cont_y->GetPhys(), coeffstmp);
1183 Cont_y->BwdTrans(coeffstmp, Cont_y->UpdatePhys());
1187 for (
int k = 0; k < nedges; k++)
1193 nyQ[(k - 1) * nqedge + nqedge - 1] = nyQ[k * nqedge + 0];
1197 nxQ[(k - 1) * nqedge + nqedge - 1] = nxQ[k * nqedge + 0];
1205 cout <<
"nx,yQbefore" << endl;
1206 for (
int u = 0; u < xcQ.size(); u++)
1208 cout << xcQ[u] <<
" " << nyQ[u] <<
" " << txQ[u] << endl;
1214 cout <<
"nx,yQ" << endl;
1215 for (
int u = 0; u < x_tmpQ.size(); u++)
1217 cout << x_tmpQ[u] <<
" " << tmpnyQ[u] << endl;
1221 for (
int k = 0; k < nedges; k++)
1224 for (
int a = 0; a < npedge; a++)
1228 nxPhys[k * npedge + a] = nxQ[k * nqedge + 0];
1229 nyPhys[k * npedge + a] = nyQ[k * nqedge + 0];
1231 else if (a == npedge - 1)
1233 nxPhys[k * npedge + a] = nxQ[k * nqedge + nqedge - 1];
1234 nyPhys[k * npedge + a] = nyQ[k * nqedge + nqedge - 1];
1249 Addpointsx[k * (npedge - 2) + a - 1], x_tmpQ);
1259 Addpointsx[k * (npedge - 2) + a - 1], 4, Pxinterp,
1270 nxPhys[k * npedge + a] = -
sqrt(
abs(
1271 1 - nyPhys[k * npedge + a] * nyPhys[k * npedge + a]));
1286 nyPhys[(k - 1) * npedge + npedge - 1] =
1287 nyPhys[k * npedge + 0];
1291 nxPhys[(k - 1) * npedge + npedge - 1] =
1292 nxPhys[k * npedge + 0];
1296 cout <<
"xcPhys,," << endl;
1297 for (
int s = 0; s < np_lay; s++)
1300 cout << xcPhysMOD[s] <<
" " << ycPhysMOD[s] <<
" "
1301 << nxPhys[s] <<
" " << nyPhys[s] << endl;
1313 for (
int m = 0; m < nlays; m++)
1320 delta[m] = -(cntlow + 1 - m) * Delta0 / (cntlow + 1);
1324 delta[m] = (m - (cntlow)) * Delta0 / (cntlow + 1);
1330 for (
int h = 0; h < nvertl; h++)
1338 if (move_norm ==
false)
1340 ynew[lay_Vids[m][h]] = y_c[h] + delta[m];
1341 xnew[lay_Vids[m][h]] = x_c[h];
1345 if (h == 0 || h == nvertl - 1)
1347 ynew[lay_Vids[m][h]] = y_c[h] + delta[m];
1348 xnew[lay_Vids[m][h]] = x_c[h];
1352 ynew[lay_Vids[m][h]] =
1353 y_c[h] + delta[m] *
abs(nyPhys[h * npedge + 0]);
1354 xnew[lay_Vids[m][h]] =
1355 x_c[h] + delta[m] *
abs(nxPhys[h * npedge + 0]);
1358 cout <<
"Vid x=" << xnew[lay_Vids[m][h]]
1359 <<
" y=" << ynew[lay_Vids[m][h]] << endl;
1364 cout <<
"edge==" << h << endl;
1368 nyPhys[(h - 1) * npedge + npedge - 1],
1371 nxPhys[(h - 1) * npedge + npedge - 1],
1374 if (move_norm ==
false)
1377 layers_y[m][h * npedge + 0] = y_c[h] + delta[m];
1378 layers_x[m][h * npedge + 0] = xnew[lay_Vids[m][h]];
1380 layers_y[m][h * npedge + npedge - 1] =
1381 y_c[h + 1] + delta[m];
1382 layers_x[m][h * npedge + npedge - 1] =
1383 xnew[lay_Vids[m][h + 1]];
1385 for (
int d = 0; d < npedge - 2; d++)
1387 layers_y[m][h * npedge + d + 1] =
1388 ycPhysMOD[h * npedge + d + 1] + delta[m];
1390 layers_x[m][h * npedge + d + 1] =
1391 xcPhysMOD[h * npedge + d + 1];
1400 tmpy_lay[h * npedge + 0] = y_c[h] + delta[m];
1401 tmpx_lay[h * npedge + 0] = xnew[lay_Vids[m][h]];
1403 tmpy_lay[h * npedge + npedge - 1] =
1405 delta[m] *
abs(nyPhys[h * npedge + npedge - 1]);
1406 tmpx_lay[h * npedge + npedge - 1] =
1408 delta[m] *
abs(nxPhys[h * npedge + npedge - 1]);
1410 else if (h == nedges - 1)
1413 tmpy_lay[h * npedge + 0] =
1414 y_c[h] + delta[m] *
abs(nyPhys[h * npedge + 0]);
1415 tmpx_lay[h * npedge + 0] =
1416 x_c[h] + delta[m] *
abs(nxPhys[h * npedge + 0]);
1418 tmpy_lay[h * npedge + npedge - 1] =
1419 y_c[h + 1] + delta[m];
1420 tmpx_lay[h * npedge + npedge - 1] =
1421 xnew[lay_Vids[m][h + 1]];
1426 tmpy_lay[h * npedge + 0] =
1427 y_c[h] + delta[m] *
abs(nyPhys[h * npedge + 0]);
1428 tmpx_lay[h * npedge + 0] =
1429 x_c[h] + delta[m] *
abs(nxPhys[h * npedge + 0]);
1431 tmpy_lay[h * npedge + npedge - 1] =
1433 delta[m] *
abs(nyPhys[h * npedge + npedge - 1]);
1434 tmpx_lay[h * npedge + npedge - 1] =
1436 delta[m] *
abs(nxPhys[h * npedge + npedge - 1]);
1440 for (
int d = 0; d < npedge - 2; d++)
1443 tmpy_lay[h * npedge + d + 1] =
1444 ycPhysMOD[h * npedge + d + 1] +
1445 delta[m] *
abs(nyPhys[h * npedge + d + 1]);
1448 tmpx_lay[h * npedge + d + 1] =
1449 xcPhysMOD[h * npedge + d + 1] +
1450 delta[m] *
abs(nxPhys[h * npedge + d + 1]);
1468 for (
int s = 0; s < np_lay; s++)
1470 cout << tmpx_lay[s] <<
" " << tmpy_lay[s] << endl;
1473 cout <<
"fisrt interp" << endl;
1474 for (
int s = 0; s < np_lay; s++)
1476 cout << tmpx_lay[s] <<
" " << tmpy_lay[s] << endl;
1488 NekDouble boundright = xcPhysMOD[np_lay - 1];
1489 bool outboundleft =
false;
1490 bool outboundright =
false;
1491 if (tmpx_lay[1] < boundleft)
1493 outboundleft =
true;
1495 if (tmpx_lay[np_lay - 2] > boundright)
1497 outboundright =
true;
1505 for (
int r = 0; r < nedges; r++)
1508 if (tmpx_lay[r * npedge + npedge - 1] < boundleft &&
1509 outboundleft ==
true)
1511 vertout[outvert] = r;
1517 if (tmpx_lay[(r + 1) * npedge + npedge - 1] > boundleft)
1519 for (
int s = 0; s < npedge - 2; s++)
1521 if (tmpx_lay[(r + 1) * npedge + s + 1] <
1531 if (tmpx_lay[r * npedge + 0] > boundright &&
1532 outboundright ==
true)
1534 vertout[outvert] = r;
1540 if (tmpx_lay[(r - 1) * npedge + 0] < boundright)
1542 for (
int s = 0; s < npedge - 2; s++)
1544 if (tmpx_lay[(r - 1) * npedge + s + 1] >
1556 outcount = outvert * npedge + 1 + outmiddle;
1558 int replacepointsfromindex = 0;
1559 for (
int c = 0; c < nedges; c++)
1562 if (xcPhysMOD[c * npedge + npedge - 1] <=
1563 tmpx_lay[c * (npedge - (npedge - 2)) + 2] &&
1564 outboundright ==
true)
1566 replacepointsfromindex = c * (npedge - (npedge - 2)) + 2;
1571 if (xcPhysMOD[(nedges - 1 - c) * npedge + 0] >=
1572 tmpx_lay[np_lay - 1 -
1573 (c * (npedge - (npedge - 2)) + 2)] &&
1574 outboundleft ==
true)
1576 replacepointsfromindex =
1577 np_lay - 1 - (c * (npedge - (npedge - 2)) + 2);
1593 if (outboundright ==
true)
1595 pstart = replacepointsfromindex;
1596 shift = np_lay - outcount;
1598 (xcPhysMOD[np_lay - outcount] - xcPhysMOD[pstart]) /
1600 outcount = outcount - 1;
1601 ASSERTL0(tmpx_lay[np_lay - outcount] >
1602 xcPhysMOD[(nedges - 1) * npedge + 0],
1603 "no middle points in the last edge");
1608 pstart = outcount - 1;
1609 increment = (xcPhysMOD[replacepointsfromindex] -
1610 xcPhysMOD[pstart]) /
1613 xcPhysMOD[0 * npedge + npedge - 1],
1614 "no middle points in the first edge");
1631 NekDouble xctmp, ycinterp, nxinterp, nyinterp;
1633 for (
int v = 0; v < outcount; v++)
1635 xctmp = xcPhysMOD[pstart] + (v + 1) * increment;
1649 nxinterp =
sqrt(
abs(1 - nyinterp * nyinterp));
1657 replace_x[v] = xctmp + delta[m] *
abs(nxinterp);
1658 replace_y[v] = ycinterp + delta[m] *
abs(nyinterp);
1659 tmpx_lay[v + shift] = replace_x[v];
1660 tmpy_lay[v + shift] = replace_y[v];
1680 int closepoints = 4;
1686 int pointscount = 0;
1687 for (
int q = 0; q < np_lay; q++)
1689 for (
int e = 0; e < nedges; e++)
1691 if (tmpx_lay[q] <= x_c[e + 1] && tmpx_lay[q] >= x_c[e])
1695 if (q == e * npedge + npedge - 1 && pointscount != npedge)
1700 else if (q == e * npedge + npedge - 1)
1721 lay_Vids[m], layers_x[m], layers_y[m], xnew,
1801 if (curv_lay ==
true)
1810 int npoints = npedge;
1813 for (
int f = 0; f < nedges; f++)
1824 PolyFit(polyorder, npoints, xPedges, yPedges, coeffsinterp,
1825 xPedges, yPedges, npoints);
1829 &layers_y[m][(f)*npedge + 0], 1);
1832 layers_y[m][f * npedge + 0] = ynew[lay_Vids[m][f]];
1833 layers_y[m][f * npedge + npedge - 1] = ynew[lay_Vids[m][f + 1]];
1836 cout <<
" xlay ylay lay:" << m << endl;
1837 for (
int l = 0; l < np_lay; l++)
1840 cout << std::setprecision(8) << layers_x[m][l] <<
" "
1841 << layers_y[m][l] << endl;
1877 cout <<
"lay=" << m << endl;
1880 " different layer ymin val");
1883 " different layer ymax val");
1886 " different layer xmin val");
1889 " different layer xmax val");
1899 npedge, graphShPt, xold_c, yold_c, xold_low, yold_low, xold_up,
1900 yold_up, layers_x[0], layers_y[0], layers_x[nlays - 1],
1901 layers_y[nlays - 1], nxPhys, nyPhys, xnew, ynew);
1982 Down, Up, xnew, ynew, layers_x, layers_y);
1992 cout << std::setprecision(8) <<
"xmin=" <<
Vmath::Vmin(nVertTot, xnew, 1)
1995 " different xmin val");
1997 " different ymin val");
1999 " different xmax val");
2001 " different ymax val");
2006 charalp, layers_x, layers_y, lay_Eids, curv_lay);
2015 int nvertl = nedges + 1;
2019 for (
int j = 0; j < nedges; j++)
2023 edge = (bndSegExplow->GetGeom1D())->GetGlobalID();
2025 for (
int k = 0; k < 2; k++)
2027 Vids_temp[j + k] = (bndSegExplow->GetGeom1D())->GetVid(k);
2029 graphShPt->GetVertex(Vids_temp[j + k]);
2031 vertex->GetCoords(x1, y1, z1);
2032 if (x1 == x_connect && edge != lastedge)
2035 if (x_connect == x0layer)
2037 Vids[v1] = Vids_temp[j + k];
2044 (bndSegExplow->GetGeom1D())->GetVid(1);
2045 Vids[v2] = Vids_temp[j + 1];
2047 graphShPt->GetVertex(Vids[v2]);
2049 vertex->GetCoords(x2, y2, z2);
2056 (bndSegExplow->GetGeom1D())->GetVid(0);
2057 Vids[v2] = Vids_temp[j + 0];
2059 graphShPt->GetVertex(Vids[v2]);
2061 vertex->GetCoords(x2, y2, z2);
2071 (bndSegExplow->GetGeom1D())->GetVid(1);
2072 Vids[v1] = Vids_temp[j + 1];
2074 graphShPt->GetVertex(Vids[v1]);
2076 vertex->GetCoords(x1, y1, z1);
2083 (bndSegExplow->GetGeom1D())->GetVid(0);
2084 Vids[v1] = Vids_temp[j + 0];
2086 graphShPt->GetVertex(Vids[v1]);
2088 vertex->GetCoords(x1, y1, z1);
2096 if (Vids[v1] != -10)
2112 boost::ignore_unused(xold_up, xold_low);
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");
2393 boost::ignore_unused(xoldup, xolddown);
2395 int nlay_Eids = xcold.size() - 1;
2396 int nlay_Vids = xcold.size();
2398 int nVertsTot = mesh->GetNvertices();
2399 cout <<
"nverttot=" << nVertsTot << endl;
2403 cout <<
"init nlays=" << nlays << endl;
2410 cout <<
"yoldup=" << yoldup[0] << endl;
2411 cout <<
"yolddown=" << yolddown[0] << endl;
2413 for (
int r = 0; r < nVertsTot; r++)
2418 vertex->GetCoords(x, y, z);
2424 if (y <= yoldup[0] && y >= yolddown[0] && y != ycold[0])
2427 tmpVids0[nlays] = r;
2434 cout <<
"nlays=" << nlays << endl;
2446 for (
int w = 0; w < nlays; w++)
2449 tmpx0[w] = tmpx[index];
2450 tmpy0[w] = tmpf[index];
2451 tmpVids0[w] = tmpV[index];
2452 tmpf[index] = max + 1000;
2458 for (
int m = 0; m < nlays; m++)
2469 NekDouble xtmp, ytmp, normnext = 0.0, xnext = 0.0, ynext = 0.0, diff;
2470 NekDouble Ubef = 0.0, Utmp = 0.0, Unext = 0.0;
2473 int nTotEdges = V1.size();
2475 for (
int m = 0; m < nlays; m++)
2477 for (
int g = 0; g < nlay_Eids; g++)
2481 for (
int h = 0; h < nTotEdges; h++)
2484 if (tmpVids0[m] == V1[h])
2487 mesh->GetVertex(V2[h]);
2489 vertex->GetCoords(x, y, z);
2493 Vids_lay[m][0] = V1[h];
2494 Vids_lay[m][1] = V2[h];
2496 mesh->GetVertex(V1[h]);
2498 vertex1->GetCoords(x1, y1, z1);
2500 sqrt((y - y1) * (y - y1) + (x - x1) * (x - x1));
2505 elmtid = streak->GetExpIndex(coord, 0.00001);
2506 offset = streak->GetPhys_Offset(elmtid);
2507 Ubef = streak->GetExp(elmtid)->PhysEvaluate(
2508 coord, streak->GetPhys() + offset);
2511 if (tmpVids0[m] == V2[h])
2514 mesh->GetVertex(V1[h]);
2516 vertex->GetCoords(x, y, z);
2520 Vids_lay[m][0] = V2[h];
2521 Vids_lay[m][1] = V1[h];
2523 mesh->GetVertex(V2[h]);
2526 sqrt((y - y2) * (y - y2) + (x - x2) * (x - x2));
2531 elmtid = streak->GetExpIndex(coord, 0.00001);
2532 offset = streak->GetPhys_Offset(elmtid);
2533 Ubef = streak->GetExp(elmtid)->PhysEvaluate(
2534 coord, streak->GetPhys() + offset);
2539 cout <<
"Eid=" << Eids_lay[m][0]
2540 <<
" Vids_lay0=" << Vids_lay[m][0]
2541 <<
" Vidslay1=" << Vids_lay[m][1] << endl;
2547 for (
int h = 0; h < nTotEdges; h++)
2551 if ((Vids_lay[m][g] == V1[h] || Vids_lay[m][g] == V2[h]) &&
2552 h != Eids_lay[m][g - 1])
2554 cout <<
"edgetmp=" << h << endl;
2555 ASSERTL0(cnt <= 6,
"wrong number of candidates");
2564 cout <<
"normbef=" << normbef << endl;
2565 cout <<
"Ubefcc=" << Ubef << endl;
2567 for (
int e = 0; e < cnt; e++)
2570 mesh->GetVertex(V1[edgestmp[e]]);
2572 vertex1->GetCoords(x1, y1, z1);
2574 mesh->GetVertex(V2[edgestmp[e]]);
2576 vertex2->GetCoords(x2, y2, z2);
2579 sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
2581 cout <<
"edgetmp1=" << edgestmp[e] << endl;
2582 cout <<
"V1 x1=" << x1 <<
" y1=" << y1 << endl;
2583 cout <<
"V2 x2=" << x2 <<
" y2=" << y2 << endl;
2584 if (Vids_lay[m][g] == V1[edgestmp[e]])
2591 elmtid = streak->GetExpIndex(coord, 0.00001);
2592 offset = streak->GetPhys_Offset(elmtid);
2593 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2594 coord, streak->GetPhys() + offset);
2595 diffarray[e] =
abs((xtmp * xbef + ytmp * ybef) /
2596 (normtmp * normbef) -
2598 diffUarray[e] =
abs(Ubef - Utmp);
2599 cout <<
" normtmp=" << normtmp << endl;
2600 cout <<
" Utmpcc=" << Utmp << endl;
2601 cout << xtmp <<
" ytmp=" << ytmp <<
" diff="
2602 <<
abs(((xtmp * xbef + ytmp * ybef) /
2603 (normtmp * normbef)) -
2606 if (
abs((xtmp * xbef + ytmp * ybef) /
2607 (normtmp * normbef) -
2609 y2 <= yoldup[g + 1] && y2 >= yolddown[g + 1] &&
2610 y1 <= yoldup[g] && y1 >= yolddown[g])
2613 Eids_lay[m][g] = edgestmp[e];
2614 Vids_lay[m][g + 1] = V2[edgestmp[e]];
2615 diff =
abs((xtmp * xbef + ytmp * ybef) /
2616 (normtmp * normbef) -
2624 else if (Vids_lay[m][g] == V2[edgestmp[e]])
2631 elmtid = streak->GetExpIndex(coord, 0.00001);
2632 offset = streak->GetPhys_Offset(elmtid);
2633 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2634 coord, streak->GetPhys() + offset);
2635 diffarray[e] =
abs((xtmp * xbef + ytmp * ybef) /
2636 (normtmp * normbef) -
2638 diffUarray[e] =
abs(Ubef - Utmp);
2639 cout <<
" normtmp=" << normtmp << endl;
2640 cout <<
" Utmpcc=" << Utmp << endl;
2641 cout << xtmp <<
" ytmp=" << ytmp <<
" diff="
2642 <<
abs(((xtmp * xbef + ytmp * ybef) /
2643 (normtmp * normbef)) -
2646 if (
abs((xtmp * xbef + ytmp * ybef) /
2647 (normtmp * normbef) -
2649 y2 <= yoldup[g] && y2 >= yolddown[g] &&
2650 y1 <= yoldup[g + 1] && y1 >= yolddown[g + 1])
2652 Eids_lay[m][g] = edgestmp[e];
2653 Vids_lay[m][g + 1] = V1[edgestmp[e]];
2654 diff =
abs((xtmp * xbef + ytmp * ybef) /
2655 (normtmp * normbef) -
2668 cout <<
"Eid before check=" << Eids_lay[m][g] << endl;
2669 for (
int q = 0; q < cnt; q++)
2671 cout << q <<
" diff" << diffarray[q] << endl;
2675 if (m > 0 && m < nlays)
2678 Vids_lay[m][g + 1]);
2682 cout <<
"COMMON VERT" << endl;
2684 diffarray[eid] = 1000;
2688 mesh->GetVertex(V1[edgestmp[eid]]);
2690 vertex1->GetCoords(x1, y1, z1);
2692 mesh->GetVertex(V2[edgestmp[eid]]);
2694 vertex2->GetCoords(x2, y2, z2);
2697 sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
2699 Eids_lay[m][g] = edgestmp[eid];
2700 if (Vids_lay[m][g] == V1[edgestmp[eid]])
2704 elmtid = streak->GetExpIndex(coord, 0.00001);
2705 offset = streak->GetPhys_Offset(elmtid);
2706 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2707 coord, streak->GetPhys() + offset);
2708 Vids_lay[m][g + 1] = V2[edgestmp[eid]];
2715 if (Vids_lay[m][g] == V2[edgestmp[eid]])
2719 elmtid = streak->GetExpIndex(coord, 0.00001);
2720 offset = streak->GetPhys_Offset(elmtid);
2721 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2722 coord, streak->GetPhys() + offset);
2723 Vids_lay[m][g + 1] = V1[edgestmp[eid]];
2732 cout << m <<
"edge aft:" << Eids_lay[m][g]
2733 <<
" Vid=" << Vids_lay[m][g + 1] << endl;
2739 cout <<
"endelse" << normtmp << endl;
2746 for (
int w = 0; w < nlays; w++)
2748 for (
int f = 0; f < nlay_Eids; f++)
2750 cout <<
"check=" << w <<
" Eid:" << Eids_lay[w][f] << endl;
2759 for (
int u = 0; u < Vids_laybefore.size(); u++)
2761 if (Vids_laybefore[u] == Vid || Vids_c[u] == Vid)
2765 cout << Vid <<
" Vert test=" << Vids_laybefore[u] << endl;
2775 int np_lay = inarray.size();
2776 ASSERTL0(inarray.size() % nedges == 0,
" something on number npedge");
2780 for (
int w = 0; w < np_lay; w++)
2785 if (inarray[w] == inarray[w + 1])
2790 outarray[cnt] = inarray[w];
2794 ASSERTL0(cnt == np_lay - (nedges - 1),
"wrong cut");
2799 int npts = xArray.size();
2808 if (xArray[index] > x)
2821 ASSERTL0(neighpoints % 2 == 0,
"number of neighbour points should be even");
2822 int leftpoints = (neighpoints / 2) - 1;
2823 int rightpoints = neighpoints / 2;
2828 if (index - leftpoints < 0)
2831 diff = index - leftpoints;
2833 Vmath::Vcopy(neighpoints, &yArray[0], 1, &Neighbour_y[0], 1);
2834 Vmath::Vcopy(neighpoints, &xArray[0], 1, &Neighbour_x[0], 1);
2836 else if ((yArray.size() - 1) - index < rightpoints)
2839 int rpoints = (yArray.size() - 1) - index;
2840 diff = rightpoints - rpoints;
2842 start = index - leftpoints - diff;
2843 Vmath::Vcopy(neighpoints, &yArray[start], 1, &Neighbour_y[0], 1);
2844 Vmath::Vcopy(neighpoints, &xArray[start], 1, &Neighbour_x[0], 1);
2849 start = index - leftpoints;
2850 Vmath::Vcopy(neighpoints, &yArray[start], 1, &Neighbour_y[0], 1);
2851 Vmath::Vcopy(neighpoints, &xArray[start], 1, &Neighbour_x[0], 1);
2860 for (
int f = 1; f < neighpoints; f++)
2862 ASSERTL0(Neighbour_x[f] != Neighbour_x[f - 1],
2863 " repetition on NeighbourArrays");
2874 for (
int pt = 0; pt < npts; ++pt)
2878 for (
int j = 0; j < pt; ++j)
2880 h = h * (x - xpts[j]) / (xpts[pt] - xpts[j]);
2883 for (
int k = pt + 1; k < npts; ++k)
2885 h = h * (x - xpts[k]) / (xpts[pt] - xpts[k]);
2889 sum += funcvals[pt] * LagrangePoly;
2901 int np_pol = coeffsinterp.size();
2902 cout <<
"evaluatetan with " << np_pol << endl;
2908 for (
int q = 0; q < npoints; q++)
2910 polorder = np_pol - 1;
2911 derorder = np_pol - 2;
2913 for (
int d = 0; d < np_pol - 1; d++)
2915 yprime[q] += (derorder + 1) * coeffsinterp[d] *
2916 std::pow(xcQedge[q], derorder);
2920 for (
int a = 0; a < np_pol; a++)
2922 yinterp[q] += coeffsinterp[a] * std::pow(xcQedge[q], polorder);
2930 for (
int n = 0; n < npoints; n++)
2934 txQedge[n] = cos((atan((yprime[n]))));
2935 tyQedge[n] = sin((atan((yprime[n]))));
2936 cout << xcQedge[n] <<
" " << yinterp[n] <<
" " << yprime[n]
2937 <<
" " << txQedge[n] <<
" " << tyQedge[n] << endl;
2944 int edge,
int npedge)
2946 int np_pol = xpol.size();
2952 for (
int e = 0; e < N; e++)
2955 for (
int w = 0; w < N; w++)
2957 A[N * e + row] = std::pow(xpol[w], N - 1 - e);
2962 for (
int r = 0; r < np_pol; r++)
2976 std::string message =
2977 "ERROR: The " + boost::lexical_cast<std::string>(-info) +
2978 "th parameter had an illegal parameter for dgetrf";
2983 std::string message =
2984 "ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2985 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2991 Lapack::Dgetrs(
'N', N, ncolumns_b,
A.get(), N, ipivot.get(), b.get(), N,
2995 std::string message =
2996 "ERROR: The " + boost::lexical_cast<std::string>(-info) +
2997 "th parameter had an illegal parameter for dgetrf";
3002 std::string message =
3003 "ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
3004 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
3016 for (
int c = 0; c < npedge; c++)
3018 polorder = np_pol - 1;
3020 ycout[edge * (npedge) + c + 1] = 0;
3021 for (
int d = 0; d < np_pol; d++)
3023 ycout[edge * (npedge) + c + 1] +=
3024 b[d] * std::pow(xcout[edge * (npedge) + c + 1], polorder);
3039 int N = polyorder + 1;
3042 cout << npoints << endl;
3043 for (
int u = 0; u < npoints; u++)
3045 cout <<
"c=" << xin[u] <<
" " << fin[u] << endl;
3049 for (
int e = 0; e < N; e++)
3052 for (
int row = 0; row < N; row++)
3054 for (
int w = 0; w < npoints; w++)
3056 A[N * e + row] += std::pow(xin[w], e + row);
3061 for (
int row = 0; row < N; row++)
3063 for (
int h = 0; h < npoints; h++)
3065 b[row] += fin[h] * std::pow(xin[h], row);
3078 std::string message =
3079 "ERROR: The " + boost::lexical_cast<std::string>(-info) +
3080 "th parameter had an illegal parameter for dgetrf";
3085 std::string message =
3086 "ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
3087 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
3092 Lapack::Dgetrs(
'N', N, ncolumns_b,
A.get(), N, ipivot.get(), b.get(), N,
3096 std::string message =
3097 "ERROR: The " + boost::lexical_cast<std::string>(-info) +
3098 "th parameter had an illegal parameter for dgetrf";
3103 std::string message =
3104 "ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
3105 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
3114 for (
int j = 0; j < N; j++)
3116 b[j] = tmp[cnt - 1];
3120 for (
int h = 0; h < N; h++)
3122 cout <<
"coeff:" << b[h] << endl;
3127 for (
int c = 0; c < npout; c++)
3129 polorder = polyorder;
3132 for (
int d = 0; d < N; d++)
3135 fout[c] += b[d] * std::pow(xout[c], polorder);
3158 for (
int w = 0; w < tmpx.size(); w++)
3161 outarray_x[w] = tmpx[index];
3162 outarray_y[w] = tmpy[index];
3163 if (w < tmpx.size() - 1)
3165 if (tmpx[index] == tmpx[index + 1])
3167 outarray_x[w + 1] = tmpx[index + 1];
3168 outarray_y[w + 1] = tmpy[index + 1];
3169 tmpx[index + 1] = max + 1000;
3185 tmpx[index] = max + 1000;
3198 int np_lay = layers_y[0].size();
3200 for (
int h = 1; h < nlays - 1; h++)
3203 for (
int s = 0; s < nvertl; s++)
3206 ASSERTL0(ynew[lay_Vids[h][s]] == -20,
"ynew layers not empty");
3210 ynew[lay_Vids[h][s]] =
3212 h *
abs(ynew[Down[s]] - yc[s]) / (cntlow + 1);
3214 xnew[lay_Vids[h][s]] = xc[s];
3218 layers_y[h][s] = ynew[lay_Vids[h][s]];
3219 layers_x[h][s] = xnew[lay_Vids[h][s]];
3224 ynew[lay_Vids[h][s]] = yc[s] + (h - cntlow) *
3225 abs(ynew[Up[s]] - yc[s]) /
3228 xnew[lay_Vids[h][s]] = xc[s];
3230 layers_y[h][s] = ynew[lay_Vids[h][s]];
3231 layers_x[h][s] = xnew[lay_Vids[h][s]];
3245 int np_lay = xcPhys.size();
3246 int nedges = nvertl - 1;
3253 int closepoints = 4;
3258 for (
int g = 0; g < nedges; g++)
3267 Pxinterp, Pyinterp);
3268 xnew[Vids[g]] = xcPhys[g * npedge + 0];
3269 ylay[g * npedge + 0] = ynew[Vids[g]];
3270 xlay[g * npedge + 0] = xnew[Vids[g]];
3280 xcPhys[g * npedge + npedge - 1], closepoints, Pxinterp, Pyinterp);
3281 xnew[Vids[g + 1]] = xcPhys[g * npedge + npedge - 1];
3282 ylay[g * npedge + npedge - 1] = ynew[Vids[g + 1]];
3283 xlay[g * npedge + npedge - 1] = xnew[Vids[g + 1]];
3286 for (
int r = 0; r < npedge - 2; r++)
3293 ASSERTL0(index <= tmpy.size() - 1,
" index wrong");
3299 xcPhys[g * npedge + r + 1], closepoints, Pxinterp, Pyinterp);
3301 xlay[g * npedge + r + 1] = xcPhys[g * npedge + r + 1];
3322 int np_lay = xcPhys.size();
3323 int nedges = nvertl - 1;
3331 int closepoints = 4;
3336 for (
int g = 0; g < nedges; g++)
3340 ynew[Vids[g]] = tmpy_lay[g * npedge + 0];
3341 xnew[Vids[g]] = tmpx_lay[g * npedge + 0];
3343 ylay[g * npedge + 0] = ynew[Vids[g]];
3344 xlay[g * npedge + 0] = xnew[Vids[g]];
3347 ynew[Vids[g + 1]] = tmpy_lay[g * npedge + npedge - 1];
3348 xnew[Vids[g + 1]] = tmpx_lay[g * npedge + npedge - 1];
3349 ylay[g * npedge + npedge - 1] = ynew[Vids[g + 1]];
3350 xlay[g * npedge + npedge - 1] = xnew[Vids[g + 1]];
3353 for (
int r = 0; r < npedge - 2; r++)
3355 x0 = xlay[g * npedge + 0];
3356 x1 = xlay[g * npedge + npedge - 1];
3357 xtmp = x0 + r * (x1 - x0) / (npedge - 1);
3362 ASSERTL0(index <= tmpy.size() - 1,
" index wrong");
3367 ylay[g * npedge + r + 1] =
3370 xlay[g * npedge + r + 1] = xtmp;
3384 boost::ignore_unused(xolddown, xoldup);
3387 int nvertl = ycold.size();
3388 int nVertTot = mesh->GetNvertices();
3389 for (
int n = 0; n < nVertTot; n++)
3394 vertex->GetCoords(x, y, z);
3399 for (
int k = 0; k < nvertl; k++)
3401 if (
abs(x - xcold[k]) < tmp)
3403 tmp =
abs(x - xcold[k]);
3415 nplay_closer = (qp_closer - 1) * npedge + npedge - 1;
3418 if (y > yoldup[qp_closer] && y < 1)
3424 ratio = (1 - ylayup[nplay_closer]) / ((1 - yoldup[qp_closer]));
3426 ynew[n] = ylayup[nplay_closer] + (y - yoldup[qp_closer]) * ratio;
3429 else if (y < yolddown[qp_closer] && y > -1)
3432 ratio = (1 + ylaydown[nplay_closer]) / ((1 + yolddown[qp_closer]));
3435 ylaydown[nplay_closer] + (y - yolddown[qp_closer]) * ratio;
3451 boost::ignore_unused(xcold, ycold);
3467 int nvertl = xoldup.size();
3468 int nedges = nvertl - 1;
3477 for (
int a = 0; a < nedges; a++)
3482 xnew_down[a] = xlaydown[a * npedge + 0];
3483 ynew_down[a] = ylaydown[a * npedge + 0];
3484 xnew_up[a] = xlayup[a * npedge + 0];
3485 ynew_up[a] = ylayup[a * npedge + 0];
3486 nxvert[a] = nxPhys[a * npedge + 0];
3487 nyvert[a] = nyPhys[a * npedge + 0];
3489 xnew_down[a + 1] = xlaydown[a * npedge + npedge - 1];
3490 ynew_down[a + 1] = ylaydown[a * npedge + npedge - 1];
3491 xnew_up[a + 1] = xlayup[a * npedge + npedge - 1];
3492 ynew_up[a + 1] = ylayup[a * npedge + npedge - 1];
3493 nxvert[a + 1] = nxPhys[a * npedge + npedge - 1];
3494 nyvert[a + 1] = nyPhys[a * npedge + npedge - 1];
3499 xnew_down[a + 1] = xlaydown[a * npedge + npedge - 1];
3500 ynew_down[a + 1] = ylaydown[a * npedge + npedge - 1];
3501 xnew_up[a + 1] = xlayup[a * npedge + npedge - 1];
3502 ynew_up[a + 1] = ylayup[a * npedge + npedge - 1];
3503 nxvert[a + 1] = nxPhys[a * npedge + npedge - 1];
3504 nyvert[a + 1] = nyPhys[a * npedge + npedge - 1];
3515 int nVertTot = mesh->GetNvertices();
3516 for (
int n = 0; n < nVertTot; n++)
3521 vertex->GetCoords(x, y, z);
3522 int qp_closeroldup = 0, qp_closerolddown = 0;
3528 for (
int k = 0; k < nvertl; k++)
3530 if (
abs(x - xolddown[k]) < diffdown)
3532 diffdown =
abs(x - xolddown[k]);
3533 qp_closerolddown = k;
3535 if (
abs(x - xoldup[k]) < diffup)
3537 diffup =
abs(x - xoldup[k]);
3546 int qp_closerup = 0, qp_closerdown = 0;
3548 for (
int f = 0; f < nvertl; f++)
3550 if (
abs(x - xnew_down[f]) < diffdown)
3552 diffdown =
abs(x - xnew_down[f]);
3555 if (
abs(x - xnew_up[f]) < diffup)
3557 diffup =
abs(x - xnew_up[f]);
3584 int qp_closernormup;
3595 int qp_closernormdown;
3603 if (y > yoldup[qp_closeroldup] && y < 1)
3609 ratio = (1 - ynew_up[qp_closerup]) / ((1 - yoldup[qp_closeroldup]));
3615 ynew_up[qp_closerup] + (y - yoldup[qp_closeroldup]) * ratio;
3623 if (x > (xmax - xmin) / 2. && x < xmax)
3625 ratiox = (xmax - xnew_up[qp_closernormup]) /
3626 (xmax - xoldup[qp_closernormup]);
3627 if ((xmax - xoldup[qp_closernormup]) == 0)
3635 x +
abs(nxvert[qp_closernormup]) *
3636 (xnew_up[qp_closeroldup] - xoldup[qp_closeroldup]) *
3638 ASSERTL0(x > xmin,
" x value <xmin up second half");
3639 ASSERTL0(x < xmax, " x value >xmax up second half
");
3641 else if (x > xmin && x <= (xmax - xmin) / 2.)
3643 // cout<<"up close normold=
"<<qp_closernormoldup<<"
3645 ratiox = (xnew_up[qp_closernormup] - xmin) /
3646 ((xoldup[qp_closernormup] - xmin));
3647 if ((xoldup[qp_closernormup] - xmin) == 0)
3654 x +
abs(nxvert[qp_closernormup]) *
3655 (xnew_up[qp_closeroldup] - xoldup[qp_closeroldup]) *
3658 ASSERTL0(x > xmin,
" x value <xmin up first half");
3659 ASSERTL0(x < xmax, " x value >xmax up first half
");
3662 else if (y < yolddown[qp_closerolddown] && y > -1)
3665 ratio = (1 + ynew_down[qp_closerdown]) /
3666 ((1 + yolddown[qp_closerolddown]));
3668 // ratioy = (1-ynew_down[qp_closernormdown])/
3669 // ( (1-yolddown[qp_closernormolddown]) );
3671 // distance prop to layerlow
3672 ynew[n] = ynew_down[qp_closerdown] +
3673 (y - yolddown[qp_closerolddown]) * ratio;
3674 // ynew[n] = y +abs(nyvert[qp_closernormdown])*
3675 // (ynew_down[qp_closerolddown]-yolddown[qp_closerolddown])*ratioy;
3677 // 0.3*(ynew_down[qp_closerdown]-yolddown[qp_closerdown]); xnew[n] =
3679 // abs(nxvert[qp_closerolddown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown]);
3683 cout<<qp_closerolddown<<" nplaydown=
"<<qp_closerdown<<endl;
3684 cout<<"xolddown=
"<<xolddown[qp_closerolddown]<<"
3685 xnewdown=
"<<xnew_down[qp_closerdown]<<endl; cout<<"xold+
"<<x<<"
3686 xnew+
"<<xnew[n]<<endl;
3690 if (x > (xmax - xmin) / 2. && x < xmax)
3692 ratiox = (xmax - xnew_down[qp_closernormdown]) /
3693 ((xmax - xolddown[qp_closernormdown]));
3694 if ((xmax - xolddown[qp_closernormdown]) == 0)
3698 // xnew[n] = xnew_down[qp_closerdown]
3699 // + (x-xolddown[qp_closerolddown])*ratiox;
3700 xnew[n] = x + abs(nxvert[qp_closernormdown]) *
3701 (xnew_down[qp_closerolddown] -
3702 xolddown[qp_closerolddown]) *
3704 ASSERTL0(x > xmin, " x value <xmin down second half
");
3705 ASSERTL0(x < xmax, " x value >xmax down second half
");
3707 else if (x > xmin && x <= (xmax - xmin) / 2.)
3709 ratiox = (xnew_down[qp_closernormdown] - xmin) /
3710 ((xolddown[qp_closernormdown] - xmin));
3711 if ((xolddown[qp_closernormdown] - xmin) == 0)
3715 // xnew[n] = xnew_down[qp_closerdown]
3716 // + (x-xolddown[qp_closerolddown])*ratiox;
3717 xnew[n] = x + abs(nxvert[qp_closernormdown]) *
3718 (xnew_down[qp_closerolddown] -
3719 xolddown[qp_closerolddown]) *
3721 ASSERTL0(x > xmin, " x value <xmin down first half
");
3722 ASSERTL0(x < xmax, " x value >xmax down first half
");
3726 cout << "xold
" << x << " xnew=
" << xnew[n] << endl;
3727 ASSERTL0(xnew[n] >= xmin, "newx < xmin
");
3728 ASSERTL0(xnew[n] <= xmax, "newx > xmax
");
3733 void CheckSingularQuads(MultiRegions::ExpListSharedPtr Exp, Array<OneD, int> V1,
3734 Array<OneD, int> V2, Array<OneD, NekDouble> &xnew,
3735 Array<OneD, NekDouble> &ynew)
3737 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D = Exp->GetExp();
3738 int nel = exp2D->size();
3739 LocalRegions::QuadExpSharedPtr locQuadExp;
3740 LocalRegions::TriExpSharedPtr locTriExp;
3741 SpatialDomains::Geometry1DSharedPtr SegGeom;
3743 NekDouble xV1, yV1, xV2, yV2;
3744 NekDouble slopebef = 0.0, slopenext = 0.0, slopenew = 0.0;
3745 Array<OneD, int> locEids(4);
3746 for (int i = 0; i < nel; i++)
3748 if ((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
3750 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(0);
3751 idbef = SegGeom->GetGlobalID();
3752 if (xnew[V1[idbef]] <= xnew[V2[idbef]])
3754 xV1 = xnew[V1[idbef]];
3755 yV1 = ynew[V1[idbef]];
3756 xV2 = xnew[V2[idbef]];
3757 yV2 = ynew[V2[idbef]];
3758 slopebef = (yV2 - yV1) / (xV2 - xV1);
3762 xV1 = xnew[V2[idbef]];
3763 yV1 = ynew[V2[idbef]];
3764 xV2 = xnew[V1[idbef]];
3765 yV2 = ynew[V1[idbef]];
3766 slopebef = (yV2 - yV1) / (xV2 - xV1);
3768 // cout<<"00 V1 x=
"<<xnew[ V1[idbef] ]<<" y=
"<<ynew[ V1[idbef]
3769 // ]<<endl; cout<<"00 V2 x=
"<<xnew[ V2[idbef] ]<<" y=
"<<ynew[
3770 // V2[idbef] ]<<endl;
3771 for (int j = 1; j < locQuadExp->GetNtraces(); ++j)
3773 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
3774 idnext = SegGeom->GetGlobalID();
3775 // cout<<"id=
"<<idnext<<" locid=
"<<j<<endl;
3776 // cout<<" V1 x=
"<<xnew[ V1[idnext] ]<<" y=
"<<ynew[
3777 // V1[idnext] ]<<endl; cout<<" V2 x=
"<<xnew[ V2[idnext] ]<<"
3779 if (xV1 == xnew[V1[idnext]] && yV1 == ynew[V1[idnext]])
3781 xV1 = xnew[V1[idnext]];
3782 yV1 = ynew[V1[idnext]];
3783 xV2 = xnew[V2[idnext]];
3784 yV2 = ynew[V2[idnext]];
3785 slopenext = (yV2 - yV1) / (xV2 - xV1);
3788 cout <<
"case1 x0=" << xV1 <<
" x1=" << xV2 << endl;
3789 cout << idnext <<
" 11slope bef =" << slopebef
3790 <<
" slopenext=" << slopenext << endl;
3793 if (slopebef / slopenext > 0.84 &&
3794 slopebef / slopenext < 1.18)
3796 xnew[V1[idnext]] = xnew[V1[idnext]] - 0.01;
3797 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3799 if (
abs(slopebef - slopenew) <
3800 abs(slopebef - slopenext))
3802 xnew[V1[idnext]] = xnew[V1[idnext]] + 0.02;
3803 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3805 slopenext = slopenew;
3806 cout <<
"slopenew=" << slopenew << endl;
3807 cout <<
"moved x=" << xnew[V1[idnext]] << endl;
3810 else if (xV2 == xnew[V2[idnext]] && yV2 == ynew[V2[idnext]])
3812 xV1 = xnew[V2[idnext]];
3813 yV1 = ynew[V2[idnext]];
3814 xV2 = xnew[V1[idnext]];
3815 yV2 = ynew[V1[idnext]];
3816 slopenext = (yV2 - yV1) / (xV2 - xV1);
3819 cout <<
"case2 x0=" << xV1 <<
" x1=" << xV2 << endl;
3820 cout << idnext <<
" 22slope bef =" << slopebef
3821 <<
" slopenext=" << slopenext << endl;
3824 if (slopebef / slopenext > 0.84 &&
3825 slopebef / slopenext < 1.18)
3827 xnew[V2[idnext]] = xnew[V2[idnext]] - 0.01;
3828 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3830 if (
abs(slopebef - slopenew) <
3831 abs(slopebef - slopenext))
3833 xnew[V2[idnext]] = xnew[V2[idnext]] + 0.02;
3834 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3836 slopenext = slopenew;
3837 cout <<
"slopenew=" << slopenew << endl;
3838 cout <<
"moved x=" << xnew[V2[idnext]] << endl;
3841 else if (xV1 == xnew[V2[idnext]] && yV1 == ynew[V2[idnext]])
3843 xV1 = xnew[V2[idnext]];
3844 yV1 = ynew[V2[idnext]];
3845 xV2 = xnew[V1[idnext]];
3846 yV2 = ynew[V1[idnext]];
3847 slopenext = (yV2 - yV1) / (xV2 - xV1);
3850 cout <<
"case3 x0=" << xV1 <<
" x1=" << xV2 << endl;
3851 cout << idnext <<
" 22slope bef =" << slopebef
3852 <<
" slopenext=" << slopenext << endl;
3855 if (slopebef / slopenext > 0.84 &&
3856 slopebef / slopenext < 1.18)
3858 xnew[V2[idnext]] = xnew[V2[idnext]] - 0.01;
3859 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3861 if (
abs(slopebef - slopenew) <
3862 abs(slopebef - slopenext))
3864 xnew[V2[idnext]] = xnew[V2[idnext]] + 0.02;
3865 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3867 slopenext = slopenew;
3868 cout <<
"slopenew=" << slopenew << endl;
3869 cout <<
"moved x=" << xnew[V2[idnext]] << endl;
3872 else if (xV2 == xnew[V1[idnext]] && yV2 == ynew[V1[idnext]])
3874 xV1 = xnew[V1[idnext]];
3875 yV1 = ynew[V1[idnext]];
3876 xV2 = xnew[V2[idnext]];
3877 yV2 = ynew[V2[idnext]];
3878 slopenext = (yV2 - yV1) / (xV2 - xV1);
3881 cout <<
"case4 x0=" << xV1 <<
" x1=" << xV2 << endl;
3882 cout << idnext <<
" 22slope bef =" << slopebef
3883 <<
" slopenext=" << slopenext << endl;
3886 if (slopebef / slopenext > 0.84 &&
3887 slopebef / slopenext < 1.18)
3889 xnew[V1[idnext]] = xnew[V1[idnext]] - 0.01;
3890 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3892 if (
abs(slopebef - slopenew) <
3893 abs(slopebef - slopenext))
3895 xnew[V1[idnext]] = xnew[V1[idnext]] + 0.02;
3896 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3898 slopenext = slopenew;
3899 cout <<
"slopenew=" << slopenew << endl;
3900 cout <<
"moved x=" << xnew[V1[idnext]] << endl;
3905 ASSERTL0(
false,
"edge not connected");
3907 slopebef = slopenext;
3916 int Npoints,
string s_alp,
3923 TiXmlDocument doc(filename);
3925 TiXmlElement *master = doc.FirstChildElement(
"NEKTAR");
3926 TiXmlElement *mesh = master->FirstChildElement(
"GEOMETRY");
3927 TiXmlElement *element = mesh->FirstChildElement(
"VERTEX");
3930 const char *xscal = element->Attribute(
"XSCALE");
3933 std::string xscalstr = xscal;
3935 xscale = expEvaluator.
Evaluate(expr_id);
3939 newfile = filename.substr(0, filename.find_last_of(
".")) +
"_moved.xml";
3940 doc.SaveFile(newfile);
3943 TiXmlDocument docnew(newfile);
3944 bool loadOkaynew = docnew.LoadFile();
3946 std::string errstr =
"Unable to load file: ";
3948 ASSERTL0(loadOkaynew, errstr.c_str());
3950 TiXmlHandle docHandlenew(&docnew);
3951 TiXmlElement *meshnew = NULL;
3952 TiXmlElement *masternew = NULL;
3953 TiXmlElement *condnew = NULL;
3954 TiXmlElement *Parsnew = NULL;
3955 TiXmlElement *parnew = NULL;
3959 masternew = docnew.FirstChildElement(
"NEKTAR");
3960 ASSERTL0(masternew,
"Unable to find NEKTAR tag in file.");
3964 condnew = masternew->FirstChildElement(
"CONDITIONS");
3965 Parsnew = condnew->FirstChildElement(
"PARAMETERS");
3966 cout <<
"alpha=" << s_alp << endl;
3967 parnew = Parsnew->FirstChildElement(
"P");
3970 TiXmlNode *node = parnew->FirstChild();
3974 std::string line = node->ToText()->Value();
3978 int beg = line.find_first_not_of(
" ");
3979 int end = line.find_first_of(
"=");
3984 if (end != line.find_last_of(
"="))
3987 if (end == std::string::npos)
3989 lhs = line.substr(line.find_first_not_of(
" "), end - beg);
3990 lhs = lhs.substr(0, lhs.find_last_not_of(
" ") + 1);
3996 boost::to_upper(lhs);
3999 alphastring =
"Alpha = " + s_alp;
4000 parnew->RemoveChild(node);
4001 parnew->LinkEndChild(
new TiXmlText(alphastring));
4005 parnew = parnew->NextSiblingElement(
"P");
4009 meshnew = masternew->FirstChildElement(
"GEOMETRY");
4011 ASSERTL0(meshnew,
"Unable to find GEOMETRY tag in file.");
4013 TiXmlElement *elementnew = meshnew->FirstChildElement(
"VERTEX");
4014 ASSERTL0(elementnew,
"Unable to find mesh VERTEX tag in file.");
4018 elementnew->SetAttribute(
"XSCALE", 1.0);
4020 TiXmlElement *vertexnew = elementnew->FirstChildElement(
"V");
4024 int nextVertexNumber = -1;
4030 TiXmlAttribute *vertexAttr = vertexnew->FirstAttribute();
4031 std::string attrName(vertexAttr->Name());
4033 (std::string(
"Unknown attribute name: ") + attrName).c_str());
4035 err = vertexAttr->QueryIntValue(&indx);
4036 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
4038 "Vertex IDs must begin with zero and be sequential.");
4040 std::string vertexBodyStr;
4042 TiXmlNode *vertexBody = vertexnew->FirstChild();
4044 if (vertexBody->Type() == TiXmlNode::TINYXML_TEXT)
4046 vertexBodyStr += vertexBody->ToText()->Value();
4047 vertexBodyStr +=
" ";
4050 "Vertex definitions must contain vertex data.");
4052 vertexnew->RemoveChild(vertexBody);
4059 s << std::scientific << std::setprecision(8) << newx[nextVertexNumber]
4060 <<
" " << newy[nextVertexNumber] <<
" " << 0.0;
4061 vertexnew->LinkEndChild(
new TiXmlText(s.str()));
4066 vertexnew = vertexnew->NextSiblingElement(
"V");
4070 TiXmlElement *curvednew = meshnew->FirstChildElement(
"CURVED");
4071 ASSERTL0(curvednew,
"Unable to find mesh CURVED tag in file.");
4072 TiXmlElement *edgenew = curvednew->FirstChildElement(
"E");
4075 std::string charindex;
4079 int neids_lay = lay_eids[0].size();
4086 TiXmlAttribute *edgeAttr = edgenew->FirstAttribute();
4087 std::string attrName(edgeAttr->Name());
4088 charindex = edgeAttr->Value();
4089 std::istringstream iss(charindex);
4090 iss >> std::dec >> index;
4092 edgenew->QueryIntAttribute(
"EDGEID", &eid);
4095 for (
int u = 0; u < Eids.size(); u++)
4105 curvednew->RemoveChild(edgenew);
4111 std::string edgeBodyStr;
4113 TiXmlNode *edgeBody = edgenew->FirstChild();
4114 if (edgeBody->Type() == TiXmlNode::TINYXML_TEXT)
4116 edgeBodyStr += edgeBody->ToText()->Value();
4120 "Edge definitions must contain edge data");
4122 edgenew->RemoveChild(edgeBody);
4129 err = edgenew->QueryIntAttribute(
"NUMPOINTS", &numPts);
4131 "Unable to read curve attribute NUMPOINTS.");
4134 edgenew->SetAttribute(
"NUMPOINTS", Npoints);
4135 for (
int u = 0; u < Npoints; u++)
4137 st << std::scientific << std::setprecision(8)
4138 << xcPhys[cnt * Npoints + u] <<
" "
4139 << ycPhys[cnt * Npoints + u] <<
" " << 0.000 <<
" ";
4142 edgenew->LinkEndChild(
new TiXmlText(st.str()));
4163 edgenew = edgenew->NextSiblingElement(
"E");
4167 if (curv_lay ==
true)
4169 cout <<
"write other curved edges" << endl;
4170 TiXmlElement *curved = meshnew->FirstChildElement(
"CURVED");
4172 int nlays = lay_eids.size();
4177 for (
int g = 0; g < nlays; ++g)
4179 for (
int p = 0;
p < neids_lay;
p++)
4182 TiXmlElement *e =
new TiXmlElement(
"E");
4183 e->SetAttribute(
"ID", idcnt++);
4184 e->SetAttribute(
"EDGEID", lay_eids[g][
p]);
4185 e->SetAttribute(
"NUMPOINTS", Npoints);
4186 e->SetAttribute(
"TYPE",
"PolyEvenlySpaced");
4187 for (
int c = 0; c < Npoints; c++)
4189 st << std::scientific << std::setprecision(8)
4190 << x_lay[g][
p * Npoints + c] <<
" "
4191 << y_lay[g][
p * Npoints + c] <<
" " << 0.000 <<
" ";
4194 TiXmlText *t0 =
new TiXmlText(st.str());
4195 e->LinkEndChild(t0);
4196 curved->LinkEndChild(e);
4201 docnew.SaveFile(newfile);
4203 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 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 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 GenerateNeighbourArrays(int index, int neighpoints, Array< OneD, NekDouble > xArray, Array< OneD, NekDouble > yArray, Array< OneD, NekDouble > &Neighbour_x, Array< OneD, NekDouble > &Neighbour_y)
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)
bool checkcommonvert(Array< OneD, int > Vids_laybefore, Array< OneD, int > Vids_c, int Vid)
int DetermineclosePointxindex(NekDouble x, Array< OneD, NekDouble > xArray)
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 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)
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)
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
The above copyright notice and this permission notice shall be included.
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/y.
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 scalar 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)