41 #include <boost/core/ignore_unused.hpp> 65 #include <boost/lexical_cast.hpp> 118 int edge,
int npedge);
119 void PolyFit(
int polyorder,
int npoints,
175 int main(
int argc,
char *argv[])
181 if(argc > 6 || argc < 5)
184 "Usage: ./MoveMesh meshfile fieldfile changefile alpha cr(optional)\n");
190 = LibUtilities::SessionReader::CreateInstance(2, argv);
195 vSession->DefinesSolverInfo(
"INTERFACE")
196 && vSession->GetSolverInfo(
"INTERFACE")==
"phase" )
198 cr = boost::lexical_cast<
NekDouble>(argv[argc-1]);
216 string changefile(argv[argc-2]);
220 string charalp (argv[argc-1]);
222 cout<<
"read alpha="<<charalp<<endl;
226 string fieldfile(argv[argc-3]);
227 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
228 vector<vector<NekDouble> > fielddata;
237 for(
int i=0; i<fielddata.size(); i++)
239 streak->ExtractDataToCoeffs(fielddef[i], fielddata[i], fielddef[i]->m_fields[0], streak->UpdateCoeffs());
241 streak->BwdTrans_IterPerExp(streak->GetCoeffs(), streak->UpdatePhys());
247 int nIregions, lastIregion=0;
252 int nbnd= bndConditions.num_elements();
253 for(
int r=0; r<nbnd; r++)
255 if(bndConditions[r]->GetUserDefined()==
"CalcBC")
263 ASSERTL0(nIregions>0,
"there is any boundary region with the tag USERDEFINEDTYPE=""CalcBC"" specified");
264 cout<<
"nIregions="<<nIregions<<endl;
269 int nedges = bndfieldx[lastIregion]->GetExpSize();
270 int nvertl = nedges +1 ;
286 ( (bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
291 vertex0->GetCoords(x0,y0,z0);
294 cout<<
"WARNING x0="<<x0<<endl;
300 Vids_low, v1, v2 , x_connect ,lastedge, xold_low,yold_low);
301 ASSERTL0(Vids_low[v2]!=-10,
"Vids_low[v2] is wrong");
305 cout<<
"x_conn="<<x_connect<<
" yt="<<yt<<
" zt="<<zt<<
" vid="<<Vids_low[v2]<<endl;
306 vertex->GetCoords(x_connect,yt,zt);
313 Vids_low, v1, v2 , x_connect, lastedge, xold_low, yold_low );
316 vertex->GetCoords(x_connect,yt,zt);
330 ( (bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
335 vertex0->GetCoords(x0,y0,z0);
338 cout<<
"WARNING x0="<<x0<<endl;
346 Vids_up, v1, v2 , x_connect ,lastedge, xold_up, yold_up);
348 vertexU->GetCoords(x_connect,yt,zt);
355 Vids_up, v1, v2 , x_connect, lastedge, xold_up, yold_up );
359 vertex->GetCoords(x_connect,yt,zt);
371 graphShPt->GetVertex(((bndfieldx[lastIregion]->GetExp(0)
372 ->as<LocalRegions::SegExp>())->GetGeom1D())->GetVid(0));
373 vertex0->GetCoords(x0,y0,z0);
376 cout<<
"WARNING x0="<<x0<<endl;
385 Vids_c, v1, v2 , x_connect ,lastedge, xold_c, yold_c);
389 vertexc->GetCoords(x_connect,yt,zt);
396 Vids_c, v1, v2 , x_connect, lastedge, xold_c, yold_c );
400 vertex->GetCoords(x_connect,yt,zt);
409 for(
int r=0; r<nvertl; r++)
413 Deltaup[r] = yold_up[r] - yold_c[r];
414 Deltalow[r] = yold_c[r] - yold_low[r];
415 ASSERTL0(Deltaup[r]>0,
"distance between upper and layer curve is not positive");
416 ASSERTL0(Deltalow[r]>0,
"distance between lower and layer curve is not positive");
437 if(vSession->DefinesParameter(
"npedge"))
439 npedge = (int)vSession->GetParameter(
"npedge");
447 int nq= streak->GetTotPoints();
450 streak->GetCoords(x,y);
459 xold_low, yold_low, xold_c, yold_c, x_c, y_c,cr,
true);
462 for(
int q=0; q<nvertl; q++)
464 if(y_c[q] < yold_c[q])
469 Delta_c[q] = abs(yold_c[q]-y_c[q]);
472 cout<<x_c[q]<<
" "<<y_c[q]<<endl;
477 cout<<
"Warning: the critical layer is stationary"<<endl;
500 for(
int r=0; r<nedges; r++)
503 bndSegExp = bndfieldx[lastIregion]->GetExp(r)
505 Eid = (bndSegExp->GetGeom1D())->GetGlobalID();
506 id1 = (bndSegExp->GetGeom1D())->GetVid(0);
507 id2 = (bndSegExp->GetGeom1D())->GetVid(1);
508 vertex1 = graphShPt->GetVertex(id1);
509 vertex2 = graphShPt->GetVertex(id2);
511 vertex2->GetCoords(x2,y2,z2);
514 cout<<
"edge="<<r<<
" x1="<<x1<<
" y1="<<y1<<
" x2="<<x2<<
" y2="<<y2<<endl;
517 Cpointsx[r] = x1 +(x2-x1)/2;
520 if( Cpointsx[r]>x2 || Cpointsx[r]< x1)
522 Cpointsx[r] = -Cpointsx[r];
524 for(
int w=0; w< npedge-2; w++)
527 Addpointsx[r*(npedge-2) +w] = x1 +((x2-x1)/(npedge - 1))*(w+1);
528 if( Addpointsx[r*(npedge-2) +w] > x2 || Addpointsx[r*(npedge-2) +w] < x1)
530 Addpointsx[r*(npedge-2) +w] = -Addpointsx[r*(npedge-2) +w];
533 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);
536 Addpointsx[r*(npedge-2) +w], Addpointsy[r*(npedge-2) +w], streak, dU,cr);
549 Cpointsx[r] = x2+ (x1-x2)/2;
551 if( Cpointsx[r] > x1 || Cpointsx[r] < x2)
553 Cpointsx[r] = -Cpointsx[r];
555 for(
int w=0; w< npedge-2; w++)
557 Addpointsx[r*(npedge-2) +w] = x2 +((x1-x2)/(npedge - 1))*(w+1);
558 if( Addpointsx[r*(npedge-2) +w] > x1 || Addpointsx[r*(npedge-2) +w] < x2)
560 Addpointsx[r*(npedge-2) +w] = -Addpointsx[r*(npedge-2) +w];
564 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);
568 Addpointsx[r*(npedge-2) +w], Addpointsy[r*(npedge-2) +w], streak, dU,cr);
579 ASSERTL0(
false,
"point not generated");
598 for(
int a=0; a<nedges; a++)
601 xcPhys[a*npedge+0] = x_c[a];
602 ycPhys[a*npedge+0] = y_c[a];
604 xcPhys[a*npedge+npedge-1] = x_c[a+1];
605 ycPhys[a*npedge+npedge-1] = y_c[a+1];
607 for(
int b=0; b<npedge-2; b++)
609 xcPhys[a*npedge +b+1] = Addpointsx[a*(npedge-2)+b];
610 ycPhys[a*npedge +b+1] = Addpointsy[a*(npedge-2)+b];
614 cout<<
"xc,yc before tanevaluate"<<endl;
615 for(
int v=0; v< xcPhys.num_elements(); v++)
617 cout<<xcPhys[v]<<
" "<<ycPhys[v]<<endl;
630 MappingEVids(xold_up, yold_up, xold_low, yold_low, xold_c, yold_c, Vids_c,
631 graphShPt,streak, V1, V2, nlays, lay_Eids, lay_Vids);
635 cout<<
"nlays="<<nlays<<endl;
639 for(
int g=0; g<nlays; g++)
652 if(vSession->DefinesParameter(
"Delta"))
654 Delta0 = vSession->GetParameter(
"Delta");
666 int nVertTot = graphShPt->GetNvertices();
682 for(
int i=0; i<nVertTot; i++)
687 vertex->GetCoords(x,y,z);
697 if(x==0 && y< yold_low[0]
703 if(x== xold_c[nvertl-1] && y> yold_up[nvertl-1]
709 if(x==xold_c[nvertl-1] && y<yold_low[nvertl-1]
715 if(x== 0 && y> yold_up[0]
721 for(
int j=0; j<nvertl; j++)
723 if((xold_up[j]==x)&&(yold_up[j]==y))
727 ynew[i] = y_c[j] +Delta0;
731 if((xold_low[j]==x)&&(yold_low[j]==y))
735 ynew[i] = y_c[j] -Delta0;
739 if((xold_c[j]==x)&&(yold_c[j]==y))
750 for(
int k=0; k<nvertl; k++)
752 if(abs(x-xold_up[k]) < diff)
754 diff = abs(x-xold_up[k]);
758 if( y>yold_up[qp_closer] && y< 1)
766 ynew[i] = y_c[qp_closer] +(y-yold_c[qp_closer])*
767 (1-y_c[qp_closer])/(1-yold_c[qp_closer]);
773 else if(y<yold_low[qp_closer] && y> -1)
781 ynew[i] = y_c[qp_closer] + (y-yold_c[qp_closer] )*
782 (-1-y_c[qp_closer])/(-1-yold_c[qp_closer]);
786 else if ( y>yold_c[qp_closer] && y < yold_up[qp_closer])
793 else if (y<yold_c[qp_closer] && y > yold_low[qp_closer])
795 if(x==0){ cntlow++; }
800 else if( y==1 || y==-1)
807 if( (ynew[i]>1 || ynew[i]<-1)
808 && ( y>yold_up[qp_closer] || y<yold_low[qp_closer]) )
810 cout<<
"point x="<<xnew[i]<<
" y="<<y<<
" closer x="<<xold_up[qp_closer]<<
" ynew="<<ynew[i]<<endl;
811 ASSERTL0(
false,
"shifting out of range");
821 int nqedge = streak->GetExp(0)->GetNumPoints(0);
822 int nquad_lay = (nvertl-1)*nqedge;
827 int np_lay = (nvertl-1)*npedge;
837 if( move_norm==
true )
844 Vmath::Vcopy(xcPhys.num_elements(),xcPhys,1,xcPhysMOD,1);
845 Vmath::Vcopy(xcPhys.num_elements(),ycPhys,1,ycPhysMOD,1);
849 cout<<
"nquad per edge="<<nqedge<<endl;
850 for(
int l=0; l<2; l++)
852 Edge_newcoords[l] = bndfieldx[lastIregion]->GetExp(0)
877 bndfieldx[lastIregion]->GetCoords(xcQ, ycQ, zcQ);
886 for(
int l=0; l< xcQ.num_elements(); l++)
896 xcQ[l],4,closex,closey );
909 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffsy);
910 Cont_y->BwdTrans_IterPerExp( coeffsy, Cont_y->UpdatePhys());
913 cout<<
"xcQ, ycQ"<<endl;
914 for(
int s=0; s<xcQ.num_elements(); s++)
916 cout<<xcQ[s]<<
" "<<ycQ[s]<<endl;
919 bool evaluatetan=
false;
923 for(
int k=0; k<nedges; k++)
928 Edge_newcoords[0]->StdPhysDeriv(xcedgeQ,txedgeQ);
929 Edge_newcoords[1]->StdPhysDeriv(ycedgeQ,tyedgeQ);
933 Vmath::Vvtvp(nqedge,tyedgeQ,1,tyedgeQ,1,normsQ,1,normsQ,1);
948 for(
int u=0; u<nqedge-1; u++)
950 incratio = (ycedgeQ[u+1]- ycedgeQ[u])/(xcedgeQ[u+1]- xcedgeQ[u]);
951 cout<<
"incratio="<<incratio<<endl;
952 if(abs(incratio)> 4.0 && evaluatetan==false )
954 cout<<
"wrong="<<wrong<<endl;
956 ASSERTL0(wrong<2,
"number edges to change is too high!!");
964 cout<<
"tan bef"<<endl;
965 for(
int e=0; e< nqedge; e++)
967 cout<<xcedgeQ[e]<<
" "<<ycedgeQ[e]<<
" "<<txedgeQ[e]<<endl;
975 Vmath::Vcopy(npedge, &xcPhysMOD[k*npedge+0],1,&xPedges[0],1);
976 Vmath::Vcopy(npedge, &ycPhysMOD[k*npedge+0],1,&yPedges[0],1);
978 PolyFit(polyorder,nqedge, xcedgeQ,ycedgeQ, coeffsinterp, xPedges,yPedges, npedge);
980 Vmath::Vcopy(npedge, &xPedges[0],1, &xcPhysMOD[k*npedge+0],1);
981 Vmath::Vcopy(npedge, &yPedges[0],1, &ycPhysMOD[k*npedge+0],1);
988 Vmath::Vcopy(nqedge, &(txedgeQ[0]), 1, &(txQ[nqedge*k]),1);
989 Vmath::Vcopy(nqedge, &(tyedgeQ[0]), 1, &(tyQ[nqedge*k]),1);
994 for(
int w=0; w< fz.num_elements(); w++)
996 txQ[w] = cos(atan(fz[w]));
997 tyQ[w] = sin(atan(fz[w]));
998 cout<<xcQ[w]<<
" "<<ycQ[w]<<
" "<<fz[w]<<endl;
1003 Vmath::Vcopy(nquad_lay, txQ,1, Cont_y->UpdatePhys(),1);
1004 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffsy);
1005 Cont_y->BwdTrans_IterPerExp( coeffsy, Cont_y->UpdatePhys());
1008 Vmath::Vcopy(nquad_lay, tyQ,1, Cont_y->UpdatePhys(),1);
1009 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffsy);
1010 Cont_y->BwdTrans_IterPerExp( coeffsy, Cont_y->UpdatePhys());
1022 for(
int q=0; q<2; q++)
1024 edgebef = edgeinterp[q]-1;
1025 incbefore = (txQ[edgebef*nqedge+nqedge-1]-txQ[edgebef*nqedge])/
1026 (xcQ[edgebef*nqedge+nqedge-1]-xcQ[edgebef*nqedge]);
1027 inc = (txQ[edgeinterp[q]*nqedge+nqedge-1]-txQ[edgeinterp[q]*nqedge])/
1028 (xcQ[edgeinterp[q]*nqedge+nqedge-1]-xcQ[edgeinterp[q]*nqedge]);
1029 int npoints = 2*nqedge;
1035 cout<<
"inc="<<inc<<
" incbef="<<incbefore<<endl;
1036 if( (inc/incbefore)>0. )
1038 cout<<
"before!!"<<edgebef<<endl;
1041 Vmath::Vcopy(npoints, &xcQ[edgebef*nqedge+0],1,&xQedges[0],1);
1042 Vmath::Vcopy(npoints, &ycQ[edgebef*nqedge+0],1,&yQedges[0],1);
1043 Vmath::Vcopy(npoints, &txQ[edgebef*nqedge+0],1,&txQedges[0],1);
1044 Vmath::Vcopy(npoints, &tyQ[edgebef*nqedge+0],1,&tyQedges[0],1);
1048 coeffsinterp, xQedges,txQedges, npoints);
1051 Vmath::Vcopy(npoints,&txQedges[0],1, &txQ[edgebef*nqedge+0],1);
1055 coeffsinterp, xQedges,tyQedges, npoints);
1058 Vmath::Vcopy(npoints,&tyQedges[0],1, &tyQ[edgebef*nqedge+0],1);
1063 cout<<
"after!!"<<endl;
1066 Vmath::Vcopy(npoints, &xcQ[edgeinterp[q]*nqedge+0],1,&xQedges[0],1);
1067 Vmath::Vcopy(npoints, &ycQ[edgeinterp[q]*nqedge+0],1,&yQedges[0],1);
1068 Vmath::Vcopy(npoints, &txQ[edgeinterp[q]*nqedge+0],1,&txQedges[0],1);
1069 Vmath::Vcopy(npoints, &tyQ[edgeinterp[q]*nqedge+0],1,&tyQedges[0],1);
1074 coeffsinterp, xQedges,txQedges, npoints);
1077 Vmath::Vcopy(npoints,&txQedges[0],1, &txQ[edgeinterp[q]*nqedge+0],1);
1081 coeffsinterp, xQedges,tyQedges, npoints);
1084 Vmath::Vcopy(npoints,&tyQedges[0],1, &tyQ[edgeinterp[q]*nqedge+0],1);
1093 Vmath::Vcopy(nquad_lay, tyQ,1, Cont_y->UpdatePhys(),1);
1094 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffstmp);
1095 Cont_y->BwdTrans_IterPerExp( coeffstmp, Cont_y->UpdatePhys());
1098 Vmath::Vcopy(nquad_lay, txQ,1, Cont_y->UpdatePhys(),1);
1099 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffstmp);
1100 Cont_y->BwdTrans_IterPerExp( coeffstmp, Cont_y->UpdatePhys());
1103 for(
int k=0; k<nedges; k++)
1111 Vmath::Vcopy(nqedge, &(txQ[nqedge*k]),1, &(txedgeQ[0]), 1);
1112 Vmath::Vcopy(nqedge, &(tyQ[nqedge*k]),1, &(tyedgeQ[0]), 1);
1114 Vmath::Vdiv(nqedge, txedgeQ,1,tyedgeQ,1,tx_tyedgeQ,1);
1115 Vmath::Vmul(nqedge, tx_tyedgeQ,1,tx_tyedgeQ,1,tx_tyedgeQ,1);
1121 Vmath::Vcopy(nqedge, &(nxedgeQ[0]),1, &(nxQ[nqedge*k]),1);
1123 Vmath::Vmul(nqedge, nxedgeQ,1,nxedgeQ,1,nyedgeQ,1);
1129 Vmath::Vcopy(nqedge, &(nyedgeQ[0]), 1, &(nyQ[nqedge*k]),1);
1132 cout<<
"edge:"<<k<<endl;
1133 cout<<
"tan/normal"<<endl;
1134 for(
int r=0; r<nqedge; r++)
1136 cout<<xcQ[k*nqedge+r]<<
" "<<txedgeQ[r]<<
" "<<tyedgeQ[r]<<
" " 1137 <<nxedgeQ[r]<<
" "<<nyedgeQ[r]<<endl;
1143 Vmath::Vcopy(nquad_lay, nyQ,1, Cont_y->UpdatePhys(),1);
1145 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffstmp);
1146 Cont_y->BwdTrans_IterPerExp( coeffstmp, Cont_y->UpdatePhys());
1150 Vmath::Zero(Cont_y->GetNcoeffs(),Cont_y->UpdateCoeffs(),1);
1151 Vmath::Vcopy(nquad_lay, nxQ,1, Cont_y->UpdatePhys(),1);
1152 Cont_y->FwdTrans_IterPerExp(Cont_y->GetPhys(), coeffstmp);
1153 Cont_y->BwdTrans_IterPerExp( coeffstmp, Cont_y->UpdatePhys());
1157 for(
int k=0; k<nedges; k++)
1163 nyQ[(k-1)*nqedge+nqedge-1]=
1168 nxQ[(k-1)*nqedge+nqedge-1]=
1177 cout<<
"nx,yQbefore"<<endl;
1178 for(
int u=0; u<xcQ.num_elements(); u++)
1180 cout<<xcQ[u]<<
" "<<nyQ[u]<<
" "<<txQ[u]<<endl;
1186 cout<<
"nx,yQ"<<endl;
1187 for(
int u=0; u<x_tmpQ.num_elements(); u++)
1189 cout<<x_tmpQ[u]<<
" "<<tmpnyQ[u]<<endl;
1193 for(
int k=0; k<nedges; k++)
1196 for(
int a=0; a<npedge; a++)
1200 nxPhys[k*npedge +a]= nxQ[k*nqedge +0];
1201 nyPhys[k*npedge +a]= nyQ[k*nqedge +0];
1204 else if(a== npedge-1)
1206 nxPhys[k*npedge +a]= nxQ[k*nqedge +nqedge-1];
1207 nyPhys[k*npedge +a]= nyQ[k*nqedge +nqedge-1];
1231 nyPhys[k*npedge +a]=
1241 nxPhys[k*npedge +a]= -sqrt(abs(1- nyPhys[k*npedge +a]*nyPhys[k*npedge +a]));
1257 nyPhys[(k-1)*npedge+npedge-1]=
1262 nxPhys[(k-1)*npedge+npedge-1]=
1267 cout<<
"xcPhys,,"<<endl;
1268 for(
int s=0; s<np_lay; s++)
1271 cout<<xcPhysMOD[s]<<
" "<<ycPhysMOD[s]<<
" "<<nxPhys[s]<<
" "<<nyPhys[s]<<endl;
1284 for(
int m=0; m<nlays; m++)
1291 delta[m] = -(cntlow+1-m)*Delta0/(cntlow+1);
1295 delta[m] = ( m-(cntlow) )*Delta0/(cntlow+1);
1302 for(
int h=0; h< nvertl; h++)
1309 if(move_norm==
false)
1311 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m];
1312 xnew[lay_Vids[m][h] ]= x_c[h];
1316 if(h==0 || h==nvertl-1 )
1318 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m];
1319 xnew[lay_Vids[m][h] ]= x_c[h];
1323 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m]*abs(nyPhys[h*npedge+0]);
1324 xnew[lay_Vids[m][h] ]= x_c[h] +delta[m]*abs(nxPhys[h*npedge+0]);
1327 cout<<
"Vid x="<<xnew[lay_Vids[m][h] ]<<
" y="<<ynew[lay_Vids[m][h] ]<<endl;
1332 cout<<
"edge=="<<h<<endl;
1335 ASSERTL0( nyPhys[h*npedge+0]==nyPhys[(h-1)*npedge+npedge-1],
" normaly wrong");
1336 ASSERTL0( nxPhys[h*npedge+0]==nxPhys[(h-1)*npedge+npedge-1],
" normalx wrong");
1339 if(move_norm==
false)
1342 layers_y[m][h*npedge +0] = y_c[h] +delta[m];
1343 layers_x[m][h*npedge +0] = xnew[lay_Vids[m][h] ];
1345 layers_y[m][h*npedge +npedge-1] = y_c[h+1] +delta[m];
1346 layers_x[m][h*npedge +npedge-1] = xnew[lay_Vids[m][h+1] ];
1348 for(
int d=0; d< npedge-2; d++)
1350 layers_y[m][h*npedge +d+1]= ycPhysMOD[h*npedge +d+1] +delta[m];
1352 layers_x[m][h*npedge +d+1]= xcPhysMOD[h*npedge +d+1];
1361 tmpy_lay[h*npedge +0] = y_c[h] +delta[m];
1362 tmpx_lay[h*npedge +0] = xnew[lay_Vids[m][h] ];
1364 tmpy_lay[h*npedge +npedge-1] =
1365 y_c[h+1] +delta[m]*abs(nyPhys[h*npedge +npedge-1]);
1366 tmpx_lay[h*npedge +npedge-1] =
1367 x_c[h+1] +delta[m]*abs(nxPhys[h*npedge +npedge-1]);
1369 else if(h==nedges-1)
1372 tmpy_lay[h*npedge +0] =
1373 y_c[h] +delta[m]*abs(nyPhys[h*npedge +0]);
1374 tmpx_lay[h*npedge +0] =
1375 x_c[h] +delta[m]*abs(nxPhys[h*npedge +0]);
1377 tmpy_lay[h*npedge +npedge-1] = y_c[h+1] +delta[m];
1378 tmpx_lay[h*npedge +npedge-1] = xnew[lay_Vids[m][h+1] ];
1383 tmpy_lay[h*npedge +0] =
1384 y_c[h] +delta[m]*abs(nyPhys[h*npedge +0]);
1385 tmpx_lay[h*npedge +0] =
1386 x_c[h] +delta[m]*abs(nxPhys[h*npedge +0]);
1388 tmpy_lay[h*npedge +npedge-1] =
1389 y_c[h+1] +delta[m]*abs(nyPhys[h*npedge +npedge-1]);
1390 tmpx_lay[h*npedge +npedge-1] =
1391 x_c[h+1] +delta[m]*abs(nxPhys[h*npedge +npedge-1]);
1395 for(
int d=0; d< npedge-2; d++)
1398 tmpy_lay[h*npedge +d+1] = ycPhysMOD[h*npedge +d+1] +
1399 delta[m]*abs(nyPhys[h*npedge +d+1]);
1402 tmpx_lay[h*npedge +d+1]= xcPhysMOD[h*npedge +d+1] +
1403 delta[m]*abs(nxPhys[h*npedge +d+1]);
1420 for(
int s=0; s<np_lay; s++)
1422 cout<<tmpx_lay[s]<<
" "<<tmpy_lay[s]<<endl;
1425 cout<<
"fisrt interp"<<endl;
1426 for(
int s=0; s<np_lay; s++)
1428 cout<<tmpx_lay[s]<<
" "<<tmpy_lay[s]<<endl;
1440 NekDouble boundright = xcPhysMOD[np_lay-1];
1441 bool outboundleft=
false;
1442 bool outboundright=
false;
1443 if(tmpx_lay[1]< boundleft )
1445 outboundleft =
true;
1447 if(tmpx_lay[np_lay-2] > boundright )
1449 outboundright =
true;
1457 for(
int r=0; r< nedges; r++)
1460 if(tmpx_lay[r*npedge + npedge-1]< boundleft && outboundleft==
true )
1468 if( tmpx_lay[(r+1)*npedge + npedge-1]> boundleft )
1470 for(
int s=0; s<npedge-2; s++)
1472 if(tmpx_lay[(r+1)*npedge + s+1]< boundleft)
1482 if(tmpx_lay[r*npedge + 0]> boundright && outboundright==
true )
1490 if( tmpx_lay[(r-1)*npedge + 0]< boundright )
1492 for(
int s=0; s<npedge-2; s++)
1494 if(tmpx_lay[(r-1)*npedge + s+1]> boundright)
1506 outcount = outvert*npedge+1+ outmiddle;
1508 int replacepointsfromindex=0;
1509 for(
int c=0; c<nedges; c++)
1512 if(xcPhysMOD[c*npedge+npedge-1] <= tmpx_lay[c*(npedge-(npedge-2)) +2] && outboundright==
true)
1514 replacepointsfromindex = c*(npedge-(npedge-2))+2;
1519 if(xcPhysMOD[(nedges-1 -c)*npedge+0] >= tmpx_lay[np_lay-1 -(c*(npedge-(npedge-2)) +2)] && outboundleft==
true)
1521 replacepointsfromindex = np_lay-1 -(c*(npedge-(npedge-2)) +2);
1537 if( outboundright==
true)
1539 pstart = replacepointsfromindex;
1540 shift = np_lay-outcount;
1541 increment = (xcPhysMOD[np_lay-outcount]-xcPhysMOD[pstart])/(outcount+1);
1542 outcount = outcount-1;
1543 ASSERTL0(tmpx_lay[np_lay-outcount]>xcPhysMOD[(nedges-1)*npedge+0],
"no middle points in the last edge");
1549 increment = (xcPhysMOD[replacepointsfromindex]-xcPhysMOD[pstart])/(outcount+1);
1550 ASSERTL0(tmpx_lay[pstart]<xcPhysMOD[0*npedge +npedge-1],
"no middle points in the first edge");
1567 NekDouble xctmp,ycinterp,nxinterp,nyinterp;
1569 for(
int v=0; v<outcount;v++)
1571 xctmp = xcPhysMOD[pstart]+(v+1)*increment;
1584 xctmp,4,closex,closeny );
1587 nxinterp = sqrt(abs(1-nyinterp*nyinterp));
1594 replace_x[v] = xctmp +delta[m]*abs(nxinterp);
1595 replace_y[v] = ycinterp +delta[m]*abs(nyinterp);
1596 tmpx_lay[ v+shift ] = replace_x[v];
1597 tmpy_lay[ v+shift ] = replace_y[v];
1618 int closepoints = 4;
1625 for(
int q=0; q<np_lay; q++)
1627 for(
int e=0; e<nedges; e++)
1629 if(tmpx_lay[q]<= x_c[e+1] && tmpx_lay[q]>= x_c[e])
1633 if(q == e*npedge +npedge-1 && pointscount!=npedge )
1638 else if(q == e*npedge +npedge-1)
1658 lay_Vids[m], layers_x[m], layers_y[m],xnew,ynew);
1741 int npoints = npedge;
1744 for(
int f=0; f<nedges; f++)
1750 Vmath::Vcopy(npoints, &layers_x[m][(f)*npedge+0],1,&xPedges[0],1);
1751 Vmath::Vcopy(npoints, &layers_y[m][(f)*npedge+0],1,&yPedges[0],1);
1755 coeffsinterp, xPedges,yPedges, npoints);
1758 Vmath::Vcopy(npoints,&yPedges[0],1, &layers_y[m][(f)*npedge+0],1);
1761 layers_y[m][f*npedge+0]= ynew[lay_Vids[m][f]];
1762 layers_y[m][f*npedge+npedge-1]= ynew[lay_Vids[m][f+1]];
1765 cout<<
" xlay ylay lay:"<<m<<endl;
1766 for(
int l=0; l<np_lay; l++)
1769 cout<<std::setprecision(8)<<layers_x[m][l]<<
" "<<layers_y[m][l]<<endl;
1803 cout<<
"lay="<<m<<endl;
1805 " different layer ymin val");
1807 " different layer ymax val");
1809 " different layer xmin val");
1811 " different layer xmax val");
1821 layers_x[0], layers_y[0], layers_x[nlays-1], layers_y[nlays-1],nxPhys, nyPhys,xnew, ynew);
1903 lay_Vids, x_c, y_c, Down, Up, xnew, ynew, layers_x, layers_y);
1914 cout<<std::setprecision(8)<<
"xmin="<<
Vmath::Vmin(nVertTot, xnew,1)<<endl;
1916 " different xmin val");
1918 " different ymin val");
1920 " different xmax val");
1922 " different ymax val");
1928 Replacevertices(changefile, xnew , ynew, xcPhys, ycPhys, Eids, npedge, charalp, layers_x,layers_y, lay_Eids, curv_lay);
1939 int nvertl = nedges+1;
1943 for(
int j=0; j<nedges; j++)
1947 edge = (bndSegExplow->GetGeom1D())->GetGlobalID();
1949 for(
int k=0; k<2; k++)
1951 Vids_temp[j+k]=(bndSegExplow->GetGeom1D())->GetVid(k);
1954 vertex->GetCoords(x1,y1,z1);
1955 if(x1==x_connect && edge!=lastedge)
1958 if(x_connect==x0layer)
1960 Vids[v1]=Vids_temp[j+k];
1966 Vids_temp[j+1]=(bndSegExplow->GetGeom1D())->GetVid(1);
1967 Vids[v2]=Vids_temp[j+1];
1970 vertex->GetCoords(x2,y2,z2);
1976 Vids_temp[j+0]=(bndSegExplow->GetGeom1D())->GetVid(0);
1977 Vids[v2]=Vids_temp[j+0];
1980 vertex->GetCoords(x2,y2,z2);
1989 Vids_temp[j+1]=(bndSegExplow->GetGeom1D())->GetVid(1);
1990 Vids[v1]=Vids_temp[j+1];
1993 vertex->GetCoords(x1,y1,z1);
1999 Vids_temp[j+0]=(bndSegExplow->GetGeom1D())->GetVid(0);
2000 Vids[v1]=Vids_temp[j+0];
2003 vertex->GetCoords(x1,y1,z1);
2028 boost::ignore_unused(xold_up, xold_low);
2030 cout<<
"Computestreakpositions"<<endl;
2031 int nq = streak->GetTotPoints();
2045 Vmath::Vadd(xc.num_elements(), yold_up,1,yold_low,1, yc,1);
2059 for(
int e=0; e<npoints; e++)
2064 elmtid = streak->GetExpIndex(coord,0.00001);
2065 offset = streak->GetPhys_Offset(elmtid);
2071 while( abs(F)> 0.000000001)
2074 elmtid = streak->GetExpIndex(coord,0.00001);
2079 if( (abs(coord[1])>1 || elmtid==-1)
2080 && attempt==0 && verts==
true 2084 coord[1] = yold_c[e];
2087 else if( (abs(coord[1])>1 || elmtid==-1) )
2089 coord[1] = ytmp +0.01;
2090 elmtid = streak->GetExpIndex(coord,0.001);
2091 offset = streak->GetPhys_Offset(elmtid);
2092 NekDouble Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2093 NekDouble dUtmp = streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2094 coord[1] = coord[1] - (Utmp-cr)/dUtmp;
2095 if( (abs(Utmp-cr)>abs(F))||(abs(coord[1])>1) )
2097 coord[1] = ytmp -0.01;
2104 ASSERTL0(abs(coord[1])<= 1,
" y value out of bound +/-1");
2106 offset = streak->GetPhys_Offset(elmtid);
2107 U = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2108 dU = streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2109 coord[1] = coord[1] - (U-cr)/dU;
2111 ASSERTL0( coord[0]==xc[e],
" x coordinate must remain the same");
2114 if(its>200 && abs(F)<0.00001)
2116 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2119 else if(its>1000 && abs(F)< 0.0001)
2121 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2126 ASSERTL0(
false,
"no convergence after 1000 iterations");
2129 yc[e] = coord[1] - (U-cr)/dU;
2130 ASSERTL0( U<= cr + tol,
"streak wrong+");
2131 ASSERTL0( U>= cr -tol,
"streak wrong-");
2133 cout<<
"result streakvert x="<<xc[e]<<
" y="<<yc[e]<<
" streak="<<U<<endl;
2154 while( abs(F)> 0.00000001)
2158 elmtid =
function->GetExpIndex(coords, 0.01);
2160 cout<<
"gen newton xi="<<xi<<
" yi="<<coords[1]<<
" elmtid="<<elmtid<<
" F="<<F<<endl;
2162 if( (abs(coords[1])>1 || elmtid==-1) )
2165 coords[1] = ytmp +0.01;
2166 elmtid =
function->GetExpIndex(coords,0.01);
2167 offset =
function->GetPhys_Offset(elmtid);
2168 NekDouble Utmp =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() + offset);
2169 NekDouble dUtmp =
function->GetExp(elmtid)->PhysEvaluate(coords, derfunction + offset);
2170 coords[1] = coords[1] - (Utmp-cr)/dUtmp;
2171 cout<<
"attempt:"<<coords[1]<<endl;
2172 if( (abs(Utmp-cr)>abs(F))||(abs(coords[1])>1.01) )
2174 coords[1] = ytmp -0.01;
2179 else if( abs(coords[1])<1.01 &&attempt==0)
2186 ASSERTL0(abs(coords[1])<= 1.00,
" y value out of bound +/-1");
2188 offset =
function->GetPhys_Offset(elmtid);
2189 U =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() + offset);
2190 dU =
function->GetExp(elmtid)->PhysEvaluate(coords, derfunction + offset);
2191 coords[1] = coords[1] - (U-cr)/dU;
2192 cout<<cr<<
"U-cr="<<U-cr<<
" tmp result y:"<<coords[1]<<
" dU="<<dU<<endl;
2196 if(its>200 && abs(F)<0.00001)
2198 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2201 else if(its>1000 && abs(F)< 0.0001)
2203 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2208 ASSERTL0(
false,
"no convergence after 1000 iterations");
2212 ASSERTL0( coords[0]==xi,
" x coordinate must remain the same");
2215 yout = coords[1] - (U-cr)/dU;
2216 cout<<
"NewtonIt result x="<<xout<<
" y="<<coords[1]<<
" U="<<U<<endl;
2223 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D = field->GetExp();
2224 int nel = exp2D->size();
2232 for(
int i=0; i<nel; i++)
2234 if((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
2236 for(
int j = 0; j < locQuadExp->GetNedges(); ++j)
2238 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
2239 id = SegGeom->GetGlobalID();
2240 if( V1tmp[
id] == 10000)
2242 V1tmp[id]= SegGeom->GetVertex(0)->GetVid();
2243 V2tmp[id]= SegGeom->GetVertex(1)->GetVid();
2250 else if((locTriExp = (*exp2D)[i]->as<LocalRegions::TriExp>()))
2252 for(
int j = 0; j < locTriExp->GetNedges(); ++j)
2254 SegGeom = (locTriExp->GetGeom2D())->GetEdge(j);
2255 id = SegGeom->GetGlobalID();
2257 if( V1tmp[
id] == 10000)
2259 V1tmp[id]= SegGeom->GetVertex(0)->GetVid();
2260 V2tmp[id]= SegGeom->GetVertex(1)->GetVid();
2272 for(
int g=0; g<cnt; g++)
2275 ASSERTL0(V1tmp[g]!=10000,
"V1 wrong");
2277 ASSERTL0(V2tmp[g]!=10000,
"V2 wrong");
2299 boost::ignore_unused(xoldup, xolddown);
2301 int nlay_Eids = xcold.num_elements()-1;
2302 int nlay_Vids = xcold.num_elements();
2304 int nVertsTot = mesh->GetNvertices();
2305 cout<<
"nverttot="<<nVertsTot<<endl;
2309 cout<<
"init nlays="<<nlays<<endl;
2316 cout<<
"yoldup="<<yoldup[0]<<endl;
2317 cout<<
"yolddown="<<yolddown[0]<<endl;
2319 for(
int r=0; r< nVertsTot; r++)
2324 vertex->GetCoords(x,y,z);
2331 y<= yoldup[0] && y>= yolddown[0]
2344 cout<<
"nlays="<<nlays<<endl;
2356 for(
int w=0; w< nlays; w++)
2359 tmpx0[w]= tmpx[index];
2360 tmpy0[w]= tmpf[index];
2361 tmpVids0[w] = tmpV[index];
2362 tmpf[index] = max+1000;
2373 for(
int m=0; m<nlays; m++)
2384 NekDouble xtmp,ytmp,normnext=0.0,xnext=0.0,ynext=0.0,diff;
2385 NekDouble Ubef = 0.0, Utmp = 0.0, Unext = 0.0;
2388 int nTotEdges = V1.num_elements();
2390 for(
int m=0; m<nlays; m++)
2392 for(
int g=0; g<nlay_Eids; g++)
2396 for(
int h=0; h< nTotEdges; h++)
2399 if( tmpVids0[m]== V1[h] )
2403 vertex->GetCoords(x,y,z);
2407 Vids_lay[m][0] = V1[h];
2408 Vids_lay[m][1] = V2[h];
2410 = mesh->GetVertex(V1[h]);
2412 vertex1->GetCoords(x1,y1,z1);
2413 normbef= sqrt( (y-y1)*(y-y1)+(x-x1)*(x-x1) );
2418 elmtid = streak->GetExpIndex(coord,0.00001);
2419 offset = streak->GetPhys_Offset(elmtid);
2420 Ubef = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2425 if( tmpVids0[m]== V2[h] )
2429 vertex->GetCoords(x,y,z);
2433 Vids_lay[m][0] = V2[h];
2434 Vids_lay[m][1] = V1[h];
2436 = mesh->GetVertex(V2[h]);
2438 normbef= sqrt( (y-y2)*(y-y2)+(x-x2)*(x-x2) );
2443 elmtid = streak->GetExpIndex(coord,0.00001);
2444 offset = streak->GetPhys_Offset(elmtid);
2445 Ubef = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2452 cout<<
"Eid="<<Eids_lay[m][0]<<
" Vids_lay0="<<Vids_lay[m][0]<<
" Vidslay1="<<Vids_lay[m][1]<<endl;
2459 for(
int h=0; h< nTotEdges; h++)
2462 if( (Vids_lay[m][g]==V1[h] || Vids_lay[m][g]==V2[h]) && h!= Eids_lay[m][g-1])
2464 cout<<
"edgetmp="<<h<<endl;
2465 ASSERTL0(cnt<=6,
"wrong number of candidates");
2474 cout<<
"normbef="<<normbef<<endl;
2475 cout<<
"Ubefcc="<<Ubef<<endl;
2477 for(
int e=0; e< cnt; e++)
2481 vertex1->GetCoords(x1,y1,z1);
2484 vertex2->GetCoords(x2,y2,z2);
2486 normtmp= sqrt( (y2-y1)*(y2-y1)+(x2-x1)*(x2-x1) );
2488 cout<<
"edgetmp1="<<edgestmp[e]<<endl;
2489 cout<<
"V1 x1="<<x1<<
" y1="<<y1<<endl;
2490 cout<<
"V2 x2="<<x2<<
" y2="<<y2<<endl;
2491 if( Vids_lay[m][g]==V1[edgestmp[e]] )
2499 elmtid = streak->GetExpIndex(coord,0.00001);
2500 offset = streak->GetPhys_Offset(elmtid);
2501 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2502 diffarray[e] = abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2503 diffUarray[e] = abs(Ubef-Utmp);
2504 cout<<
" normtmp="<<normtmp<<endl;
2505 cout<<
" Utmpcc="<<Utmp<<endl;
2506 cout<<xtmp<<
" ytmp="<<ytmp<<
" diff="<<abs(((xtmp*xbef+ytmp*ybef)/(normtmp*normbef))-1)<<endl;
2508 abs( (xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1)<diff
2509 && y2<= yoldup[g+1] && y2>= yolddown[g+1]
2510 && y1<= yoldup[g] && y1>= yolddown[g]
2514 Eids_lay[m][g] = edgestmp[e];
2515 Vids_lay[m][g+1] = V2[edgestmp[e]];
2516 diff = abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2523 else if( Vids_lay[m][g]==V2[edgestmp[e]] )
2531 elmtid = streak->GetExpIndex(coord,0.00001);
2532 offset = streak->GetPhys_Offset(elmtid);
2533 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2534 diffarray[e] = abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2535 diffUarray[e] = abs(Ubef-Utmp);
2536 cout<<
" normtmp="<<normtmp<<endl;
2537 cout<<
" Utmpcc="<<Utmp<<endl;
2538 cout<<xtmp<<
" ytmp="<<ytmp<<
" diff="<<abs(((xtmp*xbef+ytmp*ybef)/(normtmp*normbef))-1)<<endl;
2540 abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1)<diff
2541 && y2<= yoldup[g] && y2>= yolddown[g]
2542 && y1<= yoldup[g+1] && y1>= yolddown[g+1]
2545 Eids_lay[m][g] = edgestmp[e];
2546 Vids_lay[m][g+1] = V1[edgestmp[e]];
2547 diff = abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2563 cout<<
"Eid before check="<<Eids_lay[m][g]<<endl;
2564 for(
int q=0; q<cnt; q++)
2566 cout<<q<<
" diff"<<diffarray[q]<<endl;
2576 cout<<
"COMMON VERT"<<endl;
2578 diffarray[eid]=1000;
2584 vertex1->GetCoords(x1,y1,z1);
2587 vertex2->GetCoords(x2,y2,z2);
2589 normtmp= sqrt( (y2-y1)*(y2-y1)+(x2-x1)*(x2-x1) );
2591 Eids_lay[m][g] = edgestmp[eid];
2592 if(Vids_lay[m][g] == V1[edgestmp[eid]])
2596 elmtid = streak->GetExpIndex(coord,0.00001);
2597 offset = streak->GetPhys_Offset(elmtid);
2598 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2599 Vids_lay[m][g+1] = V2[edgestmp[eid]];
2607 if(Vids_lay[m][g] == V2[edgestmp[eid]])
2611 elmtid = streak->GetExpIndex(coord,0.00001);
2612 offset = streak->GetPhys_Offset(elmtid);
2613 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2614 Vids_lay[m][g+1] = V1[edgestmp[eid]];
2625 cout<<m<<
"edge aft:"<<Eids_lay[m][g]<<
" Vid="<<Vids_lay[m][g+1]<<endl;
2631 cout<<
"endelse"<<normtmp<<endl;
2643 for(
int w=0; w< nlays; w++)
2645 for(
int f=0; f< nlay_Eids; f++)
2647 cout<<
"check="<<w<<
" Eid:"<<Eids_lay[w][f]<<endl;
2657 for(
int u=0; u< Vids_laybefore.num_elements(); u++)
2659 if( Vids_laybefore[u]==Vid || Vids_c[u]==Vid)
2663 cout<<Vid<<
" Vert test="<<Vids_laybefore[u]<<endl;
2675 int np_lay = inarray.num_elements();
2676 ASSERTL0(inarray.num_elements()%nedges==0,
" something on number npedge");
2680 for(
int w=0; w< np_lay; w++)
2685 if(inarray[w] ==inarray[w+1])
2690 outarray[cnt]= inarray[w];
2695 ASSERTL0( cnt== np_lay-(nedges-1),
"wrong cut");
2701 int npts = xArray.num_elements();
2710 if(xArray[index]> x)
2721 ASSERTL0( neighpoints%2==0,
"number of neighbour points should be even");
2722 int leftpoints = (neighpoints/2)-1;
2723 int rightpoints = neighpoints/2;
2727 if(index-leftpoints<0)
2730 diff = index-leftpoints;
2732 Vmath::Vcopy(neighpoints, &yArray[0],1,&Neighbour_y[0],1);
2733 Vmath::Vcopy(neighpoints, &xArray[0],1,&Neighbour_x[0],1);
2735 else if( (yArray.num_elements()-1)-index < rightpoints)
2738 int rpoints = (yArray.num_elements()-1)-index;
2739 diff = rightpoints-rpoints;
2741 start = index-leftpoints-diff;
2742 Vmath::Vcopy(neighpoints, &yArray[start],1,&Neighbour_y[0],1);
2743 Vmath::Vcopy(neighpoints, &xArray[start],1,&Neighbour_x[0],1);
2748 start = index-leftpoints;
2749 Vmath::Vcopy(neighpoints, &yArray[start],1,&Neighbour_y[0],1);
2750 Vmath::Vcopy(neighpoints, &xArray[start],1,&Neighbour_x[0],1);
2759 for(
int f=1; f< neighpoints; f++)
2761 ASSERTL0(Neighbour_x[f]!=Neighbour_x[f-1],
" repetition on NeighbourArrays");
2772 for(
int pt=0;pt<npts;++pt)
2776 for(
int j=0;j<pt; ++j)
2778 h = h * (x - xpts[j])/(xpts[pt]-xpts[j]);
2781 for(
int k=pt+1;k<npts;++k)
2783 h = h * (x - xpts[k])/(xpts[pt]-xpts[k]);
2787 sum += funcvals[pt]*LagrangePoly;
2799 int np_pol= coeffsinterp.num_elements();
2800 cout<<
"evaluatetan with "<<np_pol<<endl;
2806 for(
int q=0; q< npoints; q++)
2811 for(
int d=0; d< np_pol-1; d++)
2813 yprime[q] += (derorder +1)*coeffsinterp[d]*std::pow(xcQedge[q],derorder);
2817 for(
int a=0; a< np_pol; a++)
2819 yinterp[q] += coeffsinterp[a]*std::pow(xcQedge[q],polorder);
2827 for(
int n=0; n< npoints; n++)
2831 txQedge[n] = cos((atan((yprime[n]))));
2832 tyQedge[n] = sin((atan((yprime[n]))));
2833 cout<<xcQedge[n]<<
" "<<yinterp[n]<<
" "<<yprime[n]<<
" "<<txQedge[n]<<
" "<<tyQedge[n]<<endl;
2840 int edge,
int npedge)
2842 int np_pol = xpol.num_elements();
2848 for(
int e=0; e<N; e++)
2851 for(
int w=0; w < N; w++)
2853 A[N*e+row] = std::pow( xpol[w], N-1-e);
2858 for(
int r= 0; r< np_pol; r++)
2872 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2873 "th parameter had an illegal parameter for dgetrf";
2878 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2879 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2885 Lapack::Dgetrs(
'N', N, ncolumns_b , A.get() , N, ipivot.get(), b.get(), N, info);
2888 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2889 "th parameter had an illegal parameter for dgetrf";
2894 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2895 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2909 for(
int c=0; c< npedge; c++)
2913 ycout[edge*(npedge)+c+1]=0;
2914 for(
int d=0; d< np_pol; d++)
2916 ycout[edge*(npedge)+c+1] += b[d]
2917 *std::pow(xcout[edge*(npedge)+c+1],polorder);
2935 int N = polyorder+1;
2938 cout<<npoints<<endl;
2939 for(
int u=0; u<npoints; u++)
2941 cout<<
"c="<<xin[u]<<
" "<<
2946 for(
int e=0; e<N; e++)
2949 for(
int row=0; row<N; row++)
2951 for(
int w=0; w < npoints; w++)
2953 A[N*e+row] += std::pow( xin[w], e+row);
2958 for(
int row= 0; row< N; row++)
2960 for(
int h=0; h< npoints; h++)
2962 b[row] += fin[h]*std::pow(xin[h],row);
2980 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2981 "th parameter had an illegal parameter for dgetrf";
2986 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2987 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, info);
2995 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2996 "th parameter had an illegal parameter for dgetrf";
3001 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
3002 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
3011 for(
int j=0; j<N; j++)
3017 for(
int h=0; h<N; h++)
3019 cout<<
"coeff:"<<b[h]<<endl;
3024 for(
int c=0; c< npout; c++)
3029 for(
int d=0; d< N; d++)
3033 *std::pow(xout[c],polorder);
3053 Vmath::Vcopy(inarray_x.num_elements() , inarray_x,1,tmpx,1);
3054 Vmath::Vcopy(inarray_x.num_elements() , inarray_y,1,tmpy,1);
3059 for(
int w=0; w<tmpx.num_elements(); w++)
3062 outarray_x[w]= tmpx[index];
3063 outarray_y[w]= tmpy[index];
3064 if(w< tmpx.num_elements()-1)
3066 if(tmpx[index] == tmpx[index+1])
3068 outarray_x[w+1]= tmpx[index+1];
3069 outarray_y[w+1]= tmpy[index+1];
3070 tmpx[index+1] = max+1000;
3086 tmpx[index] = max+1000;
3098 int np_lay = layers_y[0].num_elements();
3100 for(
int h=1; h<nlays-1; h++)
3103 for(
int s=0; s<nvertl; s++)
3106 ASSERTL0(ynew[ lay_Vids[h][s] ]==-20,
"ynew layers not empty");
3110 ynew[ lay_Vids[h][s] ] = ynew[Down[s]]+ h*abs(ynew[Down[s]] - yc[s])/(cntlow+1);
3112 xnew[lay_Vids[h][s] ] = xc[s];
3116 layers_y[h][s] = ynew[ lay_Vids[h][s] ];
3117 layers_x[h][s] = xnew[ lay_Vids[h][s] ];
3122 ynew[ lay_Vids[h][s] ] = yc[s] + (h-cntlow)*abs(ynew[Up[s]] - yc[s])/(cntup+1);
3124 xnew[lay_Vids[h][s] ] = xc[s];
3126 layers_y[h][s] = ynew[ lay_Vids[h][s] ];
3127 layers_x[h][s] = xnew[ lay_Vids[h][s] ];
3141 int np_lay = xcPhys.num_elements();
3142 int nedges = nvertl-1;
3149 int closepoints = 4;
3154 for(
int g=0; g< nedges; g++)
3163 xnew[Vids[g] ]= xcPhys[g*npedge+0];
3164 ylay[g*npedge +0] = ynew[ Vids[g] ];
3165 xlay[g*npedge +0] = xnew[ Vids[g] ];
3173 ynew[Vids[g+1] ]=
LagrangeInterpolant(xcPhys[g*npedge +npedge-1],closepoints,Pxinterp,Pyinterp );
3174 xnew[Vids[g+1] ]= xcPhys[g*npedge +npedge-1];
3175 ylay[g*npedge +npedge-1] = ynew[Vids[g+1] ];
3176 xlay[g*npedge +npedge-1] = xnew[Vids[g+1] ];
3181 for(
int r=0; r< npedge-2; r++)
3189 ASSERTL0( index<= tmpy.num_elements()-1,
" index wrong");
3193 ylay[g*npedge +r+1]=
3195 xcPhys[g*npedge +r+1],closepoints,Pxinterp,Pyinterp );
3197 xlay[g*npedge +r+1]= xcPhys[g*npedge +r+1];
3220 int np_lay = xcPhys.num_elements();
3221 int nedges = nvertl-1;
3229 int closepoints = 4;
3234 for(
int g=0; g< nedges; g++)
3238 ynew[Vids[g] ]= tmpy_lay[g*npedge+0];
3239 xnew[Vids[g] ]= tmpx_lay[g*npedge+0];
3242 ylay[g*npedge +0] = ynew[ Vids[g] ];
3243 xlay[g*npedge +0] = xnew[ Vids[g] ];
3246 ynew[Vids[g+1] ]= tmpy_lay[g*npedge+npedge-1];
3247 xnew[Vids[g+1] ]= tmpx_lay[g*npedge+npedge-1];
3248 ylay[g*npedge +npedge-1] = ynew[Vids[g+1] ];
3249 xlay[g*npedge +npedge-1] = xnew[Vids[g+1] ];
3254 for(
int r=0; r< npedge-2; r++)
3256 x0 = xlay[g*npedge +0];
3257 x1 = xlay[g*npedge +npedge-1];
3258 xtmp = x0 + r*(x1-x0)/(npedge-1);
3264 ASSERTL0( index<= tmpy.num_elements()-1,
" index wrong");
3268 ylay[g*npedge +r+1]=
3270 xtmp,closepoints,Pxinterp,Pyinterp );
3272 xlay[g*npedge +r+1]= xtmp;
3287 boost::ignore_unused(xolddown, xoldup);
3290 int nvertl = ycold.num_elements();
3291 int nVertTot = mesh->GetNvertices();
3292 for(
int n=0; n<nVertTot; n++)
3297 vertex->GetCoords(x,y,z);
3302 for(
int k=0; k<nvertl; k++)
3304 if(abs(x-xcold[k]) < tmp)
3306 tmp = abs(x-xcold[k]);
3319 nplay_closer= (qp_closer-1)*npedge +npedge-1;
3323 if( y>yoldup[qp_closer] && y<1 )
3328 ratio = (1-ylayup[nplay_closer])/
3329 ( (1-yoldup[qp_closer]) );
3331 ynew[n] = ylayup[nplay_closer]
3332 + (y-yoldup[qp_closer])*ratio;
3336 else if( y< yolddown[qp_closer] && y>-1 )
3339 ratio = (1+ylaydown[nplay_closer])/
3340 ( (1+yolddown[qp_closer]) );
3342 ynew[n] = ylaydown[nplay_closer]
3343 + (y-yolddown[qp_closer])*ratio;
3359 boost::ignore_unused(xcold, ycold);
3375 int nvertl = xoldup.num_elements();
3376 int nedges = nvertl-1;
3385 for(
int a=0; a< nedges;a++)
3390 xnew_down[a] = xlaydown[a*npedge+0];
3391 ynew_down[a] = ylaydown[a*npedge+0];
3392 xnew_up[a] = xlayup[a*npedge+0];
3393 ynew_up[a] = ylayup[a*npedge+0];
3394 nxvert[a] = nxPhys[a*npedge+0];
3395 nyvert[a] = nyPhys[a*npedge+0];
3397 xnew_down[a+1] = xlaydown[a*npedge+npedge-1];
3398 ynew_down[a+1] = ylaydown[a*npedge+npedge-1];
3399 xnew_up[a+1] = xlayup[a*npedge+npedge-1];
3400 ynew_up[a+1] = ylayup[a*npedge+npedge-1];
3401 nxvert[a+1] = nxPhys[a*npedge+npedge-1];
3402 nyvert[a+1] = nyPhys[a*npedge+npedge-1];
3407 xnew_down[a+1] = xlaydown[a*npedge+npedge-1];
3408 ynew_down[a+1] = ylaydown[a*npedge+npedge-1];
3409 xnew_up[a+1] = xlayup[a*npedge+npedge-1];
3410 ynew_up[a+1] = ylayup[a*npedge+npedge-1];
3411 nxvert[a+1] = nxPhys[a*npedge+npedge-1];
3412 nyvert[a+1] = nyPhys[a*npedge+npedge-1];
3424 int nVertTot = mesh->GetNvertices();
3425 for(
int n=0; n<nVertTot; n++)
3430 vertex->GetCoords(x,y,z);
3431 int qp_closeroldup = 0, qp_closerolddown = 0;
3440 for(
int k=0; k<nvertl; k++)
3442 if(abs(x-xolddown[k]) < diffdown)
3444 diffdown = abs(x-xolddown[k]);
3447 if(abs(x-xoldup[k]) < diffup)
3449 diffup = abs(x-xoldup[k]);
3459 int qp_closerup = 0, qp_closerdown = 0;
3461 for(
int f=0; f< nvertl; f++)
3463 if(abs(x-xnew_down[f]) < diffdown)
3465 diffdown = abs(x-xnew_down[f]);
3468 if(abs(x-xnew_up[f]) < diffup)
3470 diffup = abs(x-xnew_up[f]);
3497 int qp_closernormup;
3508 int qp_closernormdown;
3519 if( y>yoldup[qp_closeroldup] && y<1 )
3524 ratio = (1-ynew_up[qp_closerup])/
3525 ( (1-yoldup[qp_closeroldup]) );
3530 ynew[n] = ynew_up[qp_closerup]
3531 + (y-yoldup[qp_closeroldup])*ratio;
3537 if(x> (xmax-xmin)/2. && x< xmax)
3539 ratiox = (xmax-xnew_up[qp_closernormup])/
3540 (xmax-xoldup[qp_closernormup]) ;
3541 if( (xmax-xoldup[qp_closernormup])==0)
3548 xnew[n] = x + abs(nxvert[qp_closernormup])*(xnew_up[qp_closeroldup]-xoldup[qp_closeroldup])*ratiox;
3549 ASSERTL0(x>xmin,
" x value <xmin up second half");
3550 ASSERTL0(x<xmax," x value >xmax up second half
"); 3552 else if( x> xmin && x<= (xmax-xmin)/2.) 3554 //cout<<"up close normold=
"<<qp_closernormoldup<<" closenorm=
"<<qp_closernormup<<endl; 3555 ratiox = (xnew_up[qp_closernormup]-xmin)/ 3556 ( (xoldup[qp_closernormup]-xmin) ); 3557 if( (xoldup[qp_closernormup]-xmin)==0) 3561 //xnew[n] = xnew_up[qp_closerup] 3562 // + (x-xoldup[qp_closeroldup])*ratiox; 3563 xnew[n] = x + abs(nxvert[qp_closernormup])*(xnew_up[qp_closeroldup]-xoldup[qp_closeroldup])*ratiox; 3564 //cout<<"up xold=
"<<x<<" xnew=
"<<xnew[n]<<endl; 3565 ASSERTL0(x>xmin," x value <xmin up first half
"); 3566 ASSERTL0(x<xmax," x value >xmax up first half
"); 3571 else if( y< yolddown[qp_closerolddown] && y>-1 ) 3574 ratio = (1+ynew_down[qp_closerdown])/ 3575 ( (1+yolddown[qp_closerolddown]) ); 3577 // ratioy = (1-ynew_down[qp_closernormdown])/ 3578 // ( (1-yolddown[qp_closernormolddown]) ); 3580 //distance prop to layerlow 3581 ynew[n] = ynew_down[qp_closerdown] 3582 + (y-yolddown[qp_closerolddown])*ratio; 3583 //ynew[n] = y +abs(nyvert[qp_closernormdown])* 3584 // (ynew_down[qp_closerolddown]-yolddown[qp_closerolddown])*ratioy; 3585 //ynew[n] = y + 0.3*(ynew_down[qp_closerdown]-yolddown[qp_closerdown]); 3586 //xnew[n] = x + abs(nxvert[qp_closerolddown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown]); 3590 cout<<qp_closerolddown<<" nplaydown=
"<<qp_closerdown<<endl; 3591 cout<<"xolddown=
"<<xolddown[qp_closerolddown]<<" xnewdown=
"<<xnew_down[qp_closerdown]<<endl; 3592 cout<<"xold+
"<<x<<" xnew+
"<<xnew[n]<<endl; 3596 if(x> (xmax-xmin)/2. && x <xmax) 3598 ratiox = (xmax-xnew_down[qp_closernormdown])/ 3599 ( (xmax-xolddown[qp_closernormdown]) ); 3600 if( (xmax-xolddown[qp_closernormdown])==0) 3604 //xnew[n] = xnew_down[qp_closerdown] 3605 // + (x-xolddown[qp_closerolddown])*ratiox; 3607 abs(nxvert[qp_closernormdown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown])*ratiox; 3608 ASSERTL0(x>xmin," x value <xmin down second half
"); 3609 ASSERTL0(x<xmax," x value >xmax down second half
"); 3611 else if( x>xmin && x<= (xmax-xmin)/2.) 3613 ratiox = (xnew_down[qp_closernormdown]-xmin)/ 3614 ( (xolddown[qp_closernormdown]-xmin) ); 3615 if( (xolddown[qp_closernormdown]-xmin)==0) 3619 //xnew[n] = xnew_down[qp_closerdown] 3620 // + (x-xolddown[qp_closerolddown])*ratiox; 3622 abs(nxvert[qp_closernormdown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown])*ratiox; 3623 ASSERTL0(x>xmin," x value <xmin down first half
"); 3624 ASSERTL0(x<xmax," x value >xmax down first half
"); 3629 cout<<"xold
"<<x<<" xnew=
"<<xnew[n]<<endl; 3630 ASSERTL0(xnew[n] >= xmin, "newx < xmin
"); 3631 ASSERTL0(xnew[n]<= xmax, "newx > xmax
"); 3636 void CheckSingularQuads( MultiRegions::ExpListSharedPtr Exp, 3637 Array<OneD, int> V1, Array<OneD, int> V2, 3638 Array<OneD, NekDouble>& xnew,Array<OneD, NekDouble>& ynew) 3640 const std::shared_ptr<LocalRegions::ExpansionVector> exp2D = Exp->GetExp(); 3641 int nel = exp2D->size(); 3642 LocalRegions::QuadExpSharedPtr locQuadExp; 3643 LocalRegions::TriExpSharedPtr locTriExp; 3644 SpatialDomains::Geometry1DSharedPtr SegGeom; 3646 NekDouble xV1, yV1, xV2,yV2; 3647 NekDouble slopebef = 0.0,slopenext = 0.0,slopenew = 0.0; 3648 Array<OneD, int> locEids(4); 3649 for(int i=0; i<nel; i++) 3651 if((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>())) 3653 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(0); 3654 idbef = SegGeom->GetGlobalID(); 3655 if(xnew[ V1[idbef] ]<= xnew[ V2[idbef] ]) 3657 xV1 = xnew[ V1[idbef] ]; 3658 yV1 = ynew[ V1[idbef] ]; 3659 xV2 = xnew[ V2[idbef] ]; 3660 yV2 = ynew[ V2[idbef] ]; 3661 slopebef = (yV2 -yV1)/(xV2 -xV1); 3665 xV1 = xnew[ V2[idbef] ]; 3666 yV1 = ynew[ V2[idbef] ]; 3667 xV2 = xnew[ V1[idbef] ]; 3668 yV2 = ynew[ V1[idbef] ]; 3669 slopebef = (yV2 -yV1)/(xV2 -xV1); 3671 //cout<<"00 V1 x=
"<<xnew[ V1[idbef] ]<<" y=
"<<ynew[ V1[idbef] ]<<endl; 3672 //cout<<"00 V2 x=
"<<xnew[ V2[idbef] ]<<" y=
"<<ynew[ V2[idbef] ]<<endl; 3673 for(int j = 1; j < locQuadExp->GetNedges(); ++j) 3675 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j); 3676 idnext = SegGeom->GetGlobalID(); 3677 //cout<<"id=
"<<idnext<<" locid=
"<<j<<endl; 3678 //cout<<" V1 x=
"<<xnew[ V1[idnext] ]<<" y=
"<<ynew[ V1[idnext] ]<<endl; 3679 //cout<<" V2 x=
"<<xnew[ V2[idnext] ]<<" y=
"<<ynew[ V2[idnext] ]<<endl; 3680 if(xV1 == xnew[ V1[idnext] ] && yV1 == ynew[ V1[idnext] ] ) 3682 xV1 = xnew[ V1[idnext] ]; 3683 yV1 = ynew[ V1[idnext] ]; 3684 xV2 = xnew[ V2[idnext] ]; 3685 yV2 = ynew[ V2[idnext] ]; 3686 slopenext = (yV2 -yV1)/(xV2 -xV1); 3689 cout<<"case1 x0=
"<<xV1<<" x1=
"<<xV2<<endl; 3690 cout<<idnext<<" 11slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl; 3692 //compare with slope before 3693 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18) 3695 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] -0.01; 3696 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]); 3698 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) ) 3700 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] +0.02; 3701 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]); 3703 slopenext = slopenew; 3704 cout<<"slopenew=
"<<slopenew<<endl; 3705 cout<<"moved x=
"<<xnew[ V1[idnext] ]<<endl; 3708 else if(xV2 == xnew[ V2[idnext] ] && yV2 == ynew[ V2[idnext] ] ) 3710 xV1 = xnew[ V2[idnext] ]; 3711 yV1 = ynew[ V2[idnext] ]; 3712 xV2 = xnew[ V1[idnext] ]; 3713 yV2 = ynew[ V1[idnext] ]; 3714 slopenext = (yV2 -yV1)/(xV2 -xV1); 3717 cout<<"case2 x0=
"<<xV1<<" x1=
"<<xV2<<endl; 3718 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl; 3720 //compare with slope before 3721 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18) 3723 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] -0.01; 3724 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]); 3726 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) ) 3728 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] +0.02; 3729 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]); 3732 slopenext = slopenew; 3733 cout<<"slopenew=
"<<slopenew<<endl; 3734 cout<<"moved x=
"<<xnew[ V2[idnext] ]<<endl; 3737 else if(xV1 == xnew[ V2[idnext] ] && yV1 == ynew[ V2[idnext] ] ) 3739 xV1 = xnew[ V2[idnext] ]; 3740 yV1 = ynew[ V2[idnext] ]; 3741 xV2 = xnew[ V1[idnext] ]; 3742 yV2 = ynew[ V1[idnext] ]; 3743 slopenext = (yV2 -yV1)/(xV2 -xV1); 3746 cout<<"case3 x0=
"<<xV1<<" x1=
"<<xV2<<endl; 3747 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl; 3749 //compare with slope before 3750 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18) 3752 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] -0.01; 3753 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]); 3755 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) ) 3757 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] +0.02; 3758 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]); 3760 slopenext = slopenew; 3761 cout<<"slopenew=
"<<slopenew<<endl; 3762 cout<<"moved x=
"<<xnew[ V2[idnext] ]<<endl; 3766 else if(xV2 == xnew[ V1[idnext] ] && yV2 == ynew[ V1[idnext] ] ) 3768 xV1 = xnew[ V1[idnext] ]; 3769 yV1 = ynew[ V1[idnext] ]; 3770 xV2 = xnew[ V2[idnext] ]; 3771 yV2 = ynew[ V2[idnext] ]; 3772 slopenext = (yV2 -yV1)/(xV2 -xV1); 3775 cout<<"case4 x0=
"<<xV1<<" x1=
"<<xV2<<endl; 3776 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl; 3778 //compare with slope before 3779 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18) 3781 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] -0.01; 3782 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]); 3784 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) ) 3786 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] +0.02; 3787 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]); 3789 slopenext = slopenew; 3790 cout<<"slopenew=
"<<slopenew<<endl; 3791 cout<<"moved x=
"<<xnew[ V1[idnext] ]<<endl; 3797 ASSERTL0(false, "edge not connected
"); 3799 slopebef = slopenext; 3808 void Replacevertices(string filename, Array<OneD, NekDouble> newx, 3809 Array<OneD, NekDouble> newy, 3810 Array<OneD, NekDouble> xcPhys, Array<OneD, NekDouble> ycPhys, 3811 Array<OneD, int>Eids, int Npoints, string s_alp, 3812 Array<OneD, Array<OneD, NekDouble> > x_lay, 3813 Array<OneD, Array<OneD, NekDouble> > y_lay, 3814 Array<OneD, Array<OneD, int > >lay_eids, bool curv_lay) 3816 //load existing file 3818 TiXmlDocument doc(filename); 3819 //load xscale parameter (if exists) 3820 TiXmlElement* master = doc.FirstChildElement("NEKTAR
"); 3821 TiXmlElement* mesh = master->FirstChildElement("GEOMETRY
"); 3822 TiXmlElement* element = mesh->FirstChildElement("VERTEX
"); 3823 NekDouble xscale = 1.0; 3824 LibUtilities::Interpreter expEvaluator; 3825 const char *xscal = element->Attribute("XSCALE
"); 3828 std::string xscalstr = xscal; 3829 int expr_id = expEvaluator.DefineFunction("",xscalstr); 3830 xscale = expEvaluator.Evaluate(expr_id); 3834 // Save a new XML file. 3835 newfile = filename.substr(0, filename.find_last_of(".
"))+"_moved.xml
"; 3836 doc.SaveFile( newfile ); 3838 //write the new vertices 3839 TiXmlDocument docnew(newfile); 3840 bool loadOkaynew = docnew.LoadFile(); 3842 std::string errstr = "Unable to load file:
"; 3844 ASSERTL0(loadOkaynew, errstr.c_str()); 3846 TiXmlHandle docHandlenew(&docnew); 3847 TiXmlElement* meshnew = NULL; 3848 TiXmlElement* masternew = NULL; 3849 TiXmlElement* condnew = NULL; 3850 TiXmlElement* Parsnew = NULL; 3851 TiXmlElement* parnew = NULL; 3853 // Master tag within which all data is contained. 3856 masternew = docnew.FirstChildElement("NEKTAR
"); 3857 ASSERTL0(masternew, "Unable to
find NEKTAR tag in file.
"); 3859 //set the alpha value 3861 condnew = masternew->FirstChildElement("CONDITIONS
"); 3862 Parsnew = condnew->FirstChildElement("PARAMETERS
"); 3863 cout<<"alpha=
"<<s_alp<<endl; 3864 parnew = Parsnew->FirstChildElement("P"); 3867 TiXmlNode *node = parnew->FirstChild(); 3870 // Format is "paramName = value
" 3871 std::string line = node->ToText()->Value(); 3875 int beg = line.find_first_not_of("
"); 3876 int end = line.find_first_of("=
"); 3877 // Check for no parameter name 3878 if (beg == end) throw 1; 3879 // Check for no parameter value 3880 if (end != line.find_last_of("=
")) throw 1; 3881 // Check for no equals sign 3882 if (end == std::string::npos) throw 1; 3883 lhs = line.substr(line.find_first_not_of(" "), end-beg); 3884 lhs = lhs.substr(0, lhs.find_last_not_of(" ")+1); 3886 //rhs = line.substr(line.find_last_of("=
")+1); 3887 //rhs = rhs.substr(rhs.find_first_not_of(" ")); 3888 //rhs = rhs.substr(0, rhs.find_last_not_of(" ")+1); 3890 boost::to_upper(lhs); 3893 alphastring = "Alpha =
"+ s_alp; 3894 parnew->RemoveChild(node); 3895 parnew->LinkEndChild(new TiXmlText(alphastring) ); 3899 parnew = parnew->NextSiblingElement("P"); 3903 // Find the Mesh tag and same the dim and space attributes 3904 meshnew = masternew->FirstChildElement("GEOMETRY
"); 3906 ASSERTL0(meshnew, "Unable to
find GEOMETRY tag in file.
"); 3907 // Now read the vertices 3908 TiXmlElement* elementnew = meshnew->FirstChildElement("VERTEX
"); 3909 ASSERTL0(elementnew, "Unable to
find mesh VERTEX tag in file.
"); 3913 elementnew->SetAttribute("XSCALE
",1.0); 3915 TiXmlElement *vertexnew = elementnew->FirstChildElement("V
"); 3921 int nextVertexNumber = -1; 3926 //delete the old one 3927 TiXmlAttribute *vertexAttr = vertexnew->FirstAttribute(); 3928 std::string attrName(vertexAttr->Name()); 3929 ASSERTL0(attrName == "ID
", (std::string("Unknown attribute
name:
") + attrName).c_str()); 3931 err = vertexAttr->QueryIntValue(&indx); 3932 ASSERTL0(err == TIXML_SUCCESS, "Unable to read attribute ID.
"); 3933 ASSERTL0(indx == nextVertexNumber, "Vertex IDs must begin with zero and be sequential.
"); 3935 std::string vertexBodyStr; 3936 // Now read body of vertex 3937 TiXmlNode *vertexBody = vertexnew->FirstChild(); 3938 // Accumulate all non-comment body data. 3939 if (vertexBody->Type() == TiXmlNode::TINYXML_TEXT) 3941 vertexBodyStr += vertexBody->ToText()->Value(); 3942 vertexBodyStr += " "; 3944 ASSERTL0(!vertexBodyStr.empty(), "Vertex definitions must contain vertex data.
"); 3945 //remove the old coordinates 3946 vertexnew->RemoveChild(vertexBody); 3948 //cout<<"writing.. v:
"<<nextVertexNumber<<endl; 3950 //we need at least 5 digits (setprecision 5) to get the streak position with 3952 s << std::scientific << std::setprecision(8) << newx[nextVertexNumber] << " " 3953 << newy[nextVertexNumber] << " " << 0.0; 3954 vertexnew->LinkEndChild(new TiXmlText(s.str())); 3955 //TiXmlNode *newvertexBody = vertexnew->FirstChild(); 3956 //string newvertexbodystr= newvertexBody->SetValue(s.str()); 3957 //vertexnew->ReplaceChild(vertexBody,new TiXmlText(newvertexbodystr)); 3959 vertexnew = vertexnew->NextSiblingElement("V
"); 3964 //read the curved tag 3965 TiXmlElement* curvednew = meshnew->FirstChildElement("CURVED
"); 3966 ASSERTL0(curvednew, "Unable to
find mesh CURVED tag in file.
"); 3967 TiXmlElement *edgenew = curvednew->FirstChildElement("E
"); 3969 //ID is different from index... 3970 std::string charindex; 3974 int neids_lay = lay_eids[0].num_elements(); 3975 //if edgenew belongs to the crit lay replace it, else delete it. 3981 TiXmlAttribute *edgeAttr = edgenew->FirstAttribute(); 3982 std::string attrName(edgeAttr->Name()); 3983 charindex = edgeAttr->Value(); 3984 std::istringstream iss(charindex); 3985 iss >> std::dec >> index; 3987 edgenew->QueryIntAttribute("EDGEID
", &eid); 3988 //cout<<"eid=
"<<eid<<" neid=
"<<Eids.num_elements()<<endl; 3989 //find the corresponding index curve point 3990 for(int u=0; u<Eids.num_elements(); u++) 3992 //cout<<"Eids=
"<<Eids[u]<<" eid=
"<<eid<<endl; 4000 curvednew->RemoveChild(edgenew); 4001 //ASSERTL0(false, "edge to update not found
"); 4006 std::string edgeBodyStr; 4007 //read the body of the edge 4008 TiXmlNode *edgeBody = edgenew->FirstChild(); 4009 if(edgeBody->Type() == TiXmlNode::TINYXML_TEXT) 4011 edgeBodyStr += edgeBody->ToText()->Value(); 4014 ASSERTL0(!edgeBodyStr.empty(), "Edge definitions must contain edge data
"); 4015 //remove the old coordinates 4016 edgenew->RemoveChild(edgeBody); 4017 //write the new points coordinates 4018 //we need at least 5 digits (setprecision 5) to get the streak position with 4021 //Determine the number of points 4022 err = edgenew->QueryIntAttribute("NUMPOINTS
", &numPts); 4023 ASSERTL0(err == TIXML_SUCCESS, "Unable to read curve attribute NUMPOINTS.
"); 4026 edgenew->SetAttribute("NUMPOINTS
", Npoints); 4027 for(int u=0; u< Npoints; u++) 4029 st << std::scientific << 4030 std::setprecision(8) <<xcPhys[cnt*Npoints+u] 4031 << " " << ycPhys[cnt*Npoints+u] << " " << 0.000<<" "; 4034 edgenew->LinkEndChild(new TiXmlText(st.str())); 4038 st << std::scientific << std::setprecision(8) << x_crit[v1] << " " 4039 << y_crit[v1] << " " << 0.000<<" "; 4040 for(int a=0; a< Npoints-2; a++) 4042 st << std::scientific << std::setprecision(8) << 4043 " "<<Pcurvx[indexeid*(Npoints-2) +a]<<" "<<Pcurvy[indexeid*(Npoints-2) +a] 4047 st << std::scientific << std::setprecision(8) << 4048 " "<<x_crit[v2]<<" "<< y_crit[v2] <<" "<< 0.000; 4049 edgenew->LinkEndChild(new TiXmlText(st.str())); 4056 edgenew = edgenew->NextSiblingElement("E
"); 4060 //write also the others layers curve points 4061 if(curv_lay == true) 4063 cout<<"write other curved edges
"<<endl; 4064 TiXmlElement * curved = meshnew->FirstChildElement("CURVED
"); 4066 int nlays = lay_eids.num_elements(); 4068 //TiXmlComment * comment = new TiXmlComment(); 4069 //comment->SetValue(" new edges
"); 4070 //curved->LinkEndChild(comment); 4071 for (int g=0; g< nlays; ++g) 4073 for(int p=0; p< neids_lay; p++) 4076 TiXmlElement * e = new TiXmlElement( "E
" ); 4077 e->SetAttribute("ID
", idcnt++); 4078 e->SetAttribute("EDGEID
", lay_eids[g][p]); 4079 e->SetAttribute("NUMPOINTS
", Npoints); 4080 e->SetAttribute("TYPE
", "PolyEvenlySpaced
"); 4081 for(int c=0; c< Npoints; c++) 4083 st << std::scientific << std::setprecision(8) <<x_lay[g][p*Npoints +c] 4084 << " " << y_lay[g][p*Npoints +c] << " " << 0.000<<" "; 4088 TiXmlText * t0 = new TiXmlText(st.str()); 4089 e->LinkEndChild(t0); 4090 curved->LinkEndChild(e); 4098 docnew.SaveFile( newfile ); 4100 cout<<"new file:
"<<newfile<<endl; 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)
bool checkcommonvert(Array< OneD, int > Vids_laybefore, Array< OneD, int > Vids_c, int Vid)
static void Dgetrf(const int &m, const int &n, double *a, const int &lda, int *ipiv, int &info)
General matrix LU factorisation.
#define ASSERTL0(condition, msg)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< ContField1D > ContField1DSharedPtr
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)
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void GenerateMapEidsv1v2(MultiRegions::ExpListSharedPtr field, Array< OneD, int > &V1, Array< OneD, int > &V2)
void Vsqrt(int n, const T *x, const int incx, T *y, const int incy)
sqrt y = sqrt(x)
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 GenerateAddPointsNewtonIt(NekDouble xi, NekDouble yi, NekDouble &xout, NekDouble &yout, MultiRegions::ExpListSharedPtr function, Array< OneD, NekDouble > derfunction, NekDouble cr)
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...
T Vmax(int n, const T *x, const int incx)
Return the maximum element in x – called vmax to avoid conflict with max.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
T Vmin(int n, const T *x, const int incx)
Return the minimum element in x - called vmin to avoid conflict with min.
std::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
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)
int Imin(int n, const T *x, const int incx)
Return the index of the minimum element in x.
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 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.
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 Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |x|
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 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 ...
void Cutrepetitions(int nedges, Array< OneD, NekDouble > inarray, Array< OneD, NekDouble > &outarray)
int main(int argc, char *argv[])
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*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)
NekDouble LagrangeInterpolant(NekDouble x, int npts, Array< OneD, NekDouble > xpts, Array< OneD, NekDouble > funcvals)
void CheckSingularQuads(MultiRegions::ExpListSharedPtr Exp, Array< OneD, int > V1, Array< OneD, int > V2, 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)
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
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)
std::shared_ptr< PointGeom > PointGeomSharedPtr
Represents a vertex in the mesh.
void Sadd(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Add vector y = alpha + x.
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 Orderfunctionx(Array< OneD, NekDouble > inarray_x, Array< OneD, NekDouble > inarray_y, Array< OneD, NekDouble > &outarray_x, Array< OneD, NekDouble > &outarray_y)
std::shared_ptr< SegExp > SegExpSharedPtr
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
std::shared_ptr< TriExp > TriExpSharedPtr
std::shared_ptr< Geometry1D > Geometry1DSharedPtr
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 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)
std::shared_ptr< QuadExp > QuadExpSharedPtr
void Zero(int n, T *x, const int incx)
Zero vector.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
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)
std::shared_ptr< ExpList1D > ExpList1DSharedPtr
Shared pointer to an ExpList1D object.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
const BoundaryRegionCollection & GetBoundaryRegions(void) const
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 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 GenerateNeighbourArrays(int index, int neighpoints, Array< OneD, NekDouble > xArray, Array< OneD, NekDouble > yArray, Array< OneD, NekDouble > &Neighbour_x, Array< OneD, NekDouble > &Neighbour_y)