def __init__(self, params, physics, mesh): super().__init__(params, physics, mesh) self.stepper = stepper_tools.set_stepper(params, self.state_coeffs) stepper_tools.set_time_stepping_approach(self.stepper, params) stepper_tools.set_source_treatment(physics) # Precompute helpers self.precompute_matrix_helpers() if self.limiters: for limiter in self.limiters: limiter.precompute_helpers(self) physics.conv_flux_fcn.alloc_helpers( np.zeros([ mesh.num_interior_faces, self.int_face_helpers.quad_wts.shape[0], physics.NUM_STATE_VARS ])) if physics.diff_flux_fcn: physics.diff_flux_fcn.alloc_helpers( np.zeros([ mesh.num_interior_faces, self.int_face_helpers.quad_wts.shape[0], physics.NUM_STATE_VARS ])) # Construct the necessary functions dependent upon required physics solver_tools.set_function_definitions(self, params) # Initial condition if params["RestartFile"] is None: self.init_state_from_fcn()
def set_split_schemes(self, explicit, implicit, U): ''' Specifies the explicit and implicit schemes to be used in the operator splitting technique Inputs: ------- explicit: name of chosen explicit scheme from params implicit: name of chosen implicit (ODE) solver from params U: solution state vector used to initialize solver [num_elems, nb, ns] Outputs: -------- explicit: stepper object instantiation for explicit scheme implicit: stepper object instantiation for ODE solver ''' param = {"TimeStepper": explicit} # call set_stepper from stepper tools for the explicit scheme self.explicit = stepper_tools.set_stepper(param, U) if SourceStepperType[implicit] == SourceStepperType.BDF1: self.implicit = source_stepper.SourceSolvers.BDF1(U) elif SourceStepperType[implicit] == SourceStepperType.Trapezoidal: self.implicit = source_stepper.SourceSolvers.Trapezoidal(U) elif SourceStepperType[implicit] == SourceStepperType.LSODA: self.implicit = source_stepper.SourceSolvers.LSODA(U) else: raise NotImplementedError("Time scheme not supported")
def test_set_stepper_SSPRK3(): ''' Checks setter function for stepper SSPRK3 ''' time_scheme = "SSPRK3" params = {'TimeStepper': time_scheme} stepper = stepper_tools.set_stepper(params, None) expected = stepper_defs.SSPRK3(None) assert stepper == expected
def test_set_stepper_LSRK4(): ''' Checks setter function for stepper LSRK4 ''' time_scheme = "LSRK4" params = {'TimeStepper': time_scheme} stepper = stepper_tools.set_stepper(params, None) expected = stepper_defs.LSRK4(None) assert stepper == expected
def test_set_stepper_not_FE(): ''' Checks setter function for stepper not FE ''' time_scheme = "RK4" params = {'TimeStepper': time_scheme} stepper = stepper_tools.set_stepper(params, None) expected = stepper_defs.FE(None) assert stepper != expected
def test_set_stepper_Strang(): ''' Checks setter function for stepper Strang ''' time_scheme = "Strang" params = { 'TimeStepper': time_scheme, 'OperatorSplittingExplicit': 'SSPRK3', 'OperatorSplittingImplicit': 'BDF1', } stepper = stepper_tools.set_stepper(params, None) expected = stepper_defs.Strang(None) assert stepper == expected