Ejemplo n.º 1
0
    def setUp(self):
        dim = len(self.SIZES)
        self.da = PETSc.DMStag().create(dim,
                                        dofs=self.DOFS,
                                        sizes=self.SIZES,
                                        boundary_types=self.BOUNDARY,
                                        stencil_type=self.STENCIL,
                                        stencil_width=self.SWIDTH,
                                        comm=self.COMM,
                                        proc_sizes=self.PROC_SIZES,
                                        ownership_ranges=self.OWNERSHIP_RANGES,
                                        setUp=True)

        self.directda = PETSc.DMStag().create(dim)
        self.directda.setStencilType(self.STENCIL)
        self.directda.setStencilWidth(self.SWIDTH)
        self.directda.setBoundaryTypes(self.BOUNDARY)
        self.directda.setDof(self.DOFS)
        self.directda.setGlobalSizes(self.SIZES)
        if self.PROC_SIZES is not None:
            self.directda.setProcSizes(self.PROC_SIZES)
        if self.OWNERSHIP_RANGES is not None:
            self.directda.setOwnershipRanges(self.OWNERSHIP_RANGES)
        self.directda.setUp()
Ejemplo n.º 2
0
                                def testCreate(self, kargs=kargs):
                                    kargs = dict(kargs)
                                    cda = PETSc.DMStag().create(
                                        kargs['dim'],
                                        dofs=kargs['dofs'],
                                        sizes=[
                                            8 * SCALE,
                                        ] * kargs['dim'],
                                        boundary_types=[
                                            kargs['boundary_type'],
                                        ] * kargs['dim'],
                                        stencil_type=kargs['stencil_type'],
                                        stencil_width=kargs['stencil_width'],
                                        setUp=True)

                                    dda = PETSc.DMStag().create(kargs['dim'])
                                    dda.setStencilType(kargs['stencil_type'])
                                    dda.setStencilWidth(kargs['stencil_width'])
                                    dda.setBoundaryTypes([
                                        kargs['boundary_type'],
                                    ] * kargs['dim'])
                                    dda.setDof(kargs['dofs'])
                                    dda.setGlobalSizes([
                                        8 * SCALE,
                                    ] * kargs['dim'])
                                    dda.setUp()

                                    cdim = cda.getDim()
                                    cdof = cda.getDof()
                                    cgsizes = cda.getGlobalSizes()
                                    clsizes = cda.getLocalSizes()
                                    cboundary = cda.getBoundaryTypes()
                                    cstencil_type = cda.getStencilType()
                                    cstencil_width = cda.getStencilWidth()
                                    centries_per_element = cda.getEntriesPerElement(
                                    )
                                    cstarts, csizes, cnextra = cda.getCorners()
                                    cisLastRank = cda.getIsLastRank()
                                    cisFirstRank = cda.getIsFirstRank()
                                    cownershipranges = cda.getOwnershipRanges()
                                    cprocsizes = cda.getProcSizes()

                                    ddim = dda.getDim()
                                    ddof = dda.getDof()
                                    dgsizes = dda.getGlobalSizes()
                                    dlsizes = dda.getLocalSizes()
                                    dboundary = dda.getBoundaryTypes()
                                    dstencil_type = dda.getStencilType()
                                    dstencil_width = dda.getStencilWidth()
                                    dentries_per_element = dda.getEntriesPerElement(
                                    )
                                    dstarts, dsizes, dnextra = dda.getCorners()
                                    disLastRank = dda.getIsLastRank()
                                    disFirstRank = dda.getIsFirstRank()
                                    downershipranges = dda.getOwnershipRanges()
                                    dprocsizes = dda.getProcSizes()

                                    self.assertEqual(cdim, kargs['dim'])
                                    self.assertEqual(cdof,
                                                     tuple(kargs['dofs']))
                                    self.assertEqual(
                                        cboundary,
                                        tuple([
                                            kargs['boundary_type'],
                                        ] * kargs['dim']))
                                    self.assertEqual(cstencil_type,
                                                     kargs['stencil_type'])
                                    self.assertEqual(cstencil_width,
                                                     kargs['stencil_width'])
                                    self.assertEqual(
                                        cgsizes,
                                        tuple([
                                            8 * SCALE,
                                        ] * kargs['dim']))

                                    self.assertEqual(cdim, ddim)
                                    self.assertEqual(cdof, ddof)
                                    self.assertEqual(cgsizes, dgsizes)
                                    self.assertEqual(clsizes, dlsizes)
                                    self.assertEqual(cboundary, dboundary)
                                    self.assertEqual(cstencil_type,
                                                     dstencil_type)
                                    self.assertEqual(cstencil_width,
                                                     dstencil_width)
                                    self.assertEqual(centries_per_element,
                                                     dentries_per_element)
                                    self.assertEqual(cstarts, dstarts)
                                    self.assertEqual(csizes, dsizes)
                                    self.assertEqual(cnextra, dnextra)
                                    self.assertEqual(cisLastRank, disLastRank)
                                    self.assertEqual(cisFirstRank,
                                                     disFirstRank)
                                    self.assertEqual(cprocsizes, dprocsizes)
                                    for co, do in zip(cownershipranges,
                                                      downershipranges):
                                        for i, j in zip(co, do):
                                            self.assertEqual(i, j)

                                    self.assertEqual(cdim + 1, len(cdof))
                                    self.assertEqual(cdim, len(cgsizes))
                                    self.assertEqual(cdim, len(clsizes))
                                    self.assertEqual(cdim, len(cboundary))
                                    self.assertEqual(cdim, len(cstarts))
                                    self.assertEqual(cdim, len(csizes))
                                    self.assertEqual(cdim, len(cnextra))
                                    self.assertEqual(cdim, len(cisLastRank))
                                    self.assertEqual(cdim, len(cisLastRank))
                                    if cdim == 1:
                                        self.assertEqual(
                                            centries_per_element,
                                            cdof[0] + cdof[1])
                                    if cdim == 2:
                                        self.assertEqual(
                                            centries_per_element,
                                            cdof[0] + 2 * cdof[1] + cdof[2])
                                    if cdim == 3:
                                        self.assertEqual(
                                            centries_per_element,
                                            cdof[0] + 3 * cdof[1] +
                                            3 * cdof[2] + cdof[3])
                                    for i in range(cdim):
                                        self.assertEqual(csizes[i], clsizes[i])
                                        if cisLastRank[i]:
                                            self.assertEqual(cnextra[i], 1)
                                        if (cnextra[i] == 1):
                                            self.assertTrue(cisLastRank[i])
                                        if (cisFirstRank[i]):
                                            self.assertEqual(cstarts[i], 0)
                                    self.assertEqual(len(cprocsizes),
                                                     len(cownershipranges))
                                    self.assertEqual(len(cprocsizes), cdim)
                                    for i, m in enumerate(cprocsizes):
                                        self.assertEqual(
                                            m, len(cownershipranges[i]))
                                    dda.destroy()
                                    cda.destroy()