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");
1901 npedge, graphShPt, xold_c, yold_c, xold_low, yold_low, xold_up,
1902 yold_up, layers_x[0], layers_y[0], layers_x[nlays - 1],
1903 layers_y[nlays - 1], nxPhys, nyPhys, xnew, ynew);
1984 Down, Up, xnew, ynew, layers_x, layers_y);
1994 cout << std::setprecision(8) <<
"xmin=" <<
Vmath::Vmin(nVertTot, xnew, 1)
1997 " different xmin val");
1999 " different ymin val");
2001 " different xmax val");
2003 " different ymax val");
2008 charalp, layers_x, layers_y, lay_Eids, curv_lay);
2017 int nvertl = nedges + 1;
2021 for (
int j = 0; j < nedges; j++)
2025 edge = (bndSegExplow->GetGeom1D())->GetGlobalID();
2027 for (
int k = 0; k < 2; k++)
2029 Vids_temp[j + k] = (bndSegExplow->GetGeom1D())->GetVid(k);
2031 graphShPt->GetVertex(Vids_temp[j + k]);
2033 vertex->GetCoords(x1, y1, z1);
2034 if (x1 == x_connect && edge != lastedge)
2037 if (x_connect == x0layer)
2039 Vids[v1] = Vids_temp[j + k];
2046 (bndSegExplow->GetGeom1D())->GetVid(1);
2047 Vids[v2] = Vids_temp[j + 1];
2049 graphShPt->GetVertex(Vids[v2]);
2051 vertex->GetCoords(x2, y2, z2);
2058 (bndSegExplow->GetGeom1D())->GetVid(0);
2059 Vids[v2] = Vids_temp[j + 0];
2061 graphShPt->GetVertex(Vids[v2]);
2063 vertex->GetCoords(x2, y2, z2);
2073 (bndSegExplow->GetGeom1D())->GetVid(1);
2074 Vids[v1] = Vids_temp[j + 1];
2076 graphShPt->GetVertex(Vids[v1]);
2078 vertex->GetCoords(x1, y1, z1);
2085 (bndSegExplow->GetGeom1D())->GetVid(0);
2086 Vids[v1] = Vids_temp[j + 0];
2088 graphShPt->GetVertex(Vids[v1]);
2090 vertex->GetCoords(x1, y1, z1);
2098 if (Vids[v1] != -10)
2114 boost::ignore_unused(xold_up, xold_low);
2116 cout <<
"Computestreakpositions" << endl;
2117 int nq = streak->GetTotPoints();
2131 Vmath::Vadd(xc.size(), yold_up, 1, yold_low, 1, yc, 1);
2145 for (
int e = 0; e < npoints; e++)
2150 elmtid = streak->GetExpIndex(coord, 0.00001);
2151 offset = streak->GetPhys_Offset(elmtid);
2157 while (
abs(F) > 0.000000001)
2160 elmtid = streak->GetExpIndex(coord, 0.00001);
2167 if ((
abs(coord[1]) > 1 || elmtid == -1) && attempt == 0 &&
2171 coord[1] = yold_c[e];
2174 else if ((
abs(coord[1]) > 1 || elmtid == -1))
2176 coord[1] = ytmp + 0.01;
2177 elmtid = streak->GetExpIndex(coord, 0.001);
2178 offset = streak->GetPhys_Offset(elmtid);
2179 NekDouble Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2180 coord, streak->GetPhys() + offset);
2181 NekDouble dUtmp = streak->GetExp(elmtid)->PhysEvaluate(
2182 coord, derstreak + offset);
2183 coord[1] = coord[1] - (Utmp - cr) / dUtmp;
2184 if ((
abs(Utmp - cr) >
abs(F)) || (
abs(coord[1]) > 1))
2186 coord[1] = ytmp - 0.01;
2193 ASSERTL0(
abs(coord[1]) <= 1,
" y value out of bound +/-1");
2195 offset = streak->GetPhys_Offset(elmtid);
2196 U = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() +
2199 streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2200 coord[1] = coord[1] - (U - cr) / dU;
2202 ASSERTL0(coord[0] == xc[e],
" x coordinate must remain the same");
2205 if (its > 200 &&
abs(F) < 0.00001)
2207 cout <<
"warning streak position obtained with precision:" << F
2211 else if (its > 1000 &&
abs(F) < 0.0001)
2213 cout <<
"warning streak position obtained with precision:" << F
2217 else if (its > 1000)
2219 ASSERTL0(
false,
"no convergence after 1000 iterations");
2222 yc[e] = coord[1] - (U - cr) / dU;
2223 ASSERTL0(U <= cr + tol,
"streak wrong+");
2224 ASSERTL0(U >= cr - tol,
"streak wrong-");
2227 cout <<
"result streakvert x=" << xc[e] <<
" y=" << yc[e]
2228 <<
" streak=" << U << endl;
2248 while (
abs(F) > 0.00000001)
2252 elmtid =
function->GetExpIndex(coords, 0.01);
2254 cout <<
"gen newton xi=" << xi <<
" yi=" << coords[1]
2255 <<
" elmtid=" << elmtid <<
" F=" << F << endl;
2257 if ((
abs(coords[1]) > 1 || elmtid == -1))
2260 coords[1] = ytmp + 0.01;
2261 elmtid =
function->GetExpIndex(coords, 0.01);
2262 offset =
function->GetPhys_Offset(elmtid);
2263 NekDouble Utmp =
function->GetExp(elmtid)->PhysEvaluate(
2264 coords, function->GetPhys() + offset);
2265 NekDouble dUtmp =
function->GetExp(elmtid)->PhysEvaluate(
2266 coords, derfunction + offset);
2267 coords[1] = coords[1] - (Utmp - cr) / dUtmp;
2268 cout <<
"attempt:" << coords[1] << endl;
2269 if ((
abs(Utmp - cr) >
abs(F)) || (
abs(coords[1]) > 1.01))
2271 coords[1] = ytmp - 0.01;
2276 else if (
abs(coords[1]) < 1.01 && attempt == 0)
2283 ASSERTL0(
abs(coords[1]) <= 1.00,
" y value out of bound +/-1");
2285 offset =
function->GetPhys_Offset(elmtid);
2286 U =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() +
2288 dU =
function->GetExp(elmtid)->PhysEvaluate(coords,
2289 derfunction + offset);
2290 coords[1] = coords[1] - (U - cr) / dU;
2291 cout << cr <<
"U-cr=" << U - cr <<
" tmp result y:" << coords[1]
2292 <<
" dU=" << dU << endl;
2296 if (its > 200 &&
abs(F) < 0.00001)
2298 cout <<
"warning streak position obtained with precision:" << F
2302 else if (its > 1000 &&
abs(F) < 0.0001)
2304 cout <<
"warning streak position obtained with precision:" << F
2308 else if (its > 1000)
2310 ASSERTL0(
false,
"no convergence after 1000 iterations");
2313 ASSERTL0(coords[0] == xi,
" x coordinate must remain the same");
2316 yout = coords[1] - (U - cr) / dU;
2317 cout <<
"NewtonIt result x=" << xout <<
" y=" << coords[1] <<
" U=" << U
2325 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D =
2327 int nel = exp2D->size();
2335 for (
int i = 0; i < nel; i++)
2337 if ((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
2339 for (
int j = 0; j < locQuadExp->GetNtraces(); ++j)
2341 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
2342 id = SegGeom->GetGlobalID();
2344 if (V1tmp[
id] == 10000)
2346 V1tmp[id] = SegGeom->GetVertex(0)->GetVid();
2347 V2tmp[id] = SegGeom->GetVertex(1)->GetVid();
2355 else if ((locTriExp = (*exp2D)[i]->as<LocalRegions::TriExp>()))
2357 for (
int j = 0; j < locTriExp->GetNtraces(); ++j)
2359 SegGeom = (locTriExp->GetGeom2D())->GetEdge(j);
2360 id = SegGeom->GetGlobalID();
2362 if (V1tmp[
id] == 10000)
2364 V1tmp[id] = SegGeom->GetVertex(0)->GetVid();
2365 V2tmp[id] = SegGeom->GetVertex(1)->GetVid();
2375 for (
int g = 0; g < cnt; g++)
2378 ASSERTL0(V1tmp[g] != 10000,
"V1 wrong");
2380 ASSERTL0(V2tmp[g] != 10000,
"V2 wrong");
2394 boost::ignore_unused(xoldup, xolddown);
2396 int nlay_Eids = xcold.size() - 1;
2397 int nlay_Vids = xcold.size();
2399 int nVertsTot = mesh->GetNvertices();
2400 cout <<
"nverttot=" << nVertsTot << endl;
2404 cout <<
"init nlays=" << nlays << endl;
2411 cout <<
"yoldup=" << yoldup[0] << endl;
2412 cout <<
"yolddown=" << yolddown[0] << endl;
2414 for (
int r = 0; r < nVertsTot; r++)
2419 vertex->GetCoords(x, y, z);
2425 if (y <= yoldup[0] && y >= yolddown[0] && y != ycold[0])
2428 tmpVids0[nlays] = r;
2435 cout <<
"nlays=" << nlays << endl;
2447 for (
int w = 0; w < nlays; w++)
2450 tmpx0[w] = tmpx[index];
2451 tmpy0[w] = tmpf[index];
2452 tmpVids0[w] = tmpV[index];
2453 tmpf[index] = max + 1000;
2459 for (
int m = 0; m < nlays; m++)
2470 NekDouble xtmp, ytmp, normnext = 0.0, xnext = 0.0, ynext = 0.0, diff;
2471 NekDouble Ubef = 0.0, Utmp = 0.0, Unext = 0.0;
2474 int nTotEdges = V1.size();
2476 for (
int m = 0; m < nlays; m++)
2478 for (
int g = 0; g < nlay_Eids; g++)
2482 for (
int h = 0; h < nTotEdges; h++)
2485 if (tmpVids0[m] == V1[h])
2488 mesh->GetVertex(V2[h]);
2490 vertex->GetCoords(x, y, z);
2494 Vids_lay[m][0] = V1[h];
2495 Vids_lay[m][1] = V2[h];
2497 mesh->GetVertex(V1[h]);
2499 vertex1->GetCoords(x1, y1, z1);
2501 sqrt((y - y1) * (y - y1) + (x - x1) * (x - x1));
2506 elmtid = streak->GetExpIndex(coord, 0.00001);
2507 offset = streak->GetPhys_Offset(elmtid);
2508 Ubef = streak->GetExp(elmtid)->PhysEvaluate(
2509 coord, streak->GetPhys() + offset);
2512 if (tmpVids0[m] == V2[h])
2515 mesh->GetVertex(V1[h]);
2517 vertex->GetCoords(x, y, z);
2521 Vids_lay[m][0] = V2[h];
2522 Vids_lay[m][1] = V1[h];
2524 mesh->GetVertex(V2[h]);
2527 sqrt((y - y2) * (y - y2) + (x - x2) * (x - x2));
2532 elmtid = streak->GetExpIndex(coord, 0.00001);
2533 offset = streak->GetPhys_Offset(elmtid);
2534 Ubef = streak->GetExp(elmtid)->PhysEvaluate(
2535 coord, streak->GetPhys() + offset);
2540 cout <<
"Eid=" << Eids_lay[m][0]
2541 <<
" Vids_lay0=" << Vids_lay[m][0]
2542 <<
" Vidslay1=" << Vids_lay[m][1] << endl;
2548 for (
int h = 0; h < nTotEdges; h++)
2552 if ((Vids_lay[m][g] == V1[h] || Vids_lay[m][g] == V2[h]) &&
2553 h != Eids_lay[m][g - 1])
2555 cout <<
"edgetmp=" << h << endl;
2556 ASSERTL0(cnt <= 6,
"wrong number of candidates");
2565 cout <<
"normbef=" << normbef << endl;
2566 cout <<
"Ubefcc=" << Ubef << endl;
2568 for (
int e = 0; e < cnt; e++)
2571 mesh->GetVertex(V1[edgestmp[e]]);
2573 vertex1->GetCoords(x1, y1, z1);
2575 mesh->GetVertex(V2[edgestmp[e]]);
2577 vertex2->GetCoords(x2, y2, z2);
2580 sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
2582 cout <<
"edgetmp1=" << edgestmp[e] << endl;
2583 cout <<
"V1 x1=" << x1 <<
" y1=" << y1 << endl;
2584 cout <<
"V2 x2=" << x2 <<
" y2=" << y2 << endl;
2585 if (Vids_lay[m][g] == V1[edgestmp[e]])
2592 elmtid = streak->GetExpIndex(coord, 0.00001);
2593 offset = streak->GetPhys_Offset(elmtid);
2594 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2595 coord, streak->GetPhys() + offset);
2596 diffarray[e] =
abs((xtmp * xbef + ytmp * ybef) /
2597 (normtmp * normbef) -
2599 diffUarray[e] =
abs(Ubef - Utmp);
2600 cout <<
" normtmp=" << normtmp << endl;
2601 cout <<
" Utmpcc=" << Utmp << endl;
2602 cout << xtmp <<
" ytmp=" << ytmp <<
" diff="
2603 <<
abs(((xtmp * xbef + ytmp * ybef) /
2604 (normtmp * normbef)) -
2607 if (
abs((xtmp * xbef + ytmp * ybef) /
2608 (normtmp * normbef) -
2610 y2 <= yoldup[g + 1] && y2 >= yolddown[g + 1] &&
2611 y1 <= yoldup[g] && y1 >= yolddown[g])
2614 Eids_lay[m][g] = edgestmp[e];
2615 Vids_lay[m][g + 1] = V2[edgestmp[e]];
2616 diff =
abs((xtmp * xbef + ytmp * ybef) /
2617 (normtmp * normbef) -
2625 else if (Vids_lay[m][g] == V2[edgestmp[e]])
2632 elmtid = streak->GetExpIndex(coord, 0.00001);
2633 offset = streak->GetPhys_Offset(elmtid);
2634 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2635 coord, streak->GetPhys() + offset);
2636 diffarray[e] =
abs((xtmp * xbef + ytmp * ybef) /
2637 (normtmp * normbef) -
2639 diffUarray[e] =
abs(Ubef - Utmp);
2640 cout <<
" normtmp=" << normtmp << endl;
2641 cout <<
" Utmpcc=" << Utmp << endl;
2642 cout << xtmp <<
" ytmp=" << ytmp <<
" diff="
2643 <<
abs(((xtmp * xbef + ytmp * ybef) /
2644 (normtmp * normbef)) -
2647 if (
abs((xtmp * xbef + ytmp * ybef) /
2648 (normtmp * normbef) -
2650 y2 <= yoldup[g] && y2 >= yolddown[g] &&
2651 y1 <= yoldup[g + 1] && y1 >= yolddown[g + 1])
2653 Eids_lay[m][g] = edgestmp[e];
2654 Vids_lay[m][g + 1] = V1[edgestmp[e]];
2655 diff =
abs((xtmp * xbef + ytmp * ybef) /
2656 (normtmp * normbef) -
2669 cout <<
"Eid before check=" << Eids_lay[m][g] << endl;
2670 for (
int q = 0; q < cnt; q++)
2672 cout << q <<
" diff" << diffarray[q] << endl;
2676 if (m > 0 && m < nlays)
2679 Vids_lay[m][g + 1]);
2683 cout <<
"COMMON VERT" << endl;
2685 diffarray[eid] = 1000;
2689 mesh->GetVertex(V1[edgestmp[eid]]);
2691 vertex1->GetCoords(x1, y1, z1);
2693 mesh->GetVertex(V2[edgestmp[eid]]);
2695 vertex2->GetCoords(x2, y2, z2);
2698 sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
2700 Eids_lay[m][g] = edgestmp[eid];
2701 if (Vids_lay[m][g] == V1[edgestmp[eid]])
2705 elmtid = streak->GetExpIndex(coord, 0.00001);
2706 offset = streak->GetPhys_Offset(elmtid);
2707 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2708 coord, streak->GetPhys() + offset);
2709 Vids_lay[m][g + 1] = V2[edgestmp[eid]];
2716 if (Vids_lay[m][g] == V2[edgestmp[eid]])
2720 elmtid = streak->GetExpIndex(coord, 0.00001);
2721 offset = streak->GetPhys_Offset(elmtid);
2722 Utmp = streak->GetExp(elmtid)->PhysEvaluate(
2723 coord, streak->GetPhys() + offset);
2724 Vids_lay[m][g + 1] = V1[edgestmp[eid]];
2733 cout << m <<
"edge aft:" << Eids_lay[m][g]
2734 <<
" Vid=" << Vids_lay[m][g + 1] << endl;
2740 cout <<
"endelse" << normtmp << endl;
2747 for (
int w = 0; w < nlays; w++)
2749 for (
int f = 0; f < nlay_Eids; f++)
2751 cout <<
"check=" << w <<
" Eid:" << Eids_lay[w][f] << endl;
2760 for (
int u = 0; u < Vids_laybefore.size(); u++)
2762 if (Vids_laybefore[u] == Vid || Vids_c[u] == Vid)
2766 cout << Vid <<
" Vert test=" << Vids_laybefore[u] << endl;
2776 int np_lay = inarray.size();
2777 ASSERTL0(inarray.size() % nedges == 0,
" something on number npedge");
2781 for (
int w = 0; w < np_lay; w++)
2786 if (inarray[w] == inarray[w + 1])
2791 outarray[cnt] = inarray[w];
2795 ASSERTL0(cnt == np_lay - (nedges - 1),
"wrong cut");
2800 int npts = xArray.size();
2809 if (xArray[index] > x)
2822 ASSERTL0(neighpoints % 2 == 0,
"number of neighbour points should be even");
2823 int leftpoints = (neighpoints / 2) - 1;
2824 int rightpoints = neighpoints / 2;
2829 if (index - leftpoints < 0)
2832 diff = index - leftpoints;
2834 Vmath::Vcopy(neighpoints, &yArray[0], 1, &Neighbour_y[0], 1);
2835 Vmath::Vcopy(neighpoints, &xArray[0], 1, &Neighbour_x[0], 1);
2837 else if ((yArray.size() - 1) - index < rightpoints)
2840 int rpoints = (yArray.size() - 1) - index;
2841 diff = rightpoints - rpoints;
2843 start = index - leftpoints - diff;
2844 Vmath::Vcopy(neighpoints, &yArray[start], 1, &Neighbour_y[0], 1);
2845 Vmath::Vcopy(neighpoints, &xArray[start], 1, &Neighbour_x[0], 1);
2850 start = index - leftpoints;
2851 Vmath::Vcopy(neighpoints, &yArray[start], 1, &Neighbour_y[0], 1);
2852 Vmath::Vcopy(neighpoints, &xArray[start], 1, &Neighbour_x[0], 1);
2861 for (
int f = 1; f < neighpoints; f++)
2863 ASSERTL0(Neighbour_x[f] != Neighbour_x[f - 1],
2864 " repetition on NeighbourArrays");
2875 for (
int pt = 0; pt < npts; ++pt)
2879 for (
int j = 0; j < pt; ++j)
2881 h = h * (x - xpts[j]) / (xpts[pt] - xpts[j]);
2884 for (
int k = pt + 1; k < npts; ++k)
2886 h = h * (x - xpts[k]) / (xpts[pt] - xpts[k]);
2890 sum += funcvals[pt] * LagrangePoly;
2902 int np_pol = coeffsinterp.size();
2903 cout <<
"evaluatetan with " << np_pol << endl;
2909 for (
int q = 0; q < npoints; q++)
2911 polorder = np_pol - 1;
2912 derorder = np_pol - 2;
2914 for (
int d = 0; d < np_pol - 1; d++)
2916 yprime[q] += (derorder + 1) * coeffsinterp[d] *
2917 std::pow(xcQedge[q], derorder);
2921 for (
int a = 0; a < np_pol; a++)
2923 yinterp[q] += coeffsinterp[a] * std::pow(xcQedge[q], polorder);
2931 for (
int n = 0; n < npoints; n++)
2935 txQedge[n] = cos((atan((yprime[n]))));
2936 tyQedge[n] = sin((atan((yprime[n]))));
2937 cout << xcQedge[n] <<
" " << yinterp[n] <<
" " << yprime[n]
2938 <<
" " << txQedge[n] <<
" " << tyQedge[n] << endl;
2945 int edge,
int npedge)
2947 int np_pol = xpol.size();
2953 for (
int e = 0; e < N; e++)
2956 for (
int w = 0; w < N; w++)
2958 A[N * e + row] = std::pow(xpol[w], N - 1 - e);
2963 for (
int r = 0; r < np_pol; r++)
2977 std::string message =
2978 "ERROR: The " + boost::lexical_cast<std::string>(-info) +
2979 "th parameter had an illegal parameter for dgetrf";
2984 std::string message =
2985 "ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2986 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2992 Lapack::Dgetrs(
'N', N, ncolumns_b,
A.get(), N, ipivot.get(), b.get(), N,
2996 std::string message =
2997 "ERROR: The " + boost::lexical_cast<std::string>(-info) +
2998 "th parameter had an illegal parameter for dgetrf";
3003 std::string message =
3004 "ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
3005 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
3017 for (
int c = 0; c < npedge; c++)
3019 polorder = np_pol - 1;
3021 ycout[edge * (npedge) + c + 1] = 0;
3022 for (
int d = 0; d < np_pol; d++)
3024 ycout[edge * (npedge) + c + 1] +=
3025 b[d] * std::pow(xcout[edge * (npedge) + c + 1], polorder);
3040 int N = polyorder + 1;
3043 cout << npoints << endl;
3044 for (
int u = 0; u < npoints; u++)
3046 cout <<
"c=" << xin[u] <<
" " << fin[u] << endl;
3050 for (
int e = 0; e < N; e++)
3053 for (
int row = 0; row < N; row++)
3055 for (
int w = 0; w < npoints; w++)
3057 A[N * e + row] += std::pow(xin[w], e + row);
3062 for (
int row = 0; row < N; row++)
3064 for (
int h = 0; h < npoints; h++)
3066 b[row] += fin[h] * std::pow(xin[h], row);
3079 std::string message =
3080 "ERROR: The " + boost::lexical_cast<std::string>(-info) +
3081 "th parameter had an illegal parameter for dgetrf";
3086 std::string message =
3087 "ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
3088 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
3093 Lapack::Dgetrs(
'N', N, ncolumns_b,
A.get(), N, ipivot.get(), b.get(), N,
3097 std::string message =
3098 "ERROR: The " + boost::lexical_cast<std::string>(-info) +
3099 "th parameter had an illegal parameter for dgetrf";
3104 std::string message =
3105 "ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
3106 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
3115 for (
int j = 0; j < N; j++)
3117 b[j] = tmp[cnt - 1];
3121 for (
int h = 0; h < N; h++)
3123 cout <<
"coeff:" << b[h] << endl;
3128 for (
int c = 0; c < npout; c++)
3130 polorder = polyorder;
3133 for (
int d = 0; d < N; d++)
3136 fout[c] += b[d] * std::pow(xout[c], polorder);
3159 for (
int w = 0; w < tmpx.size(); w++)
3162 outarray_x[w] = tmpx[index];
3163 outarray_y[w] = tmpy[index];
3164 if (w < tmpx.size() - 1)
3166 if (tmpx[index] == tmpx[index + 1])
3168 outarray_x[w + 1] = tmpx[index + 1];
3169 outarray_y[w + 1] = tmpy[index + 1];
3170 tmpx[index + 1] = max + 1000;
3186 tmpx[index] = max + 1000;
3199 int np_lay = layers_y[0].size();
3201 for (
int h = 1; h < nlays - 1; h++)
3204 for (
int s = 0; s < nvertl; s++)
3207 ASSERTL0(ynew[lay_Vids[h][s]] == -20,
"ynew layers not empty");
3211 ynew[lay_Vids[h][s]] =
3213 h *
abs(ynew[Down[s]] - yc[s]) / (cntlow + 1);
3215 xnew[lay_Vids[h][s]] = xc[s];
3219 layers_y[h][s] = ynew[lay_Vids[h][s]];
3220 layers_x[h][s] = xnew[lay_Vids[h][s]];
3225 ynew[lay_Vids[h][s]] = yc[s] + (h - cntlow) *
3226 abs(ynew[Up[s]] - yc[s]) /
3229 xnew[lay_Vids[h][s]] = xc[s];
3231 layers_y[h][s] = ynew[lay_Vids[h][s]];
3232 layers_x[h][s] = xnew[lay_Vids[h][s]];
3246 int np_lay = xcPhys.size();
3247 int nedges = nvertl - 1;
3254 int closepoints = 4;
3259 for (
int g = 0; g < nedges; g++)
3268 Pxinterp, Pyinterp);
3269 xnew[Vids[g]] = xcPhys[g * npedge + 0];
3270 ylay[g * npedge + 0] = ynew[Vids[g]];
3271 xlay[g * npedge + 0] = xnew[Vids[g]];
3281 xcPhys[g * npedge + npedge - 1], closepoints, Pxinterp, Pyinterp);
3282 xnew[Vids[g + 1]] = xcPhys[g * npedge + npedge - 1];
3283 ylay[g * npedge + npedge - 1] = ynew[Vids[g + 1]];
3284 xlay[g * npedge + npedge - 1] = xnew[Vids[g + 1]];
3287 for (
int r = 0; r < npedge - 2; r++)
3294 ASSERTL0(index <= tmpy.size() - 1,
" index wrong");
3300 xcPhys[g * npedge + r + 1], closepoints, Pxinterp, Pyinterp);
3302 xlay[g * npedge + r + 1] = xcPhys[g * npedge + r + 1];
3323 int np_lay = xcPhys.size();
3324 int nedges = nvertl - 1;
3332 int closepoints = 4;
3337 for (
int g = 0; g < nedges; g++)
3341 ynew[Vids[g]] = tmpy_lay[g * npedge + 0];
3342 xnew[Vids[g]] = tmpx_lay[g * npedge + 0];
3344 ylay[g * npedge + 0] = ynew[Vids[g]];
3345 xlay[g * npedge + 0] = xnew[Vids[g]];
3348 ynew[Vids[g + 1]] = tmpy_lay[g * npedge + npedge - 1];
3349 xnew[Vids[g + 1]] = tmpx_lay[g * npedge + npedge - 1];
3350 ylay[g * npedge + npedge - 1] = ynew[Vids[g + 1]];
3351 xlay[g * npedge + npedge - 1] = xnew[Vids[g + 1]];
3354 for (
int r = 0; r < npedge - 2; r++)
3356 x0 = xlay[g * npedge + 0];
3357 x1 = xlay[g * npedge + npedge - 1];
3358 xtmp = x0 + r * (x1 - x0) / (npedge - 1);
3363 ASSERTL0(index <= tmpy.size() - 1,
" index wrong");
3368 ylay[g * npedge + r + 1] =
3371 xlay[g * npedge + r + 1] = xtmp;
3385 boost::ignore_unused(xolddown, xoldup);
3388 int nvertl = ycold.size();
3389 int nVertTot = mesh->GetNvertices();
3390 for (
int n = 0; n < nVertTot; n++)
3395 vertex->GetCoords(x, y, z);
3400 for (
int k = 0; k < nvertl; k++)
3402 if (
abs(x - xcold[k]) < tmp)
3404 tmp =
abs(x - xcold[k]);
3416 nplay_closer = (qp_closer - 1) * npedge + npedge - 1;
3419 if (y > yoldup[qp_closer] && y < 1)
3425 ratio = (1 - ylayup[nplay_closer]) / ((1 - yoldup[qp_closer]));
3427 ynew[n] = ylayup[nplay_closer] + (y - yoldup[qp_closer]) * ratio;
3430 else if (y < yolddown[qp_closer] && y > -1)
3433 ratio = (1 + ylaydown[nplay_closer]) / ((1 + yolddown[qp_closer]));
3436 ylaydown[nplay_closer] + (y - yolddown[qp_closer]) * ratio;
3452 boost::ignore_unused(xcold, ycold);
3468 int nvertl = xoldup.size();
3469 int nedges = nvertl - 1;
3478 for (
int a = 0; a < nedges; a++)
3483 xnew_down[a] = xlaydown[a * npedge + 0];
3484 ynew_down[a] = ylaydown[a * npedge + 0];
3485 xnew_up[a] = xlayup[a * npedge + 0];
3486 ynew_up[a] = ylayup[a * npedge + 0];
3487 nxvert[a] = nxPhys[a * npedge + 0];
3488 nyvert[a] = nyPhys[a * npedge + 0];
3490 xnew_down[a + 1] = xlaydown[a * npedge + npedge - 1];
3491 ynew_down[a + 1] = ylaydown[a * npedge + npedge - 1];
3492 xnew_up[a + 1] = xlayup[a * npedge + npedge - 1];
3493 ynew_up[a + 1] = ylayup[a * npedge + npedge - 1];
3494 nxvert[a + 1] = nxPhys[a * npedge + npedge - 1];
3495 nyvert[a + 1] = nyPhys[a * npedge + npedge - 1];
3500 xnew_down[a + 1] = xlaydown[a * npedge + npedge - 1];
3501 ynew_down[a + 1] = ylaydown[a * npedge + npedge - 1];
3502 xnew_up[a + 1] = xlayup[a * npedge + npedge - 1];
3503 ynew_up[a + 1] = ylayup[a * npedge + npedge - 1];
3504 nxvert[a + 1] = nxPhys[a * npedge + npedge - 1];
3505 nyvert[a + 1] = nyPhys[a * npedge + npedge - 1];
3516 int nVertTot = mesh->GetNvertices();
3517 for (
int n = 0; n < nVertTot; n++)
3522 vertex->GetCoords(x, y, z);
3523 int qp_closeroldup = 0, qp_closerolddown = 0;
3529 for (
int k = 0; k < nvertl; k++)
3531 if (
abs(x - xolddown[k]) < diffdown)
3533 diffdown =
abs(x - xolddown[k]);
3534 qp_closerolddown = k;
3536 if (
abs(x - xoldup[k]) < diffup)
3538 diffup =
abs(x - xoldup[k]);
3547 int qp_closerup = 0, qp_closerdown = 0;
3549 for (
int f = 0; f < nvertl; f++)
3551 if (
abs(x - xnew_down[f]) < diffdown)
3553 diffdown =
abs(x - xnew_down[f]);
3556 if (
abs(x - xnew_up[f]) < diffup)
3558 diffup =
abs(x - xnew_up[f]);
3585 int qp_closernormup;
3596 int qp_closernormdown;
3604 if (y > yoldup[qp_closeroldup] && y < 1)
3610 ratio = (1 - ynew_up[qp_closerup]) / ((1 - yoldup[qp_closeroldup]));
3616 ynew_up[qp_closerup] + (y - yoldup[qp_closeroldup]) * ratio;
3624 if (x > (xmax - xmin) / 2. && x < xmax)
3626 ratiox = (xmax - xnew_up[qp_closernormup]) /
3627 (xmax - xoldup[qp_closernormup]);
3628 if ((xmax - xoldup[qp_closernormup]) == 0)
3636 x +
abs(nxvert[qp_closernormup]) *
3637 (xnew_up[qp_closeroldup] - xoldup[qp_closeroldup]) *
3639 ASSERTL0(x > xmin,
" x value <xmin up second half");
3640 ASSERTL0(x < xmax, " x value >xmax up second half
");
3642 else if (x > xmin && x <= (xmax - xmin) / 2.)
3644 // cout<<"up close normold=
"<<qp_closernormoldup<<"
3646 ratiox = (xnew_up[qp_closernormup] - xmin) /
3647 ((xoldup[qp_closernormup] - xmin));
3648 if ((xoldup[qp_closernormup] - xmin) == 0)
3655 x +
abs(nxvert[qp_closernormup]) *
3656 (xnew_up[qp_closeroldup] - xoldup[qp_closeroldup]) *
3659 ASSERTL0(x > xmin,
" x value <xmin up first half");
3660 ASSERTL0(x < xmax, " x value >xmax up first half
");
3663 else if (y < yolddown[qp_closerolddown] && y > -1)
3666 ratio = (1 + ynew_down[qp_closerdown]) /
3667 ((1 + yolddown[qp_closerolddown]));
3669 // ratioy = (1-ynew_down[qp_closernormdown])/
3670 // ( (1-yolddown[qp_closernormolddown]) );
3672 // distance prop to layerlow
3673 ynew[n] = ynew_down[qp_closerdown] +
3674 (y - yolddown[qp_closerolddown]) * ratio;
3675 // ynew[n] = y +abs(nyvert[qp_closernormdown])*
3676 // (ynew_down[qp_closerolddown]-yolddown[qp_closerolddown])*ratioy;
3678 // 0.3*(ynew_down[qp_closerdown]-yolddown[qp_closerdown]); xnew[n] =
3680 // abs(nxvert[qp_closerolddown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown]);
3684 cout<<qp_closerolddown<<" nplaydown=
"<<qp_closerdown<<endl;
3685 cout<<"xolddown=
"<<xolddown[qp_closerolddown]<<"
3686 xnewdown=
"<<xnew_down[qp_closerdown]<<endl; cout<<"xold+
"<<x<<"
3687 xnew+
"<<xnew[n]<<endl;
3691 if (x > (xmax - xmin) / 2. && x < xmax)
3693 ratiox = (xmax - xnew_down[qp_closernormdown]) /
3694 ((xmax - xolddown[qp_closernormdown]));
3695 if ((xmax - xolddown[qp_closernormdown]) == 0)
3699 // xnew[n] = xnew_down[qp_closerdown]
3700 // + (x-xolddown[qp_closerolddown])*ratiox;
3701 xnew[n] = x + abs(nxvert[qp_closernormdown]) *
3702 (xnew_down[qp_closerolddown] -
3703 xolddown[qp_closerolddown]) *
3705 ASSERTL0(x > xmin, " x value <xmin down second half
");
3706 ASSERTL0(x < xmax, " x value >xmax down second half
");
3708 else if (x > xmin && x <= (xmax - xmin) / 2.)
3710 ratiox = (xnew_down[qp_closernormdown] - xmin) /
3711 ((xolddown[qp_closernormdown] - xmin));
3712 if ((xolddown[qp_closernormdown] - xmin) == 0)
3716 // xnew[n] = xnew_down[qp_closerdown]
3717 // + (x-xolddown[qp_closerolddown])*ratiox;
3718 xnew[n] = x + abs(nxvert[qp_closernormdown]) *
3719 (xnew_down[qp_closerolddown] -
3720 xolddown[qp_closerolddown]) *
3722 ASSERTL0(x > xmin, " x value <xmin down first half
");
3723 ASSERTL0(x < xmax, " x value >xmax down first half
");
3727 cout << "xold
" << x << " xnew=
" << xnew[n] << endl;
3728 ASSERTL0(xnew[n] >= xmin, "newx < xmin
");
3729 ASSERTL0(xnew[n] <= xmax, "newx > xmax
");
3734 void CheckSingularQuads(MultiRegions::ExpListSharedPtr Exp, Array<OneD, int> V1,
3735 Array<OneD, int> V2, Array<OneD, NekDouble> &xnew,
3736 Array<OneD, NekDouble> &ynew)
3738 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D = Exp->GetExp();
3739 int nel = exp2D->size();
3740 LocalRegions::QuadExpSharedPtr locQuadExp;
3741 LocalRegions::TriExpSharedPtr locTriExp;
3742 SpatialDomains::Geometry1DSharedPtr SegGeom;
3744 NekDouble xV1, yV1, xV2, yV2;
3745 NekDouble slopebef = 0.0, slopenext = 0.0, slopenew = 0.0;
3746 Array<OneD, int> locEids(4);
3747 for (int i = 0; i < nel; i++)
3749 if ((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
3751 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(0);
3752 idbef = SegGeom->GetGlobalID();
3753 if (xnew[V1[idbef]] <= xnew[V2[idbef]])
3755 xV1 = xnew[V1[idbef]];
3756 yV1 = ynew[V1[idbef]];
3757 xV2 = xnew[V2[idbef]];
3758 yV2 = ynew[V2[idbef]];
3759 slopebef = (yV2 - yV1) / (xV2 - xV1);
3763 xV1 = xnew[V2[idbef]];
3764 yV1 = ynew[V2[idbef]];
3765 xV2 = xnew[V1[idbef]];
3766 yV2 = ynew[V1[idbef]];
3767 slopebef = (yV2 - yV1) / (xV2 - xV1);
3769 // cout<<"00 V1 x=
"<<xnew[ V1[idbef] ]<<" y=
"<<ynew[ V1[idbef]
3770 // ]<<endl; cout<<"00 V2 x=
"<<xnew[ V2[idbef] ]<<" y=
"<<ynew[
3771 // V2[idbef] ]<<endl;
3772 for (int j = 1; j < locQuadExp->GetNtraces(); ++j)
3774 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
3775 idnext = SegGeom->GetGlobalID();
3776 // cout<<"id=
"<<idnext<<" locid=
"<<j<<endl;
3777 // cout<<" V1 x=
"<<xnew[ V1[idnext] ]<<" y=
"<<ynew[
3778 // V1[idnext] ]<<endl; cout<<" V2 x=
"<<xnew[ V2[idnext] ]<<"
3780 if (xV1 == xnew[V1[idnext]] && yV1 == ynew[V1[idnext]])
3782 xV1 = xnew[V1[idnext]];
3783 yV1 = ynew[V1[idnext]];
3784 xV2 = xnew[V2[idnext]];
3785 yV2 = ynew[V2[idnext]];
3786 slopenext = (yV2 - yV1) / (xV2 - xV1);
3789 cout <<
"case1 x0=" << xV1 <<
" x1=" << xV2 << endl;
3790 cout << idnext <<
" 11slope bef =" << slopebef
3791 <<
" slopenext=" << slopenext << endl;
3794 if (slopebef / slopenext > 0.84 &&
3795 slopebef / slopenext < 1.18)
3797 xnew[V1[idnext]] = xnew[V1[idnext]] - 0.01;
3798 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3800 if (
abs(slopebef - slopenew) <
3801 abs(slopebef - slopenext))
3803 xnew[V1[idnext]] = xnew[V1[idnext]] + 0.02;
3804 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3806 slopenext = slopenew;
3807 cout <<
"slopenew=" << slopenew << endl;
3808 cout <<
"moved x=" << xnew[V1[idnext]] << endl;
3811 else if (xV2 == xnew[V2[idnext]] && yV2 == ynew[V2[idnext]])
3813 xV1 = xnew[V2[idnext]];
3814 yV1 = ynew[V2[idnext]];
3815 xV2 = xnew[V1[idnext]];
3816 yV2 = ynew[V1[idnext]];
3817 slopenext = (yV2 - yV1) / (xV2 - xV1);
3820 cout <<
"case2 x0=" << xV1 <<
" x1=" << xV2 << endl;
3821 cout << idnext <<
" 22slope bef =" << slopebef
3822 <<
" slopenext=" << slopenext << endl;
3825 if (slopebef / slopenext > 0.84 &&
3826 slopebef / slopenext < 1.18)
3828 xnew[V2[idnext]] = xnew[V2[idnext]] - 0.01;
3829 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3831 if (
abs(slopebef - slopenew) <
3832 abs(slopebef - slopenext))
3834 xnew[V2[idnext]] = xnew[V2[idnext]] + 0.02;
3835 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3837 slopenext = slopenew;
3838 cout <<
"slopenew=" << slopenew << endl;
3839 cout <<
"moved x=" << xnew[V2[idnext]] << endl;
3842 else if (xV1 == xnew[V2[idnext]] && yV1 == ynew[V2[idnext]])
3844 xV1 = xnew[V2[idnext]];
3845 yV1 = ynew[V2[idnext]];
3846 xV2 = xnew[V1[idnext]];
3847 yV2 = ynew[V1[idnext]];
3848 slopenext = (yV2 - yV1) / (xV2 - xV1);
3851 cout <<
"case3 x0=" << xV1 <<
" x1=" << xV2 << endl;
3852 cout << idnext <<
" 22slope bef =" << slopebef
3853 <<
" slopenext=" << slopenext << endl;
3856 if (slopebef / slopenext > 0.84 &&
3857 slopebef / slopenext < 1.18)
3859 xnew[V2[idnext]] = xnew[V2[idnext]] - 0.01;
3860 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3862 if (
abs(slopebef - slopenew) <
3863 abs(slopebef - slopenext))
3865 xnew[V2[idnext]] = xnew[V2[idnext]] + 0.02;
3866 slopenew = (yV2 - yV1) / (xV2 - xnew[V2[idnext]]);
3868 slopenext = slopenew;
3869 cout <<
"slopenew=" << slopenew << endl;
3870 cout <<
"moved x=" << xnew[V2[idnext]] << endl;
3873 else if (xV2 == xnew[V1[idnext]] && yV2 == ynew[V1[idnext]])
3875 xV1 = xnew[V1[idnext]];
3876 yV1 = ynew[V1[idnext]];
3877 xV2 = xnew[V2[idnext]];
3878 yV2 = ynew[V2[idnext]];
3879 slopenext = (yV2 - yV1) / (xV2 - xV1);
3882 cout <<
"case4 x0=" << xV1 <<
" x1=" << xV2 << endl;
3883 cout << idnext <<
" 22slope bef =" << slopebef
3884 <<
" slopenext=" << slopenext << endl;
3887 if (slopebef / slopenext > 0.84 &&
3888 slopebef / slopenext < 1.18)
3890 xnew[V1[idnext]] = xnew[V1[idnext]] - 0.01;
3891 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3893 if (
abs(slopebef - slopenew) <
3894 abs(slopebef - slopenext))
3896 xnew[V1[idnext]] = xnew[V1[idnext]] + 0.02;
3897 slopenew = (yV2 - yV1) / (xV2 - xnew[V1[idnext]]);
3899 slopenext = slopenew;
3900 cout <<
"slopenew=" << slopenew << endl;
3901 cout <<
"moved x=" << xnew[V1[idnext]] << endl;
3906 ASSERTL0(
false,
"edge not connected");
3908 slopebef = slopenext;
3917 int Npoints,
string s_alp,
3924 TiXmlDocument doc(filename);
3926 TiXmlElement *master = doc.FirstChildElement(
"NEKTAR");
3927 TiXmlElement *mesh = master->FirstChildElement(
"GEOMETRY");
3928 TiXmlElement *element = mesh->FirstChildElement(
"VERTEX");
3931 const char *xscal = element->Attribute(
"XSCALE");
3934 std::string xscalstr = xscal;
3936 xscale = expEvaluator.
Evaluate(expr_id);
3940 newfile = filename.substr(0, filename.find_last_of(
".")) +
"_moved.xml";
3941 doc.SaveFile(newfile);
3944 TiXmlDocument docnew(newfile);
3945 bool loadOkaynew = docnew.LoadFile();
3947 std::string errstr =
"Unable to load file: ";
3949 ASSERTL0(loadOkaynew, errstr.c_str());
3951 TiXmlHandle docHandlenew(&docnew);
3952 TiXmlElement *meshnew = NULL;
3953 TiXmlElement *masternew = NULL;
3954 TiXmlElement *condnew = NULL;
3955 TiXmlElement *Parsnew = NULL;
3956 TiXmlElement *parnew = NULL;
3960 masternew = docnew.FirstChildElement(
"NEKTAR");
3961 ASSERTL0(masternew,
"Unable to find NEKTAR tag in file.");
3965 condnew = masternew->FirstChildElement(
"CONDITIONS");
3966 Parsnew = condnew->FirstChildElement(
"PARAMETERS");
3967 cout <<
"alpha=" << s_alp << endl;
3968 parnew = Parsnew->FirstChildElement(
"P");
3971 TiXmlNode *node = parnew->FirstChild();
3975 std::string line = node->ToText()->Value();
3979 int beg = line.find_first_not_of(
" ");
3980 int end = line.find_first_of(
"=");
3985 if (end != line.find_last_of(
"="))
3988 if (end == std::string::npos)
3990 lhs = line.substr(line.find_first_not_of(
" "), end - beg);
3991 lhs = lhs.substr(0, lhs.find_last_not_of(
" ") + 1);
3997 boost::to_upper(lhs);
4000 alphastring =
"Alpha = " + s_alp;
4001 parnew->RemoveChild(node);
4002 parnew->LinkEndChild(
new TiXmlText(alphastring));
4006 parnew = parnew->NextSiblingElement(
"P");
4010 meshnew = masternew->FirstChildElement(
"GEOMETRY");
4012 ASSERTL0(meshnew,
"Unable to find GEOMETRY tag in file.");
4014 TiXmlElement *elementnew = meshnew->FirstChildElement(
"VERTEX");
4015 ASSERTL0(elementnew,
"Unable to find mesh VERTEX tag in file.");
4019 elementnew->SetAttribute(
"XSCALE", 1.0);
4021 TiXmlElement *vertexnew = elementnew->FirstChildElement(
"V");
4025 int nextVertexNumber = -1;
4031 TiXmlAttribute *vertexAttr = vertexnew->FirstAttribute();
4032 std::string attrName(vertexAttr->Name());
4034 (std::string(
"Unknown attribute name: ") + attrName).c_str());
4036 err = vertexAttr->QueryIntValue(&indx);
4037 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
4039 "Vertex IDs must begin with zero and be sequential.");
4041 std::string vertexBodyStr;
4043 TiXmlNode *vertexBody = vertexnew->FirstChild();
4045 if (vertexBody->Type() == TiXmlNode::TINYXML_TEXT)
4047 vertexBodyStr += vertexBody->ToText()->Value();
4048 vertexBodyStr +=
" ";
4051 "Vertex definitions must contain vertex data.");
4053 vertexnew->RemoveChild(vertexBody);
4060 s << std::scientific << std::setprecision(8) << newx[nextVertexNumber]
4061 <<
" " << newy[nextVertexNumber] <<
" " << 0.0;
4062 vertexnew->LinkEndChild(
new TiXmlText(s.str()));
4067 vertexnew = vertexnew->NextSiblingElement(
"V");
4071 TiXmlElement *curvednew = meshnew->FirstChildElement(
"CURVED");
4072 ASSERTL0(curvednew,
"Unable to find mesh CURVED tag in file.");
4073 TiXmlElement *edgenew = curvednew->FirstChildElement(
"E");
4076 std::string charindex;
4080 int neids_lay = lay_eids[0].size();
4087 TiXmlAttribute *edgeAttr = edgenew->FirstAttribute();
4088 std::string attrName(edgeAttr->Name());
4089 charindex = edgeAttr->Value();
4090 std::istringstream iss(charindex);
4091 iss >> std::dec >> index;
4093 edgenew->QueryIntAttribute(
"EDGEID", &eid);
4096 for (
int u = 0; u < Eids.size(); u++)
4106 curvednew->RemoveChild(edgenew);
4112 std::string edgeBodyStr;
4114 TiXmlNode *edgeBody = edgenew->FirstChild();
4115 if (edgeBody->Type() == TiXmlNode::TINYXML_TEXT)
4117 edgeBodyStr += edgeBody->ToText()->Value();
4121 "Edge definitions must contain edge data");
4123 edgenew->RemoveChild(edgeBody);
4130 err = edgenew->QueryIntAttribute(
"NUMPOINTS", &numPts);
4132 "Unable to read curve attribute NUMPOINTS.");
4135 edgenew->SetAttribute(
"NUMPOINTS", Npoints);
4136 for (
int u = 0; u < Npoints; u++)
4138 st << std::scientific << std::setprecision(8)
4139 << xcPhys[cnt * Npoints + u] <<
" "
4140 << ycPhys[cnt * Npoints + u] <<
" " << 0.000 <<
" ";
4143 edgenew->LinkEndChild(
new TiXmlText(st.str()));
4164 edgenew = edgenew->NextSiblingElement(
"E");
4168 if (curv_lay ==
true)
4170 cout <<
"write other curved edges" << endl;
4171 TiXmlElement *curved = meshnew->FirstChildElement(
"CURVED");
4173 int nlays = lay_eids.size();
4178 for (
int g = 0; g < nlays; ++g)
4180 for (
int p = 0;
p < neids_lay;
p++)
4183 TiXmlElement *e =
new TiXmlElement(
"E");
4184 e->SetAttribute(
"ID", idcnt++);
4185 e->SetAttribute(
"EDGEID", lay_eids[g][
p]);
4186 e->SetAttribute(
"NUMPOINTS", Npoints);
4187 e->SetAttribute(
"TYPE",
"PolyEvenlySpaced");
4188 for (
int c = 0; c < Npoints; c++)
4190 st << std::scientific << std::setprecision(8)
4191 << x_lay[g][
p * Npoints + c] <<
" "
4192 << y_lay[g][
p * Npoints + c] <<
" " << 0.000 <<
" ";
4195 TiXmlText *t0 =
new TiXmlText(st.str());
4196 e->LinkEndChild(t0);
4197 curved->LinkEndChild(e);
4202 docnew.SaveFile(newfile);
4204 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 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)