Esempio n. 1
0
    def __init__(self, kRef, meshname, doms, J_is='BlockedDiscrete'):

        if isinstance(doms, list):
            domains = Domains(doms)
        elif isinstance(doms, Domains):
            domains = doms
        else:
            raise TypeError(
                'configuration needs to be a list or a Domains class')

        self._collected = False

        self._assembled = False
        self._A_assembled = False
        self._X_assembled = False
        self._J_assembled = False
        self._iJ_assembled = False

        self._J_is = J_is

        self.domains = domains
        self.N = len(domains)

        print('==Importing Grid/Mesh', end=' ', flush=True)
        self.grid = grid = bem.import_grid(meshname)
        print('done.', flush=True)

        N = self.N
        self.opA = bem.BlockedOperator(N, N)
        self.opX = bem.BlockedOperator(N, N)
        self.opI = bem.BlockedOperator(N, N)

        if np.abs(kRef) <= 0.0:
            kernel = 'lapl'
            self.kRef = 0.0
            dtype = np.float
        else:
            kernel = 'helm'
            self.kRef = kRef  #float(kRef)
            dtype = np.complex
        self.kernel = kernel

        if dtype is None:
            if kernel == 'helm':
                dtype = np.complex
            else:
                dtype = np.float
        self.dtype = dtype

        if kernel == 'helm':
            funEFIE = lambda trial, ran, test, k: bem.operators.boundary.maxwell.electric_field(
                trial, ran, test, k)
            funMFIE = lambda trial, ran, test, k: bem.operators.boundary.maxwell.magnetic_field(
                trial, ran, test, k)

        self._funEFIE = funEFIE
        self._funMFIE = funMFIE

        self._funI = bem.operators.boundary.sparse.maxwell_identity
Esempio n. 2
0
    conf = sanitize_config(init_offset=truefalse,
                           tag=i+1,
                           kRef=kRef,
                           rad=rads[i],
                           phys=phys[i],
                           center=centers[i],
    )
    dgen = generate_concentric_dict(conf)
    cmds = write_params_geo(conf)
    call(cmds)

    dgens.append(dgen)

doms = merge_msh_bubbles(dgens)

myd = Domains(doms)
myd.write2dot('graph.dot')
call(['dot', '-Teps', 'graph.dot'], stdout=open('graph.eps', 'wb'))

dd = myd

print(N)

##################################

meshname = "./geo/all.msh"


mtf = MultiTrace(kRef, meshname, dd)

At, X, J, iJ = mtf.tolinop()
Esempio n. 3
0
    def __init__(self,
                 kRef,
                 meshname,
                 doms,
                 J_is='BlockedDiscrete',
                 X_is='BlockedDiscrete',
                 use_slp=True):

        if isinstance(doms, list):
            domains = Domains(doms)
        elif isinstance(doms, Domains):
            domains = doms
        else:
            raise TypeError(
                'configuration needs to be a list or a Domains class')

        self._collected = False

        self._assembled = False
        self._A_assembled = False
        self._X_assembled = False
        self._J_assembled = False
        self._iJ_assembled = False

        if not J_is in ['BlockedDiscrete', 'CSC', 'Blocked']:
            warnings.warn('{0} is not supported. Default used {1}'.format(
                J_is, 'BlockedDiscrete'))
            J_is = 'BlockedDiscrete'
        self._J_is = J_is

        if not X_is in ['BlockedDiscrete', 'Blocked']:
            warnings.warn('{0} is not supported. Default used {1}'.format(
                J_is, 'BlockedDiscrete'))
            X_is = 'BlockedDiscrete'
        self._X_is = X_is

        self.use_slp = use_slp

        print('==J_is: {0} , X_is: {1} , use_slp={2}'.format(
            J_is, X_is, use_slp))

        self.domains = domains
        self.N = len(domains)

        print('==Importing Grid/Mesh {}'.format(meshname), end=' ', flush=True)
        self.grid = grid = bem.import_grid(meshname)
        print('done.', flush=True)

        N = self.N
        self.opA = bem.BlockedOperator(N, N)
        self.opX = bem.BlockedOperator(N, N)
        self.opI = bem.BlockedOperator(N, N)

        if np.abs(kRef) == 0.0:
            kernel = 'lapl'
            self.kRef = 0.0
            dtype = np.float
        else:
            kernel = 'helm'
            self.kRef = kRef  #float(kRef)
            dtype = np.complex
        self.kernel = kernel

        if not dtype is None:
            if kernel == 'helm':
                if dtype != np.complex:
                    warnings.warn('Helmholtz is complex. dtype={}'.format(
                        np.complex))
                    dtype = np.complex
            else:
                if dtype != np.float:
                    warnings.warn('Unsupported dtype. Converted to {}'.format(
                        np.float))
                    dtype = np.float
        self.dtype = dtype

        if kernel == 'helm':
            funK = lambda trial, ran, test, k: bem.operators.boundary.helmholtz.double_layer(
                trial, ran, test, k)
            funV = lambda trial, ran, test, k: bem.operators.boundary.helmholtz.single_layer(
                trial, ran, test, k)
            funQ = lambda trial, ran, test, k: bem.operators.boundary.helmholtz.adjoint_double_layer(
                trial, ran, test, k)
            funW = lambda trial, ran, test, k: bem.operators.boundary.helmholtz.hypersingular(
                trial, ran, test, k, use_slp=use_slp)
        else:
            funK = lambda trial, ran, test, k: bem.operators.boundary.laplace.double_layer(
                trial, ran, test)
            funV = lambda trial, ran, test, k: bem.operators.boundary.laplace.single_layer(
                trial, ran, test)
            funQ = lambda trial, ran, test, k: bem.operators.boundary.laplace.adjoint_double_layer(
                trial, ran, test)
            funW = lambda trial, ran, test, k: bem.operators.boundary.laplace.hypersingular(
                trial, ran, test, use_slp=use_slp)

        self._funK, self._funV = funK, funV
        self._funW, self._funQ = funW, funQ

        self._funI = bem.operators.boundary.sparse.identity

        self.spaces = [(('test_d', 'trial_d'), ('test_n', 'trial_n'))
                       for d in domains]