CG  Version 25
gaussianPulse.h
Go to the documentation of this file.
1 
2 // =============================================================
3 // Assign initial conditions for the Gaussian pulse
4 //
5 // GRIDTYPE: curvilinear or rectangular
6 // ==============================================================
7 #beginMacro assignGaussianPulseInitialConditions(GRIDTYPE)
8 if( mg.numberOfDimensions()==2 )
9 {
10  J1 = Range(max(Ie1.getBase(),uel.getBase(0)),min(Ie1.getBound(),uel.getBound(0)));
11  J2 = Range(max(Ie2.getBase(),uel.getBase(1)),min(Ie2.getBound(),uel.getBound(1)));
12  J3 = Range(max(Ie3.getBase(),uel.getBase(2)),min(Ie3.getBound(),uel.getBound(2)));
13  FOR_3D(i1,i2,i3,J1,J2,J3)
14  {
15  #If #GRIDTYPE eq "curvilinear"
16  real xe = XEP(i1,i2,i3,0)-x0;
17  real ye = XEP(i1,i2,i3,1)-y0;
18  #Else
19  real xe = X0(i1,i2,i3)-x0;
20  real ye = X1(i1,i2,i3)-y0;
21  #End
22 
23  real temp=exp( -pow(beta*(xe*xe+ye*ye),exponent) );
24 
25  UEX(i1,i2,i3) =c0*UEX(i1,i2,i3)-ye*scale*temp; // Ex = -C (Hz).y
26  UEY(i1,i2,i3) =c0*UEY(i1,i2,i3)+xe*scale*temp; // Ey = C (Hz).x
27 
28  UMEX(i1,i2,i3)=UEX(i1,i2,i3);
29  UMEY(i1,i2,i3)=UEY(i1,i2,i3);
30 
31  }
32 
33  J1 = Range(max(Ih1.getBase(),uhl.getBase(0)),min(Ih1.getBound(),uhl.getBound(0)));
34  J2 = Range(max(Ih2.getBase(),uhl.getBase(1)),min(Ih2.getBound(),uhl.getBound(1)));
35  J3 = Range(max(Ih3.getBase(),uhl.getBase(2)),min(Ih3.getBound(),uhl.getBound(2)));
36  FOR_3(i1,i2,i3,J1,J2,J3)
37  {
38  #If #GRIDTYPE eq "curvilinear"
39  real xh = XHP(i1,i2,i3,0)-x0;
40  real yh = XHP(i1,i2,i3,1)-y0;
41  #Else
42  real xh = X0(i1,i2,i3)-x0;
43  real yh = X1(i1,i2,i3)-y0;
44  #End
45 
46  real temp=exp( -pow(beta*(xh*xh+yh*yh),exponent) );
47 
48  UHZ(i1,i2,i3) =c0*UHZ(i1,i2,i3) + exp( -pow(beta*(xh*xh+yh*yh),exponent) );
49  UMHZ(i1,i2,i3)=UHZ(i1,i2,i3); // This is wrong : should use u_t = w_y ...
50  }
51 }
52 else
53 {
54  J1 = Range(max(Ie1.getBase(),uel.getBase(0)),min(Ie1.getBound(),uel.getBound(0)));
55  J2 = Range(max(Ie2.getBase(),uel.getBase(1)),min(Ie2.getBound(),uel.getBound(1)));
56  J3 = Range(max(Ie3.getBase(),uel.getBase(2)),min(Ie3.getBound(),uel.getBound(2)));
58  {
59  #If #GRIDTYPE eq "curvilinear"
60  real xe = XEP(i1,i2,i3,0)-x0;
61  real ye = XEP(i1,i2,i3,1)-y0;
62  real ze = XEP(i1,i2,i3,2)-z0;
63 
64  #Else
65  real xe = X0(i1,i2,i3)-x0;
66  real ye = X1(i1,i2,i3)-y0;
67  real ze = X2(i1,i2,i3)-z0;
68 
69  #End
70 
71  // XXX NONE of the 3D part of this macro has really been implemented for staggered grids
72  real rsq = xe*xe+ye*ye+ze*ze;
73 
74  // E = curl( phi ), phi = (phix,phiy,phiz)
75  // real phix = constant*exp( -pow(beta*rsq,exponent) );
76 
77  real dphix = scale*exp( -pow(beta*rsq,exponent) ); // exponent*pow(beta*rsq,exponent-1.);
78  real dphiy = dphix;
79  real dphiz = dphix;
80 
81  UEX(i1,i2,i3)=c0*UEX(i1,i2,i3)+ ye*dphiz -ze*dphiy; // (phiz).y - (phiy).z
82  UEY(i1,i2,i3)=c0*UEX(i1,i2,i3)+ ze*dphix -xe*dphiz ; //
83  UEZ(i1,i2,i3)=c0*UEX(i1,i2,i3)+ xe*dphiy -ye*dphix ;
84  UMEX(i1,i2,i3)=UEX(i1,i2,i3);
85  UMEY(i1,i2,i3)=UEY(i1,i2,i3);
86  UMEZ(i1,i2,i3)=UEZ(i1,i2,i3); // This is wrong : should use u_t = w_y ...
87  }
88 
89 
90  J1 = Range(max(Ih1.getBase(),uhl.getBase(0)),min(Ih1.getBound(),uhl.getBound(0)));
91  J2 = Range(max(Ih2.getBase(),uhl.getBase(1)),min(Ih2.getBound(),uhl.getBound(1)));
92  J3 = Range(max(Ih3.getBase(),uhl.getBase(2)),min(Ih3.getBound(),uhl.getBound(2)));
94  {
95 
96 #If #GRIDTYPE eq "curvilinear"
97  real xh = XHP(i1,i2,i3,0)-x0;
98  real yh = XHP(i1,i2,i3,1)-y0;
99  real zh = XHP(i1,i2,i3,2)-z0;
100 #Else
101  real xe = X0(i1,i2,i3)-x0;
102  real ye = X1(i1,i2,i3)-y0;
103  real ze = X2(i1,i2,i3)-z0;
104 
105  real xh = xe;// Cartesian grid stuff not implemented for staggered grids yet (Yee, DSI)
106  real yh = ye;
107  real zh = ze;
108 #End
109 
110  // XXX NONE of the 3D part of this macro has really been properly implemented for staggered grids
111  real rsq = xh*xh+yh*yh+zh*zh;
112 
113  // E = curl( phi ), phi = (phix,phiy,phiz)
114  // real phix = constant*exp( -pow(beta*rsq,exponent) );
115 
116  real dphix = scale*exp( -pow(beta*rsq,exponent) ); // exponent*pow(beta*rsq,exponent-1.);
117  real dphiy = dphix;
118  real dphiz = dphix;
119 
120  UHX(i1,i2,i3)=c0*UHX(i1,i2,i3) + dphix;
121  UHY(i1,i2,i3)=c0*UHY(i1,i2,i3) + dphiy;
122  UHZ(i1,i2,i3)=c0*UHZ(i1,i2,i3) + dphiz;
123  UMHX(i1,i2,i3)=UHX(i1,i2,i3);
124  UMHY(i1,i2,i3)=UHY(i1,i2,i3);
125  UMHZ(i1,i2,i3)=UHZ(i1,i2,i3); // This is wrong : should use u_t = w_y ...
126  }
127 }
128 #endMacro