5 #define exTrue(x,y,t) sin(twoPi*(kx*(x)+ky*(y)-cc*(t)))*pwc[0]
6 #define eyTrue(x,y,t) sin(twoPi*(kx*(x)+ky*(y)-cc*(t)))*pwc[1]
7 #define hzTrue(x,y,t) sin(twoPi*(kx*(x)+ky*(y)-cc*(t)))*pwc[5]
9 #define extTrue(x,y,t) (-twoPi*cc)*cos(twoPi*(kx*(x)+ky*(y)-cc*(t)))*pwc[0]
10 #define eytTrue(x,y,t) (-twoPi*cc)*cos(twoPi*(kx*(x)+ky*(y)-cc*(t)))*pwc[1]
11 #define hztTrue(x,y,t) (-twoPi*cc)*cos(twoPi*(kx*(x)+ky*(y)-cc*(t)))*pwc[5]
13 #define exLaplacianTrue(x,y,t) sin(twoPi*(kx*(x)+ky*(y)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky))*pwc[0])
14 #define eyLaplacianTrue(x,y,t) sin(twoPi*(kx*(x)+ky*(y)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky))*pwc[1])
15 #define hzLaplacianTrue(x,y,t) sin(twoPi*(kx*(x)+ky*(y)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky))*pwc[5])
20 #define hzGaussianPulse(xi) exp(-betaGaussianPlaneWave*((xi)*(xi)))
21 #define exGaussianPulse(xi) hzGaussianPulse(xi)*(-ky/(eps*cc))
22 #define eyGaussianPulse(xi) hzGaussianPulse(xi)*( kx/(eps*cc))
24 #define hzLaplacianGaussianPulse(xi) ((4.*betaGaussianPlaneWave*betaGaussianPlaneWave*(kx*kx+ky*ky))*xi*xi-\
25 (2.*betaGaussianPlaneWave*(kx*kx+ky*ky)))*exp(-betaGaussianPlaneWave*((xi)*(xi)))
26 #define exLaplacianGaussianPulse(xi) hzLaplacianGaussianPulse(xi,t)*(-ky/(eps*cc))
27 #define eyLaplacianGaussianPulse(xi) hzLaplacianGaussianPulse(xi,t)*( kx/(eps*cc))
40 #define exTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[0]
41 #define eyTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[1]
42 #define ezTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[2]
44 #define extTrue3d(x,y,z,t) (-twoPi*cc)*cos(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[0]
45 #define eytTrue3d(x,y,z,t) (-twoPi*cc)*cos(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[1]
46 #define eztTrue3d(x,y,z,t) (-twoPi*cc)*cos(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[2]
50 #define hxTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[3]
51 #define hyTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[4]
52 #define hzTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*pwc[5]
54 #define exLaplacianTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky+kz*kz))*pwc[0])
55 #define eyLaplacianTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky+kz*kz))*pwc[1])
56 #define ezLaplacianTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky+kz*kz))*pwc[2])
58 #define hxLaplacianTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky+kz*kz))*pwc[3])
59 #define hyLaplacianTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky+kz*kz))*pwc[4])
60 #define hzLaplacianTrue3d(x,y,z,t) sin(twoPi*(kx*(x)+ky*(y)+kz*(z)-cc*(t)))*(-(twoPi*twoPi*(kx*kx+ky*ky+kz*kz))*pwc[5])
71 #beginMacro getGaussianIntegralSolution(OPTION,VEX,VEY,VHZ,t,I1,I2,I3)
78 double xs[nsources], ys[nsources], tau[nsources], var[nsources], amp[nsources];
92 double x=
X(i1,i2,i3,0);
93 double y=
X(i1,i2,i3,1);
95 exmax(wt,wx,wy,nsources,xs[0],ys[0],tau[0],var[0],amp[0],period,x,y,time);
97 #If #OPTION eq "solution"
101 #Elif #OPTION eq "error"
102 ERREX(i1,i2,i3) = VEX(i1,i2,i3) - wy;
103 ERREY(i1,i2,i3) = VEY(i1,i2,i3) + wx;
104 ERRHZ(i1,i2,i3) = VHZ(i1,i2,i3) - wt;
122 #beginMacro DEFINE_GF_MACRO(GFM,GFP,DIM0,DIM1,DIM2,DFA,CCX)
125 ERROR :
GFM ## already defined!
127 #define GFM ## (i0,i1,i2) GFP ## [i0+DIM0 ## *(i1+DIM1 ## *(i2+DIM2 ## *( CCX )))]
207 #beginMacro EXTRACT_GFP(OPTION)
209 #ifdef EXTGFP_SENTINEL
210 ERROR : XXX : you have not closed
the current EXTRACT_GFP macro before starting
a new one!
212 #define EXTGFP_SENTINEL
213 #ifdef EXTGFP_SENTINEL
224 const bool isStructured = mg.getGridType()==MappedGrid::structuredGrid;
226 assert( !(isRectangular && !isStructured) );
228 real
dx[3]={1.,1.,1.},
xab[2][3]={{0.,0.,0.},{0.,0.,0.}};
230 mg.getRectangularGridParameters( dx,
xab );
239 intSerialArray
maskLocal; getLocalArrayWithGhostBoundaries(mask,maskLocal);
241 intSerialArray & maskLocal =
mask;
257 mg.update(MappedGrid::THEcenter | MappedGrid::THEvertex);
269 bool ok = ParallelUtility::getLocalArrayBounds(mask,
maskLocal,I1,I2,I3,includeGhost);
270 #If #OPTION ne "FORCING"
278 if( method==nfdtd || method==sosup )
285 realMappedGridFunction & uall =
mgp==NULL ? getCGField(HField,current)[
grid] : fields[current];
286 realMappedGridFunction & umall =
mgp==NULL ? getCGField(HField,prev)[
grid] : fields[prev];
287 realMappedGridFunction & unall =
mgp==NULL ? getCGField(HField,next)[
grid] : fields[next];
290 getLocalArrayWithGhostBoundaries(uall,uLocal);
291 realSerialArray umLocal; getLocalArrayWithGhostBoundaries(umall,umLocal);
292 realSerialArray unLocal; getLocalArrayWithGhostBoundaries(unall,unLocal);
294 uLocal.reference(uall);
295 realSerialArray & umLocal = umall;
296 realSerialArray & unLocal = unall;
299 if (
cg.numberOfDimensions()==2 )
301 ue.reference(
uLocal(I1,I2,I3,Range(
ex,
ey)) );
302 uh.reference(
uLocal(I1,I2,I3,hz) );
303 ume.reference( umLocal(I1,I2,I3,Range(
ex,
ey)) );
304 umh.reference( umLocal(I1,I2,I3,hz) );
305 une.reference( unLocal(I1,I2,I3,Range(
ex,
ey)) );
306 unh.reference( unLocal(I1,I2,I3,hz) );
311 realSerialArray errLocal; getLocalArrayWithGhostBoundaries(*errp,errLocal);
312 errh.reference(errLocal(I1,I2,I3,hz));
313 erre.reference(errLocal(I1,I2,I3,Range(
ex,
ey)));
315 errh.reference((*errp)(I1,I2,I3,hz));
316 erre.reference((*errp)(I1,I2,I3,Range(
ex,
ey)));
322 realSerialArray errLocal; getLocalArrayWithGhostBoundaries((*cgerrp)[
grid],errLocal);
323 errh.reference(errLocal(I1,I2,I3,hz));
324 erre.reference(errLocal(I1,I2,I3,Range(
ex,
ey)));
326 errh.reference((*cgerrp)[grid](I1,I2,I3,hz));
327 erre.reference((*cgerrp)[grid](I1,I2,I3,Range(
ex,
ey)));
333 if ( solveForElectricField )
335 ue.reference(
uLocal(I1,I2,I3,Range(
ex,
ez)) );
336 ume.reference( umLocal(I1,I2,I3,Range(
ex,
ez)) );
337 une.reference( unLocal(I1,I2,I3,Range(
ex,
ez)) );
341 realSerialArray errLocal; getLocalArrayWithGhostBoundaries(*errp,errLocal);
342 erre.reference(errLocal(I1,I2,I3,Range(
ex,
ez)));
344 erre.reference((*errp)(I1,I2,I3,Range(
ex,
ez)));
351 realSerialArray errLocal; getLocalArrayWithGhostBoundaries((*cgerrp)[
grid],errLocal);
352 erre.reference(errLocal(I1,I2,I3,Range(
ex,
ez)));
354 erre.reference((*cgerrp)[grid](I1,I2,I3,Range(
ex,
ez)));
359 if ( solveForMagneticField )
361 uh.reference(
uLocal(I1,I2,I3,Range(
hx,hz)) );
362 umh.reference( umLocal(I1,I2,I3,Range(
hx,hz)) );
363 unh.reference( unLocal(I1,I2,I3,Range(
hx,hz)) );
367 realSerialArray errLocal; getLocalArrayWithGhostBoundaries(*errp,errLocal);
368 errh.reference(errLocal(I1,I2,I3,Range(
hx,hz)));
370 errh.reference((*errp)(I1,I2,I3,Range(
hx,hz)));
376 realSerialArray errLocal; getLocalArrayWithGhostBoundaries((*cgerrp)[
grid],errLocal);
377 errh.reference(errLocal(I1,I2,I3,Range(
hx,hz)));
379 errh.reference((*cgerrp)[grid](I1,I2,I3,Range(
hx,hz)));
386 realSerialArray xLocal;
if(
buildCenter ) getLocalArrayWithGhostBoundaries(center,xLocal);
388 const realSerialArray & xLocal =
center;
394 xe.reference( (
buildCenter ? xLocal(I1,I2,I3,0) : emptySerialArray) );
395 ye.reference( (
buildCenter ? xLocal(I1,I2,I3,1) : emptySerialArray) );
396 if ( numberOfDimensions==3 )
397 ze.reference( (
buildCenter ? xLocal(I1,I2,I3,2) : emptySerialArray) );
407 xce.reference(xLocal);
415 if ( method==dsiMatVec )
417 realMappedGridFunction &
uep = (
mgp==NULL ? getCGField(EField,current)[
grid] : fields[current+numberOfTimeLevels]);
418 realMappedGridFunction &
uhp = (
mgp==NULL ? getCGField(HField,current)[
grid] : fields[current]);
419 realMappedGridFunction &uepm = (
mgp==NULL ? getCGField(EField,next)[
grid] : fields[next+numberOfTimeLevels]);
420 realMappedGridFunction &uhpm = (
mgp==NULL ? getCGField(HField,next)[
grid] : fields[next]);
423 realSerialArray uepLocal; getLocalArrayWithGhostBoundaries(uep,uepLocal);
424 realSerialArray uhpLocal; getLocalArrayWithGhostBoundaries(uhp,uhpLocal);
425 realSerialArray uepmLocal; getLocalArrayWithGhostBoundaries(uepm,uepmLocal);
426 realSerialArray uhpmLocal; getLocalArrayWithGhostBoundaries(uhpm,uhpmLocal);
428 realSerialArray & uepLocal=
uep;
429 realSerialArray & uhpLocal=
uhp;
430 realSerialArray & uepmLocal=uepm;
431 realSerialArray & uhpmLocal=uhpm;
434 realMappedGridFunction uer, uhr, uerm, uhrm;
435 uepp.reference(uepLocal);
436 uhpp.reference(uhpLocal);
438 #If #OPTION == "FORCING"
440 ue.reference ( uepLocal );
441 uh.reference ( uhpLocal );
442 ume.reference ( uepmLocal );
443 umh.reference ( uhpmLocal );
447 uer.updateToMatchGrid(mg,GridFunctionParameters::edgeCentered,numberOfDimensions);
448 uerm.updateToMatchGrid(mg,GridFunctionParameters::edgeCentered,numberOfDimensions);
449 if ( numberOfDimensions==2 )
451 uhr.updateToMatchGrid(mg,GridFunctionParameters::cellCentered);
452 uhrm.updateToMatchGrid(mg,GridFunctionParameters::cellCentered);
456 uhr.updateToMatchGrid(mg,GridFunctionParameters::faceCenteredAll,numberOfDimensions);
457 uhrm.updateToMatchGrid(mg,GridFunctionParameters::faceCenteredAll,numberOfDimensions);
467 reconstructDSIField(tE,EField,uep,uer);
468 reconstructDSIField(tE-dt,EField,uepm,uerm);
470 reconstructDSIField(tH,HField,uhp,uhr);
471 reconstructDSIField(tH-dt,HField,uhpm,uhrm);
475 realSerialArray uerLocal; getLocalArrayWithGhostBoundaries(uer,uerLocal);
476 realSerialArray uhrLocal; getLocalArrayWithGhostBoundaries(uhr,uhrLocal);
477 realSerialArray uermLocal; getLocalArrayWithGhostBoundaries(uerm,uermLocal);
478 realSerialArray uhrmLocal; getLocalArrayWithGhostBoundaries(uhrm,uhrmLocal);
480 realSerialArray & uerLocal=uer;
481 realSerialArray & uhrLocal=uhr;
482 realSerialArray & uermLocal=uerm;
483 realSerialArray & uhrmLocal=uhrm;
485 ue.reference ( uerLocal );
486 uh.reference ( uhrLocal );
487 ume.reference ( uermLocal );
488 umh.reference ( uhrmLocal );
497 Overture::abort(
"finish me for parallel");
499 ue.reference ( (
mgp==NULL ? getCGField(EField,current)[
grid] : fields[current+numberOfTimeLevels]) );
500 uh.reference ( (
mgp==NULL ? getCGField(HField,current)[
grid] : fields[current]) );
501 ume.reference ( (
mgp==NULL ? getCGField(EField,next)[
grid] : fields[next+numberOfTimeLevels]) );
502 umh.reference ( (
mgp==NULL ? getCGField(HField,next)[
grid] : fields[next]) );
517 Overture::abort(
"finish me for parallel");
519 erre.reference(errp[0]);
520 errh.reference(errp[1]);
526 Overture::abort(
"finish me for parallel");
528 erre.reference(cgerrp[0][
grid]);
529 errh.reference(cgerrp[1][grid]);
533 Ih1 = Range(uh.getBase(0),uh.getBound(0));
534 Ih2 = Range(uh.getBase(1),uh.getBound(1));
535 Ih3 = Range(uh.getBase(2),uh.getBound(2));
537 Ie1 = Range(ue.getBase(0),ue.getBound(0));
538 Ie2 = Range(ue.getBase(1),ue.getBound(1));
539 Ie3 = Range(ue.getBase(2),ue.getBound(2));
547 const realArray & center = mg.isAllVertexCentered() ? mg.corner() : mg.center();
553 Overture::abort(
"finish me for parallel");
556 if ( mg.numberOfDimensions()==2 )
558 getCenters(mg, UnstructuredMapping::Edge, xce);
559 xch.reference(center);
560 xce.reshape(Range(xce.getLength(0)),1,1,Range(xce.getLength(1)));
564 getCenters(mg, UnstructuredMapping::Face, xch);
565 getCenters(mg, UnstructuredMapping::Edge, xce);
566 xce.reshape(Range(xce.getLength(0)),1,1,Range(xce.getLength(1)));
567 xch.reshape(Range(xch.getLength(0)),1,1,Range(xch.getLength(1)));
575 xh.reference(
xch(Ih1,Ih2,Ih3,0,all));
576 yh.reference(
xch(Ih1,Ih2,Ih3,1,all));
577 if ( numberOfDimensions==3 )
578 zh.reference(
xch(Ih1,Ih2,Ih3,2,all));
580 xe.reference(
xce(Ie1,Ie2,Ie3,0,all));
581 ye.reference(
xce(Ie1,Ie2,Ie3,1,all));
582 if ( numberOfDimensions==3 )
583 ze.reference(
xce(Ie1,Ie2,Ie3,2,all));
594 uhDim0=uhDim1=uhDim2=ueDim0=ueDim1=ueDim2=xeDim0=xeDim1=xeDim2=xhDim0=xhDim1=xhDim2=-1;
630 uhp = uhl.Array_Descriptor.Array_View_Pointer3;
631 if ( umhl.getLength(0) )
633 umhp = umhl.Array_Descriptor.Array_View_Pointer3;
635 unhp = unhl.Array_Descriptor.Array_View_Pointer3;
636 uhDim0 = uhl.getRawDataSize(0);
637 uhDim1 = uhl.getRawDataSize(1);
638 uhDim2 = uhl.getRawDataSize(2);
639 uhDimFA = uhl.getRawDataSize(4);
654 errhp = errhl.Array_Descriptor.Array_View_Pointer3;
665 xhp = xchl.Array_Descriptor.Array_View_Pointer3;
666 xhDim0 = xchl.getRawDataSize(0);
667 xhDim1 = xchl.getRawDataSize(1);
668 xhDim2 = xchl.getRawDataSize(2);
670 ERROR :
XHP already defined!
672 #define XHP(i0,i1,i2,i3) xhp[i0+xhDim0*(i1+xhDim1*(i2+xhDim2*(i3)))]
676 ERROR :
X already defined!
678 #define X(i0,i1,i2,i3) xhp[i0+xhDim0*(i1+xhDim1*(i2+xhDim2*(i3)))]
682 uep = uel.Array_Descriptor.Array_View_Pointer3;
683 if ( umel.getLength(0) )
685 umep = umel.Array_Descriptor.Array_View_Pointer3;
687 unep = unel.Array_Descriptor.Array_View_Pointer3;
688 ueDim0 = uel.getRawDataSize(0);
689 ueDim1 = uel.getRawDataSize(1);
690 ueDim2 = uel.getRawDataSize(2);
691 ueDimFA = uel.getRawDataSize(4);
706 errep = errel.Array_Descriptor.Array_View_Pointer3;
715 #define MASK(i0,i1,i2) maskp[(i0)+(i1)*md1+(i2)*md2]
723 xep = xcel.Array_Descriptor.Array_View_Pointer3;
724 xeDim0 = xcel.getRawDataSize(0);
725 xeDim1 = xcel.getRawDataSize(1);
726 xeDim2 = xcel.getRawDataSize(2);
728 ERROR :
XEP already defined!
730 #define XEP(i0,i1,i2,i3) xep[i0+xeDim0*(i1+xeDim1*(i2+xeDim2*(i3)))]
751 #beginMacro EXTRACT_GFP_END(OPTION)
754 #If ( #OPTION == "IC" )
755 if( method==dsiMatVec )
758 Overture::abort(
"finish me for parallel");
762 bool vCent = mg.isAllVertexCentered();
763 int nDim = mg.numberOfDimensions();
764 realMappedGridFunction &uep = (
mgp==NULL ? getCGField(EField,current)[
grid] : fields[current+numberOfTimeLevels]);
765 realMappedGridFunction &uhp = (
mgp==NULL ? getCGField(HField,current)[
grid] : fields[current]);
766 realMappedGridFunction &uepm = (
mgp==NULL ? getCGField(EField,next)[
grid] : fields[next+numberOfTimeLevels]);
767 realMappedGridFunction &uhpm = (
mgp==NULL ? getCGField(HField,next)[
grid] : fields[next]);
769 if ( mg.numberOfDimensions()==2 )
771 for (
int e=0;
e<edgeAreaNormals.getLength(0);
e++ )
775 for (
int a=0;
a<mg.numberOfDimensions();
a++ )
777 uep(
e,0,0,0) += edgeAreaNormals(
e,0,0,
a)*
ue(
e,0,0,
a);
778 uepm(
e,0,0,0) += edgeAreaNormals(
e,0,0,
a)*
ume(
e,0,0,
a);
787 for (
int f=0;
f<faceAreaNormals.getLength(0);
f++ )
791 for (
int a=0;
a<mg.numberOfDimensions();
a++ )
793 uhp(
f,0,0,0) += faceAreaNormals(
f,0,0,
a)*
uh(
f,0,0,
a);
794 uhpm(
f,0,0,0) += faceAreaNormals(
f,0,0,
a)*
umh(
f,0,0,
a);
798 for (
int e=0;
e<edgeAreaNormals.getLength(0);
e++ )
802 for (
int a=0;
a<mg.numberOfDimensions();
a++ )
804 uep(
e,0,0,0) += edgeAreaNormals(
e,0,0,
a)*
ue(
e,0,0,
a);
805 uepm(
e,0,0,0) += edgeAreaNormals(
e,0,0,
a)*
ume(
e,0,0,
a);
812 if( method==nfdtd || method==sosup )
814 (
mgp==NULL ? getCGField(HField,current)[
grid] : fields[current]).periodicUpdate();
815 (
mgp==NULL ? getCGField(HField,prev)[
grid] : fields[prev]).periodicUpdate();
820 (
mgp==NULL ? getCGField(HField,current)[
grid] : fields[current]).periodicUpdate();
821 (
mgp==NULL ? getCGField(EField,current)[
grid] : fields[current+2]).periodicUpdate();
859 #undef EXTGFP_SENTINEL