41 #include <boost/core/ignore_unused.hpp>
51 #include <boost/lexical_cast.hpp>
104 int edge,
int npedge);
105 void PolyFit(
int polyorder,
int npoints,
161 int main(
int argc,
char *argv[])
167 if(argc > 6 || argc < 5)
170 "Usage: ./MoveMesh meshfile fieldfile changefile alpha cr(optional)\n");
176 = LibUtilities::SessionReader::CreateInstance(2, argv);
181 vSession->DefinesSolverInfo(
"INTERFACE")
182 && vSession->GetSolverInfo(
"INTERFACE")==
"phase" )
184 cr = boost::lexical_cast<NekDouble>(argv[argc-1]);
202 string changefile(argv[argc-2]);
206 string charalp (argv[argc-1]);
208 cout<<
"read alpha="<<charalp<<endl;
212 string fieldfile(argv[argc-3]);
213 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
214 vector<vector<NekDouble> > fielddata;
223 for(
int i=0; i<fielddata.size(); i++)
225 streak->ExtractDataToCoeffs(fielddef[i], fielddata[i], fielddef[i]->m_fields[0], streak->UpdateCoeffs());
227 streak->BwdTrans_IterPerExp(streak->GetCoeffs(), streak->UpdatePhys());
233 int nIregions, lastIregion=0;
238 int nbnd= bndConditions.size();
239 for(
int r=0; r<nbnd; r++)
241 if(bndConditions[r]->GetUserDefined()==
"CalcBC")
249 ASSERTL0(nIregions>0,
"there is any boundary region with the tag USERDEFINEDTYPE=""CalcBC"" specified");
250 cout<<
"nIregions="<<nIregions<<endl;
255 int nedges = bndfieldx[lastIregion]->GetExpSize();
256 int nvertl = nedges +1 ;
272 ( (bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
277 vertex0->GetCoords(x0,y0,z0);
280 cout<<
"WARNING x0="<<x0<<endl;
286 Vids_low, v1, v2 , x_connect ,lastedge, xold_low,yold_low);
287 ASSERTL0(Vids_low[v2]!=-10,
"Vids_low[v2] is wrong");
291 cout<<
"x_conn="<<x_connect<<
" yt="<<yt<<
" zt="<<zt<<
" vid="<<Vids_low[v2]<<endl;
292 vertex->GetCoords(x_connect,yt,zt);
299 Vids_low, v1, v2 , x_connect, lastedge, xold_low, yold_low );
302 vertex->GetCoords(x_connect,yt,zt);
316 ( (bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
321 vertex0->GetCoords(x0,y0,z0);
324 cout<<
"WARNING x0="<<x0<<endl;
332 Vids_up, v1, v2 , x_connect ,lastedge, xold_up, yold_up);
334 vertexU->GetCoords(x_connect,yt,zt);
341 Vids_up, v1, v2 , x_connect, lastedge, xold_up, yold_up );
345 vertex->GetCoords(x_connect,yt,zt);
357 graphShPt->GetVertex(((bndfieldx[lastIregion]->GetExp(0)
358 ->as<LocalRegions::SegExp>())->GetGeom1D())->GetVid(0));
359 vertex0->GetCoords(x0,y0,z0);
362 cout<<
"WARNING x0="<<x0<<endl;
371 Vids_c, v1, v2 , x_connect ,lastedge, xold_c, yold_c);
375 vertexc->GetCoords(x_connect,yt,zt);
382 Vids_c, v1, v2 , x_connect, lastedge, xold_c, yold_c );
386 vertex->GetCoords(x_connect,yt,zt);
395 for(
int r=0; r<nvertl; r++)
399 Deltaup[r] = yold_up[r] - yold_c[r];
400 Deltalow[r] = yold_c[r] - yold_low[r];
401 ASSERTL0(Deltaup[r]>0,
"distance between upper and layer curve is not positive");
402 ASSERTL0(Deltalow[r]>0,
"distance between lower and layer curve is not positive");
423 if(vSession->DefinesParameter(
"npedge"))
425 npedge = (int)vSession->GetParameter(
"npedge");
433 int nq= streak->GetTotPoints();
436 streak->GetCoords(x,y);
445 xold_low, yold_low, xold_c, yold_c, x_c, y_c,cr,
true);
448 for(
int q=0; q<nvertl; q++)
450 if(y_c[q] < yold_c[q])
455 Delta_c[q] =
abs(yold_c[q]-y_c[q]);
458 cout<<x_c[q]<<
" "<<y_c[q]<<endl;
463 cout<<
"Warning: the critical layer is stationary"<<endl;
486 for(
int r=0; r<nedges; r++)
489 bndSegExp = bndfieldx[lastIregion]->GetExp(r)
491 Eid = (bndSegExp->GetGeom1D())->GetGlobalID();
492 id1 = (bndSegExp->GetGeom1D())->GetVid(0);
493 id2 = (bndSegExp->GetGeom1D())->GetVid(1);
494 vertex1 = graphShPt->GetVertex(id1);
495 vertex2 = graphShPt->GetVertex(id2);
497 vertex2->GetCoords(x2,y2,z2);
500 cout<<
"edge="<<r<<
" x1="<<x1<<
" y1="<<y1<<
" x2="<<x2<<
" y2="<<y2<<endl;
503 Cpointsx[r] = x1 +(x2-x1)/2;
506 if( Cpointsx[r]>x2 || Cpointsx[r]< x1)
508 Cpointsx[r] = -Cpointsx[r];
510 for(
int w=0; w< npedge-2; w++)
513 Addpointsx[r*(npedge-2) +w] = x1 +((x2-x1)/(npedge - 1))*(w+1);
514 if( Addpointsx[r*(npedge-2) +w] > x2 || Addpointsx[r*(npedge-2) +w] < x1)
516 Addpointsx[r*(npedge-2) +w] = -Addpointsx[r*(npedge-2) +w];
519 Addpointsy[r*(npedge-2) +w] = y_c[r] + ((y_c[r+1]-y_c[r])/(x_c[r+1]-x_c[r]))*(Addpointsx[r*(npedge-2) +w]-x1);
522 Addpointsx[r*(npedge-2) +w], Addpointsy[r*(npedge-2) +w], streak, dU,cr);
535 Cpointsx[r] = x2+ (x1-x2)/2;
537 if( Cpointsx[r] > x1 || Cpointsx[r] < x2)
539 Cpointsx[r] = -Cpointsx[r];
541 for(
int w=0; w< npedge-2; w++)
543 Addpointsx[r*(npedge-2) +w] = x2 +((x1-x2)/(npedge - 1))*(w+1);
544 if( Addpointsx[r*(npedge-2) +w] > x1 || Addpointsx[r*(npedge-2) +w] < x2)
546 Addpointsx[r*(npedge-2) +w] = -Addpointsx[r*(npedge-2) +w];
550 Addpointsy[r*(npedge-2) +w] = y_c[r+1] + ((y_c[r]-y_c[r+1])/(x_c[r]-x_c[r+1]))*(Addpointsx[r*(npedge-2) +w]-x2);
554 Addpointsx[r*(npedge-2) +w], Addpointsy[r*(npedge-2) +w], streak, dU,cr);
565 ASSERTL0(
false,
"point not generated");
584 for(
int a=0; a<nedges; a++)
587 xcPhys[a*npedge+0] = x_c[a];
588 ycPhys[a*npedge+0] = y_c[a];
590 xcPhys[a*npedge+npedge-1] = x_c[a+1];
591 ycPhys[a*npedge+npedge-1] = y_c[a+1];
593 for(
int b=0; b<npedge-2; b++)
595 xcPhys[a*npedge +b+1] = Addpointsx[a*(npedge-2)+b];
596 ycPhys[a*npedge +b+1] = Addpointsy[a*(npedge-2)+b];
600 cout<<
"xc,yc before tanevaluate"<<endl;
601 for(
int v=0; v< xcPhys.size(); v++)
603 cout<<xcPhys[v]<<
" "<<ycPhys[v]<<endl;
616 MappingEVids(xold_up, yold_up, xold_low, yold_low, xold_c, yold_c, Vids_c,
617 graphShPt,streak, V1, V2, nlays, lay_Eids, lay_Vids);
621 cout<<
"nlays="<<nlays<<endl;
625 for(
int g=0; g<nlays; g++)
638 if(vSession->DefinesParameter(
"Delta"))
640 Delta0 = vSession->GetParameter(
"Delta");
652 int nVertTot = graphShPt->GetNvertices();
668 for(
int i=0; i<nVertTot; i++)
673 vertex->GetCoords(x,y,z);
683 if(x==0 && y< yold_low[0]
689 if(x== xold_c[nvertl-1] && y> yold_up[nvertl-1]
695 if(x==xold_c[nvertl-1] && y<yold_low[nvertl-1]
701 if(x== 0 && y> yold_up[0]
707 for(
int j=0; j<nvertl; j++)
709 if((xold_up[j]==x)&&(yold_up[j]==y))
713 ynew[i] = y_c[j] +Delta0;
717 if((xold_low[j]==x)&&(yold_low[j]==y))
721 ynew[i] = y_c[j] -Delta0;
725 if((xold_c[j]==x)&&(yold_c[j]==y))
736 for(
int k=0; k<nvertl; k++)
738 if(
abs(x-xold_up[k]) < diff)
740 diff =
abs(x-xold_up[k]);
744 if( y>yold_up[qp_closer] && y< 1)
752 ynew[i] = y_c[qp_closer] +(y-yold_c[qp_closer])*
753 (1-y_c[qp_closer])/(1-yold_c[qp_closer]);
759 else if(y<yold_low[qp_closer] && y> -1)
767 ynew[i] = y_c[qp_closer] + (y-yold_c[qp_closer] )*
768 (-1-y_c[qp_closer])/(-1-yold_c[qp_closer]);
772 else if ( y>yold_c[qp_closer] && y < yold_up[qp_closer])
779 else if (y<yold_c[qp_closer] && y > yold_low[qp_closer])
781 if(x==0){ cntlow++; }
786 else if( y==1 || y==-1)
793 if( (ynew[i]>1 || ynew[i]<-1)
794 && ( y>yold_up[qp_closer] || y<yold_low[qp_closer]) )
796 cout<<
"point x="<<xnew[i]<<
" y="<<y<<
" closer x="<<xold_up[qp_closer]<<
" ynew="<<ynew[i]<<endl;
797 ASSERTL0(
false,
"shifting out of range");
807 int nqedge = streak->GetExp(0)->GetNumPoints(0);
808 int nquad_lay = (nvertl-1)*nqedge;
813 int np_lay = (nvertl-1)*npedge;
823 if( move_norm==
true )
835 cout<<
"nquad per edge="<<nqedge<<endl;
836 for(
int l=0; l<2; l++)
838 Edge_newcoords[l] = bndfieldx[lastIregion]->GetExp(0)
863 bndfieldx[lastIregion]->GetCoords(xcQ, ycQ, zcQ);
872 for(
int l=0; l< xcQ.size(); l++)
882 xcQ[l],4,closex,closey );
895 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffsy);
896 Cont_y->BwdTrans_IterPerExp( coeffsy, Cont_y->UpdatePhys());
899 cout<<
"xcQ, ycQ"<<endl;
900 for(
int s=0; s<xcQ.size(); s++)
902 cout<<xcQ[s]<<
" "<<ycQ[s]<<endl;
905 bool evaluatetan=
false;
909 for(
int k=0; k<nedges; k++)
914 Edge_newcoords[0]->StdPhysDeriv(xcedgeQ,txedgeQ);
915 Edge_newcoords[1]->StdPhysDeriv(ycedgeQ,tyedgeQ);
919 Vmath::Vvtvp(nqedge,tyedgeQ,1,tyedgeQ,1,normsQ,1,normsQ,1);
934 for(
int u=0; u<nqedge-1; u++)
936 incratio = (ycedgeQ[u+1]- ycedgeQ[u])/(xcedgeQ[u+1]- xcedgeQ[u]);
937 cout<<
"incratio="<<incratio<<endl;
938 if(
abs(incratio)> 4.0 && evaluatetan==false )
940 cout<<
"wrong="<<wrong<<endl;
942 ASSERTL0(wrong<2,
"number edges to change is too high!!");
950 cout<<
"tan bef"<<endl;
951 for(
int e=0; e< nqedge; e++)
953 cout<<xcedgeQ[e]<<
" "<<ycedgeQ[e]<<
" "<<txedgeQ[e]<<endl;
961 Vmath::Vcopy(npedge, &xcPhysMOD[k*npedge+0],1,&xPedges[0],1);
962 Vmath::Vcopy(npedge, &ycPhysMOD[k*npedge+0],1,&yPedges[0],1);
964 PolyFit(polyorder,nqedge, xcedgeQ,ycedgeQ, coeffsinterp, xPedges,yPedges, npedge);
966 Vmath::Vcopy(npedge, &xPedges[0],1, &xcPhysMOD[k*npedge+0],1);
967 Vmath::Vcopy(npedge, &yPedges[0],1, &ycPhysMOD[k*npedge+0],1);
974 Vmath::Vcopy(nqedge, &(txedgeQ[0]), 1, &(txQ[nqedge*k]),1);
975 Vmath::Vcopy(nqedge, &(tyedgeQ[0]), 1, &(tyQ[nqedge*k]),1);
980 for(
int w=0; w< fz.size(); w++)
982 txQ[w] = cos(atan(fz[w]));
983 tyQ[w] = sin(atan(fz[w]));
984 cout<<xcQ[w]<<
" "<<ycQ[w]<<
" "<<fz[w]<<endl;
990 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffsy);
991 Cont_y->BwdTrans_IterPerExp( coeffsy, Cont_y->UpdatePhys());
995 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffsy);
996 Cont_y->BwdTrans_IterPerExp( coeffsy, Cont_y->UpdatePhys());
1008 for(
int q=0; q<2; q++)
1010 edgebef = edgeinterp[q]-1;
1011 incbefore = (txQ[edgebef*nqedge+nqedge-1]-txQ[edgebef*nqedge])/
1012 (xcQ[edgebef*nqedge+nqedge-1]-xcQ[edgebef*nqedge]);
1013 inc = (txQ[edgeinterp[q]*nqedge+nqedge-1]-txQ[edgeinterp[q]*nqedge])/
1014 (xcQ[edgeinterp[q]*nqedge+nqedge-1]-xcQ[edgeinterp[q]*nqedge]);
1015 int npoints = 2*nqedge;
1021 cout<<
"inc="<<inc<<
" incbef="<<incbefore<<endl;
1022 if( (inc/incbefore)>0. )
1024 cout<<
"before!!"<<edgebef<<endl;
1027 Vmath::Vcopy(npoints, &xcQ[edgebef*nqedge+0],1,&xQedges[0],1);
1028 Vmath::Vcopy(npoints, &ycQ[edgebef*nqedge+0],1,&yQedges[0],1);
1029 Vmath::Vcopy(npoints, &txQ[edgebef*nqedge+0],1,&txQedges[0],1);
1030 Vmath::Vcopy(npoints, &tyQ[edgebef*nqedge+0],1,&tyQedges[0],1);
1034 coeffsinterp, xQedges,txQedges, npoints);
1037 Vmath::Vcopy(npoints,&txQedges[0],1, &txQ[edgebef*nqedge+0],1);
1041 coeffsinterp, xQedges,tyQedges, npoints);
1044 Vmath::Vcopy(npoints,&tyQedges[0],1, &tyQ[edgebef*nqedge+0],1);
1049 cout<<
"after!!"<<endl;
1052 Vmath::Vcopy(npoints, &xcQ[edgeinterp[q]*nqedge+0],1,&xQedges[0],1);
1053 Vmath::Vcopy(npoints, &ycQ[edgeinterp[q]*nqedge+0],1,&yQedges[0],1);
1054 Vmath::Vcopy(npoints, &txQ[edgeinterp[q]*nqedge+0],1,&txQedges[0],1);
1055 Vmath::Vcopy(npoints, &tyQ[edgeinterp[q]*nqedge+0],1,&tyQedges[0],1);
1060 coeffsinterp, xQedges,txQedges, npoints);
1063 Vmath::Vcopy(npoints,&txQedges[0],1, &txQ[edgeinterp[q]*nqedge+0],1);
1067 coeffsinterp, xQedges,tyQedges, npoints);
1070 Vmath::Vcopy(npoints,&tyQedges[0],1, &tyQ[edgeinterp[q]*nqedge+0],1);
1079 Vmath::Vcopy(nquad_lay, tyQ,1, Cont_y->UpdatePhys(),1);
1080 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffstmp);
1081 Cont_y->BwdTrans_IterPerExp( coeffstmp, Cont_y->UpdatePhys());
1084 Vmath::Vcopy(nquad_lay, txQ,1, Cont_y->UpdatePhys(),1);
1085 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffstmp);
1086 Cont_y->BwdTrans_IterPerExp( coeffstmp, Cont_y->UpdatePhys());
1089 for(
int k=0; k<nedges; k++)
1097 Vmath::Vcopy(nqedge, &(txQ[nqedge*k]),1, &(txedgeQ[0]), 1);
1098 Vmath::Vcopy(nqedge, &(tyQ[nqedge*k]),1, &(tyedgeQ[0]), 1);
1100 Vmath::Vdiv(nqedge, txedgeQ,1,tyedgeQ,1,tx_tyedgeQ,1);
1101 Vmath::Vmul(nqedge, tx_tyedgeQ,1,tx_tyedgeQ,1,tx_tyedgeQ,1);
1107 Vmath::Vcopy(nqedge, &(nxedgeQ[0]),1, &(nxQ[nqedge*k]),1);
1109 Vmath::Vmul(nqedge, nxedgeQ,1,nxedgeQ,1,nyedgeQ,1);
1115 Vmath::Vcopy(nqedge, &(nyedgeQ[0]), 1, &(nyQ[nqedge*k]),1);
1118 cout<<
"edge:"<<k<<endl;
1119 cout<<
"tan/normal"<<endl;
1120 for(
int r=0; r<nqedge; r++)
1122 cout<<xcQ[k*nqedge+r]<<
" "<<txedgeQ[r]<<
" "<<tyedgeQ[r]<<
" "
1123 <<nxedgeQ[r]<<
" "<<nyedgeQ[r]<<endl;
1129 Vmath::Vcopy(nquad_lay, nyQ,1, Cont_y->UpdatePhys(),1);
1131 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffstmp);
1132 Cont_y->BwdTrans_IterPerExp( coeffstmp, Cont_y->UpdatePhys());
1136 Vmath::Zero(Cont_y->GetNcoeffs(),Cont_y->UpdateCoeffs(),1);
1137 Vmath::Vcopy(nquad_lay, nxQ,1, Cont_y->UpdatePhys(),1);
1138 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffstmp);
1139 Cont_y->BwdTrans_IterPerExp( coeffstmp, Cont_y->UpdatePhys());
1143 for(
int k=0; k<nedges; k++)
1149 nyQ[(k-1)*nqedge+nqedge-1]=
1154 nxQ[(k-1)*nqedge+nqedge-1]=
1163 cout<<
"nx,yQbefore"<<endl;
1164 for(
int u=0; u<xcQ.size(); u++)
1166 cout<<xcQ[u]<<
" "<<nyQ[u]<<
" "<<txQ[u]<<endl;
1172 cout<<
"nx,yQ"<<endl;
1173 for(
int u=0; u<x_tmpQ.size(); u++)
1175 cout<<x_tmpQ[u]<<
" "<<tmpnyQ[u]<<endl;
1179 for(
int k=0; k<nedges; k++)
1182 for(
int a=0; a<npedge; a++)
1186 nxPhys[k*npedge +a]= nxQ[k*nqedge +0];
1187 nyPhys[k*npedge +a]= nyQ[k*nqedge +0];
1190 else if(a== npedge-1)
1192 nxPhys[k*npedge +a]= nxQ[k*nqedge +nqedge-1];
1193 nyPhys[k*npedge +a]= nyQ[k*nqedge +nqedge-1];
1217 nyPhys[k*npedge +a]=
1227 nxPhys[k*npedge +a]= -
sqrt(
abs(1- nyPhys[k*npedge +a]*nyPhys[k*npedge +a]));
1243 nyPhys[(k-1)*npedge+npedge-1]=
1248 nxPhys[(k-1)*npedge+npedge-1]=
1253 cout<<
"xcPhys,,"<<endl;
1254 for(
int s=0; s<np_lay; s++)
1257 cout<<xcPhysMOD[s]<<
" "<<ycPhysMOD[s]<<
" "<<nxPhys[s]<<
" "<<nyPhys[s]<<endl;
1270 for(
int m=0; m<nlays; m++)
1277 delta[m] = -(cntlow+1-m)*Delta0/(cntlow+1);
1281 delta[m] = ( m-(cntlow) )*Delta0/(cntlow+1);
1288 for(
int h=0; h< nvertl; h++)
1295 if(move_norm==
false)
1297 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m];
1298 xnew[lay_Vids[m][h] ]= x_c[h];
1302 if(h==0 || h==nvertl-1 )
1304 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m];
1305 xnew[lay_Vids[m][h] ]= x_c[h];
1309 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m]*
abs(nyPhys[h*npedge+0]);
1310 xnew[lay_Vids[m][h] ]= x_c[h] +delta[m]*
abs(nxPhys[h*npedge+0]);
1313 cout<<
"Vid x="<<xnew[lay_Vids[m][h] ]<<
" y="<<ynew[lay_Vids[m][h] ]<<endl;
1318 cout<<
"edge=="<<h<<endl;
1321 ASSERTL0( nyPhys[h*npedge+0]==nyPhys[(h-1)*npedge+npedge-1],
" normaly wrong");
1322 ASSERTL0( nxPhys[h*npedge+0]==nxPhys[(h-1)*npedge+npedge-1],
" normalx wrong");
1325 if(move_norm==
false)
1328 layers_y[m][h*npedge +0] = y_c[h] +delta[m];
1329 layers_x[m][h*npedge +0] = xnew[lay_Vids[m][h] ];
1331 layers_y[m][h*npedge +npedge-1] = y_c[h+1] +delta[m];
1332 layers_x[m][h*npedge +npedge-1] = xnew[lay_Vids[m][h+1] ];
1334 for(
int d=0; d< npedge-2; d++)
1336 layers_y[m][h*npedge +d+1]= ycPhysMOD[h*npedge +d+1] +delta[m];
1338 layers_x[m][h*npedge +d+1]= xcPhysMOD[h*npedge +d+1];
1347 tmpy_lay[h*npedge +0] = y_c[h] +delta[m];
1348 tmpx_lay[h*npedge +0] = xnew[lay_Vids[m][h] ];
1350 tmpy_lay[h*npedge +npedge-1] =
1351 y_c[h+1] +delta[m]*
abs(nyPhys[h*npedge +npedge-1]);
1352 tmpx_lay[h*npedge +npedge-1] =
1353 x_c[h+1] +delta[m]*
abs(nxPhys[h*npedge +npedge-1]);
1355 else if(h==nedges-1)
1358 tmpy_lay[h*npedge +0] =
1359 y_c[h] +delta[m]*
abs(nyPhys[h*npedge +0]);
1360 tmpx_lay[h*npedge +0] =
1361 x_c[h] +delta[m]*
abs(nxPhys[h*npedge +0]);
1363 tmpy_lay[h*npedge +npedge-1] = y_c[h+1] +delta[m];
1364 tmpx_lay[h*npedge +npedge-1] = xnew[lay_Vids[m][h+1] ];
1369 tmpy_lay[h*npedge +0] =
1370 y_c[h] +delta[m]*
abs(nyPhys[h*npedge +0]);
1371 tmpx_lay[h*npedge +0] =
1372 x_c[h] +delta[m]*
abs(nxPhys[h*npedge +0]);
1374 tmpy_lay[h*npedge +npedge-1] =
1375 y_c[h+1] +delta[m]*
abs(nyPhys[h*npedge +npedge-1]);
1376 tmpx_lay[h*npedge +npedge-1] =
1377 x_c[h+1] +delta[m]*
abs(nxPhys[h*npedge +npedge-1]);
1381 for(
int d=0; d< npedge-2; d++)
1384 tmpy_lay[h*npedge +d+1] = ycPhysMOD[h*npedge +d+1] +
1385 delta[m]*
abs(nyPhys[h*npedge +d+1]);
1388 tmpx_lay[h*npedge +d+1]= xcPhysMOD[h*npedge +d+1] +
1389 delta[m]*
abs(nxPhys[h*npedge +d+1]);
1406 for(
int s=0; s<np_lay; s++)
1408 cout<<tmpx_lay[s]<<
" "<<tmpy_lay[s]<<endl;
1411 cout<<
"fisrt interp"<<endl;
1412 for(
int s=0; s<np_lay; s++)
1414 cout<<tmpx_lay[s]<<
" "<<tmpy_lay[s]<<endl;
1426 NekDouble boundright = xcPhysMOD[np_lay-1];
1427 bool outboundleft=
false;
1428 bool outboundright=
false;
1429 if(tmpx_lay[1]< boundleft )
1431 outboundleft =
true;
1433 if(tmpx_lay[np_lay-2] > boundright )
1435 outboundright =
true;
1443 for(
int r=0; r< nedges; r++)
1446 if(tmpx_lay[r*npedge + npedge-1]< boundleft && outboundleft==
true )
1454 if( tmpx_lay[(r+1)*npedge + npedge-1]> boundleft )
1456 for(
int s=0; s<npedge-2; s++)
1458 if(tmpx_lay[(r+1)*npedge + s+1]< boundleft)
1468 if(tmpx_lay[r*npedge + 0]> boundright && outboundright==
true )
1476 if( tmpx_lay[(r-1)*npedge + 0]< boundright )
1478 for(
int s=0; s<npedge-2; s++)
1480 if(tmpx_lay[(r-1)*npedge + s+1]> boundright)
1492 outcount = outvert*npedge+1+ outmiddle;
1494 int replacepointsfromindex=0;
1495 for(
int c=0; c<nedges; c++)
1498 if(xcPhysMOD[c*npedge+npedge-1] <= tmpx_lay[c*(npedge-(npedge-2)) +2] && outboundright==
true)
1500 replacepointsfromindex = c*(npedge-(npedge-2))+2;
1505 if(xcPhysMOD[(nedges-1 -c)*npedge+0] >= tmpx_lay[np_lay-1 -(c*(npedge-(npedge-2)) +2)] && outboundleft==
true)
1507 replacepointsfromindex = np_lay-1 -(c*(npedge-(npedge-2)) +2);
1523 if( outboundright==
true)
1525 pstart = replacepointsfromindex;
1526 shift = np_lay-outcount;
1527 increment = (xcPhysMOD[np_lay-outcount]-xcPhysMOD[pstart])/(outcount+1);
1528 outcount = outcount-1;
1529 ASSERTL0(tmpx_lay[np_lay-outcount]>xcPhysMOD[(nedges-1)*npedge+0],
"no middle points in the last edge");
1535 increment = (xcPhysMOD[replacepointsfromindex]-xcPhysMOD[pstart])/(outcount+1);
1536 ASSERTL0(tmpx_lay[pstart]<xcPhysMOD[0*npedge +npedge-1],
"no middle points in the first edge");
1553 NekDouble xctmp,ycinterp,nxinterp,nyinterp;
1555 for(
int v=0; v<outcount;v++)
1557 xctmp = xcPhysMOD[pstart]+(v+1)*increment;
1570 xctmp,4,closex,closeny );
1573 nxinterp =
sqrt(
abs(1-nyinterp*nyinterp));
1580 replace_x[v] = xctmp +delta[m]*
abs(nxinterp);
1581 replace_y[v] = ycinterp +delta[m]*
abs(nyinterp);
1582 tmpx_lay[ v+shift ] = replace_x[v];
1583 tmpy_lay[ v+shift ] = replace_y[v];
1604 int closepoints = 4;
1611 for(
int q=0; q<np_lay; q++)
1613 for(
int e=0; e<nedges; e++)
1615 if(tmpx_lay[q]<= x_c[e+1] && tmpx_lay[q]>= x_c[e])
1619 if(q == e*npedge +npedge-1 && pointscount!=npedge )
1624 else if(q == e*npedge +npedge-1)
1644 lay_Vids[m], layers_x[m], layers_y[m],xnew,ynew);
1727 int npoints = npedge;
1730 for(
int f=0; f<nedges; f++)
1736 Vmath::Vcopy(npoints, &layers_x[m][(f)*npedge+0],1,&xPedges[0],1);
1737 Vmath::Vcopy(npoints, &layers_y[m][(f)*npedge+0],1,&yPedges[0],1);
1741 coeffsinterp, xPedges,yPedges, npoints);
1744 Vmath::Vcopy(npoints,&yPedges[0],1, &layers_y[m][(f)*npedge+0],1);
1747 layers_y[m][f*npedge+0]= ynew[lay_Vids[m][f]];
1748 layers_y[m][f*npedge+npedge-1]= ynew[lay_Vids[m][f+1]];
1751 cout<<
" xlay ylay lay:"<<m<<endl;
1752 for(
int l=0; l<np_lay; l++)
1755 cout<<std::setprecision(8)<<layers_x[m][l]<<
" "<<layers_y[m][l]<<endl;
1789 cout<<
"lay="<<m<<endl;
1791 " different layer ymin val");
1793 " different layer ymax val");
1795 " different layer xmin val");
1797 " different layer xmax val");
1807 layers_x[0], layers_y[0], layers_x[nlays-1], layers_y[nlays-1],nxPhys, nyPhys,xnew, ynew);
1889 lay_Vids, x_c, y_c, Down, Up, xnew, ynew, layers_x, layers_y);
1900 cout<<std::setprecision(8)<<
"xmin="<<
Vmath::Vmin(nVertTot, xnew,1)<<endl;
1902 " different xmin val");
1904 " different ymin val");
1906 " different xmax val");
1908 " different ymax val");
1914 Replacevertices(changefile, xnew , ynew, xcPhys, ycPhys, Eids, npedge, charalp, layers_x,layers_y, lay_Eids, curv_lay);
1925 int nvertl = nedges+1;
1929 for(
int j=0; j<nedges; j++)
1933 edge = (bndSegExplow->GetGeom1D())->GetGlobalID();
1935 for(
int k=0; k<2; k++)
1937 Vids_temp[j+k]=(bndSegExplow->GetGeom1D())->GetVid(k);
1940 vertex->GetCoords(x1,y1,z1);
1941 if(x1==x_connect && edge!=lastedge)
1944 if(x_connect==x0layer)
1946 Vids[v1]=Vids_temp[j+k];
1952 Vids_temp[j+1]=(bndSegExplow->GetGeom1D())->GetVid(1);
1953 Vids[v2]=Vids_temp[j+1];
1956 vertex->GetCoords(x2,y2,z2);
1962 Vids_temp[j+0]=(bndSegExplow->GetGeom1D())->GetVid(0);
1963 Vids[v2]=Vids_temp[j+0];
1966 vertex->GetCoords(x2,y2,z2);
1975 Vids_temp[j+1]=(bndSegExplow->GetGeom1D())->GetVid(1);
1976 Vids[v1]=Vids_temp[j+1];
1979 vertex->GetCoords(x1,y1,z1);
1985 Vids_temp[j+0]=(bndSegExplow->GetGeom1D())->GetVid(0);
1986 Vids[v1]=Vids_temp[j+0];
1989 vertex->GetCoords(x1,y1,z1);
2014 boost::ignore_unused(xold_up, xold_low);
2016 cout<<
"Computestreakpositions"<<endl;
2017 int nq = streak->GetTotPoints();
2031 Vmath::Vadd(xc.size(), yold_up,1,yold_low,1, yc,1);
2045 for(
int e=0; e<npoints; e++)
2050 elmtid = streak->GetExpIndex(coord,0.00001);
2051 offset = streak->GetPhys_Offset(elmtid);
2057 while(
abs(F)> 0.000000001)
2060 elmtid = streak->GetExpIndex(coord,0.00001);
2065 if( (
abs(coord[1])>1 || elmtid==-1)
2066 && attempt==0 && verts==
true
2070 coord[1] = yold_c[e];
2073 else if( (
abs(coord[1])>1 || elmtid==-1) )
2075 coord[1] = ytmp +0.01;
2076 elmtid = streak->GetExpIndex(coord,0.001);
2077 offset = streak->GetPhys_Offset(elmtid);
2078 NekDouble Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2079 NekDouble dUtmp = streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2080 coord[1] = coord[1] - (Utmp-cr)/dUtmp;
2081 if( (
abs(Utmp-cr)>
abs(F))||(
abs(coord[1])>1) )
2083 coord[1] = ytmp -0.01;
2090 ASSERTL0(
abs(coord[1])<= 1,
" y value out of bound +/-1");
2092 offset = streak->GetPhys_Offset(elmtid);
2093 U = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2094 dU = streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2095 coord[1] = coord[1] - (U-cr)/dU;
2097 ASSERTL0( coord[0]==xc[e],
" x coordinate must remain the same");
2100 if(its>200 &&
abs(F)<0.00001)
2102 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2105 else if(its>1000 &&
abs(F)< 0.0001)
2107 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2112 ASSERTL0(
false,
"no convergence after 1000 iterations");
2115 yc[e] = coord[1] - (U-cr)/dU;
2116 ASSERTL0( U<= cr + tol,
"streak wrong+");
2117 ASSERTL0( U>= cr -tol,
"streak wrong-");
2119 cout<<
"result streakvert x="<<xc[e]<<
" y="<<yc[e]<<
" streak="<<U<<endl;
2140 while(
abs(F)> 0.00000001)
2144 elmtid =
function->GetExpIndex(coords, 0.01);
2146 cout<<
"gen newton xi="<<xi<<
" yi="<<coords[1]<<
" elmtid="<<elmtid<<
" F="<<F<<endl;
2148 if( (
abs(coords[1])>1 || elmtid==-1) )
2151 coords[1] = ytmp +0.01;
2152 elmtid =
function->GetExpIndex(coords,0.01);
2153 offset =
function->GetPhys_Offset(elmtid);
2154 NekDouble Utmp =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() + offset);
2155 NekDouble dUtmp =
function->GetExp(elmtid)->PhysEvaluate(coords, derfunction + offset);
2156 coords[1] = coords[1] - (Utmp-cr)/dUtmp;
2157 cout<<
"attempt:"<<coords[1]<<endl;
2158 if( (
abs(Utmp-cr)>
abs(F))||(
abs(coords[1])>1.01) )
2160 coords[1] = ytmp -0.01;
2165 else if(
abs(coords[1])<1.01 &&attempt==0)
2172 ASSERTL0(
abs(coords[1])<= 1.00,
" y value out of bound +/-1");
2174 offset =
function->GetPhys_Offset(elmtid);
2175 U =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() + offset);
2176 dU =
function->GetExp(elmtid)->PhysEvaluate(coords, derfunction + offset);
2177 coords[1] = coords[1] - (U-cr)/dU;
2178 cout<<cr<<
"U-cr="<<U-cr<<
" tmp result y:"<<coords[1]<<
" dU="<<dU<<endl;
2182 if(its>200 &&
abs(F)<0.00001)
2184 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2187 else if(its>1000 &&
abs(F)< 0.0001)
2189 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2194 ASSERTL0(
false,
"no convergence after 1000 iterations");
2198 ASSERTL0( coords[0]==xi,
" x coordinate must remain the same");
2201 yout = coords[1] - (U-cr)/dU;
2202 cout<<
"NewtonIt result x="<<xout<<
" y="<<coords[1]<<
" U="<<U<<endl;
2209 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D = field->GetExp();
2210 int nel = exp2D->size();
2218 for(
int i=0; i<nel; i++)
2220 if((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
2222 for(
int j = 0; j < locQuadExp->GetNtraces(); ++j)
2224 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
2225 id = SegGeom->GetGlobalID();
2227 if( V1tmp[
id] == 10000)
2229 V1tmp[id]= SegGeom->GetVertex(0)->GetVid();
2230 V2tmp[id]= SegGeom->GetVertex(1)->GetVid();
2237 else if((locTriExp = (*exp2D)[i]->as<LocalRegions::TriExp>()))
2239 for(
int j = 0; j < locTriExp->GetNtraces(); ++j)
2241 SegGeom = (locTriExp->GetGeom2D())->GetEdge(j);
2242 id = SegGeom->GetGlobalID();
2244 if( V1tmp[
id] == 10000)
2246 V1tmp[id]= SegGeom->GetVertex(0)->GetVid();
2247 V2tmp[id]= SegGeom->GetVertex(1)->GetVid();
2259 for(
int g=0; g<cnt; g++)
2262 ASSERTL0(V1tmp[g]!=10000,
"V1 wrong");
2264 ASSERTL0(V2tmp[g]!=10000,
"V2 wrong");
2286 boost::ignore_unused(xoldup, xolddown);
2288 int nlay_Eids = xcold.size()-1;
2289 int nlay_Vids = xcold.size();
2291 int nVertsTot = mesh->GetNvertices();
2292 cout<<
"nverttot="<<nVertsTot<<endl;
2296 cout<<
"init nlays="<<nlays<<endl;
2303 cout<<
"yoldup="<<yoldup[0]<<endl;
2304 cout<<
"yolddown="<<yolddown[0]<<endl;
2306 for(
int r=0; r< nVertsTot; r++)
2311 vertex->GetCoords(x,y,z);
2318 y<= yoldup[0] && y>= yolddown[0]
2331 cout<<
"nlays="<<nlays<<endl;
2343 for(
int w=0; w< nlays; w++)
2346 tmpx0[w]= tmpx[index];
2347 tmpy0[w]= tmpf[index];
2348 tmpVids0[w] = tmpV[index];
2349 tmpf[index] = max+1000;
2360 for(
int m=0; m<nlays; m++)
2371 NekDouble xtmp,ytmp,normnext=0.0,xnext=0.0,ynext=0.0,diff;
2372 NekDouble Ubef = 0.0, Utmp = 0.0, Unext = 0.0;
2375 int nTotEdges = V1.size();
2377 for(
int m=0; m<nlays; m++)
2379 for(
int g=0; g<nlay_Eids; g++)
2383 for(
int h=0; h< nTotEdges; h++)
2386 if( tmpVids0[m]== V1[h] )
2390 vertex->GetCoords(x,y,z);
2394 Vids_lay[m][0] = V1[h];
2395 Vids_lay[m][1] = V2[h];
2397 = mesh->GetVertex(V1[h]);
2399 vertex1->GetCoords(x1,y1,z1);
2400 normbef=
sqrt( (y-y1)*(y-y1)+(x-x1)*(x-x1) );
2405 elmtid = streak->GetExpIndex(coord,0.00001);
2406 offset = streak->GetPhys_Offset(elmtid);
2407 Ubef = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2412 if( tmpVids0[m]== V2[h] )
2416 vertex->GetCoords(x,y,z);
2420 Vids_lay[m][0] = V2[h];
2421 Vids_lay[m][1] = V1[h];
2423 = mesh->GetVertex(V2[h]);
2425 normbef=
sqrt( (y-y2)*(y-y2)+(x-x2)*(x-x2) );
2430 elmtid = streak->GetExpIndex(coord,0.00001);
2431 offset = streak->GetPhys_Offset(elmtid);
2432 Ubef = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2439 cout<<
"Eid="<<Eids_lay[m][0]<<
" Vids_lay0="<<Vids_lay[m][0]<<
" Vidslay1="<<Vids_lay[m][1]<<endl;
2446 for(
int h=0; h< nTotEdges; h++)
2449 if( (Vids_lay[m][g]==V1[h] || Vids_lay[m][g]==V2[h]) && h!= Eids_lay[m][g-1])
2451 cout<<
"edgetmp="<<h<<endl;
2452 ASSERTL0(cnt<=6,
"wrong number of candidates");
2461 cout<<
"normbef="<<normbef<<endl;
2462 cout<<
"Ubefcc="<<Ubef<<endl;
2464 for(
int e=0; e< cnt; e++)
2468 vertex1->GetCoords(x1,y1,z1);
2471 vertex2->GetCoords(x2,y2,z2);
2473 normtmp=
sqrt( (y2-y1)*(y2-y1)+(x2-x1)*(x2-x1) );
2475 cout<<
"edgetmp1="<<edgestmp[e]<<endl;
2476 cout<<
"V1 x1="<<x1<<
" y1="<<y1<<endl;
2477 cout<<
"V2 x2="<<x2<<
" y2="<<y2<<endl;
2478 if( Vids_lay[m][g]==V1[edgestmp[e]] )
2486 elmtid = streak->GetExpIndex(coord,0.00001);
2487 offset = streak->GetPhys_Offset(elmtid);
2488 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2489 diffarray[e] =
abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2490 diffUarray[e] =
abs(Ubef-Utmp);
2491 cout<<
" normtmp="<<normtmp<<endl;
2492 cout<<
" Utmpcc="<<Utmp<<endl;
2493 cout<<xtmp<<
" ytmp="<<ytmp<<
" diff="<<
abs(((xtmp*xbef+ytmp*ybef)/(normtmp*normbef))-1)<<endl;
2495 abs( (xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1)<diff
2496 && y2<= yoldup[g+1] && y2>= yolddown[g+1]
2497 && y1<= yoldup[g] && y1>= yolddown[g]
2501 Eids_lay[m][g] = edgestmp[e];
2502 Vids_lay[m][g+1] = V2[edgestmp[e]];
2503 diff =
abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2510 else if( Vids_lay[m][g]==V2[edgestmp[e]] )
2518 elmtid = streak->GetExpIndex(coord,0.00001);
2519 offset = streak->GetPhys_Offset(elmtid);
2520 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2521 diffarray[e] =
abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2522 diffUarray[e] =
abs(Ubef-Utmp);
2523 cout<<
" normtmp="<<normtmp<<endl;
2524 cout<<
" Utmpcc="<<Utmp<<endl;
2525 cout<<xtmp<<
" ytmp="<<ytmp<<
" diff="<<
abs(((xtmp*xbef+ytmp*ybef)/(normtmp*normbef))-1)<<endl;
2527 abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1)<diff
2528 && y2<= yoldup[g] && y2>= yolddown[g]
2529 && y1<= yoldup[g+1] && y1>= yolddown[g+1]
2532 Eids_lay[m][g] = edgestmp[e];
2533 Vids_lay[m][g+1] = V1[edgestmp[e]];
2534 diff =
abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2550 cout<<
"Eid before check="<<Eids_lay[m][g]<<endl;
2551 for(
int q=0; q<cnt; q++)
2553 cout<<q<<
" diff"<<diffarray[q]<<endl;
2563 cout<<
"COMMON VERT"<<endl;
2565 diffarray[eid]=1000;
2571 vertex1->GetCoords(x1,y1,z1);
2574 vertex2->GetCoords(x2,y2,z2);
2576 normtmp=
sqrt( (y2-y1)*(y2-y1)+(x2-x1)*(x2-x1) );
2578 Eids_lay[m][g] = edgestmp[eid];
2579 if(Vids_lay[m][g] == V1[edgestmp[eid]])
2583 elmtid = streak->GetExpIndex(coord,0.00001);
2584 offset = streak->GetPhys_Offset(elmtid);
2585 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2586 Vids_lay[m][g+1] = V2[edgestmp[eid]];
2594 if(Vids_lay[m][g] == V2[edgestmp[eid]])
2598 elmtid = streak->GetExpIndex(coord,0.00001);
2599 offset = streak->GetPhys_Offset(elmtid);
2600 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2601 Vids_lay[m][g+1] = V1[edgestmp[eid]];
2612 cout<<m<<
"edge aft:"<<Eids_lay[m][g]<<
" Vid="<<Vids_lay[m][g+1]<<endl;
2618 cout<<
"endelse"<<normtmp<<endl;
2630 for(
int w=0; w< nlays; w++)
2632 for(
int f=0; f< nlay_Eids; f++)
2634 cout<<
"check="<<w<<
" Eid:"<<Eids_lay[w][f]<<endl;
2644 for(
int u=0; u< Vids_laybefore.size(); u++)
2646 if( Vids_laybefore[u]==Vid || Vids_c[u]==Vid)
2650 cout<<Vid<<
" Vert test="<<Vids_laybefore[u]<<endl;
2662 int np_lay = inarray.size();
2663 ASSERTL0(inarray.size()%nedges==0,
" something on number npedge");
2667 for(
int w=0; w< np_lay; w++)
2672 if(inarray[w] ==inarray[w+1])
2677 outarray[cnt]= inarray[w];
2682 ASSERTL0( cnt== np_lay-(nedges-1),
"wrong cut");
2688 int npts = xArray.size();
2697 if(xArray[index]> x)
2708 ASSERTL0( neighpoints%2==0,
"number of neighbour points should be even");
2709 int leftpoints = (neighpoints/2)-1;
2710 int rightpoints = neighpoints/2;
2714 if(index-leftpoints<0)
2717 diff = index-leftpoints;
2719 Vmath::Vcopy(neighpoints, &yArray[0],1,&Neighbour_y[0],1);
2720 Vmath::Vcopy(neighpoints, &xArray[0],1,&Neighbour_x[0],1);
2722 else if( (yArray.size()-1)-index < rightpoints)
2725 int rpoints = (yArray.size()-1)-index;
2726 diff = rightpoints-rpoints;
2728 start = index-leftpoints-diff;
2729 Vmath::Vcopy(neighpoints, &yArray[start],1,&Neighbour_y[0],1);
2730 Vmath::Vcopy(neighpoints, &xArray[start],1,&Neighbour_x[0],1);
2735 start = index-leftpoints;
2736 Vmath::Vcopy(neighpoints, &yArray[start],1,&Neighbour_y[0],1);
2737 Vmath::Vcopy(neighpoints, &xArray[start],1,&Neighbour_x[0],1);
2746 for(
int f=1; f< neighpoints; f++)
2748 ASSERTL0(Neighbour_x[f]!=Neighbour_x[f-1],
" repetition on NeighbourArrays");
2759 for(
int pt=0;pt<npts;++pt)
2763 for(
int j=0;j<pt; ++j)
2765 h = h * (x - xpts[j])/(xpts[pt]-xpts[j]);
2768 for(
int k=pt+1;k<npts;++k)
2770 h = h * (x - xpts[k])/(xpts[pt]-xpts[k]);
2774 sum += funcvals[pt]*LagrangePoly;
2786 int np_pol= coeffsinterp.size();
2787 cout<<
"evaluatetan with "<<np_pol<<endl;
2793 for(
int q=0; q< npoints; q++)
2798 for(
int d=0; d< np_pol-1; d++)
2800 yprime[q] += (derorder +1)*coeffsinterp[d]*std::pow(xcQedge[q],derorder);
2804 for(
int a=0; a< np_pol; a++)
2806 yinterp[q] += coeffsinterp[a]*std::pow(xcQedge[q],polorder);
2814 for(
int n=0; n< npoints; n++)
2818 txQedge[n] = cos((atan((yprime[n]))));
2819 tyQedge[n] = sin((atan((yprime[n]))));
2820 cout<<xcQedge[n]<<
" "<<yinterp[n]<<
" "<<yprime[n]<<
" "<<txQedge[n]<<
" "<<tyQedge[n]<<endl;
2827 int edge,
int npedge)
2829 int np_pol = xpol.size();
2835 for(
int e=0; e<N; e++)
2838 for(
int w=0; w < N; w++)
2840 A[N*e+row] = std::pow( xpol[w], N-1-e);
2845 for(
int r= 0; r< np_pol; r++)
2859 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2860 "th parameter had an illegal parameter for dgetrf";
2865 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2866 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2872 Lapack::Dgetrs(
'N', N, ncolumns_b ,
A.get() , N, ipivot.get(), b.get(), N, info);
2875 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2876 "th parameter had an illegal parameter for dgetrf";
2881 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2882 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2896 for(
int c=0; c< npedge; c++)
2900 ycout[edge*(npedge)+c+1]=0;
2901 for(
int d=0; d< np_pol; d++)
2903 ycout[edge*(npedge)+c+1] += b[d]
2904 *std::pow(xcout[edge*(npedge)+c+1],polorder);
2922 int N = polyorder+1;
2925 cout<<npoints<<endl;
2926 for(
int u=0; u<npoints; u++)
2928 cout<<
"c="<<xin[u]<<
" "<<
2933 for(
int e=0; e<N; e++)
2936 for(
int row=0; row<N; row++)
2938 for(
int w=0; w < npoints; w++)
2940 A[N*e+row] += std::pow( xin[w], e+row);
2945 for(
int row= 0; row< N; row++)
2947 for(
int h=0; h< npoints; h++)
2949 b[row] += fin[h]*std::pow(xin[h],row);
2967 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2968 "th parameter had an illegal parameter for dgetrf";
2973 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2974 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2979 Lapack::Dgetrs(
'N', N, ncolumns_b ,
A.get() , N, ipivot.get(), b.get(), N, info);
2982 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2983 "th parameter had an illegal parameter for dgetrf";
2988 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2989 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2998 for(
int j=0; j<N; j++)
3004 for(
int h=0; h<N; h++)
3006 cout<<
"coeff:"<<b[h]<<endl;
3011 for(
int c=0; c< npout; c++)
3016 for(
int d=0; d< N; d++)
3020 *std::pow(xout[c],polorder);
3046 for(
int w=0; w<tmpx.size(); w++)
3049 outarray_x[w]= tmpx[index];
3050 outarray_y[w]= tmpy[index];
3051 if(w< tmpx.size()-1)
3053 if(tmpx[index] == tmpx[index+1])
3055 outarray_x[w+1]= tmpx[index+1];
3056 outarray_y[w+1]= tmpy[index+1];
3057 tmpx[index+1] = max+1000;
3073 tmpx[index] = max+1000;
3085 int np_lay = layers_y[0].size();
3087 for(
int h=1; h<nlays-1; h++)
3090 for(
int s=0; s<nvertl; s++)
3093 ASSERTL0(ynew[ lay_Vids[h][s] ]==-20,
"ynew layers not empty");
3097 ynew[ lay_Vids[h][s] ] = ynew[Down[s]]+ h*
abs(ynew[Down[s]] - yc[s])/(cntlow+1);
3099 xnew[lay_Vids[h][s] ] = xc[s];
3103 layers_y[h][s] = ynew[ lay_Vids[h][s] ];
3104 layers_x[h][s] = xnew[ lay_Vids[h][s] ];
3109 ynew[ lay_Vids[h][s] ] = yc[s] + (h-cntlow)*
abs(ynew[Up[s]] - yc[s])/(cntup+1);
3111 xnew[lay_Vids[h][s] ] = xc[s];
3113 layers_y[h][s] = ynew[ lay_Vids[h][s] ];
3114 layers_x[h][s] = xnew[ lay_Vids[h][s] ];
3128 int np_lay = xcPhys.size();
3129 int nedges = nvertl-1;
3136 int closepoints = 4;
3141 for(
int g=0; g< nedges; g++)
3150 xnew[Vids[g] ]= xcPhys[g*npedge+0];
3151 ylay[g*npedge +0] = ynew[ Vids[g] ];
3152 xlay[g*npedge +0] = xnew[ Vids[g] ];
3160 ynew[Vids[g+1] ]=
LagrangeInterpolant(xcPhys[g*npedge +npedge-1],closepoints,Pxinterp,Pyinterp );
3161 xnew[Vids[g+1] ]= xcPhys[g*npedge +npedge-1];
3162 ylay[g*npedge +npedge-1] = ynew[Vids[g+1] ];
3163 xlay[g*npedge +npedge-1] = xnew[Vids[g+1] ];
3168 for(
int r=0; r< npedge-2; r++)
3176 ASSERTL0( index<= tmpy.size()-1,
" index wrong");
3180 ylay[g*npedge +r+1]=
3182 xcPhys[g*npedge +r+1],closepoints,Pxinterp,Pyinterp );
3184 xlay[g*npedge +r+1]= xcPhys[g*npedge +r+1];
3207 int np_lay = xcPhys.size();
3208 int nedges = nvertl-1;
3216 int closepoints = 4;
3221 for(
int g=0; g< nedges; g++)
3225 ynew[Vids[g] ]= tmpy_lay[g*npedge+0];
3226 xnew[Vids[g] ]= tmpx_lay[g*npedge+0];
3229 ylay[g*npedge +0] = ynew[ Vids[g] ];
3230 xlay[g*npedge +0] = xnew[ Vids[g] ];
3233 ynew[Vids[g+1] ]= tmpy_lay[g*npedge+npedge-1];
3234 xnew[Vids[g+1] ]= tmpx_lay[g*npedge+npedge-1];
3235 ylay[g*npedge +npedge-1] = ynew[Vids[g+1] ];
3236 xlay[g*npedge +npedge-1] = xnew[Vids[g+1] ];
3241 for(
int r=0; r< npedge-2; r++)
3243 x0 = xlay[g*npedge +0];
3244 x1 = xlay[g*npedge +npedge-1];
3245 xtmp = x0 + r*(x1-x0)/(npedge-1);
3251 ASSERTL0( index<= tmpy.size()-1,
" index wrong");
3255 ylay[g*npedge +r+1]=
3257 xtmp,closepoints,Pxinterp,Pyinterp );
3259 xlay[g*npedge +r+1]= xtmp;
3274 boost::ignore_unused(xolddown, xoldup);
3277 int nvertl = ycold.size();
3278 int nVertTot = mesh->GetNvertices();
3279 for(
int n=0; n<nVertTot; n++)
3284 vertex->GetCoords(x,y,z);
3289 for(
int k=0; k<nvertl; k++)
3291 if(
abs(x-xcold[k]) < tmp)
3293 tmp =
abs(x-xcold[k]);
3306 nplay_closer= (qp_closer-1)*npedge +npedge-1;
3310 if( y>yoldup[qp_closer] && y<1 )
3315 ratio = (1-ylayup[nplay_closer])/
3316 ( (1-yoldup[qp_closer]) );
3318 ynew[n] = ylayup[nplay_closer]
3319 + (y-yoldup[qp_closer])*ratio;
3323 else if( y< yolddown[qp_closer] && y>-1 )
3326 ratio = (1+ylaydown[nplay_closer])/
3327 ( (1+yolddown[qp_closer]) );
3329 ynew[n] = ylaydown[nplay_closer]
3330 + (y-yolddown[qp_closer])*ratio;
3346 boost::ignore_unused(xcold, ycold);
3362 int nvertl = xoldup.size();
3363 int nedges = nvertl-1;
3372 for(
int a=0; a< nedges;a++)
3377 xnew_down[a] = xlaydown[a*npedge+0];
3378 ynew_down[a] = ylaydown[a*npedge+0];
3379 xnew_up[a] = xlayup[a*npedge+0];
3380 ynew_up[a] = ylayup[a*npedge+0];
3381 nxvert[a] = nxPhys[a*npedge+0];
3382 nyvert[a] = nyPhys[a*npedge+0];
3384 xnew_down[a+1] = xlaydown[a*npedge+npedge-1];
3385 ynew_down[a+1] = ylaydown[a*npedge+npedge-1];
3386 xnew_up[a+1] = xlayup[a*npedge+npedge-1];
3387 ynew_up[a+1] = ylayup[a*npedge+npedge-1];
3388 nxvert[a+1] = nxPhys[a*npedge+npedge-1];
3389 nyvert[a+1] = nyPhys[a*npedge+npedge-1];
3394 xnew_down[a+1] = xlaydown[a*npedge+npedge-1];
3395 ynew_down[a+1] = ylaydown[a*npedge+npedge-1];
3396 xnew_up[a+1] = xlayup[a*npedge+npedge-1];
3397 ynew_up[a+1] = ylayup[a*npedge+npedge-1];
3398 nxvert[a+1] = nxPhys[a*npedge+npedge-1];
3399 nyvert[a+1] = nyPhys[a*npedge+npedge-1];
3411 int nVertTot = mesh->GetNvertices();
3412 for(
int n=0; n<nVertTot; n++)
3417 vertex->GetCoords(x,y,z);
3418 int qp_closeroldup = 0, qp_closerolddown = 0;
3427 for(
int k=0; k<nvertl; k++)
3429 if(
abs(x-xolddown[k]) < diffdown)
3431 diffdown =
abs(x-xolddown[k]);
3434 if(
abs(x-xoldup[k]) < diffup)
3436 diffup =
abs(x-xoldup[k]);
3446 int qp_closerup = 0, qp_closerdown = 0;
3448 for(
int f=0; f< nvertl; f++)
3450 if(
abs(x-xnew_down[f]) < diffdown)
3452 diffdown =
abs(x-xnew_down[f]);
3455 if(
abs(x-xnew_up[f]) < diffup)
3457 diffup =
abs(x-xnew_up[f]);
3484 int qp_closernormup;
3495 int qp_closernormdown;
3506 if( y>yoldup[qp_closeroldup] && y<1 )
3511 ratio = (1-ynew_up[qp_closerup])/
3512 ( (1-yoldup[qp_closeroldup]) );
3517 ynew[n] = ynew_up[qp_closerup]
3518 + (y-yoldup[qp_closeroldup])*ratio;
3524 if(x> (xmax-xmin)/2. && x< xmax)
3526 ratiox = (xmax-xnew_up[qp_closernormup])/
3527 (xmax-xoldup[qp_closernormup]) ;
3528 if( (xmax-xoldup[qp_closernormup])==0)
3535 xnew[n] = x +
abs(nxvert[qp_closernormup])*(xnew_up[qp_closeroldup]-xoldup[qp_closeroldup])*ratiox;
3536 ASSERTL0(x>xmin,
" x value <xmin up second half");
3537 ASSERTL0(x<xmax," x value >xmax up second half
");
3539 else if( x> xmin && x<= (xmax-xmin)/2.)
3541 //cout<<"up close normold=
"<<qp_closernormoldup<<" closenorm=
"<<qp_closernormup<<endl;
3542 ratiox = (xnew_up[qp_closernormup]-xmin)/
3543 ( (xoldup[qp_closernormup]-xmin) );
3544 if( (xoldup[qp_closernormup]-xmin)==0)
3548 //xnew[n] = xnew_up[qp_closerup]
3549 // + (x-xoldup[qp_closeroldup])*ratiox;
3550 xnew[n] = x + abs(nxvert[qp_closernormup])*(xnew_up[qp_closeroldup]-xoldup[qp_closeroldup])*ratiox;
3551 //cout<<"up xold=
"<<x<<" xnew=
"<<xnew[n]<<endl;
3552 ASSERTL0(x>xmin," x value <xmin up first half
");
3553 ASSERTL0(x<xmax," x value >xmax up first half
");
3558 else if( y< yolddown[qp_closerolddown] && y>-1 )
3561 ratio = (1+ynew_down[qp_closerdown])/
3562 ( (1+yolddown[qp_closerolddown]) );
3564 // ratioy = (1-ynew_down[qp_closernormdown])/
3565 // ( (1-yolddown[qp_closernormolddown]) );
3567 //distance prop to layerlow
3568 ynew[n] = ynew_down[qp_closerdown]
3569 + (y-yolddown[qp_closerolddown])*ratio;
3570 //ynew[n] = y +abs(nyvert[qp_closernormdown])*
3571 // (ynew_down[qp_closerolddown]-yolddown[qp_closerolddown])*ratioy;
3572 //ynew[n] = y + 0.3*(ynew_down[qp_closerdown]-yolddown[qp_closerdown]);
3573 //xnew[n] = x + abs(nxvert[qp_closerolddown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown]);
3577 cout<<qp_closerolddown<<" nplaydown=
"<<qp_closerdown<<endl;
3578 cout<<"xolddown=
"<<xolddown[qp_closerolddown]<<" xnewdown=
"<<xnew_down[qp_closerdown]<<endl;
3579 cout<<"xold+
"<<x<<" xnew+
"<<xnew[n]<<endl;
3583 if(x> (xmax-xmin)/2. && x <xmax)
3585 ratiox = (xmax-xnew_down[qp_closernormdown])/
3586 ( (xmax-xolddown[qp_closernormdown]) );
3587 if( (xmax-xolddown[qp_closernormdown])==0)
3591 //xnew[n] = xnew_down[qp_closerdown]
3592 // + (x-xolddown[qp_closerolddown])*ratiox;
3594 abs(nxvert[qp_closernormdown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown])*ratiox;
3595 ASSERTL0(x>xmin," x value <xmin down second half
");
3596 ASSERTL0(x<xmax," x value >xmax down second half
");
3598 else if( x>xmin && x<= (xmax-xmin)/2.)
3600 ratiox = (xnew_down[qp_closernormdown]-xmin)/
3601 ( (xolddown[qp_closernormdown]-xmin) );
3602 if( (xolddown[qp_closernormdown]-xmin)==0)
3606 //xnew[n] = xnew_down[qp_closerdown]
3607 // + (x-xolddown[qp_closerolddown])*ratiox;
3609 abs(nxvert[qp_closernormdown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown])*ratiox;
3610 ASSERTL0(x>xmin," x value <xmin down first half
");
3611 ASSERTL0(x<xmax," x value >xmax down first half
");
3616 cout<<"xold
"<<x<<" xnew=
"<<xnew[n]<<endl;
3617 ASSERTL0(xnew[n] >= xmin, "newx < xmin
");
3618 ASSERTL0(xnew[n]<= xmax, "newx > xmax
");
3623 void CheckSingularQuads( MultiRegions::ExpListSharedPtr Exp,
3624 Array<OneD, int> V1, Array<OneD, int> V2,
3625 Array<OneD, NekDouble>& xnew,Array<OneD, NekDouble>& ynew)
3627 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D = Exp->GetExp();
3628 int nel = exp2D->size();
3629 LocalRegions::QuadExpSharedPtr locQuadExp;
3630 LocalRegions::TriExpSharedPtr locTriExp;
3631 SpatialDomains::Geometry1DSharedPtr SegGeom;
3633 NekDouble xV1, yV1, xV2,yV2;
3634 NekDouble slopebef = 0.0,slopenext = 0.0,slopenew = 0.0;
3635 Array<OneD, int> locEids(4);
3636 for(int i=0; i<nel; i++)
3638 if((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
3640 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(0);
3641 idbef = SegGeom->GetGlobalID();
3642 if(xnew[ V1[idbef] ]<= xnew[ V2[idbef] ])
3644 xV1 = xnew[ V1[idbef] ];
3645 yV1 = ynew[ V1[idbef] ];
3646 xV2 = xnew[ V2[idbef] ];
3647 yV2 = ynew[ V2[idbef] ];
3648 slopebef = (yV2 -yV1)/(xV2 -xV1);
3652 xV1 = xnew[ V2[idbef] ];
3653 yV1 = ynew[ V2[idbef] ];
3654 xV2 = xnew[ V1[idbef] ];
3655 yV2 = ynew[ V1[idbef] ];
3656 slopebef = (yV2 -yV1)/(xV2 -xV1);
3658 //cout<<"00 V1 x=
"<<xnew[ V1[idbef] ]<<" y=
"<<ynew[ V1[idbef] ]<<endl;
3659 //cout<<"00 V2 x=
"<<xnew[ V2[idbef] ]<<" y=
"<<ynew[ V2[idbef] ]<<endl;
3660 for(int j = 1; j < locQuadExp->GetNtraces(); ++j)
3662 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
3663 idnext = SegGeom->GetGlobalID();
3664 //cout<<"id=
"<<idnext<<" locid=
"<<j<<endl;
3665 //cout<<" V1 x=
"<<xnew[ V1[idnext] ]<<" y=
"<<ynew[ V1[idnext] ]<<endl;
3666 //cout<<" V2 x=
"<<xnew[ V2[idnext] ]<<" y=
"<<ynew[ V2[idnext] ]<<endl;
3667 if(xV1 == xnew[ V1[idnext] ] && yV1 == ynew[ V1[idnext] ] )
3669 xV1 = xnew[ V1[idnext] ];
3670 yV1 = ynew[ V1[idnext] ];
3671 xV2 = xnew[ V2[idnext] ];
3672 yV2 = ynew[ V2[idnext] ];
3673 slopenext = (yV2 -yV1)/(xV2 -xV1);
3676 cout<<"case1 x0=
"<<xV1<<" x1=
"<<xV2<<endl;
3677 cout<<idnext<<" 11slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl;
3679 //compare with slope before
3680 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18)
3682 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] -0.01;
3683 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]);
3685 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) )
3687 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] +0.02;
3688 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]);
3690 slopenext = slopenew;
3691 cout<<"slopenew=
"<<slopenew<<endl;
3692 cout<<"moved x=
"<<xnew[ V1[idnext] ]<<endl;
3695 else if(xV2 == xnew[ V2[idnext] ] && yV2 == ynew[ V2[idnext] ] )
3697 xV1 = xnew[ V2[idnext] ];
3698 yV1 = ynew[ V2[idnext] ];
3699 xV2 = xnew[ V1[idnext] ];
3700 yV2 = ynew[ V1[idnext] ];
3701 slopenext = (yV2 -yV1)/(xV2 -xV1);
3704 cout<<"case2 x0=
"<<xV1<<" x1=
"<<xV2<<endl;
3705 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl;
3707 //compare with slope before
3708 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18)
3710 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] -0.01;
3711 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]);
3713 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) )
3715 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] +0.02;
3716 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]);
3719 slopenext = slopenew;
3720 cout<<"slopenew=
"<<slopenew<<endl;
3721 cout<<"moved x=
"<<xnew[ V2[idnext] ]<<endl;
3724 else if(xV1 == xnew[ V2[idnext] ] && yV1 == ynew[ V2[idnext] ] )
3726 xV1 = xnew[ V2[idnext] ];
3727 yV1 = ynew[ V2[idnext] ];
3728 xV2 = xnew[ V1[idnext] ];
3729 yV2 = ynew[ V1[idnext] ];
3730 slopenext = (yV2 -yV1)/(xV2 -xV1);
3733 cout<<"case3 x0=
"<<xV1<<" x1=
"<<xV2<<endl;
3734 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl;
3736 //compare with slope before
3737 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18)
3739 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] -0.01;
3740 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]);
3742 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) )
3744 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] +0.02;
3745 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]);
3747 slopenext = slopenew;
3748 cout<<"slopenew=
"<<slopenew<<endl;
3749 cout<<"moved x=
"<<xnew[ V2[idnext] ]<<endl;
3753 else if(xV2 == xnew[ V1[idnext] ] && yV2 == ynew[ V1[idnext] ] )
3755 xV1 = xnew[ V1[idnext] ];
3756 yV1 = ynew[ V1[idnext] ];
3757 xV2 = xnew[ V2[idnext] ];
3758 yV2 = ynew[ V2[idnext] ];
3759 slopenext = (yV2 -yV1)/(xV2 -xV1);
3762 cout<<"case4 x0=
"<<xV1<<" x1=
"<<xV2<<endl;
3763 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl;
3765 //compare with slope before
3766 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18)
3768 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] -0.01;
3769 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]);
3771 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) )
3773 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] +0.02;
3774 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]);
3776 slopenext = slopenew;
3777 cout<<"slopenew=
"<<slopenew<<endl;
3778 cout<<"moved x=
"<<xnew[ V1[idnext] ]<<endl;
3784 ASSERTL0(false, "edge not connected
");
3786 slopebef = slopenext;
3795 void Replacevertices(string filename, Array<OneD, NekDouble> newx,
3796 Array<OneD, NekDouble> newy,
3797 Array<OneD, NekDouble> xcPhys, Array<OneD, NekDouble> ycPhys,
3798 Array<OneD, int>Eids, int Npoints, string s_alp,
3799 Array<OneD, Array<OneD, NekDouble> > x_lay,
3800 Array<OneD, Array<OneD, NekDouble> > y_lay,
3801 Array<OneD, Array<OneD, int > >lay_eids, bool curv_lay)
3803 //load existing file
3805 TiXmlDocument doc(filename);
3806 //load xscale parameter (if exists)
3807 TiXmlElement* master = doc.FirstChildElement("NEKTAR
");
3808 TiXmlElement* mesh = master->FirstChildElement("GEOMETRY
");
3809 TiXmlElement* element = mesh->FirstChildElement("VERTEX
");
3810 NekDouble xscale = 1.0;
3811 LibUtilities::Interpreter expEvaluator;
3812 const char *xscal = element->Attribute("XSCALE
");
3815 std::string xscalstr = xscal;
3816 int expr_id = expEvaluator.DefineFunction("",xscalstr);
3817 xscale = expEvaluator.Evaluate(expr_id);
3821 // Save a new XML file.
3822 newfile = filename.substr(0, filename.find_last_of(".
"))+"_moved.xml
";
3823 doc.SaveFile( newfile );
3825 //write the new vertices
3826 TiXmlDocument docnew(newfile);
3827 bool loadOkaynew = docnew.LoadFile();
3829 std::string errstr = "Unable to load file:
";
3831 ASSERTL0(loadOkaynew, errstr.c_str());
3833 TiXmlHandle docHandlenew(&docnew);
3834 TiXmlElement* meshnew = NULL;
3835 TiXmlElement* masternew = NULL;
3836 TiXmlElement* condnew = NULL;
3837 TiXmlElement* Parsnew = NULL;
3838 TiXmlElement* parnew = NULL;
3840 // Master tag within which all data is contained.
3843 masternew = docnew.FirstChildElement("NEKTAR
");
3844 ASSERTL0(masternew, "Unable to
find NEKTAR tag in file.
");
3846 //set the alpha value
3848 condnew = masternew->FirstChildElement("CONDITIONS
");
3849 Parsnew = condnew->FirstChildElement("PARAMETERS
");
3850 cout<<"alpha=
"<<s_alp<<endl;
3851 parnew = Parsnew->FirstChildElement("P");
3854 TiXmlNode *node = parnew->FirstChild();
3857 // Format is "paramName = value
"
3858 std::string line = node->ToText()->Value();
3862 int beg = line.find_first_not_of("
");
3863 int end = line.find_first_of("=
");
3864 // Check for no parameter name
3865 if (beg == end) throw 1;
3866 // Check for no parameter value
3867 if (end != line.find_last_of("=
")) throw 1;
3868 // Check for no equals sign
3869 if (end == std::string::npos) throw 1;
3870 lhs = line.substr(line.find_first_not_of(" "), end-beg);
3871 lhs = lhs.substr(0, lhs.find_last_not_of(" ")+1);
3873 //rhs = line.substr(line.find_last_of("=
")+1);
3874 //rhs = rhs.substr(rhs.find_first_not_of(" "));
3875 //rhs = rhs.substr(0, rhs.find_last_not_of(" ")+1);
3877 boost::to_upper(lhs);
3880 alphastring = "Alpha =
"+ s_alp;
3881 parnew->RemoveChild(node);
3882 parnew->LinkEndChild(new TiXmlText(alphastring) );
3886 parnew = parnew->NextSiblingElement("P");
3890 // Find the Mesh tag and same the dim and space attributes
3891 meshnew = masternew->FirstChildElement("GEOMETRY
");
3893 ASSERTL0(meshnew, "Unable to
find GEOMETRY tag in file.
");
3894 // Now read the vertices
3895 TiXmlElement* elementnew = meshnew->FirstChildElement("VERTEX
");
3896 ASSERTL0(elementnew, "Unable to
find mesh VERTEX tag in file.
");
3900 elementnew->SetAttribute("XSCALE
",1.0);
3902 TiXmlElement *vertexnew = elementnew->FirstChildElement("V
");
3908 int nextVertexNumber = -1;
3913 //delete the old one
3914 TiXmlAttribute *vertexAttr = vertexnew->FirstAttribute();
3915 std::string attrName(vertexAttr->Name());
3916 ASSERTL0(attrName == "ID
", (std::string("Unknown attribute
name:
") + attrName).c_str());
3918 err = vertexAttr->QueryIntValue(&indx);
3919 ASSERTL0(err == TIXML_SUCCESS, "Unable to read attribute ID.
");
3920 ASSERTL0(indx == nextVertexNumber, "Vertex IDs must begin with zero and be sequential.
");
3922 std::string vertexBodyStr;
3923 // Now read body of vertex
3924 TiXmlNode *vertexBody = vertexnew->FirstChild();
3925 // Accumulate all non-comment body data.
3926 if (vertexBody->Type() == TiXmlNode::TINYXML_TEXT)
3928 vertexBodyStr += vertexBody->ToText()->Value();
3929 vertexBodyStr += " ";
3931 ASSERTL0(!vertexBodyStr.empty(), "Vertex definitions must contain vertex data.
");
3932 //remove the old coordinates
3933 vertexnew->RemoveChild(vertexBody);
3935 //cout<<"writing.. v:
"<<nextVertexNumber<<endl;
3937 //we need at least 5 digits (setprecision 5) to get the streak position with
3939 s << std::scientific << std::setprecision(8) << newx[nextVertexNumber] << " "
3940 << newy[nextVertexNumber] << " " << 0.0;
3941 vertexnew->LinkEndChild(new TiXmlText(s.str()));
3942 //TiXmlNode *newvertexBody = vertexnew->FirstChild();
3943 //string newvertexbodystr= newvertexBody->SetValue(s.str());
3944 //vertexnew->ReplaceChild(vertexBody,new TiXmlText(newvertexbodystr));
3946 vertexnew = vertexnew->NextSiblingElement("V
");
3951 //read the curved tag
3952 TiXmlElement* curvednew = meshnew->FirstChildElement("CURVED
");
3953 ASSERTL0(curvednew, "Unable to
find mesh CURVED tag in file.
");
3954 TiXmlElement *edgenew = curvednew->FirstChildElement("E
");
3956 //ID is different from index...
3957 std::string charindex;
3961 int neids_lay = lay_eids[0].size();
3962 //if edgenew belongs to the crit lay replace it, else delete it.
3968 TiXmlAttribute *edgeAttr = edgenew->FirstAttribute();
3969 std::string attrName(edgeAttr->Name());
3970 charindex = edgeAttr->Value();
3971 std::istringstream iss(charindex);
3972 iss >> std::dec >> index;
3974 edgenew->QueryIntAttribute("EDGEID
", &eid);
3975 //cout<<"eid=
"<<eid<<" neid=
"<<Eids.size()<<endl;
3976 //find the corresponding index curve point
3977 for(int u=0; u<Eids.size(); u++)
3979 //cout<<"Eids=
"<<Eids[u]<<" eid=
"<<eid<<endl;
3987 curvednew->RemoveChild(edgenew);
3988 //ASSERTL0(false, "edge to update not found
");
3993 std::string edgeBodyStr;
3994 //read the body of the edge
3995 TiXmlNode *edgeBody = edgenew->FirstChild();
3996 if(edgeBody->Type() == TiXmlNode::TINYXML_TEXT)
3998 edgeBodyStr += edgeBody->ToText()->Value();
4001 ASSERTL0(!edgeBodyStr.empty(), "Edge definitions must contain edge data
");
4002 //remove the old coordinates
4003 edgenew->RemoveChild(edgeBody);
4004 //write the new points coordinates
4005 //we need at least 5 digits (setprecision 5) to get the streak position with
4008 //Determine the number of points
4009 err = edgenew->QueryIntAttribute("NUMPOINTS
", &numPts);
4010 ASSERTL0(err == TIXML_SUCCESS, "Unable to read curve attribute NUMPOINTS.
");
4013 edgenew->SetAttribute("NUMPOINTS
", Npoints);
4014 for(int u=0; u< Npoints; u++)
4016 st << std::scientific <<
4017 std::setprecision(8) <<xcPhys[cnt*Npoints+u]
4018 << " " << ycPhys[cnt*Npoints+u] << " " << 0.000<<" ";
4021 edgenew->LinkEndChild(new TiXmlText(st.str()));
4025 st << std::scientific << std::setprecision(8) << x_crit[v1] << " "
4026 << y_crit[v1] << " " << 0.000<<" ";
4027 for(int a=0; a< Npoints-2; a++)
4029 st << std::scientific << std::setprecision(8) <<
4030 " "<<Pcurvx[indexeid*(Npoints-2) +a]<<" "<<Pcurvy[indexeid*(Npoints-2) +a]
4034 st << std::scientific << std::setprecision(8) <<
4035 " "<<x_crit[v2]<<" "<< y_crit[v2] <<" "<< 0.000;
4036 edgenew->LinkEndChild(new TiXmlText(st.str()));
4043 edgenew = edgenew->NextSiblingElement("E
");
4047 //write also the others layers curve points
4048 if(curv_lay == true)
4050 cout<<"write other curved edges
"<<endl;
4051 TiXmlElement * curved = meshnew->FirstChildElement("CURVED
");
4053 int nlays = lay_eids.size();
4055 //TiXmlComment * comment = new TiXmlComment();
4056 //comment->SetValue(" new edges
");
4057 //curved->LinkEndChild(comment);
4058 for (int g=0; g< nlays; ++g)
4060 for(int p=0; p< neids_lay; p++)
4063 TiXmlElement * e = new TiXmlElement( "E
" );
4064 e->SetAttribute("ID
", idcnt++);
4065 e->SetAttribute("EDGEID
", lay_eids[g][p]);
4066 e->SetAttribute("NUMPOINTS
", Npoints);
4067 e->SetAttribute("TYPE
", "PolyEvenlySpaced
");
4068 for(int c=0; c< Npoints; c++)
4070 st << std::scientific << std::setprecision(8) <<x_lay[g][p*Npoints +c]
4071 << " " << y_lay[g][p*Npoints +c] << " " << 0.000<<" ";
4075 TiXmlText * t0 = new TiXmlText(st.str());
4076 e->LinkEndChild(t0);
4077 curved->LinkEndChild(e);
4085 docnew.SaveFile( newfile );
4087 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 Replacevertices(string filename, Array< OneD, NekDouble > newx, Array< OneD, NekDouble > newy, Array< OneD, NekDouble > xcPhys, Array< OneD, NekDouble > ycPhys, Array< OneD, int >Eids, int Npoints, string s_alp, Array< OneD, Array< OneD, NekDouble > > x_lay, Array< OneD, Array< OneD, NekDouble > > y_lay, Array< OneD, Array< OneD, int > >lay_eids, bool curv_lay)
void Cutrepetitions(int nedges, Array< OneD, NekDouble > inarray, Array< OneD, NekDouble > &outarray)
void MoveOutsidePointsNnormpos(int npedge, SpatialDomains::MeshGraphSharedPtr mesh, Array< OneD, NekDouble > xcold, Array< OneD, NekDouble > ycold, Array< OneD, NekDouble > xolddown, Array< OneD, NekDouble > yolddown, Array< OneD, NekDouble > xoldup, Array< OneD, NekDouble > yoldup, Array< OneD, NekDouble > xlaydown, Array< OneD, NekDouble > ylaydown, Array< OneD, NekDouble > xlayup, Array< OneD, NekDouble > ylayup, Array< OneD, NekDouble > nxPhys, Array< OneD, NekDouble > nyPhys, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void MappingEVids(Array< OneD, NekDouble > xoldup, Array< OneD, NekDouble > yoldup, Array< OneD, NekDouble > xolddown, Array< OneD, NekDouble > yolddown, Array< OneD, NekDouble > xcold, Array< OneD, NekDouble > ycold, Array< OneD, int > Vids_c, SpatialDomains::MeshGraphSharedPtr mesh, MultiRegions::ExpListSharedPtr streak, Array< OneD, int > V1, Array< OneD, int > V2, int &nlays, Array< OneD, Array< OneD, int > > &Eids_lay, Array< OneD, Array< OneD, int > > &Vids_lay)
void CheckSingularQuads(MultiRegions::ExpListSharedPtr Exp, Array< OneD, int > V1, Array< OneD, int > V2, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void Orderfunctionx(Array< OneD, NekDouble > inarray_x, Array< OneD, NekDouble > inarray_y, Array< OneD, NekDouble > &outarray_x, Array< OneD, NekDouble > &outarray_y)
void MoveLayerNfixedxpos(int nvertl, int npedge, Array< OneD, NekDouble > xcPhys, Array< OneD, NekDouble > tmpx_lay, Array< OneD, NekDouble > tmpy_lay, Array< OneD, int > Vids, Array< OneD, NekDouble > &xlay, Array< OneD, NekDouble > &ylay, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void OrderVertices(int nedges, SpatialDomains::MeshGraphSharedPtr graphShPt, MultiRegions::ExpListSharedPtr &bndfield, Array< OneD, int > &Vids, int v1, int v2, NekDouble x_connect, int &lastedge, Array< OneD, NekDouble > &x, Array< OneD, NekDouble > &y)
void PolyFit(int polyorder, int npoints, Array< OneD, NekDouble > xin, Array< OneD, NekDouble > fin, Array< OneD, NekDouble > &coeffsinterp, Array< OneD, NekDouble > &xout, Array< OneD, NekDouble > &fout, int npout)
void GenerateAddPointsNewtonIt(NekDouble xi, NekDouble yi, NekDouble &xout, NekDouble &yout, MultiRegions::ExpListSharedPtr function, Array< OneD, NekDouble > derfunction, NekDouble cr)
void MoveLayersvertically(int nlays, int nvertl, int cntlow, int cntup, Array< OneD, Array< OneD, int > > lay_Vids, Array< OneD, NekDouble > xc, Array< OneD, NekDouble > yc, Array< OneD, int > Down, Array< OneD, int > Up, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew, Array< OneD, Array< OneD, NekDouble > > &layers_x, Array< OneD, Array< OneD, NekDouble > > &layers_y)
void GenerateNeighbourArrays(int index, int neighpoints, Array< OneD, NekDouble > xArray, Array< OneD, NekDouble > yArray, Array< OneD, NekDouble > &Neighbour_x, Array< OneD, NekDouble > &Neighbour_y)
bool checkcommonvert(Array< OneD, int > Vids_laybefore, Array< OneD, int > Vids_c, int Vid)
int DetermineclosePointxindex(NekDouble x, Array< OneD, NekDouble > xArray)
void MoveOutsidePointsfixedxpos(int npedge, SpatialDomains::MeshGraphSharedPtr mesh, Array< OneD, NekDouble > xcold, Array< OneD, NekDouble > ycold, Array< OneD, NekDouble > xolddown, Array< OneD, NekDouble > yolddown, Array< OneD, NekDouble > xoldup, Array< OneD, NekDouble > yoldup, Array< OneD, NekDouble > ylaydown, Array< OneD, NekDouble > ylayup, Array< OneD, NekDouble > &xnew, Array< OneD, NekDouble > &ynew)
void PolyInterp(Array< OneD, NekDouble > xpol, Array< OneD, NekDouble > ypol, Array< OneD, NekDouble > &coeffsinterp, Array< OneD, NekDouble > &xcout, Array< OneD, NekDouble > &ycout, int edge, int npedge)
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
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
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)
Represents a vertex in the mesh.