63 #include <boost/lexical_cast.hpp>
114 int edge,
int npedge);
115 void PolyFit(
int polyorder,
int npoints,
171 int main(
int argc,
char *argv[])
177 if(argc > 6 || argc < 5)
180 "Usage: ./MoveMesh meshfile fieldfile changefile alpha cr(optional)\n");
186 = LibUtilities::SessionReader::CreateInstance(2, argv);
190 vSession->DefinesSolverInfo(
"INTERFACE")
191 && vSession->GetSolverInfo(
"INTERFACE")==
"phase" )
193 cr = boost::lexical_cast<
NekDouble>(argv[argc-1]);
198 string meshfile(argv[argc-4]);
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;
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())->GetEid();
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())->GetEid();
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 cout<<
"Computestreakpositions"<<endl;
2029 int nq = streak->GetTotPoints();
2043 Vmath::Vadd(xc.num_elements(), yold_up,1,yold_low,1, yc,1);
2057 for(
int e=0; e<npoints; e++)
2062 elmtid = streak->GetExpIndex(coord,0.00001);
2063 offset = streak->GetPhys_Offset(elmtid);
2069 while( abs(F)> 0.000000001)
2072 elmtid = streak->GetExpIndex(coord,0.00001);
2077 if( (abs(coord[1])>1 || elmtid==-1)
2078 && attempt==0 && verts==
true
2082 coord[1] = yold_c[e];
2085 else if( (abs(coord[1])>1 || elmtid==-1) )
2087 coord[1] = ytmp +0.01;
2088 elmtid = streak->GetExpIndex(coord,0.001);
2089 offset = streak->GetPhys_Offset(elmtid);
2090 NekDouble Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2091 NekDouble dUtmp = streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2092 coord[1] = coord[1] - (Utmp-cr)/dUtmp;
2093 if( (abs(Utmp-cr)>abs(F))||(abs(coord[1])>1) )
2095 coord[1] = ytmp -0.01;
2102 ASSERTL0(abs(coord[1])<= 1,
" y value out of bound +/-1");
2104 offset = streak->GetPhys_Offset(elmtid);
2105 U = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2106 dU = streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2107 coord[1] = coord[1] - (U-cr)/dU;
2109 ASSERTL0( coord[0]==xc[e],
" x coordinate must remain the same");
2112 if(its>200 && abs(F)<0.00001)
2114 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2117 else if(its>1000 && abs(F)< 0.0001)
2119 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2124 ASSERTL0(
false,
"no convergence after 1000 iterations");
2127 yc[e] = coord[1] - (U-cr)/dU;
2128 ASSERTL0( U<= cr + tol,
"streak wrong+");
2129 ASSERTL0( U>= cr -tol,
"streak wrong-");
2131 cout<<
"result streakvert x="<<xc[e]<<
" y="<<yc[e]<<
" streak="<<U<<endl;
2152 while( abs(F)> 0.00000001)
2156 elmtid =
function->GetExpIndex(coords, 0.01);
2158 cout<<
"gen newton xi="<<xi<<
" yi="<<coords[1]<<
" elmtid="<<elmtid<<
" F="<<F<<endl;
2160 if( (abs(coords[1])>1 || elmtid==-1) )
2163 coords[1] = ytmp +0.01;
2164 elmtid =
function->GetExpIndex(coords,0.01);
2165 offset =
function->GetPhys_Offset(elmtid);
2166 NekDouble Utmp =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() + offset);
2167 NekDouble dUtmp =
function->GetExp(elmtid)->PhysEvaluate(coords, derfunction + offset);
2168 coords[1] = coords[1] - (Utmp-cr)/dUtmp;
2169 cout<<
"attempt:"<<coords[1]<<endl;
2170 if( (abs(Utmp-cr)>abs(F))||(abs(coords[1])>1.01) )
2172 coords[1] = ytmp -0.01;
2177 else if( abs(coords[1])<1.01 &&attempt==0)
2184 ASSERTL0(abs(coords[1])<= 1.00,
" y value out of bound +/-1");
2186 offset =
function->GetPhys_Offset(elmtid);
2187 U =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() + offset);
2188 dU =
function->GetExp(elmtid)->PhysEvaluate(coords, derfunction + offset);
2189 coords[1] = coords[1] - (U-cr)/dU;
2190 cout<<cr<<
"U-cr="<<U-cr<<
" tmp result y:"<<coords[1]<<
" dU="<<dU<<endl;
2194 if(its>200 && abs(F)<0.00001)
2196 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2199 else if(its>1000 && abs(F)< 0.0001)
2201 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2206 ASSERTL0(
false,
"no convergence after 1000 iterations");
2210 ASSERTL0( coords[0]==xi,
" x coordinate must remain the same");
2213 yout = coords[1] - (U-cr)/dU;
2214 cout<<
"NewtonIt result x="<<xout<<
" y="<<coords[1]<<
" U="<<U<<endl;
2221 const boost::shared_ptr<LocalRegions::ExpansionVector> exp2D = field->GetExp();
2222 int nel = exp2D->size();
2230 for(
int i=0; i<nel; i++)
2232 if((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
2234 for(
int j = 0; j < locQuadExp->GetNedges(); ++j)
2236 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
2237 id = SegGeom->GetEid();
2238 if( V1tmp[
id] == 10000)
2240 V1tmp[id]= SegGeom->GetVertex(0)->GetVid();
2241 V2tmp[id]= SegGeom->GetVertex(1)->GetVid();
2248 else if((locTriExp = (*exp2D)[i]->as<LocalRegions::TriExp>()))
2250 for(
int j = 0; j < locTriExp->GetNedges(); ++j)
2252 SegGeom = (locTriExp->GetGeom2D())->GetEdge(j);
2253 id = SegGeom->GetEid();
2255 if( V1tmp[
id] == 10000)
2257 V1tmp[id]= SegGeom->GetVertex(0)->GetVid();
2258 V2tmp[id]= SegGeom->GetVertex(1)->GetVid();
2270 for(
int g=0; g<cnt; g++)
2273 ASSERTL0(V1tmp[g]!=10000,
"V1 wrong");
2275 ASSERTL0(V2tmp[g]!=10000,
"V2 wrong");
2298 int nlay_Eids = xcold.num_elements()-1;
2299 int nlay_Vids = xcold.num_elements();
2301 int nVertsTot = mesh->GetNvertices();
2302 cout<<
"nverttot="<<nVertsTot<<endl;
2306 cout<<
"init nlays="<<nlays<<endl;
2313 cout<<
"yoldup="<<yoldup[0]<<endl;
2314 cout<<
"yolddown="<<yolddown[0]<<endl;
2316 for(
int r=0; r< nVertsTot; r++)
2321 vertex->GetCoords(x,y,z);
2328 y<= yoldup[0] && y>= yolddown[0]
2341 cout<<
"nlays="<<nlays<<endl;
2353 for(
int w=0; w< nlays; w++)
2356 tmpx0[w]= tmpx[index];
2357 tmpy0[w]= tmpf[index];
2358 tmpVids0[w] = tmpV[index];
2359 tmpf[index] = max+1000;
2370 for(
int m=0; m<nlays; m++)
2381 NekDouble xtmp,ytmp,normnext,xnext,ynext,diff;
2382 NekDouble Ubef = 0.0, Utmp = 0.0, Unext = 0.0;
2385 int nTotEdges = V1.num_elements();
2387 for(
int m=0; m<nlays; m++)
2389 for(
int g=0; g<nlay_Eids; g++)
2393 for(
int h=0; h< nTotEdges; h++)
2396 if( tmpVids0[m]== V1[h] )
2400 vertex->GetCoords(x,y,z);
2404 Vids_lay[m][0] = V1[h];
2405 Vids_lay[m][1] = V2[h];
2407 = mesh->GetVertex(V1[h]);
2409 vertex1->GetCoords(x1,y1,z1);
2410 normbef= sqrt( (y-y1)*(y-y1)+(x-x1)*(x-x1) );
2415 elmtid = streak->GetExpIndex(coord,0.00001);
2416 offset = streak->GetPhys_Offset(elmtid);
2417 Ubef = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2422 if( tmpVids0[m]== V2[h] )
2426 vertex->GetCoords(x,y,z);
2430 Vids_lay[m][0] = V2[h];
2431 Vids_lay[m][1] = V1[h];
2433 = mesh->GetVertex(V2[h]);
2435 normbef= sqrt( (y-y2)*(y-y2)+(x-x2)*(x-x2) );
2440 elmtid = streak->GetExpIndex(coord,0.00001);
2441 offset = streak->GetPhys_Offset(elmtid);
2442 Ubef = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2449 cout<<
"Eid="<<Eids_lay[m][0]<<
" Vids_lay0="<<Vids_lay[m][0]<<
" Vidslay1="<<Vids_lay[m][1]<<endl;
2456 for(
int h=0; h< nTotEdges; h++)
2459 if( (Vids_lay[m][g]==V1[h] || Vids_lay[m][g]==V2[h]) && h!= Eids_lay[m][g-1])
2461 cout<<
"edgetmp="<<h<<endl;
2462 ASSERTL0(cnt<=6,
"wrong number of candidates");
2471 cout<<
"normbef="<<normbef<<endl;
2472 cout<<
"Ubefcc="<<Ubef<<endl;
2474 for(
int e=0; e< cnt; e++)
2478 vertex1->GetCoords(x1,y1,z1);
2481 vertex2->GetCoords(x2,y2,z2);
2483 normtmp= sqrt( (y2-y1)*(y2-y1)+(x2-x1)*(x2-x1) );
2485 cout<<
"edgetmp1="<<edgestmp[e]<<endl;
2486 cout<<
"V1 x1="<<x1<<
" y1="<<y1<<endl;
2487 cout<<
"V2 x2="<<x2<<
" y2="<<y2<<endl;
2488 if( Vids_lay[m][g]==V1[edgestmp[e]] )
2496 elmtid = streak->GetExpIndex(coord,0.00001);
2497 offset = streak->GetPhys_Offset(elmtid);
2498 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2499 diffarray[e] = abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2500 diffUarray[e] = abs(Ubef-Utmp);
2501 cout<<
" normtmp="<<normtmp<<endl;
2502 cout<<
" Utmpcc="<<Utmp<<endl;
2503 cout<<xtmp<<
" ytmp="<<ytmp<<
" diff="<<abs(((xtmp*xbef+ytmp*ybef)/(normtmp*normbef))-1)<<endl;
2505 abs( (xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1)<diff
2506 && y2<= yoldup[g+1] && y2>= yolddown[g+1]
2507 && y1<= yoldup[g] && y1>= yolddown[g]
2511 Eids_lay[m][g] = edgestmp[e];
2512 Vids_lay[m][g+1] = V2[edgestmp[e]];
2513 diff = abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2520 else if( Vids_lay[m][g]==V2[edgestmp[e]] )
2528 elmtid = streak->GetExpIndex(coord,0.00001);
2529 offset = streak->GetPhys_Offset(elmtid);
2530 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2531 diffarray[e] = abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2532 diffUarray[e] = abs(Ubef-Utmp);
2533 cout<<
" normtmp="<<normtmp<<endl;
2534 cout<<
" Utmpcc="<<Utmp<<endl;
2535 cout<<xtmp<<
" ytmp="<<ytmp<<
" diff="<<abs(((xtmp*xbef+ytmp*ybef)/(normtmp*normbef))-1)<<endl;
2537 abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1)<diff
2538 && y2<= yoldup[g] && y2>= yolddown[g]
2539 && y1<= yoldup[g+1] && y1>= yolddown[g+1]
2542 Eids_lay[m][g] = edgestmp[e];
2543 Vids_lay[m][g+1] = V1[edgestmp[e]];
2544 diff = abs((xtmp*xbef+ytmp*ybef)/(normtmp*normbef)-1);
2560 cout<<
"Eid before check="<<Eids_lay[m][g]<<endl;
2561 for(
int q=0; q<cnt; q++)
2563 cout<<q<<
" diff"<<diffarray[q]<<endl;
2573 cout<<
"COMMON VERT"<<endl;
2575 diffarray[eid]=1000;
2581 vertex1->GetCoords(x1,y1,z1);
2584 vertex2->GetCoords(x2,y2,z2);
2586 normtmp= sqrt( (y2-y1)*(y2-y1)+(x2-x1)*(x2-x1) );
2588 Eids_lay[m][g] = edgestmp[eid];
2589 if(Vids_lay[m][g] == V1[edgestmp[eid]])
2593 elmtid = streak->GetExpIndex(coord,0.00001);
2594 offset = streak->GetPhys_Offset(elmtid);
2595 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2596 Vids_lay[m][g+1] = V2[edgestmp[eid]];
2604 if(Vids_lay[m][g] == V2[edgestmp[eid]])
2608 elmtid = streak->GetExpIndex(coord,0.00001);
2609 offset = streak->GetPhys_Offset(elmtid);
2610 Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2611 Vids_lay[m][g+1] = V1[edgestmp[eid]];
2622 cout<<m<<
"edge aft:"<<Eids_lay[m][g]<<
" Vid="<<Vids_lay[m][g+1]<<endl;
2628 cout<<
"endelse"<<normtmp<<endl;
2640 for(
int w=0; w< nlays; w++)
2642 for(
int f=0; f< nlay_Eids; f++)
2644 cout<<
"check="<<w<<
" Eid:"<<Eids_lay[w][f]<<endl;
2654 for(
int u=0; u< Vids_laybefore.num_elements(); u++)
2656 if( Vids_laybefore[u]==Vid || Vids_c[u]==Vid)
2660 cout<<Vid<<
" Vert test="<<Vids_laybefore[u]<<endl;
2672 int np_lay = inarray.num_elements();
2673 ASSERTL0(inarray.num_elements()%nedges==0,
" something on number npedge");
2677 for(
int w=0; w< np_lay; w++)
2682 if(inarray[w] ==inarray[w+1])
2687 outarray[cnt]= inarray[w];
2692 ASSERTL0( cnt== np_lay-(nedges-1),
"wrong cut");
2698 int npts = xArray.num_elements();
2707 if(xArray[index]> x)
2718 ASSERTL0( neighpoints%2==0,
"number of neighbour points should be even");
2719 int leftpoints = (neighpoints/2)-1;
2720 int rightpoints = neighpoints/2;
2724 if(index-leftpoints<0)
2727 diff = index-leftpoints;
2729 Vmath::Vcopy(neighpoints, &yArray[0],1,&Neighbour_y[0],1);
2730 Vmath::Vcopy(neighpoints, &xArray[0],1,&Neighbour_x[0],1);
2732 else if( (yArray.num_elements()-1)-index < rightpoints)
2735 int rpoints = (yArray.num_elements()-1)-index;
2736 diff = rightpoints-rpoints;
2738 start = index-leftpoints-diff;
2739 Vmath::Vcopy(neighpoints, &yArray[start],1,&Neighbour_y[0],1);
2740 Vmath::Vcopy(neighpoints, &xArray[start],1,&Neighbour_x[0],1);
2745 start = index-leftpoints;
2746 Vmath::Vcopy(neighpoints, &yArray[start],1,&Neighbour_y[0],1);
2747 Vmath::Vcopy(neighpoints, &xArray[start],1,&Neighbour_x[0],1);
2756 for(
int f=1; f< neighpoints; f++)
2758 ASSERTL0(Neighbour_x[f]!=Neighbour_x[f-1],
" repetition on NeighbourArrays");
2769 for(
int pt=0;pt<
npts;++pt)
2773 for(
int j=0;j<pt; ++j)
2775 h = h * (x - xpts[j])/(xpts[pt]-xpts[j]);
2778 for(
int k=pt+1;k<
npts;++k)
2780 h = h * (x - xpts[k])/(xpts[pt]-xpts[k]);
2784 sum += funcvals[pt]*LagrangePoly;
2796 int np_pol= coeffsinterp.num_elements();
2797 cout<<
"evaluatetan with "<<np_pol<<endl;
2803 for(
int q=0; q< npoints; q++)
2808 for(
int d=0; d< np_pol-1; d++)
2810 yprime[q] += (derorder +1)*coeffsinterp[d]*std::pow(xcQedge[q],derorder);
2814 for(
int a=0; a< np_pol; a++)
2816 yinterp[q] += coeffsinterp[a]*std::pow(xcQedge[q],polorder);
2824 for(
int n=0; n< npoints; n++)
2828 txQedge[n] = cos((atan((yprime[n]))));
2829 tyQedge[n] = sin((atan((yprime[n]))));
2830 cout<<xcQedge[n]<<
" "<<yinterp[n]<<
" "<<yprime[n]<<
" "<<txQedge[n]<<
" "<<tyQedge[n]<<endl;
2837 int edge,
int npedge)
2839 int np_pol = xpol.num_elements();
2845 for(
int e=0; e<N; e++)
2848 for(
int w=0; w < N; w++)
2850 A[N*e+row] = std::pow( xpol[w], N-1-e);
2855 for(
int r= 0; r< np_pol; r++)
2866 Lapack::Dgetrf( N, N, A.get(), N, ipivot.get(), info);
2869 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2870 "th parameter had an illegal parameter for dgetrf";
2875 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2876 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2882 Lapack::Dgetrs(
'N', N, ncolumns_b , A.get() , N, ipivot.get(), b.get(), N, info);
2885 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2886 "th parameter had an illegal parameter for dgetrf";
2891 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2892 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2906 for(
int c=0; c< npedge; c++)
2910 ycout[edge*(npedge)+c+1]=0;
2911 for(
int d=0; d< np_pol; d++)
2913 ycout[edge*(npedge)+c+1] += b[d]
2914 *std::pow(xcout[edge*(npedge)+c+1],polorder);
2932 int N = polyorder+1;
2935 cout<<npoints<<endl;
2936 for(
int u=0; u<npoints; u++)
2938 cout<<
"c="<<xin[u]<<
" "<<
2943 for(
int e=0; e<N; e++)
2946 for(
int row=0; row<N; row++)
2948 for(
int w=0; w < npoints; w++)
2950 A[N*e+row] += std::pow( xin[w], e+row);
2955 for(
int row= 0; row< N; row++)
2957 for(
int h=0; h< npoints; h++)
2959 b[row] += fin[h]*std::pow(xin[h],row);
2973 Lapack::Dgetrf( N, N, A.get(), N, ipivot.get(), info);
2977 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2978 "th parameter had an illegal parameter for dgetrf";
2983 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2984 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2989 Lapack::Dgetrs(
'N', N, ncolumns_b , A.get() , N, ipivot.get(), b.get(), N, info);
2992 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2993 "th parameter had an illegal parameter for dgetrf";
2998 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2999 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
3008 for(
int j=0; j<N; j++)
3014 for(
int h=0; h<N; h++)
3016 cout<<
"coeff:"<<b[h]<<endl;
3021 for(
int c=0; c< npout; c++)
3026 for(
int d=0; d< N; d++)
3030 *std::pow(xout[c],polorder);
3050 Vmath::Vcopy(inarray_x.num_elements() , inarray_x,1,tmpx,1);
3051 Vmath::Vcopy(inarray_x.num_elements() , inarray_y,1,tmpy,1);
3056 for(
int w=0; w<tmpx.num_elements(); w++)
3059 outarray_x[w]= tmpx[index];
3060 outarray_y[w]= tmpy[index];
3061 if(w< tmpx.num_elements()-1)
3063 if(tmpx[index] == tmpx[index+1])
3065 outarray_x[w+1]= tmpx[index+1];
3066 outarray_y[w+1]= tmpy[index+1];
3067 tmpx[index+1] = max+1000;
3083 tmpx[index] = max+1000;
3095 int np_lay = layers_y[0].num_elements();
3097 for(
int h=1; h<nlays-1; h++)
3100 for(
int s=0; s<nvertl; s++)
3103 ASSERTL0(ynew[ lay_Vids[h][s] ]==-20,
"ynew layers not empty");
3107 ynew[ lay_Vids[h][s] ] = ynew[Down[s]]+ h*abs(ynew[Down[s]] - yc[s])/(cntlow+1);
3109 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] ];
3119 ynew[ lay_Vids[h][s] ] = yc[s] + (h-cntlow)*abs(ynew[Up[s]] - yc[s])/(cntup+1);
3121 xnew[lay_Vids[h][s] ] = xc[s];
3123 layers_y[h][s] = ynew[ lay_Vids[h][s] ];
3124 layers_x[h][s] = xnew[ lay_Vids[h][s] ];
3138 int np_lay = xcPhys.num_elements();
3139 int nedges = nvertl-1;
3146 int closepoints = 4;
3151 for(
int g=0; g< nedges; g++)
3160 xnew[Vids[g] ]= xcPhys[g*npedge+0];
3161 ylay[g*npedge +0] = ynew[ Vids[g] ];
3162 xlay[g*npedge +0] = xnew[ Vids[g] ];
3170 ynew[Vids[g+1] ]=
LagrangeInterpolant(xcPhys[g*npedge +npedge-1],closepoints,Pxinterp,Pyinterp );
3171 xnew[Vids[g+1] ]= xcPhys[g*npedge +npedge-1];
3172 ylay[g*npedge +npedge-1] = ynew[Vids[g+1] ];
3173 xlay[g*npedge +npedge-1] = xnew[Vids[g+1] ];
3178 for(
int r=0; r< npedge-2; r++)
3186 ASSERTL0( index<= tmpy.num_elements()-1,
" index wrong");
3190 ylay[g*npedge +r+1]=
3192 xcPhys[g*npedge +r+1],closepoints,Pxinterp,Pyinterp );
3194 xlay[g*npedge +r+1]= xcPhys[g*npedge +r+1];
3217 int np_lay = xcPhys.num_elements();
3218 int nedges = nvertl-1;
3226 int closepoints = 4;
3231 for(
int g=0; g< nedges; g++)
3235 ynew[Vids[g] ]= tmpy_lay[g*npedge+0];
3236 xnew[Vids[g] ]= tmpx_lay[g*npedge+0];
3239 ylay[g*npedge +0] = ynew[ Vids[g] ];
3240 xlay[g*npedge +0] = xnew[ Vids[g] ];
3243 ynew[Vids[g+1] ]= tmpy_lay[g*npedge+npedge-1];
3244 xnew[Vids[g+1] ]= tmpx_lay[g*npedge+npedge-1];
3245 ylay[g*npedge +npedge-1] = ynew[Vids[g+1] ];
3246 xlay[g*npedge +npedge-1] = xnew[Vids[g+1] ];
3251 for(
int r=0; r< npedge-2; r++)
3253 x0 = xlay[g*npedge +0];
3254 x1 = xlay[g*npedge +npedge-1];
3255 xtmp = x0 + r*(x1-x0)/(npedge-1);
3261 ASSERTL0( index<= tmpy.num_elements()-1,
" index wrong");
3265 ylay[g*npedge +r+1]=
3267 xtmp,closepoints,Pxinterp,Pyinterp );
3269 xlay[g*npedge +r+1]= xtmp;
3285 int nvertl = ycold.num_elements();
3286 int nVertTot = mesh->GetNvertices();
3287 for(
int n=0; n<nVertTot; n++)
3292 vertex->GetCoords(x,y,z);
3297 for(
int k=0; k<nvertl; k++)
3299 if(abs(x-xcold[k]) < tmp)
3301 tmp = abs(x-xcold[k]);
3314 nplay_closer= (qp_closer-1)*npedge +npedge-1;
3318 if( y>yoldup[qp_closer] && y<1 )
3323 ratio = (1-ylayup[nplay_closer])/
3324 ( (1-yoldup[qp_closer]) );
3326 ynew[n] = ylayup[nplay_closer]
3327 + (y-yoldup[qp_closer])*ratio;
3331 else if( y< yolddown[qp_closer] && y>-1 )
3334 ratio = (1+ylaydown[nplay_closer])/
3335 ( (1+yolddown[qp_closer]) );
3337 ynew[n] = ylaydown[nplay_closer]
3338 + (y-yolddown[qp_closer])*ratio;
3369 int nvertl = xoldup.num_elements();
3370 int nedges = nvertl-1;
3379 for(
int a=0; a< nedges;a++)
3384 xnew_down[a] = xlaydown[a*npedge+0];
3385 ynew_down[a] = ylaydown[a*npedge+0];
3386 xnew_up[a] = xlayup[a*npedge+0];
3387 ynew_up[a] = ylayup[a*npedge+0];
3388 nxvert[a] = nxPhys[a*npedge+0];
3389 nyvert[a] = nyPhys[a*npedge+0];
3391 xnew_down[a+1] = xlaydown[a*npedge+npedge-1];
3392 ynew_down[a+1] = ylaydown[a*npedge+npedge-1];
3393 xnew_up[a+1] = xlayup[a*npedge+npedge-1];
3394 ynew_up[a+1] = ylayup[a*npedge+npedge-1];
3395 nxvert[a+1] = nxPhys[a*npedge+npedge-1];
3396 nyvert[a+1] = nyPhys[a*npedge+npedge-1];
3401 xnew_down[a+1] = xlaydown[a*npedge+npedge-1];
3402 ynew_down[a+1] = ylaydown[a*npedge+npedge-1];
3403 xnew_up[a+1] = xlayup[a*npedge+npedge-1];
3404 ynew_up[a+1] = ylayup[a*npedge+npedge-1];
3405 nxvert[a+1] = nxPhys[a*npedge+npedge-1];
3406 nyvert[a+1] = nyPhys[a*npedge+npedge-1];
3418 int nVertTot = mesh->GetNvertices();
3419 for(
int n=0; n<nVertTot; n++)
3424 vertex->GetCoords(x,y,z);
3425 int qp_closeroldup = 0, qp_closerolddown = 0;
3434 for(
int k=0; k<nvertl; k++)
3436 if(abs(x-xolddown[k]) < diffdown)
3438 diffdown = abs(x-xolddown[k]);
3441 if(abs(x-xoldup[k]) < diffup)
3443 diffup = abs(x-xoldup[k]);
3453 int qp_closerup = 0, qp_closerdown = 0;
3455 for(
int f=0; f< nvertl; f++)
3457 if(abs(x-xnew_down[f]) < diffdown)
3459 diffdown = abs(x-xnew_down[f]);
3462 if(abs(x-xnew_up[f]) < diffup)
3464 diffup = abs(x-xnew_up[f]);
3491 int qp_closernormup;
3502 int qp_closernormdown;
3513 if( y>yoldup[qp_closeroldup] && y<1 )
3518 ratio = (1-ynew_up[qp_closerup])/
3519 ( (1-yoldup[qp_closeroldup]) );
3524 ynew[n] = ynew_up[qp_closerup]
3525 + (y-yoldup[qp_closeroldup])*ratio;
3531 if(x> (xmax-xmin)/2. && x< xmax)
3533 ratiox = (xmax-xnew_up[qp_closernormup])/
3534 (xmax-xoldup[qp_closernormup]) ;
3535 if( (xmax-xoldup[qp_closernormup])==0)
3542 xnew[n] = x + abs(nxvert[qp_closernormup])*(xnew_up[qp_closeroldup]-xoldup[qp_closeroldup])*ratiox;
3543 ASSERTL0(x>xmin,
" x value <xmin up second half");
3544 ASSERTL0(x<xmax," x value >xmax up second half
");
3546 else if( x> xmin && x<= (xmax-xmin)/2.)
3548 //cout<<"up close normold=
"<<qp_closernormoldup<<" closenorm=
"<<qp_closernormup<<endl;
3549 ratiox = (xnew_up[qp_closernormup]-xmin)/
3550 ( (xoldup[qp_closernormup]-xmin) );
3551 if( (xoldup[qp_closernormup]-xmin)==0)
3555 //xnew[n] = xnew_up[qp_closerup]
3556 // + (x-xoldup[qp_closeroldup])*ratiox;
3557 xnew[n] = x + abs(nxvert[qp_closernormup])*(xnew_up[qp_closeroldup]-xoldup[qp_closeroldup])*ratiox;
3558 //cout<<"up xold=
"<<x<<" xnew=
"<<xnew[n]<<endl;
3559 ASSERTL0(x>xmin," x value <xmin up first half
");
3560 ASSERTL0(x<xmax," x value >xmax up first half
");
3565 else if( y< yolddown[qp_closerolddown] && y>-1 )
3568 ratio = (1+ynew_down[qp_closerdown])/
3569 ( (1+yolddown[qp_closerolddown]) );
3571 // ratioy = (1-ynew_down[qp_closernormdown])/
3572 // ( (1-yolddown[qp_closernormolddown]) );
3574 //distance prop to layerlow
3575 ynew[n] = ynew_down[qp_closerdown]
3576 + (y-yolddown[qp_closerolddown])*ratio;
3577 //ynew[n] = y +abs(nyvert[qp_closernormdown])*
3578 // (ynew_down[qp_closerolddown]-yolddown[qp_closerolddown])*ratioy;
3579 //ynew[n] = y + 0.3*(ynew_down[qp_closerdown]-yolddown[qp_closerdown]);
3580 //xnew[n] = x + abs(nxvert[qp_closerolddown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown]);
3584 cout<<qp_closerolddown<<" nplaydown=
"<<qp_closerdown<<endl;
3585 cout<<"xolddown=
"<<xolddown[qp_closerolddown]<<" xnewdown=
"<<xnew_down[qp_closerdown]<<endl;
3586 cout<<"xold+
"<<x<<" xnew+
"<<xnew[n]<<endl;
3590 if(x> (xmax-xmin)/2. && x <xmax)
3592 ratiox = (xmax-xnew_down[qp_closernormdown])/
3593 ( (xmax-xolddown[qp_closernormdown]) );
3594 if( (xmax-xolddown[qp_closernormdown])==0)
3598 //xnew[n] = xnew_down[qp_closerdown]
3599 // + (x-xolddown[qp_closerolddown])*ratiox;
3601 abs(nxvert[qp_closernormdown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown])*ratiox;
3602 ASSERTL0(x>xmin," x value <xmin down second half
");
3603 ASSERTL0(x<xmax," x value >xmax down second half
");
3605 else if( x>xmin && x<= (xmax-xmin)/2.)
3607 ratiox = (xnew_down[qp_closernormdown]-xmin)/
3608 ( (xolddown[qp_closernormdown]-xmin) );
3609 if( (xolddown[qp_closernormdown]-xmin)==0)
3613 //xnew[n] = xnew_down[qp_closerdown]
3614 // + (x-xolddown[qp_closerolddown])*ratiox;
3616 abs(nxvert[qp_closernormdown])*(xnew_down[qp_closerolddown]-xolddown[qp_closerolddown])*ratiox;
3617 ASSERTL0(x>xmin," x value <xmin down first half
");
3618 ASSERTL0(x<xmax," x value >xmax down first half
");
3623 cout<<"xold
"<<x<<" xnew=
"<<xnew[n]<<endl;
3624 ASSERTL0(xnew[n] >= xmin, "newx < xmin
");
3625 ASSERTL0(xnew[n]<= xmax, "newx > xmax
");
3630 void CheckSingularQuads( MultiRegions::ExpListSharedPtr Exp,
3631 Array<OneD, int> V1, Array<OneD, int> V2,
3632 Array<OneD, NekDouble>& xnew,Array<OneD, NekDouble>& ynew)
3634 const boost::shared_ptr<LocalRegions::ExpansionVector> exp2D = Exp->GetExp();
3635 int nel = exp2D->size();
3636 LocalRegions::QuadExpSharedPtr locQuadExp;
3637 LocalRegions::TriExpSharedPtr locTriExp;
3638 SpatialDomains::Geometry1DSharedPtr SegGeom;
3640 NekDouble xV1, yV1, xV2,yV2;
3641 NekDouble slopebef,slopenext,slopenew;
3642 Array<OneD, int> locEids(4);
3643 for(int i=0; i<nel; i++)
3645 if((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
3647 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(0);
3648 idbef = SegGeom->GetEid();
3649 if(xnew[ V1[idbef] ]<= xnew[ V2[idbef] ])
3651 xV1 = xnew[ V1[idbef] ];
3652 yV1 = ynew[ V1[idbef] ];
3653 xV2 = xnew[ V2[idbef] ];
3654 yV2 = ynew[ V2[idbef] ];
3655 slopebef = (yV2 -yV1)/(xV2 -xV1);
3659 xV1 = xnew[ V2[idbef] ];
3660 yV1 = ynew[ V2[idbef] ];
3661 xV2 = xnew[ V1[idbef] ];
3662 yV2 = ynew[ V1[idbef] ];
3663 slopebef = (yV2 -yV1)/(xV2 -xV1);
3665 //cout<<"00 V1 x=
"<<xnew[ V1[idbef] ]<<" y=
"<<ynew[ V1[idbef] ]<<endl;
3666 //cout<<"00 V2 x=
"<<xnew[ V2[idbef] ]<<" y=
"<<ynew[ V2[idbef] ]<<endl;
3667 for(int j = 1; j < locQuadExp->GetNedges(); ++j)
3669 SegGeom = (locQuadExp->GetGeom2D())->GetEdge(j);
3670 idnext = SegGeom->GetEid();
3671 //cout<<"id=
"<<idnext<<" locid=
"<<j<<endl;
3672 //cout<<" V1 x=
"<<xnew[ V1[idnext] ]<<" y=
"<<ynew[ V1[idnext] ]<<endl;
3673 //cout<<" V2 x=
"<<xnew[ V2[idnext] ]<<" y=
"<<ynew[ V2[idnext] ]<<endl;
3674 if(xV1 == xnew[ V1[idnext] ] && yV1 == ynew[ V1[idnext] ] )
3676 xV1 = xnew[ V1[idnext] ];
3677 yV1 = ynew[ V1[idnext] ];
3678 xV2 = xnew[ V2[idnext] ];
3679 yV2 = ynew[ V2[idnext] ];
3680 slopenext = (yV2 -yV1)/(xV2 -xV1);
3683 cout<<"case1 x0=
"<<xV1<<" x1=
"<<xV2<<endl;
3684 cout<<idnext<<" 11slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl;
3686 //compare with slope before
3687 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18)
3689 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] -0.01;
3690 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]);
3692 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) )
3694 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] +0.02;
3695 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]);
3697 slopenext = slopenew;
3698 cout<<"slopenew=
"<<slopenew<<endl;
3699 cout<<"moved x=
"<<xnew[ V1[idnext] ]<<endl;
3702 else if(xV2 == xnew[ V2[idnext] ] && yV2 == ynew[ V2[idnext] ] )
3704 xV1 = xnew[ V2[idnext] ];
3705 yV1 = ynew[ V2[idnext] ];
3706 xV2 = xnew[ V1[idnext] ];
3707 yV2 = ynew[ V1[idnext] ];
3708 slopenext = (yV2 -yV1)/(xV2 -xV1);
3711 cout<<"case2 x0=
"<<xV1<<" x1=
"<<xV2<<endl;
3712 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl;
3714 //compare with slope before
3715 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18)
3717 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] -0.01;
3718 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]);
3720 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) )
3722 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] +0.02;
3723 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]);
3726 slopenext = slopenew;
3727 cout<<"slopenew=
"<<slopenew<<endl;
3728 cout<<"moved x=
"<<xnew[ V2[idnext] ]<<endl;
3731 else if(xV1 == xnew[ V2[idnext] ] && yV1 == ynew[ V2[idnext] ] )
3733 xV1 = xnew[ V2[idnext] ];
3734 yV1 = ynew[ V2[idnext] ];
3735 xV2 = xnew[ V1[idnext] ];
3736 yV2 = ynew[ V1[idnext] ];
3737 slopenext = (yV2 -yV1)/(xV2 -xV1);
3740 cout<<"case3 x0=
"<<xV1<<" x1=
"<<xV2<<endl;
3741 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl;
3743 //compare with slope before
3744 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18)
3746 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] -0.01;
3747 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]);
3749 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) )
3751 xnew[ V2[idnext] ] = xnew[ V2[idnext] ] +0.02;
3752 slopenew = (yV2-yV1)/(xV2- xnew[ V2[idnext] ]);
3754 slopenext = slopenew;
3755 cout<<"slopenew=
"<<slopenew<<endl;
3756 cout<<"moved x=
"<<xnew[ V2[idnext] ]<<endl;
3760 else if(xV2 == xnew[ V1[idnext] ] && yV2 == ynew[ V1[idnext] ] )
3762 xV1 = xnew[ V1[idnext] ];
3763 yV1 = ynew[ V1[idnext] ];
3764 xV2 = xnew[ V2[idnext] ];
3765 yV2 = ynew[ V2[idnext] ];
3766 slopenext = (yV2 -yV1)/(xV2 -xV1);
3769 cout<<"case4 x0=
"<<xV1<<" x1=
"<<xV2<<endl;
3770 cout<<idnext<<" 22slope bef =
"<<slopebef<<" slopenext=
"<<slopenext<<endl;
3772 //compare with slope before
3773 if( slopebef/slopenext>0.84 && slopebef/slopenext <1.18)
3775 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] -0.01;
3776 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]);
3778 if( abs(slopebef-slopenew) < abs(slopebef-slopenext) )
3780 xnew[ V1[idnext] ] = xnew[ V1[idnext] ] +0.02;
3781 slopenew = (yV2-yV1)/(xV2- xnew[ V1[idnext] ]);
3783 slopenext = slopenew;
3784 cout<<"slopenew=
"<<slopenew<<endl;
3785 cout<<"moved x=
"<<xnew[ V1[idnext] ]<<endl;
3791 ASSERTL0(false, "edge not connected
");
3793 slopebef = slopenext;
3802 void Replacevertices(string filename, Array<OneD, NekDouble> newx,
3803 Array<OneD, NekDouble> newy,
3804 Array<OneD, NekDouble> xcPhys, Array<OneD, NekDouble> ycPhys,
3805 Array<OneD, int>Eids, int Npoints, string s_alp,
3806 Array<OneD, Array<OneD, NekDouble> > x_lay,
3807 Array<OneD, Array<OneD, NekDouble> > y_lay,
3808 Array<OneD, Array<OneD, int > >lay_eids, bool curv_lay)
3810 //load existing file
3812 TiXmlDocument doc(filename);
3813 //load xscale parameter (if exists)
3814 TiXmlElement* master = doc.FirstChildElement("NEKTAR
");
3815 TiXmlElement* mesh = master->FirstChildElement("GEOMETRY
");
3816 TiXmlElement* element = mesh->FirstChildElement("VERTEX
");
3817 NekDouble xscale = 1.0;
3818 LibUtilities::AnalyticExpressionEvaluator expEvaluator;
3819 const char *xscal = element->Attribute("XSCALE
");
3822 std::string xscalstr = xscal;
3823 int expr_id = expEvaluator.DefineFunction("",xscalstr);
3824 xscale = expEvaluator.Evaluate(expr_id);
3828 // Save a new XML file.
3829 newfile = filename.substr(0, filename.find_last_of(".
"))+"_moved.xml
";
3830 doc.SaveFile( newfile );
3832 //write the new vertices
3833 TiXmlDocument docnew(newfile);
3834 bool loadOkaynew = docnew.LoadFile();
3836 std::string errstr = "Unable to load file:
";
3838 ASSERTL0(loadOkaynew, errstr.c_str());
3840 TiXmlHandle docHandlenew(&docnew);
3841 TiXmlElement* meshnew = NULL;
3842 TiXmlElement* masternew = NULL;
3843 TiXmlElement* condnew = NULL;
3844 TiXmlElement* Parsnew = NULL;
3845 TiXmlElement* parnew = NULL;
3847 // Master tag within which all data is contained.
3850 masternew = docnew.FirstChildElement("NEKTAR
");
3851 ASSERTL0(masternew, "Unable to
find NEKTAR tag in file.
");
3853 //set the alpha value
3855 condnew = masternew->FirstChildElement("CONDITIONS
");
3856 Parsnew = condnew->FirstChildElement("PARAMETERS
");
3857 cout<<"alpha=
"<<s_alp<<endl;
3858 parnew = Parsnew->FirstChildElement("P
");
3861 TiXmlNode *node = parnew->FirstChild();
3864 // Format is "paramName = value
"
3865 std::string line = node->ToText()->Value();
3869 int beg = line.find_first_not_of("
");
3870 int end = line.find_first_of("=
");
3871 // Check for no parameter name
3872 if (beg == end) throw 1;
3873 // Check for no parameter value
3874 if (end != line.find_last_of("=
")) throw 1;
3875 // Check for no equals sign
3876 if (end == std::string::npos) throw 1;
3877 lhs = line.substr(line.find_first_not_of(" "), end-beg);
3878 lhs = lhs.substr(0, lhs.find_last_not_of(" ")+1);
3880 //rhs = line.substr(line.find_last_of("=
")+1);
3881 //rhs = rhs.substr(rhs.find_first_not_of(" "));
3882 //rhs = rhs.substr(0, rhs.find_last_not_of(" ")+1);
3884 boost::to_upper(lhs);
3887 alphastring = "Alpha =
"+ s_alp;
3888 parnew->RemoveChild(node);
3889 parnew->LinkEndChild(new TiXmlText(alphastring) );
3893 parnew = parnew->NextSiblingElement("P
");
3897 // Find the Mesh tag and same the dim and space attributes
3898 meshnew = masternew->FirstChildElement("GEOMETRY
");
3900 ASSERTL0(meshnew, "Unable to
find GEOMETRY tag in file.
");
3901 // Now read the vertices
3902 TiXmlElement* elementnew = meshnew->FirstChildElement("VERTEX
");
3903 ASSERTL0(elementnew, "Unable to
find mesh VERTEX tag in file.
");
3907 elementnew->SetAttribute("XSCALE
",1.0);
3909 TiXmlElement *vertexnew = elementnew->FirstChildElement("V
");
3915 int nextVertexNumber = -1;
3920 //delete the old one
3921 TiXmlAttribute *vertexAttr = vertexnew->FirstAttribute();
3922 std::string attrName(vertexAttr->Name());
3923 ASSERTL0(attrName == "ID
", (std::string("Unknown attribute name:
") + attrName).c_str());
3925 err = vertexAttr->QueryIntValue(&indx);
3926 ASSERTL0(err == TIXML_SUCCESS, "Unable to read attribute ID.
");
3927 ASSERTL0(indx == nextVertexNumber, "Vertex IDs must begin with zero and be sequential.
");
3929 std::string vertexBodyStr;
3930 // Now read body of vertex
3931 TiXmlNode *vertexBody = vertexnew->FirstChild();
3932 // Accumulate all non-comment body data.
3933 if (vertexBody->Type() == TiXmlNode::TINYXML_TEXT)
3935 vertexBodyStr += vertexBody->ToText()->Value();
3936 vertexBodyStr += " ";
3938 ASSERTL0(!vertexBodyStr.empty(), "Vertex definitions must contain vertex data.
");
3939 //remove the old coordinates
3940 vertexnew->RemoveChild(vertexBody);
3942 //cout<<"writing.. v:
"<<nextVertexNumber<<endl;
3944 //we need at least 5 digits (setprecision 5) to get the streak position with
3946 s << std::scientific << std::setprecision(8) << newx[nextVertexNumber] << " "
3947 << newy[nextVertexNumber] << " " << 0.0;
3948 vertexnew->LinkEndChild(new TiXmlText(s.str()));
3949 //TiXmlNode *newvertexBody = vertexnew->FirstChild();
3950 //string newvertexbodystr= newvertexBody->SetValue(s.str());
3951 //vertexnew->ReplaceChild(vertexBody,new TiXmlText(newvertexbodystr));
3953 vertexnew = vertexnew->NextSiblingElement("V
");
3958 //read the curved tag
3959 TiXmlElement* curvednew = meshnew->FirstChildElement("CURVED
");
3960 ASSERTL0(curvednew, "Unable to
find mesh CURVED tag in file.
");
3961 TiXmlElement *edgenew = curvednew->FirstChildElement("E
");
3963 //ID is different from index...
3964 std::string charindex;
3968 int neids_lay = lay_eids[0].num_elements();
3969 //if edgenew belongs to the crit lay replace it, else delete it.
3975 TiXmlAttribute *edgeAttr = edgenew->FirstAttribute();
3976 std::string attrName(edgeAttr->Name());
3977 charindex = edgeAttr->Value();
3978 std::istringstream iss(charindex);
3979 iss >> std::dec >> index;
3981 edgenew->QueryIntAttribute("EDGEID
", &eid);
3982 //cout<<"eid=
"<<eid<<" neid=
"<<Eids.num_elements()<<endl;
3983 //find the corresponding index curve point
3984 for(int u=0; u<Eids.num_elements(); u++)
3986 //cout<<"Eids=
"<<Eids[u]<<" eid=
"<<eid<<endl;
3994 curvednew->RemoveChild(edgenew);
3995 //ASSERTL0(false, "edge to update not found
");
4000 std::string edgeBodyStr;
4001 //read the body of the edge
4002 TiXmlNode *edgeBody = edgenew->FirstChild();
4003 if(edgeBody->Type() == TiXmlNode::TINYXML_TEXT)
4005 edgeBodyStr += edgeBody->ToText()->Value();
4008 ASSERTL0(!edgeBodyStr.empty(), "Edge definitions must contain edge data
");
4009 //remove the old coordinates
4010 edgenew->RemoveChild(edgeBody);
4011 //write the new points coordinates
4012 //we need at least 5 digits (setprecision 5) to get the streak position with
4015 //Determine the number of points
4016 err = edgenew->QueryIntAttribute("NUMPOINTS
", &numPts);
4017 ASSERTL0(err == TIXML_SUCCESS, "Unable to read curve attribute NUMPOINTS.
");
4020 edgenew->SetAttribute("NUMPOINTS
", Npoints);
4021 for(int u=0; u< Npoints; u++)
4023 st << std::scientific <<
4024 std::setprecision(8) <<xcPhys[cnt*Npoints+u]
4025 << " " << ycPhys[cnt*Npoints+u] << " " << 0.000<<" ";
4028 edgenew->LinkEndChild(new TiXmlText(st.str()));
4032 st << std::scientific << std::setprecision(8) << x_crit[v1] << " "
4033 << y_crit[v1] << " " << 0.000<<" ";
4034 for(int a=0; a< Npoints-2; a++)
4036 st << std::scientific << std::setprecision(8) <<
4037 " "<<Pcurvx[indexeid*(Npoints-2) +a]<<" "<<Pcurvy[indexeid*(Npoints-2) +a]
4041 st << std::scientific << std::setprecision(8) <<
4042 " "<<x_crit[v2]<<" "<< y_crit[v2] <<" "<< 0.000;
4043 edgenew->LinkEndChild(new TiXmlText(st.str()));
4050 edgenew = edgenew->NextSiblingElement("E
");
4054 //write also the others layers curve points
4055 if(curv_lay == true)
4057 cout<<"write other curved edges
"<<endl;
4058 TiXmlElement * curved = meshnew->FirstChildElement("CURVED
");
4060 int nlays = lay_eids.num_elements();
4062 //TiXmlComment * comment = new TiXmlComment();
4063 //comment->SetValue(" new edges
");
4064 //curved->LinkEndChild(comment);
4065 for (int g=0; g< nlays; ++g)
4067 for(int p=0; p< neids_lay; p++)
4070 TiXmlElement * e = new TiXmlElement( "E
" );
4071 e->SetAttribute("ID
", idcnt++);
4072 e->SetAttribute("EDGEID
", lay_eids[g][p]);
4073 e->SetAttribute("NUMPOINTS
", Npoints);
4074 e->SetAttribute("TYPE
", "PolyEvenlySpaced
");
4075 for(int c=0; c< Npoints; c++)
4077 st << std::scientific << std::setprecision(8) <<x_lay[g][p*Npoints +c]
4078 << " " << y_lay[g][p*Npoints +c] << " " << 0.000<<" ";
4082 TiXmlText * t0 = new TiXmlText(st.str());
4083 e->LinkEndChild(t0);
4084 curved->LinkEndChild(e);
4092 docnew.SaveFile( newfile );
4094 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)
#define ASSERTL0(condition, msg)
boost::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)
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)
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.
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.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
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 Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > ElementiDs)
Imports an FLD file.
void Cutrepetitions(int nedges, Array< OneD, NekDouble > inarray, Array< OneD, NekDouble > &outarray)
int main(int argc, char *argv[])
boost::shared_ptr< SegExp > SegExpSharedPtr
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)
boost::shared_ptr< ExpList1D > ExpList1DSharedPtr
Shared pointer to an ExpList1D object.
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)
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
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)
boost::shared_ptr< QuadExp > QuadExpSharedPtr
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)
boost::shared_ptr< BoundaryConditions > BoundaryConditionsSharedPtr
boost::shared_ptr< Geometry1D > Geometry1DSharedPtr
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
int DetermineclosePointxindex(NekDouble x, Array< OneD, NekDouble > xArray)
const BoundaryRegionCollection & GetBoundaryRegions(void) const
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)
void Zero(int n, T *x, const int incx)
Zero vector.
boost::shared_ptr< MeshGraph > MeshGraphSharedPtr
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)
boost::shared_ptr< PointGeom > PointGeomSharedPtr
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)
boost::shared_ptr< TriExp > TriExpSharedPtr