1# -------------------------------------------------------------------- 2 3class SpaceType(object): 4 """The function space types.""" 5 POLYNOMIAL = S_(PETSCSPACEPOLYNOMIAL) 6 PTRIMMED = S_(PETSCSPACEPTRIMMED) 7 TENSOR = S_(PETSCSPACETENSOR) 8 SUM = S_(PETSCSPACESUM) 9 POINT = S_(PETSCSPACEPOINT) 10 SUBSPACE = S_(PETSCSPACESUBSPACE) 11 WXY = S_(PETSCSPACEWXY) 12 13# -------------------------------------------------------------------- 14 15 16cdef class Space(Object): 17 """Function space object.""" 18 Type = SpaceType 19 20 def __cinit__(self): 21 self.obj = <PetscObject*> &self.space 22 self.space = NULL 23 24 def setUp(self) -> None: 25 """Construct data structures for the `Space`. 26 27 Collective. 28 29 See Also 30 -------- 31 petsc.PetscSpaceSetUp 32 33 """ 34 CHKERR(PetscSpaceSetUp(self.space)) 35 36 def create(self, comm: Comm | None = None) -> Self: 37 """Create an empty `Space` object. 38 39 Collective. 40 41 The type can then be set with `setType`. 42 43 Parameters 44 ---------- 45 comm 46 MPI communicator, defaults to `Sys.getDefaultComm`. 47 48 See Also 49 -------- 50 petsc.PetscSpaceCreate 51 52 """ 53 cdef MPI_Comm ccomm = def_Comm(comm, PETSC_COMM_DEFAULT) 54 cdef PetscSpace newsp = NULL 55 CHKERR(PetscSpaceCreate(ccomm, &newsp)) 56 CHKERR(PetscCLEAR(self.obj)); self.space = newsp 57 return self 58 59 def destroy(self) -> Self: 60 """Destroy the `Space` object. 61 62 Collective. 63 64 See Also 65 -------- 66 petsc.PetscSpaceDestroy 67 68 """ 69 CHKERR(PetscSpaceDestroy(&self.space)) 70 return self 71 72 def view(self, Viewer viewer=None) -> None: 73 """View a `Space`. 74 75 Collective. 76 77 Parameters 78 ---------- 79 viewer 80 A `Viewer` to display the `Space`. 81 82 See Also 83 -------- 84 petsc.PetscSpaceView 85 86 """ 87 cdef PetscViewer vwr = NULL 88 if viewer is not None: vwr = viewer.vwr 89 CHKERR(PetscSpaceView(self.space, vwr)) 90 91 def setFromOptions(self) -> None: 92 """Set parameters in `Space` from the options database. 93 94 Collective. 95 96 See Also 97 -------- 98 petsc_options, petsc.PetscSpaceSetFromOptions 99 100 """ 101 CHKERR(PetscSpaceSetFromOptions(self.space)) 102 103 def getDimension(self) -> int: 104 """Return the number of basis vectors. 105 106 Not collective. 107 108 See Also 109 -------- 110 petsc.PetscSpaceGetDimension 111 112 """ 113 cdef PetscInt cdim = 0 114 CHKERR(PetscSpaceGetDimension(self.space, &cdim)) 115 return toInt(cdim) 116 117 def getDegree(self) -> tuple[int, int]: 118 """Return the polynomial degrees that characterize this space. 119 120 Not collective. 121 122 Returns 123 ------- 124 minDegree : int 125 The degree of the largest polynomial space contained in the space. 126 maxDegree : int 127 The degree of the smallest polynomial space containing the space. 128 129 See Also 130 -------- 131 setDegree, petsc.PetscSpaceGetDegree 132 133 """ 134 cdef PetscInt cdegmax = 0, cdegmin = 0 135 CHKERR(PetscSpaceGetDegree(self.space, &cdegmin, &cdegmax)) 136 return toInt(cdegmin), toInt(cdegmax) 137 138 def setDegree(self, degree: int | None, maxDegree: int | None) -> None: 139 """Set the degree of approximation for this space. 140 141 Logically collective. 142 143 One of ``degree`` and ``maxDegree`` can be `None`. 144 145 Parameters 146 ---------- 147 degree 148 The degree of the largest polynomial space contained in the space. 149 maxDegree 150 The degree of the largest polynomial space containing the space. 151 152 See Also 153 -------- 154 getDegree, petsc.PetscSpaceSetDegree 155 156 """ 157 cdef PetscInt cdegree = PETSC_DETERMINE 158 if degree is not None: cdegree = asInt(degree) 159 cdef PetscInt cmaxdegree = PETSC_DETERMINE 160 if maxDegree is not None: cmaxdegree = asInt(maxDegree) 161 CHKERR(PetscSpaceSetDegree(self.space, cdegree, cmaxdegree)) 162 163 def getNumVariables(self) -> int: 164 """Return the number of variables for this space. 165 166 Not collective. 167 168 See Also 169 -------- 170 setNumVariables, petsc.PetscSpaceGetNumVariables 171 172 """ 173 cdef PetscInt cnvars = 0 174 CHKERR(PetscSpaceGetNumVariables(self.space, &cnvars)) 175 return toInt(cnvars) 176 177 def setNumVariables(self, n: int) -> None: 178 """Set the number of variables for this space. 179 180 Logically collective. 181 182 Parameters 183 ---------- 184 n 185 The number of variables (``x``, ``y``, ``z`` etc.). 186 187 See Also 188 -------- 189 getNumVariables, petsc.PetscSpaceSetNumVariables 190 191 """ 192 cdef PetscInt cn = asInt(n) 193 CHKERR(PetscSpaceSetNumVariables(self.space, cn)) 194 195 def getNumComponents(self) -> int: 196 """Return the number of components for this space. 197 198 Not collective. 199 200 See Also 201 -------- 202 setNumComponents, petsc.PetscSpaceGetNumComponents 203 204 """ 205 cdef PetscInt cncomps = 0 206 CHKERR(PetscSpaceGetNumComponents(self.space, &cncomps)) 207 return toInt(cncomps) 208 209 def setNumComponents(self, nc: int) -> None: 210 """Set the number of components for this space. 211 212 Logically collective. 213 214 Parameters 215 ---------- 216 nc 217 The number of components. 218 219 See Also 220 -------- 221 getNumComponents, petsc.PetscSpaceSetNumComponents 222 223 """ 224 cdef PetscInt cnc = asInt(nc) 225 CHKERR(PetscSpaceSetNumComponents(self.space, cnc)) 226 227 def getType(self) -> str: 228 """Return the type of the space object. 229 230 Not collective. 231 232 See Also 233 -------- 234 setType, petsc.PetscSpaceGetType 235 236 """ 237 cdef PetscSpaceType cval = NULL 238 CHKERR(PetscSpaceGetType(self.space, &cval)) 239 return bytes2str(cval) 240 241 def setType(self, space_type: Type | str) -> Self: 242 """Build a particular type of space. 243 244 Collective. 245 246 Parameters 247 ---------- 248 space_type 249 The kind of space. 250 251 See Also 252 -------- 253 getType, petsc.PetscSpaceSetType 254 255 """ 256 cdef PetscSpaceType cval = NULL 257 space_type = str2bytes(space_type, &cval) 258 CHKERR(PetscSpaceSetType(self.space, cval)) 259 return self 260 261 def getSumConcatenate(self) -> bool: 262 """Return the concatenate flag for this space. 263 264 Not collective. 265 266 A concatenated sum space will have the number of components equal to 267 the sum of the number of components of all subspaces. 268 A non-concatenated, or direct sum space will have the same number of 269 components as its subspaces. 270 271 See Also 272 -------- 273 setSumConcatenate, petsc.PetscSpaceSumGetConcatenate 274 275 """ 276 cdef PetscBool concatenate = PETSC_FALSE 277 CHKERR(PetscSpaceSumGetConcatenate(self.space, &concatenate)) 278 return toBool(concatenate) 279 280 def setSumConcatenate(self, concatenate: bool) -> None: 281 """Set the concatenate flag for this space. 282 283 Logically collective. 284 285 A concatenated sum space will have the number of components equal to 286 the sum of the number of components of all subspaces. 287 A non-concatenated, or direct sum space will have the same number of 288 components as its subspaces. 289 290 Parameters 291 ---------- 292 concatenate 293 `True` if subspaces are concatenated components, 294 `False` if direct summands. 295 296 See Also 297 -------- 298 getSumConcatenate, petsc.PetscSpaceSumSetConcatenate 299 300 """ 301 cdef PetscBool cconcatenate = asBool(concatenate) 302 CHKERR(PetscSpaceSumSetConcatenate(self.space, cconcatenate)) 303 304 def getSumNumSubspaces(self) -> int: 305 """Return the number of spaces in the sum. 306 307 Not collective. 308 309 See Also 310 -------- 311 setSumNumSubspaces, petsc.PetscSpaceSumGetNumSubspaces 312 313 """ 314 cdef PetscInt numSumSpaces = 0 315 CHKERR(PetscSpaceSumGetNumSubspaces(self.space, &numSumSpaces)) 316 return toInt(numSumSpaces) 317 318 def getSumSubspace(self, s: int) -> Space: 319 """Return a space in the sum. 320 321 Not collective. 322 323 Parameters 324 ---------- 325 s 326 The space number. 327 328 See Also 329 -------- 330 setSumSubspace, petsc.PetscSpaceSumGetSubspace 331 332 """ 333 cdef Space subsp = Space() 334 cdef PetscInt cs = asInt(s) 335 CHKERR(PetscSpaceSumGetSubspace(self.space, cs, &subsp.space)) 336 return subsp 337 338 def setSumSubspace(self, s: int, Space subsp) -> None: 339 """Set a space in the sum. 340 341 Logically collective. 342 343 Parameters 344 ---------- 345 s 346 The space number. 347 subsp 348 The number of spaces. 349 350 See Also 351 -------- 352 getSumSubspace, petsc.PetscSpaceSumSetSubspace 353 354 """ 355 cdef PetscInt cs = asInt(s) 356 CHKERR(PetscSpaceSumSetSubspace(self.space, cs, subsp.space)) 357 358 def setSumNumSubspaces(self, numSumSpaces: int) -> None: 359 """Set the number of spaces in the sum. 360 361 Logically collective. 362 363 Parameters 364 ---------- 365 numSumSpaces 366 The number of spaces. 367 368 See Also 369 -------- 370 getSumNumSubspaces, petsc.PetscSpaceSumSetNumSubspaces 371 372 """ 373 cdef PetscInt cnumSumSpaces = asInt(numSumSpaces) 374 CHKERR(PetscSpaceSumSetNumSubspaces(self.space, cnumSumSpaces)) 375 376 def getTensorNumSubspaces(self) -> int: 377 """Return the number of spaces in the tensor product. 378 379 Not collective. 380 381 See Also 382 -------- 383 setTensorNumSubspaces, petsc.PetscSpaceTensorGetNumSubspaces 384 385 """ 386 cdef PetscInt cnumTensSpaces = 0 387 CHKERR(PetscSpaceTensorGetNumSubspaces(self.space, &cnumTensSpaces)) 388 return toInt(cnumTensSpaces) 389 390 def setTensorSubspace(self, s: int, Space subsp) -> None: 391 """Set a space in the tensor product. 392 393 Logically collective. 394 395 Parameters 396 ---------- 397 s 398 The space number. 399 subsp 400 The number of spaces. 401 402 See Also 403 -------- 404 getTensorSubspace, petsc.PetscSpaceTensorSetSubspace 405 406 """ 407 cdef PetscInt cs = asInt(s) 408 CHKERR(PetscSpaceTensorSetSubspace(self.space, cs, subsp.space)) 409 410 def getTensorSubspace(self, s: int) -> Space: 411 """Return a space in the tensor product. 412 413 Not collective. 414 415 Parameters 416 ---------- 417 s 418 The space number. 419 420 See Also 421 -------- 422 setTensorSubspace, petsc.PetscSpaceTensorGetSubspace 423 424 """ 425 cdef PetscInt cs = asInt(s) 426 cdef Space subsp = Space() 427 CHKERR(PetscSpaceTensorGetSubspace(self.space, cs, &subsp.space)) 428 return subsp 429 430 def setTensorNumSubspaces(self, numTensSpaces: int) -> None: 431 """Set the number of spaces in the tensor product. 432 433 Logically collective. 434 435 Parameters 436 ---------- 437 numTensSpaces 438 The number of spaces. 439 440 See Also 441 -------- 442 getTensorNumSubspaces, petsc.PetscSpaceTensorSetNumSubspaces 443 444 """ 445 cdef PetscInt cnumTensSpaces = asInt(numTensSpaces) 446 CHKERR(PetscSpaceTensorSetNumSubspaces(self.space, cnumTensSpaces)) 447 448 def getPolynomialTensor(self) -> bool: 449 """Return whether a function space is a space of tensor polynomials. 450 451 Not collective. 452 453 Return `True` if a function space is a space of tensor polynomials 454 (the space is spanned by polynomials whose degree in each variable is 455 bounded by the given order), as opposed to polynomials (the space is 456 spanned by polynomials whose total degree—summing over all variables 457 is bounded by the given order). 458 459 See Also 460 -------- 461 setPolynomialTensor, petsc.PetscSpacePolynomialGetTensor 462 463 """ 464 cdef PetscBool ctensor = PETSC_FALSE 465 CHKERR(PetscSpacePolynomialGetTensor(self.space, &ctensor)) 466 return toBool(ctensor) 467 468 def setPolynomialTensor(self, tensor: bool) -> None: 469 """Set whether a function space is a space of tensor polynomials. 470 471 Logically collective. 472 473 Set to `True` for a function space which is a space of tensor 474 polynomials (the space is spanned by polynomials whose degree in each 475 variable is bounded by the given order), as opposed to polynomials 476 (the space is spanned by polynomials whose total degree—summing over 477 all variables is bounded by the given order). 478 479 Parameters 480 ---------- 481 tensor 482 `True` for a tensor polynomial space, `False` for a polynomial 483 space. 484 485 See Also 486 -------- 487 getPolynomialTensor, petsc.PetscSpacePolynomialSetTensor 488 489 """ 490 cdef PetscBool ctensor = asBool(tensor) 491 CHKERR(PetscSpacePolynomialSetTensor(self.space, ctensor)) 492 493 def setPointPoints(self, Quad quad) -> None: 494 """Set the evaluation points for the space to be based on a quad. 495 496 Logically collective. 497 498 Sets the evaluation points for the space to coincide with the points 499 of a quadrature rule. 500 501 Parameters 502 ---------- 503 quad 504 The `Quad` defining the points. 505 506 See Also 507 -------- 508 getPointPoints, petsc.PetscSpacePointSetPoints 509 510 """ 511 CHKERR(PetscSpacePointSetPoints(self.space, quad.quad)) 512 513 def getPointPoints(self) -> Quad: 514 """Return the evaluation points for the space as the points of a quad. 515 516 Logically collective. 517 518 See Also 519 -------- 520 setPointPoints, petsc.PetscSpacePointGetPoints 521 522 """ 523 cdef Quad quad = Quad() 524 CHKERR(PetscSpacePointGetPoints(self.space, &quad.quad)) 525 CHKERR(PetscINCREF(quad.obj)) 526 return quad 527 528 def setPTrimmedFormDegree(self, formDegree: int) -> None: 529 """Set the form degree of the trimmed polynomials. 530 531 Logically collective. 532 533 Parameters 534 ---------- 535 formDegree 536 The form degree. 537 538 See Also 539 -------- 540 getPTrimmedFormDegree, petsc.PetscSpacePTrimmedSetFormDegree 541 542 """ 543 cdef PetscInt cformDegree = asInt(formDegree) 544 CHKERR(PetscSpacePTrimmedSetFormDegree(self.space, cformDegree)) 545 546 def getPTrimmedFormDegree(self) -> int: 547 """Return the form degree of the trimmed polynomials. 548 549 Not collective. 550 551 See Also 552 -------- 553 setPTrimmedFormDegree, petsc.PetscSpacePTrimmedGetFormDegree 554 555 """ 556 cdef PetscInt cformDegree = 0 557 CHKERR(PetscSpacePTrimmedGetFormDegree(self.space, &cformDegree)) 558 return toInt(cformDegree) 559 560# -------------------------------------------------------------------- 561 562 563class DualSpaceType(object): 564 """The dual space types.""" 565 LAGRANGE = S_(PETSCDUALSPACELAGRANGE) 566 SIMPLE = S_(PETSCDUALSPACESIMPLE) 567 REFINED = S_(PETSCDUALSPACEREFINED) 568 BDM = S_(PETSCDUALSPACEBDM) 569 570# -------------------------------------------------------------------- 571 572 573cdef class DualSpace(Object): 574 """Dual space to a linear space.""" 575 576 Type = DualSpaceType 577 578 def __cinit__(self): 579 self.obj = <PetscObject*> &self.dualspace 580 self.dualspace = NULL 581 582 def setUp(self) -> None: 583 """Construct a basis for a `DualSpace`. 584 585 Collective. 586 587 See Also 588 -------- 589 petsc.PetscDualSpaceSetUp 590 591 """ 592 CHKERR(PetscDualSpaceSetUp(self.dualspace)) 593 594 def create(self, comm: Comm | None = None) -> Self: 595 """Create an empty `DualSpace` object. 596 597 Collective. 598 599 The type can then be set with `setType`. 600 601 Parameters 602 ---------- 603 comm 604 MPI communicator, defaults to `Sys.getDefaultComm`. 605 606 See Also 607 -------- 608 petsc.PetscDualSpaceCreate 609 610 """ 611 cdef MPI_Comm ccomm = def_Comm(comm, PETSC_COMM_DEFAULT) 612 cdef PetscDualSpace newdsp = NULL 613 CHKERR(PetscDualSpaceCreate(ccomm, &newdsp)) 614 CHKERR(PetscCLEAR(self.obj)); self.dualspace = newdsp 615 return self 616 617 def view(self, Viewer viewer=None) -> None: 618 """View a `DualSpace`. 619 620 Collective. 621 622 Parameters 623 ---------- 624 viewer 625 A `Viewer` to display the `DualSpace`. 626 627 See Also 628 -------- 629 petsc.PetscDualSpaceView 630 631 """ 632 cdef PetscViewer vwr = NULL 633 if viewer is not None: vwr = viewer.vwr 634 CHKERR(PetscDualSpaceView(self.dualspace, vwr)) 635 636 def destroy(self) -> Self: 637 """Destroy the `DualSpace` object. 638 639 Collective. 640 641 See Also 642 -------- 643 petsc.PetscDualSpaceDestroy 644 645 """ 646 CHKERR(PetscDualSpaceDestroy(&self.dualspace)) 647 return self 648 649 def duplicate(self) -> DualSpace: 650 """Create a duplicate `DualSpace` object that is not set up. 651 652 Collective. 653 654 See Also 655 -------- 656 petsc.PetscDualSpaceDuplicate 657 658 """ 659 cdef DualSpace spNew = DualSpace() 660 CHKERR(PetscDualSpaceDuplicate(self.dualspace, &spNew.dualspace)) 661 662 def getDM(self) -> DM: 663 """Return the `DM` representing the reference cell of a `DualSpace`. 664 665 Not collective. 666 667 See Also 668 -------- 669 setDM, petsc.PetscDualSpaceGetDM 670 671 """ 672 cdef PetscDM newdm = NULL 673 CHKERR(PetscDualSpaceGetDM(self.dualspace, &newdm)) 674 cdef DM dm = subtype_DM(newdm)() 675 dm.dm = newdm 676 CHKERR(PetscINCREF(dm.obj)) 677 return dm 678 679 def setDM(self, DM dm) -> None: 680 """Set the `DM` representing the reference cell. 681 682 Not collective. 683 684 Parameters 685 ---------- 686 dm 687 The reference cell. 688 689 See Also 690 -------- 691 getDM, petsc.PetscDualSpaceSetDM 692 693 """ 694 CHKERR(PetscDualSpaceSetDM(self.dualspace, dm.dm)) 695 696 def getDimension(self) -> int: 697 """Return the dimension of the dual space. 698 699 Not collective. 700 701 The dimension of the dual space, i.e. the number of basis functionals. 702 703 See Also 704 -------- 705 petsc.PetscDualSpaceGetDimension 706 707 """ 708 cdef PetscInt cdim = 0 709 CHKERR(PetscDualSpaceGetDimension(self.dualspace, &cdim)) 710 return toInt(cdim) 711 712 def getNumComponents(self) -> int: 713 """Return the number of components for this space. 714 715 Not collective. 716 717 See Also 718 -------- 719 setNumComponents, petsc.PetscDualSpaceGetNumComponents 720 721 """ 722 cdef PetscInt cncomps = 0 723 CHKERR(PetscDualSpaceGetNumComponents(self.dualspace, &cncomps)) 724 return toInt(cncomps) 725 726 def setNumComponents(self, nc: int) -> None: 727 """Set the number of components for this space. 728 729 Logically collective. 730 731 Parameters 732 ---------- 733 nc 734 The number of components 735 736 See Also 737 -------- 738 getNumComponents, petsc.PetscDualSpaceSetNumComponents 739 740 """ 741 cdef PetscInt cnc = asInt(nc) 742 CHKERR(PetscDualSpaceSetNumComponents(self.dualspace, cnc)) 743 744 def getType(self) -> str: 745 """Return the type of the dual space object. 746 747 Not collective. 748 749 See Also 750 -------- 751 setType, petsc.PetscDualSpaceGetType 752 753 """ 754 cdef PetscDualSpaceType cval = NULL 755 CHKERR(PetscDualSpaceGetType(self.dualspace, &cval)) 756 return bytes2str(cval) 757 758 def setType(self, dualspace_type: Type | str) -> Self: 759 """Build a particular type of dual space. 760 761 Collective. 762 763 Parameters 764 ---------- 765 dualspace_type 766 The kind of space. 767 768 See Also 769 -------- 770 getType, petsc.PetscDualSpaceSetType 771 772 """ 773 cdef PetscDualSpaceType cval = NULL 774 dualspace_type = str2bytes(dualspace_type, &cval) 775 CHKERR(PetscDualSpaceSetType(self.dualspace, cval)) 776 return self 777 778 def getOrder(self) -> int: 779 """Return the order of the dual space. 780 781 Not collective. 782 783 See Also 784 -------- 785 setOrder, petsc.PetscDualSpaceGetOrder 786 787 """ 788 cdef PetscInt corder = 0 789 CHKERR(PetscDualSpaceGetOrder(self.dualspace, &corder)) 790 return toInt(corder) 791 792 def setOrder(self, order: int) -> None: 793 """Set the order of the dual space. 794 795 Not collective. 796 797 Parameters 798 ---------- 799 order 800 The order. 801 802 See Also 803 -------- 804 getOrder, petsc.PetscDualSpaceSetOrder 805 806 """ 807 cdef PetscInt corder = asInt(order) 808 CHKERR(PetscDualSpaceSetOrder(self.dualspace, corder)) 809 810 def getNumDof(self) -> ArrayInt: 811 """Return the number of degrees of freedom for each spatial dimension. 812 813 Not collective. 814 815 See Also 816 -------- 817 petsc.PetscDualSpaceGetNumDof 818 819 """ 820 cdef const PetscInt *cndof = NULL 821 cdef PetscInt cdim = 0 822 CHKERR(PetscDualSpaceGetDimension(self.dualspace, &cdim)) 823 CHKERR(PetscDualSpaceGetNumDof(self.dualspace, &cndof)) 824 return array_i(cdim + 1, cndof) 825 826 def getFunctional(self, i: int) -> Quad: 827 """Return the i-th basis functional in the dual space. 828 829 Not collective. 830 831 Parameters 832 ---------- 833 i 834 The basis number. 835 836 See Also 837 -------- 838 petsc.PetscDualSpaceGetFunctional 839 840 """ 841 cdef PetscInt ci = asInt(i) 842 cdef Quad functional = Quad() 843 CHKERR(PetscDualSpaceGetFunctional(self.dualspace, ci, &functional.quad)) 844 CHKERR(PetscINCREF(functional.obj)) 845 return functional 846 847 def getInteriorDimension(self) -> int: 848 """Return the interior dimension of the dual space. 849 850 Not collective. 851 852 The interior dimension of the dual space, i.e. the number of basis 853 functionals assigned to the interior of the reference domain. 854 855 See Also 856 -------- 857 petsc.PetscDualSpaceGetInteriorDimension 858 859 """ 860 cdef PetscInt cintdim = 0 861 CHKERR(PetscDualSpaceGetInteriorDimension(self.dualspace, &cintdim)) 862 return toInt(cintdim) 863 864 def getLagrangeContinuity(self) -> bool: 865 """Return whether the element is continuous. 866 867 Not collective. 868 869 See Also 870 -------- 871 setLagrangeContinuity, petsc.PetscDualSpaceLagrangeGetContinuity 872 873 """ 874 cdef PetscBool ccontinuous = PETSC_FALSE 875 CHKERR(PetscDualSpaceLagrangeGetContinuity(self.dualspace, &ccontinuous)) 876 return toBool(ccontinuous) 877 878 def setLagrangeContinuity(self, continuous: bool) -> None: 879 """Indicate whether the element is continuous. 880 881 Not collective. 882 883 Parameters 884 ---------- 885 continuous 886 The flag for element continuity. 887 888 See Also 889 -------- 890 getLagrangeContinuity, petsc.PetscDualSpaceLagrangeSetContinuity 891 892 """ 893 cdef PetscBool ccontinuous = asBool(continuous) 894 CHKERR(PetscDualSpaceLagrangeSetContinuity(self.dualspace, ccontinuous)) 895 896 def getLagrangeTensor(self) -> bool: 897 """Return the tensor nature of the dual space. 898 899 Not collective. 900 901 See Also 902 -------- 903 setLagrangeTensor, petsc.PetscDualSpaceLagrangeGetTensor 904 905 """ 906 cdef PetscBool ctensor = PETSC_FALSE 907 CHKERR(PetscDualSpaceLagrangeGetTensor(self.dualspace, &ctensor)) 908 return toBool(ctensor) 909 910 def setLagrangeTensor(self, tensor: bool) -> None: 911 """Set the tensor nature of the dual space. 912 913 Not collective. 914 915 Parameters 916 ---------- 917 tensor 918 Whether the dual space has tensor layout (vs. simplicial). 919 920 See Also 921 -------- 922 getLagrangeTensor, petsc.PetscDualSpaceLagrangeSetTensor 923 924 """ 925 cdef PetscBool ctensor = asBool(tensor) 926 CHKERR(PetscDualSpaceLagrangeSetTensor(self.dualspace, ctensor)) 927 928 def getLagrangeTrimmed(self) -> bool: 929 """Return the trimmed nature of the dual space. 930 931 Not collective. 932 933 See Also 934 -------- 935 setLagrangeTrimmed, petsc.PetscDualSpaceLagrangeGetTrimmed 936 937 """ 938 cdef PetscBool ctrimmed = PETSC_FALSE 939 CHKERR(PetscDualSpaceLagrangeGetTrimmed(self.dualspace, &ctrimmed)) 940 return toBool(ctrimmed) 941 942 def setLagrangeTrimmed(self, trimmed: bool) -> None: 943 """Set the trimmed nature of the dual space. 944 945 Not collective. 946 947 Parameters 948 ---------- 949 trimmed 950 Whether the dual space represents to dual basis of a trimmed 951 polynomial space (e.g. Raviart-Thomas and higher order / 952 other form degree variants). 953 954 See Also 955 -------- 956 getLagrangeTrimmed, petsc.PetscDualSpaceLagrangeSetTrimmed 957 958 """ 959 cdef PetscBool ctrimmed = asBool(trimmed) 960 CHKERR(PetscDualSpaceLagrangeSetTrimmed(self.dualspace, ctrimmed)) 961 962 def setSimpleDimension(self, dim: int) -> None: 963 """Set the number of functionals in the dual space basis. 964 965 Logically collective. 966 967 Parameters 968 ---------- 969 dim 970 The basis dimension. 971 972 See Also 973 -------- 974 petsc.PetscDualSpaceSimpleSetDimension 975 976 """ 977 cdef PetscInt cdim = asInt(dim) 978 CHKERR(PetscDualSpaceSimpleSetDimension(self.dualspace, cdim)) 979 980 def setSimpleFunctional(self, func: int, Quad functional) -> None: 981 """Set the given basis element for this dual space. 982 983 Not collective. 984 985 Parameters 986 ---------- 987 func 988 The basis index. 989 functional 990 The basis functional. 991 992 See Also 993 -------- 994 petsc.PetscDualSpaceSimpleSetFunctional 995 996 """ 997 cdef PetscInt cfunc = asInt(func) 998 CHKERR(PetscDualSpaceSimpleSetFunctional(self.dualspace, cfunc, functional.quad)) 999 1000del SpaceType 1001del DualSpaceType 1002