Beispiel #1
0
 def build_clustergeometry(self, idx: List[List[int]],
                           basis: 'pbem3d.BasisFunction') \
         -> 'misc.ClusterGeometry':
     csubs = [pylist_to_ptr(sub, c_uint) for sub in idx]
     cidx = pylist_to_ptr(csubs, c_uint)
     obj = libbem3d.build_bem3d_clustergeometry(self, cidx, basis.value)
     return try_wrap(obj, misc.ClusterGeometry)
Beispiel #2
0
 def fill(self, x: VectorListType, y: VectorListType, nx: VectorListType,
          ny: VectorListType, v: 'mat.AMatrix', kernel):
     cx = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in x], real)
     cy = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in y], real)
     cnx = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in nx], real)
     cny = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in ny], real)
     ckernel = libbem3d.CFuncKernelFunc3d(kernel)
     libbem3d.fill_bem3d(self, cx, cy, cnx, cny, v, ckernel)
Beispiel #3
0
def finish_gmres(addeval, matrix, b: 'vec.AVector', x: 'vec.AVector',
                 rhat: 'vec.AVector', q: 'vec.AVector', kk: List[int],
                 qr: 'mat.AMatrix', tau: 'vec.AVector'):
    caddeval = libkrylov.CFuncAddevalT(addeval)
    cmatrix = matrix.as_voidp()
    ckk = pylist_to_ptr(kk, c_uint)
    libkrylov.finish_gmres(caddeval, cmatrix, b, x, rhat, q, ckk, qr, tau)
Beispiel #4
0
    def fill_integral(self, integral_type: 'pbem3d.IntegralType',
                      idx: List[int], z: VectorListType, v: 'mat.AMatrix',
                      kernel):
        if integral_type == pbem3d.IntegralType.RowC:
            func = libbem3d.fill_row_c_bem3d
        elif integral_type == pbem3d.IntegralType.ColC:
            func = libbem3d.fill_col_c_bem3d
        elif integral_type == pbem3d.IntegralType.RowL:
            func = libbem3d.fill_row_l_bem3d
        elif integral_type == pbem3d.IntegralType.ColL:
            func = libbem3d.fill_col_l_bem3d

        cidx = pylist_to_ptr(idx, c_uint)
        cz = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in z], real)
        ckernel = libbem3d.CFuncKernelFunc3d(kernel)
        func(cidx, cz, self, v, ckernel)
Beispiel #5
0
 def fill_wave(self, x: VectorListType, y: VectorListType,
               nx: VectorListType, ny: VectorListType, v: 'mat.AMatrix',
               direc: float, kernel):
     cx = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in x], real)
     cy = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in y], real)
     cnx = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in nx], real)
     cny = pylist_to_ptr([pylist_to_ptr(list(v), real) for v in ny], real)
     cdirec = get_address(direc)
     ckernel = libbem3d.CFuncKernelWaveFunc3d(kernel)
     libbem3d.fill_wave_bem3d(self, cx, cy, cnx, cny, v, cdirec, ckernel)
Beispiel #6
0
def finish_pgmres(addeval, matrix, prcd, pdata, b: 'vec.AVector',
                  x: 'vec.AVector', rhat: 'vec.AVector', q: 'vec.AVector',
                  kk: List[int], qr: 'mat.AMatrix', tau: 'vec.AVector'):
    caddeval = libkrylov.CFuncAddevalT(addeval)
    cmatrix = matrix.as_voidp()
    cprcd = libkrylov.CFuncPrcdT(prcd)
    cpdata = cast(pdata, c_void_p)
    ckk = pylist_to_ptr(kk, c_uint)
    libkrylov.finish_pgmres(caddeval, cmatrix, cprcd, cpdata, b, x, rhat, q,
                            ckk, qr, tau)
Beispiel #7
0
 def copy(self,
          target: 'AMatrix',
          trans: bool = False,
          *,
          pivots: List[int] = None):
     if pivots:
         cpivots = pylist_to_ptr(pivots, c_uint)
         libamatrix.copy_colpiv_amatrix(trans, self, cpivots, target)
     else:
         libamatrix.copy_amatrix(trans, self, target)
Beispiel #8
0
    def assemble_lagrange(self, ltype: 'pbem3d.LagrangeType', idx: List[int],
                          px: 'vec.AVector', py: 'vec.AVector',
                          pz: 'vec.AVector', v: 'mat.AMatrix'):
        if ltype == pbem3d.LagrangeType.Const:
            func = libbem3d.assemble_bem3d_lagrange_c_amatrix
        elif ltype == pbem3d.LagrangeType.Linear:
            func = libbem3d.assemble_bem3d_lagrange_l_amatrix
        elif ltype == pbem3d.LagrangeType.DnConst:
            func = libbem3d.assemble_bem3d_dn_lagrange_c_amatrix
        elif ltype == pbem3d.LagrangeType.DnLinear:
            func = libbem3d.assemble_bem3d_dn_lagrange_l_amatrix

        cidx = pylist_to_ptr(idx, c_uint)
        func(cidx, px, py, pz, self, v)
