14 #include <boost/lexical_cast.hpp>
18 using namespace Nektar;
20 int main(
int argc,
char *argv[])
25 Array<OneD,MultiRegions::ExpListSharedPtr> &Exp,
int nvariables);
28 Array<OneD, int>& Vids,
int v1,
int v2 ,
NekDouble x_connect,
30 Array<OneD, NekDouble>& x, Array<OneD, NekDouble>& y);
32 Array<OneD, NekDouble> x, Array<OneD, NekDouble> y,
33 Array<OneD, NekDouble> &xold_up, Array<OneD, NekDouble> &yold_up,
34 Array<OneD, NekDouble> &xold_low, Array<OneD, NekDouble> &yold_low,
35 Array<OneD, NekDouble> &xold_c, Array<OneD, NekDouble> &yold_c,
36 Array<OneD, NekDouble> &xc, Array<OneD, NekDouble> &yc,
NekDouble cr,
41 void GenerateCurveSp(Array<OneD, NekDouble> &x_c, Array<OneD, NekDouble> &y_c,
42 Array<OneD, NekDouble> &x_lay, Array<OneD, NekDouble> &y_lay);
43 void GenerateCurve(
int npoints,
int npused, Array<OneD, NekDouble> &x_c,
44 Array<OneD, NekDouble> &y_c, Array<OneD, NekDouble> &curve);
47 Array<OneD, NekDouble>& outx, Array<OneD, NekDouble>& outy,
48 Array<OneD, int>&Eids);
50 Array<OneD, int> &V2);
52 Array<OneD, int> V1, Array<OneD, int> V2,
53 Array<
OneD, Array<OneD, int > >& lay_Vids,
54 Array<
OneD, Array<OneD, int > >& lay_eids);
56 Array<
OneD, Array<OneD, int > > lay_Vids, Array<OneD, NekDouble> xc,
57 Array<OneD, NekDouble> yc, Array<OneD, int> Down, Array<OneD, int> Up,
58 Array<OneD, NekDouble >& xnew, Array<OneD, NekDouble>& ynew,
59 Array<
OneD, Array<OneD, NekDouble > >& layers_x,
60 Array<
OneD, Array<OneD, NekDouble > >& layers_y);
62 Array<OneD, NekDouble>& outarray);
64 Array<OneD, NekDouble> inarray_y, Array<OneD, NekDouble>& outarray_x,
65 Array<OneD, NekDouble>& outarray_y);
68 Array<OneD, NekDouble> yArray,Array<OneD, NekDouble>& Neighbour_x,
69 Array<OneD, NekDouble>& Neighbour_y);
71 Array<OneD,NekDouble> xpts, Array<OneD, NekDouble> funcvals);
73 Array<OneD, NekDouble> yc,
74 Array<OneD, NekDouble> Addpointsy,
75 Array<
OneD, Array<OneD, NekDouble > >& layers_y,
76 Array<
OneD, Array<OneD, int> >lay_Vids,
80 Array<OneD, NekDouble> newy,
81 Array<OneD, NekDouble> x_crit, Array<OneD, NekDouble> y_crit,
82 Array<OneD, NekDouble> & Pcurvx,
83 Array<OneD, NekDouble> & Pcurvy,
84 Array<OneD, int>&Eids,
int Npoints,
string s_alp,
85 Array<
OneD, Array<OneD, NekDouble> > x_lay,
86 Array<
OneD, Array<OneD, NekDouble> > y_lay,
87 Array<
OneD, Array<OneD, int > >lay_eids,
bool curv_lay);
101 if(argc > 6 || argc <5 )
104 "Usage: ./MoveMesh meshfile fieldfile changefile alpha cr(optional)\n");
107 else if( argc == 6 &&
108 vSession->DefinesSolverInfo(
"INTERFACE")
109 && vSession->GetSolverInfo(
"INTERFACE")==
"phase" )
111 cr = boost::lexical_cast<
double>(argv[argc-1]);
116 string meshfile(argv[argc-4]);
128 Array<OneD, MultiRegions::ExpListSharedPtr> fields;
136 SetFields(graphShPt,boundaryConditions,vSession,fields,nfields);
140 string changefile(argv[argc-2]);
144 string charalp (argv[argc-1]);
146 cout<<
"read alpha="<<charalp<<endl;
148 string fieldfile(argv[argc-3]);
149 vector<LibUtilities::FieldDefinitionsSharedPtr> fielddef;
150 vector<vector<NekDouble> > fielddata;
169 for(
int i=0; i<fielddata.size(); i++)
171 streak->ExtractDataToCoeffs(fielddef[i], fielddata[i], fielddef[i]->m_fields[0], streak->UpdateCoeffs());
173 streak->BwdTrans_IterPerExp(streak->GetCoeffs(), streak->UpdatePhys());
207 int nIregions, lastIregion;
208 const Array<OneD, SpatialDomains::BoundaryConditionShPtr> bndConditions = fields[0]->GetBndConditions();
209 Array<OneD, int> Iregions =Array<OneD, int>(bndConditions.num_elements(),-1);
212 int nbnd= bndConditions.num_elements();
213 for(
int r=0; r<nbnd; r++)
223 ASSERTL0(nIregions>0,
"there is any boundary region with the tag USERDEFINEDTYPE=""CalcBC"" specified");
224 cout<<
"nIregions="<<nIregions<<endl;
226 Array<OneD, MultiRegions::ExpListSharedPtr> bndfieldx= fields[0]->GetBndCondExpansions();
230 int nq1D= bndfieldx[lastIregion]->GetTotPoints();
231 int nedges = bndfieldx[lastIregion]->GetExpSize();
232 int nvertl = nedges +1 ;
233 Array<OneD, int> Vids_low(nvertl,-10);
234 Array<OneD, NekDouble> xold_low(nvertl);
235 Array<OneD, NekDouble> yold_low(nvertl);
236 Array<OneD, NekDouble> zi(nvertl);
248 ( (bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
253 vertex0->GetCoords(x0,y0,z0);
256 cout<<
"WARNING x0="<<x0<<endl;
262 Vids_low, v1, v2 , x_connect ,lastedge, xold_low,yold_low);
263 ASSERTL0(Vids_low[v2]!=-10,
"Vids_low[v2] is wrong");
267 cout<<
"x_conn="<<x_connect<<
" yt="<<yt<<
" zt="<<zt<<
" vid="<<Vids_low[v2]<<endl;
268 vertex->GetCoords(x_connect,yt,zt);
275 Vids_low, v1, v2 , x_connect, lastedge, xold_low, yold_low );
279 vertex->GetCoords(x_connect,yt,zt);
286 Array<OneD, int> Vids_up(nvertl,-10);
287 Array<OneD,NekDouble> xold_up(nvertl);
288 Array<OneD,NekDouble> yold_up(nvertl);
294 ( (bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
299 vertex0->GetCoords(x0,y0,z0);
302 cout<<
"WARNING x0="<<x0<<endl;
310 Vids_up, v1, v2 , x_connect ,lastedge, xold_up, yold_up);
314 vertexU->GetCoords(x_connect,yt,zt);
321 Vids_up, v1, v2 , x_connect, lastedge, xold_up, yold_up );
325 vertex->GetCoords(x_connect,yt,zt);
333 Array<OneD, int> Vids_c(nvertl,-10);
334 Array<OneD,NekDouble> xold_c(nvertl);
335 Array<OneD,NekDouble> yold_c(nvertl);
341 ( (bndfieldx[lastIregion]->GetExp(0)->as<LocalRegions::SegExp>())
346 vertex0->GetCoords(x0,y0,z0);
349 cout<<
"WARNING x0="<<x0<<endl;
358 Vids_c, v1, v2 , x_connect ,lastedge, xold_c, yold_c);
362 vertexc->GetCoords(x_connect,yt,zt);
369 Vids_c, v1, v2 , x_connect, lastedge, xold_c, yold_c );
373 vertex->GetCoords(x_connect,yt,zt);
379 Array<OneD, NekDouble> Deltaup (nvertl, -200);
380 Array<OneD, NekDouble> Deltalow (nvertl, -200);
382 for(
int r=0; r<nvertl; r++)
386 Deltaup[r] = yold_up[r] - yold_c[r];
387 Deltalow[r] = yold_c[r] - yold_low[r];
388 ASSERTL0(Deltaup[r]>0,
"distance between upper and layer curve is not positive");
389 ASSERTL0(Deltalow[r]>0,
"distance between lower and layer curve is not positive");
422 if(vSession->DefinesParameter(
"npedge"))
424 npedge = (int)vSession->GetParameter(
"npedge");
432 int nq= streak->GetTotPoints();
433 Array<OneD, NekDouble> x(nq);
434 Array<OneD,NekDouble> y(nq);
435 fields[0]->GetCoords(x,y);
436 Array<OneD, NekDouble> x_c(nvertl);
437 Array<OneD,NekDouble> y_c(nvertl,-200);
438 Array<OneD, NekDouble> tmp_w (nvertl, 200);
439 Array<OneD, int> Sign (nvertl,1);
440 Array<OneD, NekDouble> Delta_c(nvertl,-200);
444 xold_low, yold_low, xold_c, yold_c, x_c, y_c,cr,
true);
447 for(
int q=0; q<nvertl; q++)
449 if(y_c[q] < yold_c[q])
454 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;
485 Array<OneD, NekDouble> Cpointsx (nedges);
486 Array<OneD, NekDouble> Cpointsy (nedges, 0.0);
487 Array<OneD, int> Eids (nedges);
640 Array<OneD, NekDouble> Addpointsx (nedges*(npedge-2), 0.0);
641 Array<OneD, NekDouble> Addpointsy (nedges*(npedge-2), 0.0);
643 Array<OneD, NekDouble> dU(streak->GetTotPoints());
654 for(
int r=0; r<nedges; r++)
657 bndSegExp = bndfieldx[lastIregion]->GetExp(r)
659 Eid = (bndSegExp->GetGeom1D())->GetEid();
660 id1 = (bndSegExp->GetGeom1D())->GetVid(0);
661 id2 = (bndSegExp->GetGeom1D())->GetVid(1);
662 vertex1 = graphShPt->GetVertex(id1);
663 vertex2 = graphShPt->GetVertex(id2);
665 vertex2->GetCoords(x2,y2,z2);
668 cout<<
"edge="<<r<<
" x1="<<x1<<
" y1="<<y1<<
" x2="<<x2<<
" y2="<<y2<<endl;
671 Cpointsx[r] = x1 +(x2-x1)/2;
674 if( Cpointsx[r]>x2 || Cpointsx[r]< x1)
676 Cpointsx[r] = -Cpointsx[r];
678 for(
int w=0; w< npedge-2; w++)
681 Addpointsx[r*(npedge-2) +w] = x1 +((x2-x1)/(npedge - 1))*(w+1);
682 if( Addpointsx[r*(npedge-2) +w] > x2 || Addpointsx[r*(npedge-2) +w] < x1)
684 Addpointsx[r*(npedge-2) +w] = -Addpointsx[r*(npedge-2) +w];
687 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);
690 Addpointsx[r*(npedge-2) +w], Addpointsy[r*(npedge-2) +w], streak, dU,cr);
703 Cpointsx[r] = x2+ (x1-x2)/2;
705 if( Cpointsx[r] > x1 || Cpointsx[r] < x2)
707 Cpointsx[r] = -Cpointsx[r];
709 for(
int w=0; w< npedge-2; w++)
711 Addpointsx[r*(npedge-2) +w] = x2 +((x1-x2)/(npedge - 1))*(w+1);
712 if( Addpointsx[r*(npedge-2) +w] > x1 || Addpointsx[r*(npedge-2) +w] < x2)
714 Addpointsx[r*(npedge-2) +w] = -Addpointsx[r*(npedge-2) +w];
718 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);
722 Addpointsx[r*(npedge-2) +w], Addpointsy[r*(npedge-2) +w], streak, dU,cr);
733 ASSERTL0(
false,
"point not generated");
750 Array<OneD, NekDouble> xcPhys (nedges*npedge, 0.0);
751 Array<OneD, NekDouble> ycPhys (nedges*npedge, 0.0);
753 for(
int a=0; a<nedges; a++)
756 xcPhys[a*npedge+0] = x_c[a];
757 ycPhys[a*npedge+0] = y_c[a];
759 xcPhys[a*npedge+npedge-1] = x_c[a+1];
760 ycPhys[a*npedge+npedge-1] = y_c[a+1];
762 for(
int b=0; b<npedge-2; b++)
764 xcPhys[a*npedge +b+1] = Addpointsx[a*(npedge-2)+b];
765 ycPhys[a*npedge +b+1] = Addpointsy[a*(npedge-2)+b];
795 Array<OneD, NekDouble> curve(nvertl);
796 cout<<
"gen curve"<<endl;
849 Array<OneD, NekDouble> curve_coeffs (nedges*(npedge-2)+nedges+1);
892 int nVertTot = graphShPt->GetNvertices();
894 Array<OneD, NekDouble> xold(nVertTot);
895 Array<OneD, NekDouble> yold(nVertTot);
897 for(
int n=0; n<nVertTot; n++)
901 vertex->GetCoords(x,y,z);
905 if(x<= xold_c[0] +5e-2 && x >= xold_c[0] -5e-2
906 && y<= yold_up[0] && y>=yold_low[0]
915 cout<<
"nlays="<<nlays<<endl;
916 Array<OneD, Array<OneD, NekDouble> > layers_y(nlays);
917 Array<OneD, Array<OneD, NekDouble> > layers_x(nlays);
918 Array<OneD, Array<OneD, int > >lay_Vids(nlays);
919 Array<OneD, Array<OneD, int > >lay_eids(nlays);
921 for(
int g=0; g<nlays; g++)
923 layers_y[g]= Array<OneD, NekDouble> ( (nvertl-1)*npedge );
924 lay_Vids[g]= Array<OneD, int> (nvertl);
925 lay_eids[g]= Array<OneD, int> (nvertl-1);
931 Array<OneD, NekDouble> xnew(nVertTot);
932 Array<OneD, NekDouble> ynew(nVertTot,-20);
933 Array<OneD, int> Up(nvertl);
934 Array<OneD, int> Down(nvertl);
941 if(vSession->DefinesParameter(
"Delta"))
943 Delta0 = vSession->GetParameter(
"Delta");
956 Array<OneD, int> Acntlay(nvertl,0);
963 int bottomleft, topright,bottomright,topleft;
964 for(
int i=0; i<nVertTot; i++)
969 vertex->GetCoords(x,y,z);
974 if(x==0 && y< yold_low[0]
981 if(x== xold_c[nvertl-1] && y> yold_up[nvertl-1]
988 if(x==xold_c[nvertl-1] && y<yold_low[nvertl-1]
995 if(x== 0 && y> yold_up[0]
1002 for(
int j=0; j<nvertl; j++)
1004 if((xold_up[j]==x)&&(yold_up[j]==y))
1008 ynew[i] = y_c[j] +Delta0;
1012 if((xold_low[j]==x)&&(yold_low[j]==y))
1016 ynew[i] = y_c[j] -Delta0;
1020 if((xold_c[j]==x)&&(yold_c[j]==y))
1031 for(
int k=0; k<nvertl; k++)
1033 if(abs(x-xold_up[k]) < diff)
1035 diff = abs(x-xold_up[k]);
1039 if( y>yold_up[qp_closer] && y< 1)
1047 ynew[i] = y_c[qp_closer] +(y-yold_c[qp_closer])*
1048 (1-y_c[qp_closer])/(1-yold_c[qp_closer]);
1054 else if(y<yold_low[qp_closer] && y> -1)
1062 ynew[i] = y_c[qp_closer] + (y-yold_c[qp_closer] )*
1063 (-1-y_c[qp_closer])/(-1-yold_c[qp_closer]);
1067 else if ( y>yold_c[qp_closer] && y < yold_up[qp_closer])
1069 if(x==0){ cntup++; }
1074 else if (y<yold_c[qp_closer] && y > yold_low[qp_closer])
1076 if(x==0){ cntlow++; }
1081 else if( y==1 || y==-1)
1088 if( (ynew[i]>1 || ynew[i]<-1)
1089 && ( y>yold_up[qp_closer] || y<yold_low[qp_closer]) )
1091 cout<<
"point x="<<xnew[i]<<
" y="<<y<<
" closer x="<<xold_up[qp_closer]<<
" ynew="<<ynew[i]<<endl;
1092 ASSERTL0(
false,
"shifting out of range");
1100 for(
int m=0; m<nvertl; m++)
1103 if( x>= x_c[m] -5e-2 && x<= x_c[m] +5e-2
1104 && y<= yold_up[m] && y>=yold_low[m]
1111 layers_y[Acntlay[m]][m]= y;
1112 lay_Vids[Acntlay[m]][m]= i;
1120 cout<<
"cntlow="<<cntlow<<endl;
1121 ASSERTL0(Acntlay[4]==nlays,
"something wrong with the number of layers");
1124 Array<OneD, int> V1;
1125 Array<OneD, int> V2;
1172 bool move_norm=
true;
1173 int np_lay = (nvertl-1)*npedge;
1174 int nqedge = streak->GetExp(0)->GetNumPoints(0);
1175 Array<OneD, NekDouble> xcQ(nqedge*nedges,0.0);
1176 Array<OneD, NekDouble> ycQ(nqedge*nedges,0.0);
1177 Array<OneD, NekDouble> zcQ(nqedge*nedges,0.0);
1178 Array<OneD, NekDouble> nxPhys(npedge*nedges,0.0);
1179 Array<OneD, NekDouble> nyPhys(npedge*nedges,0.0);
1180 Array<OneD, NekDouble> nxQ(nqedge*nedges,0.0);
1181 Array<OneD, NekDouble> nyQ(nqedge*nedges,0.0);
1182 if( move_norm==
true)
1187 Array<OneD, StdRegions::StdExpansion1DSharedPtr> Edge_newcoords(2);
1189 cout<<
"nquad per edge="<<nqedge<<endl;
1190 for(
int l=0; l<2; l++)
1192 Edge_newcoords[l] = bndfieldx[lastIregion]->GetExp(0)
1195 Array<OneD, NekDouble> xnull(nqedge);
1196 Array<OneD, NekDouble> ynull(nqedge);
1197 Array<OneD, NekDouble> xcedgeQ(nqedge,0.0);
1198 Array<OneD, NekDouble> ycedgeQ(nqedge,0.0);
1199 Array<OneD, NekDouble> txedgeQ(nqedge,0.0);
1200 Array<OneD, NekDouble> tyedgeQ(nqedge,0.0);
1201 Array<OneD, NekDouble> normsQ(nqedge,0.0);
1203 Array<OneD, NekDouble> txQ(nqedge*nedges,0.0);
1204 Array<OneD, NekDouble> tyQ(nqedge*nedges,0.0);
1205 Array<OneD, NekDouble> tx_tyedgeQ(nqedge,0.0);
1206 Array<OneD, NekDouble> nxedgeQ(nqedge,0.0);
1207 Array<OneD, NekDouble> nyedgeQ(nqedge,0.0);
1208 Array<OneD, const NekDouble> ntempQ(nqedge) ;
1210 Array<OneD, NekDouble> nxedgePhys(npedge,0.0);
1211 Array<OneD, NekDouble> nyedgePhys(npedge,0.0);
1214 Array<OneD, NekDouble> CoordsPhys(2);
1217 bndfieldx[lastIregion]->GetCoords(xcQ, ycQ, zcQ);
1226 cout<<
"xcQ, ycQ"<<endl;
1228 xnull,ynull, xcQ,ycQ, cr,
false);
1237 for(
int k=0; k<nedges; k++)
1242 Edge_newcoords[0]->StdPhysDeriv(xcedgeQ,txedgeQ);
1243 Edge_newcoords[1]->StdPhysDeriv(ycedgeQ,tyedgeQ);
1247 Vmath::Vvtvp(nqedge,tyedgeQ,1,tyedgeQ,1,normsQ,1,normsQ,1);
1260 Vmath::Vdiv(nqedge, txedgeQ,1,tyedgeQ,1,tx_tyedgeQ,1);
1261 Vmath::Vmul(nqedge, tx_tyedgeQ,1,tx_tyedgeQ,1,tx_tyedgeQ,1);
1267 Vmath::Vcopy(nqedge, &(nxedgeQ[0]),1, &(nxQ[nqedge*k]),1);
1269 Vmath::Vmul(nqedge, nxedgeQ,1,nxedgeQ,1,nyedgeQ,1);
1275 Vmath::Vcopy(nqedge, &(nyedgeQ[0]), 1, &(nyQ[nqedge*k]),1);
1290 nyQ[(k-1)*nqedge+nqedge-1]=
1295 nxQ[(k-1)*nqedge+nqedge-1]=
1300 int nquad_lay = (nvertl-1)*nqedge;
1301 Array<OneD, NekDouble>x_tmpQ(nquad_lay-(nedges-1));
1303 Array<OneD, NekDouble>tmpnyQ(nquad_lay-(nedges-1));
1317 for(
int k=0; k<nedges; k++)
1320 for(
int a=0; a<npedge; a++)
1324 nxPhys[k*npedge +a]= nxQ[k*nqedge +0];
1325 nyPhys[k*npedge +a]= nyQ[k*nqedge +0];
1328 else if(a== npedge-1)
1330 nxPhys[k*npedge +a]= nxQ[k*nqedge +nqedge-1];
1331 nyPhys[k*npedge +a]= nyQ[k*nqedge +nqedge-1];
1351 Array<OneD, NekDouble> Pxinterp(4);
1352 Array<OneD, NekDouble> Pyinterp(4);
1357 nyPhys[k*npedge +a]=
1367 nxPhys[k*npedge +a]= -sqrt(abs(1- nyPhys[k*npedge +a]*nyPhys[k*npedge +a]));
1383 nyPhys[(k-1)*npedge+npedge-1]=
1388 nxPhys[(k-1)*npedge+npedge-1]=
1418 Array<OneD, NekDouble> delta(nlays);
1419 Array<OneD, NekDouble>tmpy_lay(np_lay);
1420 Array<OneD, NekDouble>tmpx_lay(np_lay);
1421 for(
int m=0; m<nlays; m++)
1428 delta[m] = -(cntlow+1-m)*Delta0/(cntlow+1);
1432 delta[m] = ( m-(cntlow) )*Delta0/(cntlow+1);
1436 layers_x[m]= Array<OneD, NekDouble>(np_lay);
1439 for(
int h=0; h< nvertl; h++)
1446 if(move_norm==
false)
1448 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m];
1449 xnew[lay_Vids[m][h] ]= x_c[h];
1453 if(h==0 || h==nvertl-1 )
1455 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m];
1456 xnew[lay_Vids[m][h] ]= x_c[h];
1460 ynew[lay_Vids[m][h] ]= y_c[h] +delta[m]*abs(nyPhys[h*npedge+0]);
1461 xnew[lay_Vids[m][h] ]= x_c[h] +delta[m]*abs(nxPhys[h*npedge+0]);
1465 if(h< nedges && curv_lay==
true)
1470 ASSERTL0( nyPhys[h*npedge+0]==nyPhys[(h-1)*npedge+npedge-1],
" normaly wrong");
1471 ASSERTL0( nxPhys[h*npedge+0]==nxPhys[(h-1)*npedge+npedge-1],
" normalx wrong");
1474 if(move_norm==
false)
1477 layers_y[m][h*npedge +0] = y_c[h] +delta[m];
1478 layers_x[m][h*npedge +0] = xnew[lay_Vids[m][h] ];
1480 layers_y[m][h*npedge +npedge-1] = y_c[h+1] +delta[m];
1481 layers_x[m][h*npedge +npedge-1] = xnew[lay_Vids[m][h+1] ];
1483 for(
int d=0; d< npedge-2; d++)
1485 layers_y[m][h*npedge +d+1]= Addpointsy[h*(npedge-2) +d] +delta[m];
1486 layers_x[m][h*npedge +d+1]= Addpointsx[h*(npedge-2) +d];
1494 tmpy_lay[h*npedge +0] = y_c[h] +delta[m];
1495 tmpx_lay[h*npedge +0] = xnew[lay_Vids[m][h] ];
1497 tmpy_lay[h*npedge +npedge-1] =
1498 y_c[h+1] +delta[m]*abs(nyPhys[h*npedge +npedge-1]);
1499 tmpx_lay[h*npedge +npedge-1] =
1500 x_c[h+1] +delta[m]*abs(nxPhys[h*npedge +npedge-1]);
1502 else if(h==nedges-1)
1505 tmpy_lay[h*npedge +0] =
1506 y_c[h] +delta[m]*abs(nyPhys[h*npedge +0]);
1507 tmpx_lay[h*npedge +0] =
1508 x_c[h] +delta[m]*abs(nxPhys[h*npedge +0]);
1510 tmpy_lay[h*npedge +npedge-1] = y_c[h+1] +delta[m];
1511 tmpx_lay[h*npedge +npedge-1] = xnew[lay_Vids[m][h+1] ];
1516 tmpy_lay[h*npedge +0] =
1517 y_c[h] +delta[m]*abs(nyPhys[h*npedge +0]);
1518 tmpx_lay[h*npedge +0] =
1519 x_c[h] +delta[m]*abs(nxPhys[h*npedge +0]);
1521 tmpy_lay[h*npedge +npedge-1] =
1522 y_c[h+1] +delta[m]*abs(nyPhys[h*npedge +npedge-1]);
1523 tmpx_lay[h*npedge +npedge-1] =
1524 x_c[h+1] +delta[m]*abs(nxPhys[h*npedge +npedge-1]);
1528 for(
int d=0; d< npedge-2; d++)
1531 tmpy_lay[h*npedge +d+1] = Addpointsy[h*(npedge-2) +d] +
1532 delta[m]*abs(nyPhys[h*npedge +d+1]);
1533 tmpx_lay[h*npedge +d+1]= Addpointsx[h*(npedge-2) +d] +
1534 delta[m]*abs(nxPhys[h*npedge +d+1]);
1577 NekDouble boundright = xcPhys[np_lay-1];
1578 bool outboundleft=
false;
1579 bool outboundright=
false;
1580 if(tmpx_lay[1]< boundleft )
1582 outboundleft =
true;
1584 if(tmpx_lay[np_lay-2] > boundright )
1586 outboundright =
true;
1595 Array<OneD, int> vertout(nvertl);
1596 for(
int r=0; r< nedges; r++)
1599 if(tmpx_lay[r*npedge + npedge-1]< boundleft && outboundleft==
true )
1607 if( tmpx_lay[(r+1)*npedge + npedge-1]> boundleft )
1610 for(
int s=0; s<npedge-2; s++)
1612 if(tmpx_lay[(r+1)*npedge + s+1]< boundleft)
1622 if(tmpx_lay[r*npedge + 0]> boundright && outboundright==
true )
1630 if( tmpx_lay[(r-1)*npedge + 0]< boundright )
1633 for(
int s=0; s<npedge-2; s++)
1635 if(tmpx_lay[(r-1)*npedge + s+1]> boundright)
1646 outcount = outvert*npedge+1+ outmiddle;
1648 int replacepointsfromindex=0;
1649 for(
int c=0; c<nedges; c++)
1652 if(xcPhys[c*npedge+npedge-1] <= tmpx_lay[c*(npedge-(npedge-2)) +2] && outboundright==
true)
1654 replacepointsfromindex = c*(npedge-(npedge-2))+2;
1660 if(xcPhys[(nedges-1 -c)*npedge+0] >= tmpx_lay[np_lay-1 -(c*(npedge-(npedge-2)) +2)]
1661 && outboundleft==
true)
1663 replacepointsfromindex = np_lay-1 -(c*(npedge-(npedge-2)) +2);
1687 if( outboundright==
true)
1689 pstart = replacepointsfromindex;
1690 shift = np_lay-outcount;
1691 increment = (xcPhys[np_lay-outcount]-xcPhys[pstart])/(outcount+1);
1692 outcount = outcount-1;
1693 ASSERTL0(tmpx_lay[np_lay-outcount]>xcPhys[(nedges-1)*npedge+0],
"no middle points in the last edge");
1699 increment = (xcPhys[replacepointsfromindex]-xcPhys[pstart])/(outcount+1);
1700 ASSERTL0(tmpx_lay[pstart]<xcPhys[0*npedge +npedge-1],
"no middle points in the first edge");
1704 Array<OneD, NekDouble> replace_x(outcount);
1705 Array<OneD, NekDouble> replace_y(outcount);
1707 Array<OneD, NekDouble>x_tmp(np_lay-(nedges-1));
1708 Array<OneD, NekDouble>y_tmp(np_lay-(nedges-1));
1709 Array<OneD, NekDouble>tmpny(np_lay-(nedges-1));
1714 Array<OneD, NekDouble>closex(4);
1715 Array<OneD, NekDouble>closey(4);
1716 Array<OneD, NekDouble>closeny(4);
1717 NekDouble xctmp,ycinterp,nxinterp,nyinterp;
1721 for(
int v=0; v<outcount;v++)
1723 xctmp = xcPhys[pstart]+(v+1)*increment;
1740 xctmp,4,closex,closeny );
1743 nxinterp = sqrt(abs(1-nyinterp*nyinterp));
1750 replace_x[v] = xctmp +delta[m]*abs(nxinterp);
1751 replace_y[v] = ycinterp +delta[m]*abs(nyinterp);
1752 tmpx_lay[ v+shift ] = replace_x[v];
1753 tmpy_lay[ v+shift ] = replace_y[v];
1784 int closepoints = 4;
1786 Array<OneD, NekDouble> Pyinterp(closepoints);
1787 Array<OneD, NekDouble> Pxinterp(closepoints);
1791 for(
int q=0; q<np_lay; q++)
1793 for(
int e=0; e<nedges; e++)
1795 if(tmpx_lay[q]<= x_c[e+1] && tmpx_lay[q]>= x_c[e])
1799 if(q == e*npedge +npedge-1 && pointscount!=npedge )
1804 else if(q == e*npedge +npedge-1)
1820 cout<<nedges<<
"nedges"<<npedge<<
" np_lay="<<np_lay<<endl;
1823 Array<OneD, NekDouble>tmpx(np_lay-(nedges-1));
1824 Array<OneD, NekDouble>tmpy(np_lay-(nedges-1));
1851 Array<OneD, NekDouble> copyarray_x(tmpx.num_elements());
1852 Array<OneD, NekDouble> copyarray_y(tmpx.num_elements());
1883 for(
int g=0; g< nvertl; g++)
1895 xnew[lay_Vids[m][g] ]= x_c[g];
1904 layers_y[m][g*npedge +0] = ynew[lay_Vids[m][g] ];
1905 layers_x[m][g*npedge +0] = xnew[lay_Vids[m][g] ];
1913 layers_y[m][g*npedge +npedge-1] =
1915 layers_x[m][g*npedge +npedge-1] = x_c[g+1];
1920 for(
int r=0; r< npedge-2; r++)
1928 ASSERTL0( index<= tmpy.num_elements()-1,
" index wrong");
1932 layers_y[m][g*npedge +r+1]=
1934 Addpointsx[g*(npedge-2) +r],closepoints,Pxinterp,Pyinterp );
1936 layers_x[m][g*npedge +r+1]= Addpointsx[g*(npedge-2) +r];
1976 for(
int n=0; n<nVertTot; n++)
1981 vertex->GetCoords(x,y,z);
1986 for(
int k=0; k<nvertl; k++)
1988 if(abs(x-xold_c[k]) < tmp)
1990 tmp = abs(x-xold_c[k]);
2003 nplay_closer= (qp_closer-1)*npedge +npedge-1;
2007 if( y>yold_up[qp_closer] && y<1 )
2012 ratio = (1-layers_y[nlays-1][nplay_closer])/
2013 ( (1-yold_up[qp_closer]) );
2015 ynew[n] = layers_y[nlays-1][nplay_closer]
2016 + (y-yold_up[qp_closer])*ratio;
2020 else if( y< yold_low[qp_closer] && y>-1 )
2023 ratio = (1+layers_y[0][nplay_closer])/
2024 ( (1+yold_low[qp_closer]) );
2026 ynew[n] = layers_y[0][nplay_closer]
2027 + (y-yold_low[qp_closer])*ratio;
2037 lay_Vids, x_c, y_c, Down, Up, xnew, ynew, layers_x, layers_y);
2046 " different xmin val");
2048 " different ymin val");
2050 " different xmax val");
2052 " different ymax val");
2147 Replacevertices(changefile, xnew , ynew, x_c, y_c, Addpointsx, Addpointsy, Eids, npedge, charalp, layers_x,layers_y, lay_eids, curv_lay);
2155 Array<OneD,MultiRegions::ExpListSharedPtr> &Exp,
int nvariables)
2164 bool DeclareCoeffPhysArrays =
true;
2169 bool useFFT =
false;
2171 enum HomogeneousType
2179 enum HomogeneousType HomogeneousType = eNotHomogeneous;
2181 if(session->DefinesSolverInfo(
"HOMOGENEOUS"))
2183 std::string HomoStr = session->GetSolverInfo(
"HOMOGENEOUS");
2186 if((HomoStr ==
"HOMOGENEOUS1D")||(HomoStr ==
"Homogeneous1D")||
2187 (HomoStr ==
"1D")||(HomoStr ==
"Homo1D"))
2189 HomogeneousType = eHomogeneous1D;
2190 npointsZ = session->GetParameter(
"HomModesZ");
2191 LhomZ = session->GetParameter(
"LZ");
2195 if((HomoStr ==
"HOMOGENEOUS2D")||(HomoStr ==
"Homogeneous2D")||
2196 (HomoStr ==
"2D")||(HomoStr ==
"Homo2D"))
2198 HomogeneousType = eHomogeneous2D;
2199 npointsY = session->GetParameter(
"HomModesY");
2200 LhomY = session->GetParameter(
"LY");
2201 npointsZ = session->GetParameter(
"HomModesZ");
2202 LhomZ = session->GetParameter(
"LZ");
2206 if((HomoStr ==
"HOMOGENEOUS3D")||(HomoStr ==
"Homogeneous3D")||
2207 (HomoStr ==
"3D")||(HomoStr ==
"Homo3D"))
2209 HomogeneousType = eHomogeneous3D;
2210 npointsX = session->GetParameter(
"HomModesX");
2211 LhomX = session->GetParameter(
"LX");
2212 npointsY = session->GetParameter(
"HomModesY");
2213 LhomY = session->GetParameter(
"LY");
2214 npointsZ = session->GetParameter(
"HomModesZ");
2215 LhomZ = session->GetParameter(
"LZ");
2219 if(session->DefinesSolverInfo(
"USEFFT"))
2226 int expdim = mesh->GetMeshDimension();
2227 Exp= Array<OneD, MultiRegions::ExpListSharedPtr>(nvariables);
2253 for(i = 0 ; i < Exp.num_elements(); i++)
2286 Exp[0] = firstfield;
2287 for(i = 1 ; i < Exp.num_elements(); i++)
2311 Exp[0] = firstfield;
2312 for(i = 1 ; i < Exp.num_elements(); i++)
2321 ASSERTL0(
false,
"Expansion dimension not recognised");
2328 Array<OneD, int>& Vids,
int v1,
int v2,
NekDouble x_connect,
int & lastedge,
2329 Array<OneD, NekDouble>& x, Array<OneD, NekDouble>& y)
2331 int nvertl = nedges+1;
2333 Array<OneD, int> Vids_temp(nvertl,-10);
2335 for(
int j=0; j<nedges; j++)
2339 edge = (bndSegExplow->GetGeom1D())->GetEid();
2341 for(
int k=0; k<2; k++)
2343 Vids_temp[j+k]=(bndSegExplow->GetGeom1D())->GetVid(k);
2347 if(x1==x_connect && edge!=lastedge)
2350 if(x_connect==x0layer)
2352 Vids[v1]=Vids_temp[j+k];
2358 Vids_temp[j+1]=(bndSegExplow->GetGeom1D())->GetVid(1);
2359 Vids[v2]=Vids_temp[j+1];
2362 vertex->GetCoords(x2,y2,z2);
2368 Vids_temp[j+0]=(bndSegExplow->GetGeom1D())->GetVid(0);
2369 Vids[v2]=Vids_temp[j+0];
2372 vertex->GetCoords(x2,y2,z2);
2382 Vids_temp[j+1]=(bndSegExplow->GetGeom1D())->GetVid(1);
2383 Vids[v1]=Vids_temp[j+1];
2386 vertex->GetCoords(x1,y1,z1);
2392 Vids_temp[j+0]=(bndSegExplow->GetGeom1D())->GetVid(0);
2393 Vids[v1]=Vids_temp[j+0];
2396 vertex->GetCoords(x1,y1,z1);
2414 Array<OneD, NekDouble> x, Array<OneD, NekDouble> y,
2415 Array<OneD, NekDouble> &xold_up, Array<OneD, NekDouble> &yold_up,
2416 Array<OneD, NekDouble> &xold_low, Array<OneD, NekDouble> &yold_low,
2417 Array<OneD, NekDouble> &xold_c, Array<OneD, NekDouble> &yold_c,
2418 Array<OneD, NekDouble> &xc, Array<OneD, NekDouble> &yc,
NekDouble cr,
2421 cout<<
"Computestreakpositions"<<endl;
2422 int nq = streak->GetTotPoints();
2423 Array<OneD, NekDouble> coord(2);
2425 Array<OneD, NekDouble> derstreak(nq);
2501 Vmath::Vadd(xc.num_elements(), yold_up,1,yold_low,1, yc,1);
2515 for(
int e=0; e<npoints; e++)
2520 elmtid = streak->GetExpIndex(coord,0.00001);
2521 offset = streak->GetPhys_Offset(elmtid);
2526 while( abs(F)> 0.000000001)
2529 elmtid = streak->GetExpIndex(coord,0.00001);
2530 offset = streak->GetPhys_Offset(elmtid);
2531 U = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2532 dU = streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2533 coord[1] = coord[1] - (U-cr)/dU;
2535 ASSERTL0( coord[0]==xc[e],
" x coordinate must remain the same");
2539 && attempt==0 && verts==
true
2544 coord[1] = yold_c[e];
2547 else if(abs(coord[1])>1 )
2549 coord[1] = ytmp +0.01;
2550 elmtid = streak->GetExpIndex(coord,0.00001);
2551 offset = streak->GetPhys_Offset(elmtid);
2552 NekDouble Utmp = streak->GetExp(elmtid)->PhysEvaluate(coord, streak->GetPhys() + offset);
2553 NekDouble dUtmp = streak->GetExp(elmtid)->PhysEvaluate(coord, derstreak + offset);
2554 coord[1] = coord[1] - (Utmp-cr)/dUtmp;
2556 if( (abs(Utmp-cr)>abs(F))||(abs(coord[1])>1) )
2558 coord[1] = ytmp -0.01;
2565 ASSERTL0(abs(coord[1])<= 1,
" y value out of bound +/-1");
2569 if(its>1000 && F< 0.0001)
2571 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2576 ASSERTL0(
false,
"no convergence after 1000 iterations");
2579 yc[e] = coord[1] - (U-cr)/dU;
2581 ASSERTL0( U<= cr + tol,
"streak wrong+");
2582 ASSERTL0( U>= cr -tol,
"streak wrong-");
2584 cout<<
"result streakvert x="<<xc[e]<<
" y="<<yc[e]<<
" streak="<<U<<endl;
2597 Array<OneD, NekDouble> coords(2);
2605 while( abs(F)> 0.00000001)
2609 elmtid =
function->GetExpIndex(coords, 0.00001);
2612 offset =
function->GetPhys_Offset(elmtid);
2614 U =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() + offset);
2615 dU =
function->GetExp(elmtid)->PhysEvaluate(coords, derfunction + offset);
2616 coords[1] = coords[1] - (U-cr)/dU;
2620 if( abs(coords[1])>1
2625 coords[1] = ytmp +0.01;
2626 elmtid =
function->GetExpIndex(coords,0.00001);
2627 offset =
function->GetPhys_Offset(elmtid);
2628 NekDouble Utmp =
function->GetExp(elmtid)->PhysEvaluate(coords, function->GetPhys() + offset);
2629 NekDouble dUtmp =
function->GetExp(elmtid)->PhysEvaluate(coords, derfunction + offset);
2630 coords[1] = coords[1] - (Utmp-cr)/dUtmp;
2631 cout<<
"attempt:"<<coords[1]<<endl;
2632 if( (abs(Utmp-cr)>abs(F))||(abs(coords[1])>1) )
2634 coords[1] = ytmp -0.01;
2641 ASSERTL0(abs(coords[1])<= 1,
" y value out of bound +/-1");
2645 if(its>1000 && F< 0.0001)
2647 cout<<
"warning streak position obtained with precision:"<<F<<endl;
2652 ASSERTL0(
false,
"no convergence after 1000 iterations");
2656 ASSERTL0( coords[0]==xi,
" x coordinate must remain the same");
2659 y0 = coords[1] - (U-cr)/dU;
2660 cout<<
"NewtonIt result x="<<x0<<
" y="<<coords[1]<<
" U="<<U<<endl;
2664 Array<OneD, NekDouble> &y_c, Array<OneD, NekDouble> &curve)
2667 int totpoints = npoints + npused;
2669 Array<OneD, NekDouble> A (N*N,1.0);
2670 Array<OneD, NekDouble> b (N);
2673 for(
int e=0; e<N; e++)
2676 for(
int w=npused; w < totpoints; w++)
2678 A[N*e+row] = std::pow( x_c[w], N-1-e);
2683 for(
int r= npused; r< totpoints; r++)
2691 Array<OneD, int> ipivot (N);
2694 Lapack::Dgetrf( N, N, A.get(), N, ipivot.get(), info);
2698 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2699 "th parameter had an illegal parameter for dgetrf";
2704 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2705 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2711 Lapack::Dgetrs(
'N', N, ncolumns_b , A.get() , N, ipivot.get(), b.get(), N, info);
2714 std::string message =
"ERROR: The " + boost::lexical_cast<std::string>(-info) +
2715 "th parameter had an illegal parameter for dgetrf";
2720 std::string message =
"ERROR: Element u_" + boost::lexical_cast<std::string>(info) +
2721 boost::lexical_cast<std::string>(info) +
" is 0 from dgetrf";
2728 Vmath::Vcopy(totpoints, &(b[0]), 1, &(curve[npused]), 1);
2734 for(
int a= npused+1; a< totpoints+1; a++)
2748 Array<OneD, NekDouble> &x_lay, Array<OneD, NekDouble> &y_lay)
2750 Array<OneD, NekDouble> k(x_c.num_elements());
2751 Array<OneD, NekDouble> b(x_c.num_elements());
2755 for(
int s=0; s< k.num_elements(); s++)
2757 dx = x_c[s] - x_c[s-1];
2758 dy = y_c[s] - y_c[s-1];
2759 dx1 = x_c[s+1] - x_c[s];
2760 dy1 = y_c[s+1] - y_c[s];
2761 if(s==0 || s==k.num_elements()-1)
2768 b[s] = 3*( dy/(dx*dx) +dy1/(dx1*dx1) );
2778 Array<OneD, NekDouble>& outx, Array<OneD, NekDouble>& outy, Array<OneD, int>&Eids)
2793 firstcoeff = firstedge+1;
2796 int lastedge = firstedge + (np-1);
2797 int lastcoeff = firstcoeff + np;
2801 for(
int s= firstedge; s< lastedge; s++)
2804 Eid = (bndSegExp->GetGeom1D())->GetEid();
2805 id1 = (bndSegExp->GetGeom1D())->GetVid(0);
2806 id2 = (bndSegExp->GetGeom1D())->GetVid(1);
2807 vertex1 = mesh->GetVertex(id1);
2808 vertex2 = mesh->GetVertex(id2);
2810 vertex2->GetCoords(x2,y2,z2);
2814 outx[s] = x1 +(x2-x1)/2;
2815 if( outx[s]>x2 || outx[s]< x1)
2822 outx[s] = x2+ (x1-x2)/2;
2823 if( outx[s] > x1 || outx[s] <x2)
2830 ASSERTL0(
false,
"point not generated");
2833 for(
int g= firstcoeff; g< lastcoeff; g++)
2835 outy[s] += curve[g]*(std::pow(outx[s], polorder));
2837 ASSERTL0(polorder >=0,
" polynomial with one negative exponent");
2848 Array<OneD, int> &V2)
2850 const boost::shared_ptr<LocalRegions::ExpansionVector> exp2D = field->GetExp();
2851 int nel = exp2D->size();
2857 Array<OneD, int> V1tmp(4*nel, 10000);
2858 Array<OneD, int> V2tmp(4*nel, 10000);
2859 for(
int i=0; i<nel; i++)
2861 if((locQuadExp = (*exp2D)[i]->as<LocalRegions::QuadExp>()))
2863 for(
int j = 0; j < locQuadExp->GetNedges(); ++j)
2865 SegGeom = (locQuadExp->GetGeom2D())->
GetEdge(j);
2866 id = SegGeom->GetEid();
2867 if( V1tmp[
id] == 10000)
2869 V1tmp[id]= SegGeom->GetVertex(0)->GetVid();
2870 V2tmp[id]= SegGeom->GetVertex(1)->GetVid();
2877 else if((locTriExp = (*exp2D)[i]->as<LocalRegions::TriExp>()))
2879 for(
int j = 0; j < locTriExp->GetNedges(); ++j)
2881 SegGeom = (locTriExp->GetGeom2D())->
GetEdge(j);
2882 id = SegGeom->GetEid();
2884 if( V1tmp[
id] == 10000)
2886 V1tmp[id]= SegGeom->GetVertex(0)->GetVid();
2887 V2tmp[id]= SegGeom->GetVertex(1)->GetVid();
2896 V1 = Array<OneD, int>(cnt);
2897 V2 = Array<OneD, int>(cnt);
2899 for(
int g=0; g<cnt; g++)
2902 ASSERTL0(V1tmp[g]!=10000,
"V1 wrong");
2904 ASSERTL0(V2tmp[g]!=10000,
"V2 wrong");
2910 Array<OneD, int> V1, Array<OneD, int> V2,
2911 Array<
OneD, Array<OneD, int > >& lay_Vids,
2912 Array<
OneD, Array<OneD, int > >& lay_eids)
2914 int neids = V1.num_elements();
2915 int nlays = layers_y.num_elements();
2916 int nvertl = lay_Vids[0].num_elements();
2917 Array<OneD, NekDouble > tmpy(nlays,-1000);
2918 Array<OneD, int > tmpVids(nlays,-1000);
2919 Array<OneD, int > tmpIndex(nlays,-1000);
2922 for(
int a=0; a<nvertl; a++)
2924 tmpy = Array<OneD, NekDouble> (nlays,-1000);
2926 for(
int t=0; t<nlays; t++)
2928 tmpy[t] = layers_y[t][a];
2929 tmpVids[t] = lay_Vids[t][a];
2933 for(
int b=0; b<nlays; b++)
2936 layers_y[b][a] = tmpy[tmpIndex[b]];
2937 lay_Vids[b][a] = tmpVids[tmpIndex[b]];
2941 tmpy[tmpIndex[b]] = 1000;
2947 for(
int a=0; a< nvertl-1; a++)
2949 for(
int b=0; b<nlays; b++)
2951 for(
int p=0; p< neids; p++)
2954 (lay_Vids[b][a] == V1[p] && lay_Vids[b][a+1]==V2[p])||
2955 (lay_Vids[b][a] == V2[p] && lay_Vids[b][a+1]==V1[p])
2968 Array<
OneD, Array<OneD, int > > lay_Vids, Array<OneD, NekDouble> xc,
2969 Array<OneD, NekDouble> yc, Array<OneD, int> Down, Array<OneD, int> Up,
2970 Array<OneD, NekDouble >& xnew,Array<OneD, NekDouble>& ynew,
2971 Array<
OneD, Array<OneD, NekDouble > >& layers_x,
2972 Array<
OneD, Array<OneD, NekDouble > >& layers_y)
2974 int np_lay = layers_y[0].num_elements();
2976 for(
int h=1; h<nlays-1; h++)
2978 layers_x[h]= Array<OneD, NekDouble>(np_lay);
2979 for(
int s=0; s<nvertl; s++)
2982 ASSERTL0(ynew[ lay_Vids[h][s] ]==-20,
"ynew layers not empty");
2986 ynew[ lay_Vids[h][s] ] = ynew[Down[s]]+ h*abs(ynew[Down[s]] - yc[s])/(cntlow+1);
2988 xnew[lay_Vids[h][s] ] = xc[s];
2992 layers_y[h][s] = ynew[ lay_Vids[h][s] ];
2993 layers_x[h][s] = xnew[ lay_Vids[h][s] ];
2998 ynew[ lay_Vids[h][s] ] = yc[s] + (h-cntlow)*abs(ynew[Up[s]] - yc[s])/(cntup+1);
3000 xnew[lay_Vids[h][s] ] = xc[s];
3002 layers_y[h][s] = ynew[ lay_Vids[h][s] ];
3003 layers_x[h][s] = xnew[ lay_Vids[h][s] ];
3010 Array<OneD, NekDouble>& outarray)
3014 int np_lay = inarray.num_elements();
3016 int npedge = np_lay/nedges;
3017 ASSERTL0(inarray.num_elements()%nedges==0,
" something on number npedge");
3020 cout<<nedges<<
"nedges"<<npedge<<
" nplay="<<np_lay<<endl;
3024 for(
int b=0; b<nedges; b++)
3026 Vmath::Vcopy( npedge-1, &inarray[b*(npedge)],1,&outarray[b*(npedge-1)],1);
3029 outarray[b*(npedge-1)+npedge-1] = inarray[b*npedge+npedge-1];
3039 Array<OneD, NekDouble> inarray_y, Array<OneD, NekDouble>& outarray_x,
3040 Array<OneD, NekDouble>& outarray_y)
3043 Array<OneD, NekDouble>tmpx(inarray_x.num_elements());
3045 Vmath::Vcopy(inarray_x.num_elements() , inarray_x,1,tmpx,1);
3051 for(
int w=0; w<tmpx.num_elements(); w++)
3054 outarray_x[w]= tmpx[index];
3055 outarray_y[w]= inarray_y[index];
3056 tmpx[index] = max+1000;
3064 int npts = xArray.num_elements();
3065 Array<OneD, NekDouble> xcopy(npts);
3073 if(xArray[index]> x)
3082 Array<OneD, NekDouble> yArray,Array<OneD, NekDouble>& Neighbour_x,
3083 Array<OneD, NekDouble>& Neighbour_y)
3085 ASSERTL0( neighpoints%2==0,
"number of neighbour points should be even");
3086 int leftpoints = (neighpoints/2)-1;
3087 int rightpoints = neighpoints/2;
3091 if(index-leftpoints<0)
3094 diff = index-leftpoints;
3096 Vmath::Vcopy(neighpoints, &yArray[0],1,&Neighbour_y[0],1);
3097 Vmath::Vcopy(neighpoints, &xArray[0],1,&Neighbour_x[0],1);
3099 else if( (yArray.num_elements()-1)-index < rightpoints)
3102 int rpoints = (yArray.num_elements()-1)-index;
3103 diff = rightpoints-rpoints;
3105 start = index-leftpoints-diff;
3106 Vmath::Vcopy(neighpoints, &yArray[start],1,&Neighbour_y[0],1);
3107 Vmath::Vcopy(neighpoints, &xArray[start],1,&Neighbour_x[0],1);
3112 start = index-leftpoints;
3113 Vmath::Vcopy(neighpoints, &yArray[start],1,&Neighbour_y[0],1);
3114 Vmath::Vcopy(neighpoints, &xArray[start],1,&Neighbour_x[0],1);
3123 for(
int f=1; f< neighpoints; f++)
3125 ASSERTL0(Neighbour_x[f]!=Neighbour_x[f-1],
" repetition on NeighbourArrays");
3132 Array<OneD,NekDouble> xpts, Array<OneD, NekDouble> funcvals)
3137 for(
int pt=0;pt<
npts;++pt)
3141 for(
int j=0;j<pt; ++j)
3143 h = h * (x - xpts[j])/(xpts[pt]-xpts[j]);
3146 for(
int k=pt+1;k<
npts;++k)
3148 h = h * (x - xpts[k])/(xpts[pt]-xpts[k]);
3152 sum += funcvals[pt]*LagrangePoly;
3159 Array<OneD, NekDouble> yc,
3160 Array<OneD, NekDouble> Addpointsy,
3161 Array<
OneD, Array<OneD, NekDouble > >& layers_y,
3162 Array<
OneD, Array<OneD, int> >lay_Vids,
3165 int nvertl = yc.num_elements();
3166 int nedges = nvertl-1;
3167 int nlays = layers_y.num_elements();
3168 int np_lay = layers_y[0].num_elements();
3169 Array<OneD, Array<OneD, NekDouble> > tmpy(layers_y.num_elements());
3170 Array<OneD, Array<OneD, NekDouble> > tmpynew(layers_y.num_elements());
3174 cout<<
"movelay"<<movelay<<endl;
3175 if(movelay ==
"laydown")
3177 delta = abs(layers_y[nlays-1][(nvertl-2)*npedge+npedge-1]-yc[nvertl-1]);
3179 for(
int g=0; g< nlays; g++)
3181 tmpy[g] = Array<OneD, NekDouble> (np_lay);
3182 tmpynew[g] = Array<OneD, NekDouble>(nvertl);
3183 for(
int h=0; h< nvertl; h++)
3189 tmpynew[g][h]= yc[h] + delta + delta/(nlays/2);
3195 tmpy[g][h*npedge +0] = yc[h] + delta+ delta/(nlays/2);
3197 tmpy[g][h*npedge +npedge-1] = yc[h+1] + delta+delta/(nlays/2);
3199 for(
int d=0; d< npedge-2; d++)
3201 tmpy[g][h*npedge +d+1]=
3202 Addpointsy[h*(npedge-2) +d] +delta + delta/(nlays/2);
3209 tmpynew[g][h]= ynew[ lay_Vids[g][h] ];
3213 tmpy[g][h*npedge +0] = layers_y[g][h*npedge +0];
3215 tmpy[g][h*npedge +npedge-1] = layers_y[g][h*npedge +npedge-1];
3217 for(
int d=0; d< npedge-2; d++)
3219 tmpy[g][h*npedge +d+1]= layers_y[g][h*npedge +d+1];
3230 for(
int g=0; g< nlays; g++)
3232 cout<<
"move y coords"<<g<<endl;
3233 for(
int h=0; h<np_lay; h++)
3238 layers_y[nlays-1][h]= tmpy[0][h];
3242 layers_y[cnt][h] = tmpy[g][h];
3247 for(
int v=0; v<nvertl; v++)
3251 ynew[lay_Vids[nlays-1][v]] = tmpynew[0][v];
3255 ynew[lay_Vids[vcnt][v] ] = tmpynew[g][v];
3264 if( movelay ==
"layup")
3266 ASSERTL0(
false,
"not implemented layup");
3275 Array<OneD, NekDouble> newy,
3276 Array<OneD, NekDouble> x_crit, Array<OneD, NekDouble> y_crit,
3277 Array<OneD, NekDouble> & Pcurvx,
3278 Array<OneD, NekDouble> & Pcurvy,
3279 Array<OneD, int>&Eids,
int Npoints,
string s_alp,
3280 Array<
OneD, Array<OneD, NekDouble> > x_lay,
3281 Array<
OneD, Array<OneD, NekDouble> > y_lay,
3282 Array<
OneD, Array<OneD, int > >lay_eids,
bool curv_lay)
3286 TiXmlDocument doc(filename);
3287 bool loadOkay = doc.LoadFile();
3289 TiXmlElement* master = doc.FirstChildElement(
"NEKTAR");
3290 TiXmlElement* mesh = master->FirstChildElement(
"GEOMETRY");
3291 TiXmlElement* element = mesh->FirstChildElement(
"VERTEX");
3294 const char *xscal = element->Attribute(
"XSCALE");
3297 std::string xscalstr = xscal;
3299 xscale = expEvaluator.
Evaluate(expr_id);
3304 newfile = filename.substr(0, filename.find_last_of(
"."))+
"_moved.xml";
3306 doc.SaveFile( newfile );
3309 TiXmlDocument docnew(newfile);
3310 bool loadOkaynew = docnew.LoadFile();
3312 std::string errstr =
"Unable to load file: ";
3314 ASSERTL0(loadOkaynew, errstr.c_str());
3316 TiXmlHandle docHandlenew(&docnew);
3317 TiXmlNode* nodenew = NULL;
3318 TiXmlElement* meshnew = NULL;
3319 TiXmlElement* masternew = NULL;
3320 TiXmlElement* condnew = NULL;
3321 TiXmlElement* Parsnew = NULL;
3322 TiXmlElement* parnew = NULL;
3327 masternew = docnew.FirstChildElement(
"NEKTAR");
3328 ASSERTL0(masternew,
"Unable to find NEKTAR tag in file.");
3332 condnew = masternew->FirstChildElement(
"CONDITIONS");
3333 Parsnew = condnew->FirstChildElement(
"PARAMETERS");
3334 cout<<
"alpha="<<s_alp<<endl;
3335 parnew = Parsnew->FirstChildElement(
"P");
3338 TiXmlNode *node = parnew->FirstChild();
3342 std::string line = node->ToText()->Value();
3346 int beg = line.find_first_not_of(
" ");
3347 int end = line.find_first_of(
"=");
3349 if (beg == end)
throw 1;
3351 if (end != line.find_last_of(
"="))
throw 1;
3353 if (end == std::string::npos)
throw 1;
3355 lhs = line.substr(line.find_first_not_of(
" "), end-beg);
3356 lhs = lhs.substr(0, lhs.find_last_not_of(
" ")+1);
3362 boost::to_upper(lhs);
3365 alphastring =
"Alpha = "+ s_alp;
3366 parnew->RemoveChild(node);
3367 parnew->LinkEndChild(
new TiXmlText(alphastring) );
3371 parnew = parnew->NextSiblingElement(
"P");
3376 meshnew = masternew->FirstChildElement(
"GEOMETRY");
3378 ASSERTL0(meshnew,
"Unable to find GEOMETRY tag in file.");
3379 TiXmlAttribute *attrnew = meshnew->FirstAttribute();
3381 TiXmlElement* elementnew = meshnew->FirstChildElement(
"VERTEX");
3382 ASSERTL0(elementnew,
"Unable to find mesh VERTEX tag in file.");
3386 elementnew->SetAttribute(
"XSCALE",1.0);
3388 TiXmlElement *vertexnew = elementnew->FirstChildElement(
"V");
3394 int nextVertexNumber = -1;
3400 TiXmlAttribute *vertexAttr = vertexnew->FirstAttribute();
3401 std::string attrName(vertexAttr->Name());
3402 ASSERTL0(attrName ==
"ID", (std::string(
"Unknown attribute name: ") + attrName).c_str());
3404 err = vertexAttr->QueryIntValue(&indx);
3405 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read attribute ID.");
3406 ASSERTL0(indx == nextVertexNumber,
"Vertex IDs must begin with zero and be sequential.");
3408 std::string vertexBodyStr;
3410 TiXmlNode *vertexBody = vertexnew->FirstChild();
3412 if (vertexBody->Type() == TiXmlNode::TEXT)
3414 vertexBodyStr += vertexBody->ToText()->Value();
3415 vertexBodyStr +=
" ";
3417 ASSERTL0(!vertexBodyStr.empty(),
"Vertex definitions must contain vertex data.");
3419 vertexnew->RemoveChild(vertexBody);
3425 s << std::scientific << std::setprecision(8) << newx[nextVertexNumber] <<
" "
3426 << newy[nextVertexNumber] <<
" " << 0.0;
3427 vertexnew->LinkEndChild(
new TiXmlText(s.str()));
3432 vertexnew = vertexnew->NextSiblingElement(
"V");
3438 TiXmlElement* curvednew = meshnew->FirstChildElement(
"CURVED");
3439 ASSERTL0(curvednew,
"Unable to find mesh CURVED tag in file.");
3440 TiXmlElement *edgenew = curvednew->FirstChildElement(
"E");
3443 std::string charindex;
3446 int indexeid, v1,v2;
3454 TiXmlAttribute *edgeAttr = edgenew->FirstAttribute();
3455 std::string attrName(edgeAttr->Name());
3456 charindex = edgeAttr->Value();
3457 std::istringstream iss(charindex);
3458 iss >> std::dec >> index;
3460 edgenew->QueryIntAttribute(
"EDGEID", &eid);
3463 for(
int u=0; u<Eids.num_elements(); u++)
3473 curvednew->RemoveChild(edgenew);
3480 std::string edgeBodyStr;
3482 TiXmlNode *edgeBody = edgenew->FirstChild();
3483 if(edgeBody->Type() == TiXmlNode::TEXT)
3485 edgeBodyStr += edgeBody->ToText()->Value();
3488 ASSERTL0(!edgeBodyStr.empty(),
"Edge definitions must contain edge data");
3490 edgenew->RemoveChild(edgeBody);
3492 if(x_crit[cnt]< x_crit[cnt+1])
3509 cout<<
"Warning: the edges can have the vertices in the reverse order";
3515 err = edgenew->QueryIntAttribute(
"NUMPOINTS", &numPts);
3516 ASSERTL0(err == TIXML_SUCCESS,
"Unable to read curve attribute NUMPOINTS.");
3517 edgenew->SetAttribute(
"NUMPOINTS", Npoints);
3519 st << std::scientific << std::setprecision(8) << x_crit[v1] <<
" "
3520 << y_crit[v1] <<
" " << 0.000<<
" ";
3522 for(
int a=0; a< Npoints-2; a++)
3524 st << std::scientific << std::setprecision(8) <<
3525 " "<<Pcurvx[indexeid*(Npoints-2) +a]<<
" "<<Pcurvy[indexeid*(Npoints-2) +a]
3529 st << std::scientific << std::setprecision(8) <<
3530 " "<<x_crit[v2]<<
" "<< y_crit[v2] <<
" "<< 0.000;
3532 edgenew->LinkEndChild(
new TiXmlText(st.str()));
3542 edgenew = edgenew->NextSiblingElement(
"E");
3547 if(curv_lay ==
true)
3549 cout<<
"write other curved edges"<<endl;
3550 TiXmlElement * curved = meshnew->FirstChildElement(
"CURVED");
3552 int nlays = lay_eids.num_elements();
3553 int neids_lay = lay_eids[0].num_elements();
3558 for (
int g=0; g< nlays; ++g)
3560 for(
int p=0; p< neids_lay; p++)
3563 TiXmlElement * e =
new TiXmlElement(
"E" );
3564 e->SetAttribute(
"ID", idcnt++);
3565 e->SetAttribute(
"EDGEID", lay_eids[g][p]);
3566 e->SetAttribute(
"NUMPOINTS", Npoints);
3567 e->SetAttribute(
"TYPE",
"PolyEvenlySpaced");
3568 for(
int c=0; c< Npoints; c++)
3570 st << std::scientific << std::setprecision(8) <<x_lay[g][p*Npoints +c]
3571 <<
" " << y_lay[g][p*Npoints +c] <<
" " << 0.000<<
" ";
3575 TiXmlText * t0 =
new TiXmlText(st.str());
3576 e->LinkEndChild(t0);
3577 curved->LinkEndChild(e);
3585 docnew.SaveFile( newfile );
3587 cout<<
"new file: "<<newfile<<endl;