예제 #1
0
    def setVelocity(self, v=None):
        """
      set a new velocity. v is define on the entire domain but only the surface values are used.

      :param v: velocity field. If None zero is used.
      :type v: vector
      """
        self.__dt = None
        self.__v = escript.Vector(0., escript.Solution(self.getDomain()))
        if not v is None:
            xi = self.getDomain().getX()[self.getDomain().getDim() - 1]
            v = (xi - util.inf(xi)) / (util.sup(xi) - util.inf(xi)) * v
            for d in range(self.__DIM):
                self.__PDE_W.setValue(r=v[d])
                self.__v[d] = self.__PDE_W.getSolution()
예제 #2
0
  def __init__(self,phi,reinit_max=10,reinitialize_after=1,smooth=2., useReducedOrder=False):
    """
    Sets up the level set method.

    :param phi: the initial level set function
    :param reinit_max: maximum number of reinitialization steps
    :param reinitialize_after: ``phi`` is reinitialized every ``reinit_after`` step
    :param smooth: smoothing width
    """
    self.__domain = phi.getDomain()
    self.__phi = phi


    self.__transport=lpe.SingleTransportPDE(self.__domain)
    if useReducedOrder: self.__transport.setReducedOrderOn()
    self.__transport.setValue(M=1.0)
    self.__transport.setInitialSolution(phi)


    self.__reinitPDE = lpe.LinearPDE(self.__domain, numEquations=1)
    self.__reinitPDE.getSolverOptions().setSolverMethod(lpe.SolverOptions.LUMPING)
    if useReducedOrder: self.__reinitPDE.setReducedOrderOn()
    self.__reinitPDE.setValue(D=1.0)

    # revise:
    self.__reinit_max = reinit_max
    self.__reinit_after = reinitialize_after
    self.__h = es.inf(self.__domain.getSize())
    self.__smooth = smooth
    self.__n_step=0
예제 #3
0
  def __init__(self,phi,reinit_max=10,reinitialize_after=1,smooth=2., useReducedOrder=False):
    """
    Sets up the level set method.

    :param phi: the initial level set function
    :param reinit_max: maximum number of reinitialization steps
    :param reinitialize_after: ``phi`` is reinitialized every ``reinit_after`` step
    :param smooth: smoothing width
    """
    self.__domain = phi.getDomain()
    self.__phi = phi


    self.__transport=lpe.SingleTransportPDE(self.__domain)
    if useReducedOrder: self.__transport.setReducedOrderOn()
    self.__transport.setValue(M=1.0)
    self.__transport.setInitialSolution(phi)


    self.__reinitPDE = lpe.LinearPDE(self.__domain, numEquations=1)
    self.__reinitPDE.getSolverOptions().setSolverMethod(lpe.SolverOptions.LUMPING)
    if useReducedOrder: self.__reinitPDE.setReducedOrderOn()
    self.__reinitPDE.setValue(D=1.0)

    # revise:
    self.__reinit_max = reinit_max
    self.__reinit_after = reinitialize_after
    self.__h = es.inf(self.__domain.getSize())
    self.__smooth = smooth
    self.__n_step=0
예제 #4
0
    def __init__(self, domain, eps=0.01):
        """
    Sets up the level set method.

    :param domain: the domain where the mountains is used
    :param eps: the smoothing parameter for (1)
    """
        order = escript.Solution(domain).getApproximationOrder()
        if order > 1:
            reduced = True
            if escript.ReducedSolution(domain).getApproximationOrder() > 1:
                raise ValueError("Reduced order needs to be equal to 1.")
        else:
            reduced = False
        if eps < 0:
            raise ValueError("Smooting parameter eps must be non-negative.")
        self.__domain = domain
        self.__reduced = reduced
        self.__DIM = domain.getDim()
        z = domain.getX()[self.__DIM - 1]

        self.__PDE_W = lpe.LinearPDE(domain)
        self.__PDE_W.setSymmetryOn()
        A = util.kronecker(domain) * eps * 0
        A[self.__DIM - 1, self.__DIM -
          1] = (0.3 * (util.sup(z) - util.inf(z)) / util.log(2.))**2
        # A[self.__DIM-1,self.__DIM-1]=(sup(FunctionOnBoundary(self.__domain).getSize())/log(2.))**2
        self.__PDE_W.setValue(D=1,
                              A=A,
                              q=util.whereZero(util.sup(z) - z) +
                              util.whereZero(util.inf(z) - z))

        self.__PDE_H = lpe.LinearPDE(domain)
        self.__PDE_H.setSymmetryOn()
        if reduced: self.__PDE_H.setReducedOrderOn()
        # A=kronecker(domain)*0
        # A[self.__DIM-1,self.__DIM-1]=0.1
        self.__PDE_H.setValue(D=1.0, q=util.whereZero(util.inf(z) - z))
        # self.__PDE_H.getSolverOptions().setSolverMethod(SolverOptions.LUMPING)

        self.setVelocity()
        self.setTopography()
예제 #5
0
    def getSafeTimeStepSize(self):
        """
      Returns the time step value.

      :rtype: ``float``
      """
        if self.__dt is None:
            h = self.getDomain().getSize()
            self.__dt = 0.5 * util.inf(h / util.length(
                util.interpolate(self.getVelocity(), h.getFunctionSpace())))
        return self.__dt