Beispiel #9
0
    def assemble_quad(self, quadtype: 'pbem3d.QuadratureType', ridx: List[int],
                      cidx: List[int], ntrans: bool, n: 'mat.AMatrix', kernel):
        if quadtype == pbem3d.QuadratureType.CCNear:
            func = libbem3d.assemble_cc_near_bem3d
        elif quadtype == pbem3d.QuadratureType.CCFar:
            func = libbem3d.assemble_cc_far_bem3d
        elif quadtype == pbem3d.QuadratureType.CLNear:
            func = libbem3d.assemble_cl_near_bem3d
        elif quadtype == pbem3d.QuadratureType.CLFar:
            func = libbem3d.assemble_cl_far_bem3d
        elif quadtype == pbem3d.QuadratureType.LCNear:
            func = libbem3d.assemble_lc_near_bem3d
        elif quadtype == pbem3d.QuadratureType.LCFar:
            func = libbem3d.assemble_lc_far_bem3d
        elif quadtype == pbem3d.QuadratureType.LLNear:
            func = libbem3d.assemble_ll_near_bem3d
        elif quadtype == pbem3d.QuadratureType.LLFar:
            func = libbem3d.assemble_ll_far_bem3d

        cridx = pylist_to_ptr(ridx, c_uint)
        ccidx = pylist_to_ptr(cidx, c_uint)
        ckernel = libbem3d.CFuncKernelFunc3d(kernel)
        func(cridx, ccidx, self, ntrans, n, ckernel)
Beispiel #10
0
 def build_pca(cls, cf: 'misc.ClusterGeometry', size: int, idx: List[int],
               clf: int) -> 'Cluster':
     cidx = pylist_to_ptr(idx, c_uint)
     return cls(libcluster.build_pca_cluster(cf, size, cidx, clf))
Beispiel #11
0
 def build_regular(cls, cf: 'misc.ClusterGeometry', size: int,
                   idx: List[int], clf: int, direction: int) -> 'Cluster':
     cidx = pylist_to_ptr(idx, c_uint)
     obj = libcluster.build_regular_cluster(cf, size, cidx, clf, direction)
     return cls(obj)
Beispiel #12
0
 def new(cls, size: int, idx: List[int], sons: int, dim: int) -> 'Cluster':
     cidx = pylist_to_ptr(idx, c_uint)
     return cls(libcluster.new_cluster(size, cidx, sons, dim))
Beispiel #13
0
 def from_list(cls, elems: List[float], rows: int, cols: int) -> 'AMatrix':
     assert len(elems) == rows * cols
     celems = pylist_to_ptr(elems, field)
     obj = libamatrix.new_pointer_amatrix(celems, rows, cols)
     return cls(obj, refs=[celems])
Beispiel #14
0
 def eval_lagrange_wave(self, x: Tuple[float, float, float],
                        px: 'vec.AVector', py: 'vec.AVector',
                        pz: 'vec.AVector', direc: float, v: 'mat.AMatrix'):
     cx = pylist_to_ptr(list(x), real)
     func = libbem3d.assemble_bem3d_lagrange_wave_amatrix
     func(cx, px, py, pz, direc, self, v)
Beispiel #15
0
 def eval_lagrange(self, x: Tuple[float, float, float], px: 'vec.AVector',
                   py: 'vec.AVector', pz: 'vec.AVector', v: 'mat.AMatrix'):
     cx = pylist_to_ptr(list(x), real)
     libbem3d.assemble_bem3d_lagrange_amatrix(cx, px, py, pz, self, v)
Beispiel #16
0
 def build(cls, cf: 'misc.ClusterGeometry', size: int, idx: List[int],
           clf: int, mode: 'misc.ClusterMode') -> 'Cluster':
     cidx = pylist_to_ptr(idx, c_uint)
     return cls(libcluster.build_cluster(cf, size, cidx, clf, mode.value))
Beispiel #17
0
 def find_direction(self, l: int, alpha: float, d: List[float]) -> int:
     cd = pylist_to_ptr(d, real)
     return libdcluster.finddirection_leveldir(self, l, alpha, cd)
Beispiel #18
0
 def scale(self, a: List[float], b: List[float]) -> None:
     ca = pylist_to_ptr(a, real)
     cb = pylist_to_ptr(b, real)
     libsurface3d.scale_surface3d(self, ca, cb)
Beispiel #19
0
 def build_linear_clustergeometry(self, idx: List[List[int]]) \
         -> 'misc.ClusterGeometry':
     csubs = [pylist_to_ptr(sub, c_uint) for sub in idx]
     cidx = pylist_to_ptr(csubs, c_uint)
     obj = libbem3d.build_bem3d_linear_clustergeometry(self, cidx)
     return try_wrap(obj, misc.ClusterGeometry)
Beispiel #20
0
 def translate(self, t: List[float]) -> None:
     ct = pylist_to_ptr(t, real)
     libsurface3d.translate_surface3d(self, ct)
Beispiel #21
0
 def from_list(cls, elems: List[float], *, dim: int = -1) -> 'AVector':
     cdim = dim if dim != -1 else len(elems)
     celems = pylist_to_ptr(elems, field)
     obj = libavector.new_pointer_avector(celems, cdim)
     return cls(obj, refs=[celems])
Beispiel #22
0
 def update_point_bbox(self, size: int, idx: List[int]) -> None:
     cidx = pylist_to_ptr(idx, c_uint)
     libclustergeometry.update_point_bbox_clustergeometry(self, size, cidx)