2024-02-14 12:33:40 +01:00
|
|
|
import typing as typ
|
|
|
|
|
|
|
|
import bpy
|
|
|
|
import pydantic as pyd
|
|
|
|
import tidy3d as td
|
|
|
|
|
|
|
|
from .. import base
|
|
|
|
from ... import contracts
|
|
|
|
|
2024-02-19 14:28:35 +01:00
|
|
|
class MaxwellBoundFaceBLSocket(base.BLSocket):
|
|
|
|
socket_type = contracts.SocketType.MaxwellBoundFace
|
|
|
|
bl_label = "Maxwell Bound Face"
|
2024-02-14 12:33:40 +01:00
|
|
|
|
2024-02-26 16:16:06 +01:00
|
|
|
####################
|
|
|
|
# - Properties
|
|
|
|
####################
|
|
|
|
default_choice: bpy.props.EnumProperty(
|
|
|
|
name="Bound Face",
|
|
|
|
description="A choice of default boundary face",
|
|
|
|
items=[
|
|
|
|
("PML", "PML", "Perfectly matched layer"),
|
|
|
|
("PEC", "PEC", "Perfect electrical conductor"),
|
|
|
|
("PMC", "PMC", "Perfect magnetic conductor"),
|
|
|
|
("PERIODIC", "Periodic", "Infinitely periodic layer"),
|
|
|
|
],
|
|
|
|
default="PML",
|
|
|
|
update=(lambda self, context: self.trigger_updates()),
|
|
|
|
)
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - UI
|
|
|
|
####################
|
|
|
|
def draw_value(self, col: bpy.types.UILayout) -> None:
|
|
|
|
col_row = col.row(align=True)
|
|
|
|
col_row.prop(self, "default_choice", text="")
|
2024-02-14 12:33:40 +01:00
|
|
|
|
|
|
|
####################
|
|
|
|
# - Computation of Default Value
|
|
|
|
####################
|
|
|
|
@property
|
|
|
|
def default_value(self) -> td.BoundarySpec:
|
2024-02-26 16:16:06 +01:00
|
|
|
return {
|
|
|
|
"PML": td.PML(num_layers=12),
|
|
|
|
"PEC": td.PECBoundary(),
|
|
|
|
"PMC": td.PMCBoundary(),
|
|
|
|
"PERIODIC": td.Periodic(),
|
|
|
|
}[self.default_choice]
|
2024-02-14 12:33:40 +01:00
|
|
|
|
|
|
|
@default_value.setter
|
|
|
|
def default_value(self, value: typ.Any) -> None:
|
|
|
|
return None
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Socket Configuration
|
|
|
|
####################
|
2024-02-19 14:28:35 +01:00
|
|
|
class MaxwellBoundFaceSocketDef(pyd.BaseModel):
|
|
|
|
socket_type: contracts.SocketType = contracts.SocketType.MaxwellBoundFace
|
2024-02-14 12:33:40 +01:00
|
|
|
label: str
|
|
|
|
|
2024-02-26 16:16:06 +01:00
|
|
|
default_choice: str = "PML"
|
|
|
|
|
2024-02-19 14:28:35 +01:00
|
|
|
def init(self, bl_socket: MaxwellBoundFaceBLSocket) -> None:
|
2024-02-26 16:16:06 +01:00
|
|
|
bl_socket.default_choice = self.default_choice
|
2024-02-14 12:33:40 +01:00
|
|
|
|
|
|
|
####################
|
|
|
|
# - Blender Registration
|
|
|
|
####################
|
|
|
|
BL_REGISTER = [
|
2024-02-19 14:28:35 +01:00
|
|
|
MaxwellBoundFaceBLSocket,
|
2024-02-14 12:33:40 +01:00
|
|
|
]
|