module immersed_factory_m !! Creates immersed objects use error_handling_m, only: handle_error use status_codes_m, only: PARALLAX_ERR_IMMERSED use equilibrium_m, only : equilibrium_t use mesh_cart_m, only : mesh_cart_t use immersed_m, only : immersed_t use immersed_rho_m, only : immersed_rho_t use immersed_vessel_m, only : immersed_vessel_t use immersed_trace_m, only : immersed_trace_t implicit none enum, bind(C) !! Enum defining the different types of immersed that can be created !! by the factory enumerator :: IMMERSED_RHO, IMMERSED_VESSEL, IMMERSED_TRACE end enum public :: create_immersed public :: get_immersed_identifier contains subroutine create_immersed(res, identifier, equi, mesh, filename) class(immersed_t), allocatable, intent(out) :: res !! Created immersed type integer, intent(in) :: identifier !! Integer specifying the immersed to create (see header) class(equilibrium_t), intent(inout) :: equi !! Equilibrium type(mesh_cart_t), intent(in) :: mesh !! Mesh character(len=*), intent(in), optional :: filename !! Filename, where to read parameters from, !! if not provided default parameters will be used select case(identifier) case(IMMERSED_RHO) allocate( immersed_rho_t :: res ) case(IMMERSED_VESSEL) allocate( immersed_vessel_t :: res ) case(IMMERSED_TRACE) allocate( immersed_trace_t :: res ) case default call handle_error("immersed ID not recognised", & PARALLAX_ERR_IMMERSED, __LINE__, __FILE__) end select if(present(filename)) then call res%init(equi, mesh, filename) else call res%init(equi, mesh) endif end subroutine function get_immersed_identifier(immersed_as_string) result(res) !! Returns equilibrium identifier (see header) if prescribed as string character(len=*), intent(in) :: immersed_as_string !! Immersed type specified as string integer :: res select case(immersed_as_string) case('IMMERSED_RHO') res = IMMERSED_RHO case('IMMERSED_VESSEL') res = IMMERSED_VESSEL case('IMMERSED_TRACE') res = IMMERSED_TRACE case default call handle_error('Immersed not available:' // immersed_as_string, & PARALLAX_ERR_IMMERSED, __LINE__, __FILE__) end select end function end module