def from_dict(dict_):
    positivity_preserving_limiter_class_str = dict_[CLASS_KEY]
    if positivity_preserving_limiter_class_str == ZHANGSHU_STR:
        return ZhangShuLimiter()
    elif positivity_preserving_limiter_class_str is None:
        return None
    else:
        raise errors.InvalidParameter(CLASS_KEY,
                                      positivity_preserving_limiter_class_str)
Exemple #2
0
def from_dict(dict_, app_, riemann_solver=None):
    fluctuation_solver_class = dict_[CLASS_KEY]
    if fluctuation_solver_class == NUMERICALFLUX_STR:
        return NumericalFlux(app_, riemann_solver)
    elif fluctuation_solver_class == ROE_STR:
        return Roe(app_)
    elif fluctuation_solver_class == EXACTLINEAR_STR:
        return ExactLinear(app_)
    else:
        raise errors.InvalidParameter(CLASS_KEY, fluctuation_solver_class)
def from_dogpack_params(params):
    basis_type = params["basis_type"]
    num_dims = params["num_dims"]
    mesh_type = params["mesh_type"]
    space_order = params["space_order"]
    if basis_type == "space-legendre":
        if num_dims == 1:
            return basis.LegendreBasis1D(space_order)
        elif num_dims == 2:
            if mesh_type == "cartesian":
                return basis.LegendreBasis2DCartesian(space_order)
            elif mesh_type == "unstructured":
                return basis.ModalBasis2DTriangle(space_order)
            else:
                raise errors.InvalidParameter("mesh_type", mesh_type)
        else:
            raise errors.InvalidParameter("num_dims", num_dims)
    else:
        raise errors.InvalidParameter("basis_type", basis_type)
Exemple #4
0
def from_dict(dict_, problem):
    shock_capturing_limiter_class_str = dict_[CLASS_KEY]
    if shock_capturing_limiter_class_str == BOUNDS_STR:
        xi_points = dict_[BOUNDS_XI_POINTS_STR]
        alpha = dict_[BOUNDS_ALPHA_VALUE_STR]
        variable_transformation = problem.bounds_limiter_variable_transformation
        return BoundsLimiter(xi_points, alpha, variable_transformation)
    elif shock_capturing_limiter_class_str == MOMENT_STR:
        return MomentLimiter()
    elif shock_capturing_limiter_class_str is None:
        return None
    else:
        raise errors.InvalidParameter(CLASS_KEY, shock_capturing_limiter_class_str)
Exemple #5
0
def from_dict(dict_, boundary_function=None):
    boundary_condition_class = dict_[CLASS_KEY]
    if boundary_condition_class == PERIODIC_STR:
        return Periodic()
    elif boundary_condition_class == DIRICHLET_STR:
        return Dirichlet(boundary_function)
    elif boundary_condition_class == NEUMANN_STR:
        return Neumann(boundary_function)
    elif boundary_condition_class == EXTRAPOLATION_STR:
        return Extrapolation()
    elif boundary_condition_class == INTERIOR_STR:
        return Interior()
    else:
        errors.InvalidParameter(CLASS_KEY, boundary_condition_class)
Exemple #6
0
def get_dogpack_auto_cfl_max(order):
    # Note only appropriate in 1D
    max_cfl = 0.0
    if order == 1:
        max_cfl = 0.92
    elif order == 2:
        max_cfl = 0.33
    elif order == 3:
        max_cfl = 0.2
    elif order == 4:
        max_cfl = 0.45
    elif order == 5:
        max_cfl = 0.2
    else:
        raise errors.InvalidParameter("order", order)
    return max_cfl
Exemple #7
0
def get_dogpack_auto_cfl_target(order):
    # Note only appropriate in 1D
    target_cfl = 0.0
    if order == 1:
        target_cfl = 0.90
    elif order == 2:
        target_cfl = 0.31
    elif order == 3:
        target_cfl = 0.18
    elif order == 4:
        target_cfl = 0.43
    elif order == 5:
        target_cfl = 0.18
    else:
        raise errors.InvalidParameter("order", order)
    return target_cfl
def from_dict(dict_):
    class_value = dict_[flux_functions.CLASS_KEY]
    if class_value == X_FUNCTION_STR:
        return XFunction.from_dict(dict_)
    elif class_value == POLYNOMIAL_STR:
        return Polynomial.from_dict(dict_)
    elif class_value == ZERO_STR:
        return Zero()
    elif class_value == IDENTITY_STR:
        return Identity()
    elif class_value == SINE_STR:
        return Sine.from_dict(dict_)
    elif class_value == COSINE_STR:
        return Cosine.from_dict(dict_)
    elif class_value == EXPONENTIAL_STR:
        return Exponential.from_dict(dict_)
    elif class_value == RIEMANNPROBLEM_STR:
        return RiemannProblem.from_dict(dict_)
    elif class_value == FROZEN_T_STR:
        return FrozenT.from_dict(dict_)
    else:
        raise errors.InvalidParameter(flux_functions.CLASS_KEY, class_value)
Exemple #9
0
def dogpack_timestepper_from_dict(dict_):
    # 1st Order - Forward Euler
    # 2nd Order - TVDRK2
    # 3rd Order - TVDRK3
    # 4th Order - SSP RK4 10 stages
    # 5th Order - 8 Stages
    order = dict_["order"]
    num_frames = dict_["num_frames"]
    is_verbose = dict_["is_verbose"]
    target_cfl = dict_["target_cfl"]
    if target_cfl == "auto":
        target_cfl = get_dogpack_auto_cfl_target(order)

    max_cfl = dict_["max_cfl"]
    if max_cfl == "auto":
        max_cfl = get_dogpack_auto_cfl_max(order)

    dogpack_timestep_function = get_dogpack_timestep_function(
        target_cfl, max_cfl)
    if order == 1:
        return explicit_runge_kutta.ForwardEuler(num_frames,
                                                 dogpack_timestep_function,
                                                 is_verbose)
    elif order == 2:
        return explicit_runge_kutta.TVDRK2(num_frames,
                                           dogpack_timestep_function,
                                           is_verbose)
    elif order == 3:
        return explicit_runge_kutta.TVDRK3(num_frames,
                                           dogpack_timestep_function,
                                           is_verbose)
    elif order == 4:
        return low_storage_explicit_runge_kutta.SSP4(
            num_frames, dogpack_timestep_function, is_verbose)
    else:
        raise errors.InvalidParameter("order", order)