@@ -71,20 +71,6 @@ def curl_H(H: Tensorlike) -> Tensorlike:
71
71
return curl
72
72
73
73
74
- class GridList (list ):
75
- """ Special list that removes item from grid when deleted from list """
76
-
77
- def __init__ (self , grid ):
78
- super ().__init__ ([])
79
- self .grid = grid
80
-
81
- def __delitem__ (self , i ):
82
- item = self [i ]
83
- super ().__delitem__ (i )
84
- if hasattr (item , "name" ) and hasattr (self .grid , item .name ):
85
- delattr (self .grid , item .name )
86
-
87
-
88
74
## FDTD Grid Class
89
75
class Grid :
90
76
""" The FDTD Grid
@@ -163,16 +149,16 @@ def __init__(
163
149
self .time_steps_passed = 0
164
150
165
151
# dictionary containing the sources:
166
- self .sources = GridList ( self )
152
+ self .sources = []
167
153
168
154
# dictionary containing the boundaries
169
- self .boundaries = GridList ( self )
155
+ self .boundaries = []
170
156
171
157
# dictionary containing the detectors
172
- self .detectors = GridList ( self )
158
+ self .detectors = []
173
159
174
160
# dictionary containing the objects in the grid
175
- self .objects = GridList ( self )
161
+ self .objects = []
176
162
177
163
def _handle_distance (self , distance : Number ) -> int :
178
164
""" transform a distance to an integer number of gridpoints """
@@ -375,28 +361,6 @@ def __setitem__(self, key, attr):
375
361
z = self ._handle_single_key (z ),
376
362
)
377
363
378
- def __delattr__ (self , name ):
379
- attr = getattr (self , name )
380
- super ().__delattr__ (name )
381
- if not isinstance (attr , (Object , Source , Detector , Boundary )):
382
- return
383
- try :
384
- del self .objects [self .objects .index (attr )]
385
- except ValueError :
386
- pass
387
- try :
388
- del self .sources [self .sources .index (attr )]
389
- except ValueError :
390
- pass
391
- try :
392
- del self .detectors [self .detectors .index (attr )]
393
- except ValueError :
394
- pass
395
- try :
396
- del self .boundaries [self .boundaries .index (attr )]
397
- except ValueError :
398
- pass
399
-
400
364
def __repr__ (self ):
401
365
return (
402
366
f"{ self .__class__ .__name__ } (shape=({ self .Nx } ,{ self .Ny } ,{ self .Nz } ), "
@@ -426,11 +390,3 @@ def __str__(self):
426
390
for obj in self .objects :
427
391
s += str (obj )
428
392
return s
429
-
430
-
431
- ## Imports (placed here to prevent circular imports)
432
- # relative
433
- from .objects import Object
434
- from .sources import Source
435
- from .detectors import Detector
436
- from .boundaries import Boundary
0 commit comments