A wrapped C++ constructor for a form with a specified scalar type. Args: dtype: Scalar type of the required form class. Returns: Wrapped C++ form class of the requested type. Note: This function is for advanced usage, typically when writing custom kerne
(
dtype: npt.DTypeLike,
)
| 573 | |
| 574 | |
| 575 | def form_cpp_creator( |
| 576 | dtype: npt.DTypeLike, |
| 577 | ) -> ( |
| 578 | _cpp.fem.Form_float32 |
| 579 | | _cpp.fem.Form_float64 |
| 580 | | _cpp.fem.Form_complex64 |
| 581 | | _cpp.fem.Form_complex128 |
| 582 | ): |
| 583 | """A wrapped C++ constructor for a form with a specified scalar type. |
| 584 | |
| 585 | Args: |
| 586 | dtype: Scalar type of the required form class. |
| 587 | |
| 588 | Returns: |
| 589 | Wrapped C++ form class of the requested type. |
| 590 | |
| 591 | Note: |
| 592 | This function is for advanced usage, typically when writing |
| 593 | custom kernels using Numba or C. |
| 594 | """ |
| 595 | if np.issubdtype(dtype, np.float32): |
| 596 | return _cpp.fem.create_form_float32 |
| 597 | elif np.issubdtype(dtype, np.float64): |
| 598 | return _cpp.fem.create_form_float64 |
| 599 | elif np.issubdtype(dtype, np.complex64): |
| 600 | return _cpp.fem.create_form_complex64 |
| 601 | elif np.issubdtype(dtype, np.complex128): |
| 602 | return _cpp.fem.create_form_complex128 |
| 603 | else: |
| 604 | raise NotImplementedError(f"Type {dtype} not supported.") |
| 605 | |
| 606 | |
| 607 | def create_form( |