def resolve(self, subproblemcontext, existingStepper): # Return a new AdaptiveDriver object (not a Basic one) # appropriate for the given subproblem. If the # existingStepper is still appropriate, return it instead. from ooflib.engine import twostep from ooflib.SWIG.engine import steperrorscaling if subproblemcontext.second_order_fields(): from ooflib.engine import ss22 if (isinstance(existingStepper, AdaptiveDriver) and isinstance(existingStepper.stepper, twostep.TwoStep) and isinstance(existingStepper.stepper.singlestep, ss22.SS22)): return existingStepper singlestep = ss22.SS22(theta1=0.5, theta2=0.5) else: # no second order fields from ooflib.engine import euler if (isinstance(existingStepper, AdaptiveDriver) and isinstance(existingStepper.stepper, twostep.TwoStep) and isinstance(existingStepper.stepper.singlestep, euler.CrankNicolson)): return existingStepper singlestep = euler.CrankNicolson() return AdaptiveDriver( stepper=twostep.TwoStep(singlestep), tolerance=self.tolerance, errorscaling=steperrorscaling.AbsoluteErrorScaling(), initialstep=0.0, minstep=self.minstep)
'Adaptive', StepDriver, AdaptiveDriver, ordering=1, params=[ parameter.FloatParameter('tolerance', 1.e-4, tip="Maximum permissable error."), parameter.FloatParameter("initialstep", 0.1, tip="Initial step size."), parameter.FloatParameter('minstep', 1.e-5, tip="Minimum time step size."), parameter.RegisteredParameter( 'errorscaling', steperrorscaling.StepErrorScaling, value=steperrorscaling.AbsoluteErrorScaling(), tip="How to compute the error for each degree of freedom."), parameter.RegisteredParameter('stepper', QCTimeStepper, tip="Time stepping method.") ], tip="Take variable sized timesteps.", discussion=xmlmenudump.loadFile( 'DISCUSSIONS/engine/reg/adaptivedriver.xml')) ############ class UniformDriver(StepDriver): def __init__(self, stepper, stepsize): self.stepsize = stepsize