Beispiel #1
0
 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)
Beispiel #2
0
 def resolve(self, subproblemcontext, existingStepper):
     # Return a new UniformDriver object (not a Basic one)
     # appropriate for the given subproblem.  If the
     # existingStepper is still appropriate, return it instead.
     if subproblemcontext.second_order_fields():
         from ooflib.engine import ss22
         if (isinstance(existingStepper, UniformDriver)
                 and isinstance(existingStepper.stepper, ss22.SS22)):
             return existingStepper
         return UniformDriver(stepper=ss22.SS22(theta1=0.5, theta2=0.5),
                              stepsize=self.stepsize)
     else:
         from ooflib.engine import euler
         if (isinstance(existingStepper, UniformDriver) and isinstance(
                 existingStepper.stepper, euler.CrankNicolson)):
             return existingStepper
         return UniformDriver(stepper=euler.CrankNicolson(),
                              stepsize=self.stepsize)