예제 #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 setTopography(self, H=None):
        """
    set the topography to H where H defines the vertical displacement. H is defined for the entire domain.

    :param H: the topography.  If None zero is used.
    :type H: scalar
    """
        if self.__reduced:
            fs = escript.ReducedSolution(self.getDomain())
        else:
            fs = escript.Solution(self.getDomain())

        if H is None:
            self.__H = escript.Scalar(0.0, fs)
        else:
            self.__H = util.interpolate(H, fs)
예제 #3
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()