Ejemplo n.º 1
0
	def verify(s, pt0, pt1):
		print('pt0 = %s, pt1 = %s' % (pt0, pt1))
		slidx = common.get_slice_index(pt0, pt1)
		shape = common.get_shape(pt0, pt1)

		for strf in s.strf_list:
			# non-spatial
			fset = SetFields(s.fdtd, strf, pt0, pt1)
			values = np.random.rand(*shape).astype(s.fdtd.dtype)
			fset.set_fields(values)

			fget = GetFields(s.fdtd, strf, pt0, pt1)
			fget.get_event().wait()
			copy = fget.get_fields(strf)

			assert np.linalg.norm(values - copy) == 0

		if pt0 != pt1:
			for strf in s.strf_list:
				# spatial
				fset = SetFields(s.fdtd, strf, pt0, pt1, np.ndarray)
				values = np.random.rand(*shape).astype(s.fdtd.dtype)
				fset.set_fields(values)

				fget = GetFields(s.fdtd, strf, pt0, pt1)
				fget.get_event().wait()
				copy = fget.get_fields(strf)

				assert np.linalg.norm(values - copy) == 0
    def verify(s, pt0, pt1):
        print('pt0 = %s, pt1 = %s' % (pt0, pt1))
        slidx = common.get_slice_index(pt0, pt1)
        shape = common.get_shape(pt0, pt1)

        for strf in s.strf_list:
            # non-spatial
            fset = SetFields(s.fdtd, strf, pt0, pt1)
            values = np.random.rand(*shape).astype(s.fdtd.dtype)
            fset.set_fields(values)

            fget = GetFields(s.fdtd, strf, pt0, pt1)
            fget.get_event().wait()
            copy = fget.get_fields(strf)

            assert np.linalg.norm(values - copy) == 0

        if pt0 != pt1:
            for strf in s.strf_list:
                # spatial
                fset = SetFields(s.fdtd, strf, pt0, pt1, np.ndarray)
                values = np.random.rand(*shape).astype(s.fdtd.dtype)
                fset.set_fields(values)

                fget = GetFields(s.fdtd, strf, pt0, pt1)
                fget.get_event().wait()
                copy = fget.get_fields(strf)

                assert np.linalg.norm(values - copy) == 0
Ejemplo n.º 3
0
    def __init__(s, fields, str_fs, pt0, pt1):
        s.emf = fields
        if type(str_fs) == str:
            s.str_fs = [str_fs]
        else:
            s.str_fs = str_fs

        s.str_fs_size = len(s.str_fs)
        s.slidx = common.get_slice_index(pt0, pt1)
        s.shape = common.get_shape(pt0, pt1)
        s.shape[0] *= s.str_fs_size
        s.fhost = np.zeros(s.shape, dtype=s.emf.dtype)
        s.split_fs = dict(zip(s.str_fs, np.array_split(s.fhost, s.str_fs_size)))
Ejemplo n.º 4
0
    def __init__(s, fields, str_fs, pt0, pt1):
        s.emf = fields
        if type(str_fs) == str:
            s.str_fs = [
                str_fs,
            ]
        else:
            s.str_fs = str_fs

        s.str_fs_size = len(s.str_fs)
        s.slidx = common.get_slice_index(pt0, pt1)
        s.shape = common.get_shape(pt0, pt1)
        s.shape[0] *= s.str_fs_size
        s.fhost = np.zeros(s.shape, dtype=s.emf.dtype)
        s.split_fs = dict(zip(s.str_fs, np.array_split(s.fhost,
                                                       s.str_fs_size)))