-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Priority: Low
Problem
The magfie interface uses a module-level procedure pointer (magfie_ptr) to select field evaluation at runtime. This global state pattern:
procedure(magfie_iface), pointer :: magfie_ptr => null()
subroutine init_magfie(mode)
select case (mode)
case (VMEC)
magfie_ptr => magfie_vmec
case (BOOZER)
magfie_ptr => magfie_can_boozer
! ...
end select
end subroutineWhile functional, this could be modernized to use object-oriented dispatch.
Proposed Solution
Consider passing a field object directly to integrators instead of using global procedure pointer:
type(orbit_symplectic_t) :: orbit
class(magnetic_field_t), pointer :: field
call orbit%init(field) ! Field object passed directly
call orbit%timestep(z, dtau) ! Uses field internallyBenefits
- Eliminates global state
- Enables multiple simultaneous field configurations
- Better encapsulation
Caveats
- Significant refactoring effort
- Current approach works fine for typical use cases
- May impact performance if virtual dispatch adds overhead in hot loops
Related
- See
DOC/coordinates-and-fields.mdSection 4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request