Blitz logo

Blitz Support :

From: Martin Davis (martindavis_at_[hidden])
Date: 2004-07-26 00:14:01


Hi Andy,

I'm currently writing FDTD code using the Blitz++ library.

The data structures I set up are (for the base FDTD):
typedef blitz::Array<double, 3> field_type; // 3D Vector Field
typedef blitz::Array<blitz::TinyVector<double, 3>,3>
 scalar_field_type; // 3D Scalar Field

        field_type E;
        field_type H;
        field_type J;
        field_type M;
        scalar_field_type dtmud; // = dt / (MU_0 * dz)
      scalar_field_type dtepd; // = dt / (EP_0 * dz)
(This is assuming dx, dy and dz are of the same length)

I am trying to use the stencil technique (refer to chapter 4 of the Blitz++ Users Guide), so that I specify the update equation similar to:

BZ_DECLARE_STENCIL4(update_h_3D_stencil,H,E,M,dtmudz)
        H += -(curl_halfstep(E) + *M) * dtmudz(0,0,0);
BZ_END_STENCIL_WITH_SHAPE(blitz::shape(-1,-1,-1),blitz::shape(+1,+1,+1))

and call the following in each iteration

blitz::applyStencil(update_h_3D_stencil(), H, E, M, dtmudz);
blitz::applyStencil(update_e_3D_stencil(), E, H, J, dtepdz);

As you can see, this avoids explicit loops in the code and makes it easier to see the update equation.

However, I am still in the process of figuring out how to correctly (or rather cleanly and efficiently) handle the half-step grid and boundary conditions using the stencil method. Any suggestions would be appreciated.

Anyway, this should get you started - let me know how you go.

Regards,

Martin

P.S. Your segmentation faults may be caused by not initializing the array size before use (?)

--- "Andy Maloney" <schrodiscat_at_[hidden]> wrote:
I am writing a code that utilizes a finite difference time domain scheme for
solving 6 partial differential equations. The PDEs are Maxwell's equations.
Right now, I am trying to set up a grid in 3 dimensions (i,j,k) that has
assigned to each (i,j,k) 6 values. They are respectively the x-component of
the electric(E) and magnetic(M) field, the y-component of the E and M field,
and the z-component of the E and M field. Now the equations that I need to
model are coupled in the sense that to solve say the electric field in the
x-direction (ex), I need it to look at the equations for the magnetic field
in the y and z directions (hy, hz respectively). However, hy and hz also
call other components of the E and M field. I do not know how to set up the
Arrays in Blitz so that ex can look at hy and hz to find their values, loop
over all (i,j,k) values, dump the information to a file, and then loop all
over again for another time step. If any one can help in regards to setting
up the Arrays, I would greatly appreciate it. I have code written, however,
I cannot get it to work without getting a segmentation fault. If you have
anything to help, please post a reply. Thanks.

Andy_

_________________________________________________________________
Get fast, reliable Internet access with MSN 9 Dial-up now 2 months FREE!
http://join.msn.click-url.com/go/onm00200361ave/direct/01/

_______________________________________________
Blitz-support mailing list
Blitz-support_at_[hidden]
http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support

_____________________________________________________________
Free, simple, fast, memorable email
Become you_at_[hidden] at http://www.emailaccount.com/