Example #1
0
 def generateBricks(self, a, b, c):
     brickX = Brick(self.longEdge,
                    5,
                    5,
                    l0=self.longEdge,
                    l1=5,
                    l2=5,
                    d0=self.numRanks,
                    diracPoints=[(a, b, c)],
                    diracTags=["test"])
     brickY = Brick(5,
                    self.longEdge,
                    5,
                    l0=5,
                    l1=self.longEdge,
                    l2=self.shortEdge,
                    d1=self.numRanks,
                    diracPoints=[(c, a, b)],
                    diracTags=["test"])
     brickZ = Brick(5,
                    5,
                    self.longEdge,
                    l0=5,
                    l1=5,
                    l2=self.longEdge,
                    d2=self.numRanks,
                    diracPoints=[(b, c, a)],
                    diracTags=["test"])
     dims = [[self.longEdge, 5, 5], [5, self.longEdge, 5],
             [5, 5, self.longEdge]]
     return [brickX, brickY, brickZ], dims
    def test_CartesianTransformation3D(self):
      
         dom=Brick(NE,NE,NE, l0=10, l1=10, l2=10)
         
         cs=CartesianReferenceSystem()
         tf=cs.createTransformation(dom)
         
         self.assertEqual(tf.getReferenceSystem(),cs , "wrong reference")
         self.assertEqual(tf.getDomain(),dom , "wrong reference")
         self.assertTrue(tf.isCartesian(), "wrong isCartesian check")
         
         
         v=tf.getVolumeFactor()
         self.assertTrue(isinstance(v, esys.escript.Data), "wrong volume factor type")
         self.assertEqual(v.getFunctionSpace(), esys.escript.Function(dom), "wrong volume factor type")
         error=Lsup(v-1.)
         self.assertTrue(error<=RTOL, "volume factor")
         
         s=tf.getScalingFactors()
         self.assertTrue(isinstance(s, esys.escript.Data), "scaling factor type")
         self.assertEqual(s.getShape(), (dom.getDim(),), "scaling factor length")
         self.assertEqual(s.getFunctionSpace(), esys.escript.Function(dom), "wrong 0-th scaling factor type")

         error=Lsup(s[0]-1.)
         self.assertTrue(error<=RTOL, "0-th scaling factor")         
         error=Lsup(s[1]-1.)
         self.assertTrue(error<=RTOL, "1-th scaling factor")  
         error=Lsup(s[2]-1.)
         self.assertTrue(error<=RTOL, "2-th scaling factor")   
Example #3
0
 def setUp(self):
     self.domain = Brick(self.NEX,
                         self.NEX,
                         self.NEZ,
                         l0=self.xdim,
                         l1=self.ydim,
                         l2=self.zdim)
 def setUp(self):
     self.domain = Brick(l0=1.,
                         l1=1.,
                         l2=1.,
                         n0=10,
                         n1=10 * getMPISizeWorld() - 1,
                         n2=10,
                         d1=getMPISizeWorld())
 def setUp(self):
     self.domain = Brick(n0=self.NEx,
                         n1=self.NEy,
                         n2=self.NEz,
                         l0=self.Lx,
                         l1=self.Ly,
                         l2=self.Lz,
                         diracPoints=[self.POS_node, self.NEG_node],
                         diracTags=['e0', 'e1'])
 def setUp(self):
     self.domain = Brick(n0=NE0 * NXb - 1,
                         n1=NE1 * NYb - 1,
                         n2=NE2 * NZb - 1,
                         d0=NXb,
                         d1=NYb,
                         d2=NZb)
     self.package = SolverOptions.MKL
     self.method = SolverOptions.DIRECT
Example #7
0
 def setUp(self):
     self.domain = Brick(10,
                         10,
                         10,
                         l0=100.,
                         l1=100.,
                         l2=100.,
                         diracTags=["source"],
                         diracPoints=[(0, 0, 0)])
     self.wavelet = Ricker(100.)
Example #8
0
 def setUp(self):
     self.domain = Brick(n0=NE0 * NXb - 1,
                         n1=NE1 * NYb - 1,
                         n2=NE2 * NZb - 1,
                         d0=NXb,
                         d1=NYb,
                         d2=NZb)
     self.package = SolverOptions.TRILINOS
     self.method = SolverOptions.PCG
     self.preconditioner = SolverOptions.ILUT
Example #9
0
    def __createDomain(self):
        """
        Creates and returns an escript domain that spans the entire area of
        available data plus a padding zone. This method is called only once
        the first time `getDomain()` is invoked.

        :return: The escript domain
        :rtype: `esys.escript.Domain`
        """
        X0, NX, DX = self.__getTotalExtentsWithPadding()

        # number of domain elements
        NE = NX + [self._v_num_cells]

        # origin of domain
        origin = X0 + [-self._v_depth * self.__v_scale]

        if self.getReferenceSystem().isCartesian():
            # rounding will give us about meter-accuracy with UTM coordinates
            self._dom_origin = [np.floor(oi) for oi in origin]
        else:
            # this should give us about meter-accuracy with lat/lon coords
            self._dom_origin = [1e-5 * np.floor(oi * 1e5) for oi in origin]

        # cell size / point spacing
        spacing = DX + [
            self.__v_scale * np.floor(
                (self._v_depth + self._v_air_layer) / self._v_num_cells)
        ]
        #self._spacing = [float(np.floor(si)) for si in spacing]
        self._spacing = spacing

        lo = [(self._dom_origin[i],
               self._dom_origin[i] + NE[i] * self._spacing[i])
              for i in range(self.__dim)]

        if self.__dim == 3:
            dom = Brick(*NE, l0=lo[0], l1=lo[1], l2=lo[2])
        else:
            dom = Rectangle(*NE, l0=lo[0], l1=lo[1])

        # ripley may internally adjust NE and length, so recompute
        self._dom_len = [
            esu.sup(dom.getX()[i]) - esu.inf(dom.getX()[i])
            for i in range(self.__dim)
        ]
        self._dom_NE = [
            int(self._dom_len[i] / self._spacing[i]) for i in range(self.__dim)
        ]

        self.logger.debug("Domain size: " + str(self._dom_NE))
        self.logger.debug("     length: " + str(self._dom_len))
        self.logger.debug("     origin: " + str(self._dom_origin))
        return dom
Example #10
0
 def setUp(self):
     self.order = 1
     self.domain = Brick(n0=NE * NXb - 1,
                         n1=NE * NYb - 1,
                         n2=NE * NZb - 1,
                         l0=1.,
                         l1=1.,
                         l2=1.,
                         d0=NXb,
                         d1=NYb,
                         d2=NZb)
Example #11
0
 def test_FillBrick(self):
     # If we are going to do really big tests of this, the size of this brick will need to be reduced
     fs = ContinuousFunction(Brick(10 * mpiSize, 10 * mpiSize,
                                   10 * mpiSize))
     RandomData((), fs, 2, ("gaussian", 1, 0.5))
     RandomData((), fs, 0, ("gaussian", 2, 0.76))
     self.assertRaises(NotImplementedError, RandomData, (2, 2), fs, 0,
                       ("gaussian", 2, 0.76))  #data not scalar
     self.assertRaises(ValueError, RandomData, (), fs, 0,
                       ("gaussian", 20, 0.1))  #radius too large
     RandomData((2, 3), fs)
Example #12
0
    def test_Creation(self):
        r = self.numRanks
        el = self.numRanks * 3 - 1

        #test bad types
        with self.assertRaises(TypeError):
            Rectangle(5, el, d1=r, diracPoints=(.0, 0.), diracTags=["test"])
        with self.assertRaises(TypeError):
            Rectangle(5, el, d1=r, diracPoints=[(.0, 0.)], diracTags=("test"))
        with self.assertRaises(TypeError):
            Rectangle(5, el, d1=r, diracPoints=[.0], diracTags=["test"])
        with self.assertRaises(TypeError):
            Rectangle(5, el, d1=r, diracPoints=[.0, .0], diracTags=["test"])

        with self.assertRaises(TypeError):
            Brick(5, el, 5, d1=r, diracPoints=(.0, 0., 0.), diracTags=["test"])
        with self.assertRaises(TypeError):
            Brick(5,
                  el,
                  5,
                  d1=r,
                  diracPoints=[(.0, 0., 0.)],
                  diracTags=("test"))
        with self.assertRaises(TypeError):
            Brick(5, el, 5, d1=r, diracPoints=[.0, 0.], diracTags=["test"])

        #test bad arg lengths
        with self.assertRaises(RuntimeError):
            Rectangle(5, el, d1=r, diracPoints=[(.0, )], diracTags=["test"])
        with self.assertRaises(RuntimeError):
            Rectangle(5, el, d1=r, diracPoints=[(.0, 1.)], diracTags=[])
        with self.assertRaises(RuntimeError):
            Rectangle(5,
                      el,
                      d1=r,
                      diracPoints=[(.0, 0.)],
                      diracTags=["test", "break"])
        with self.assertRaises(RuntimeError):
            Rectangle(5,
                      el,
                      d1=r,
                      diracPoints=[(.0, 0., 0.)],
                      diracTags=["test"])

        with self.assertRaises(RuntimeError):
            Brick(5,
                  el,
                  5,
                  d1=r,
                  diracPoints=[(.0, 0., 0., 0.)],
                  diracTags=["test"])
        with self.assertRaises(RuntimeError):
            Brick(5, el, 5, d1=r, diracPoints=[(
                .0,
                0.,
            )], diracTags=["test"])
        with self.assertRaises(RuntimeError):
            Brick(5, el, 5, d1=r, diracPoints=[(.0, )], diracTags=["test"])
Example #13
0
 def setUp(self):
     self.domain = Brick(n0=NE * NXb - 1,
                         n1=NE * NYb - 1,
                         n2=NE * NZb - 1,
                         l0=1.,
                         l1=1.,
                         l2=1.,
                         d0=NXb,
                         d1=NYb,
                         d2=NZb)
     self.functionspaces = [
         ContinuousFunction(self.domain),
         Function(self.domain),
         ReducedFunction(self.domain),
         FunctionOnBoundary(self.domain),
         ReducedFunctionOnBoundary(self.domain)
     ]
    def setUp(self):
        for x in [(int(mpiSize**(1 / 3.)), int(mpiSize**(1 / 3.))), (2, 3),
                  (2, 2), (1, 2), (1, 1)]:
            NX = x[0]
            NY = x[1]
            NZ = mpiSize // (x[0] * x[1])
            if NX * NY * NZ == mpiSize:
                break

        self.domain = Brick(n0=NE * NX - 1,
                            n1=NE * NY - 1,
                            n2=NE * NZ - 1,
                            l0=1.,
                            l1=1.,
                            l2=1.,
                            d0=NX,
                            d1=NY,
                            d2=NZ)
        self.order = 1
Example #15
0
 def setUp(self):
     self.domain = Brick(n0=NE * NXb - 1,
                         n1=NE * NYb - 1,
                         n2=NE * NZb - 1,
                         l0=1.,
                         l1=1.,
                         l2=1.,
                         d0=NXb,
                         d1=NYb,
                         d2=NZb)
     self.functionspaces = [
         ContinuousFunction(self.domain),
         Function(self.domain),
         ReducedFunction(self.domain),
         FunctionOnBoundary(self.domain),
         ReducedFunctionOnBoundary(self.domain)
     ]
     #We aren't testing DiracDeltaFunctions
     self.xn = 5  # number of grids on x axis
     self.yn = 5  # number of grids on y axis
     self.zn = 5
 def test_SphericalTransformation3D(self):
   
      dom=Brick(NE,NE,NE, l0=90, l1=45, l2=10.)
      
      cs=SphericalReferenceSystem()
      tf=cs.createTransformation(dom)
      
      self.assertEqual(tf.getReferenceSystem(),cs , "wrong reference")
      self.assertEqual(tf.getDomain(),dom , "wrong reference")
      self.assertFalse(tf.isCartesian(), "wrong isCartesian check")
      
      R=6378137.0
      x=esys.escript.Function(dom).getX()
      phi=(90.-x[1])/180.*pi
      lam=x[0]/180.*pi
      h=x[2]*1000.
      r=h+R
      
      v=tf.getVolumeFactor()
      self.assertTrue(isinstance(v, esys.escript.Data), "wrong volume factor type")
      self.assertEqual(v.getFunctionSpace(), esys.escript.Function(dom), "wrong volume factor type")
      error=Lsup(v- r**2*sin(phi)*(pi/180.)**2*1000. )
      self.assertTrue(error<=RTOL * R*R*(pi/180.)**2*1000., "volume factor")
      
      s=tf.getScalingFactors()
      self.assertTrue(isinstance(s, esys.escript.Data), "scaling factor type")
      self.assertEqual(s.getShape(), (dom.getDim(),), "scaling factor length")
      self.assertEqual(s.getFunctionSpace(), esys.escript.Function(dom), "wrong 0-th scaling factor type")
      
      error=Lsup(s[1]-1/r/pi*180.)
      self.assertTrue(error<=RTOL/R/pi*180., "0-th scaling factor")         
      
      error=Lsup(s[0]-1/(r*sin(phi))/pi*180.)
      self.assertTrue(error<=RTOL/R/pi*180., "1-th scaling factor")  
      
      error=Lsup(s[2]-1./1000.)
      self.assertTrue(error<=RTOL/1000., "2-th scaling factor")   
Example #17
0
if __name__ == "__main__":
    try:
        from esys.ripley import Brick
        HAVE_RIPLEY = True
    except ImportError:
        HAVE_RIPLEY = False
        print("Ripley module not available")

    if HAVE_RIPLEY:
        from esys.escript import *
        from esys.escript.linearPDEs import Poisson
        from esys.weipa import saveSilo, saveVoxet

        import tempfile

        dom = Brick(l0=1., l1=1., n0=9, n1=9, n2=9)
        x = dom.getX()
        gammaD = whereZero(x[0]) + whereZero(x[1])
        pde = Poisson(dom)
        q = gammaD
        pde.setValue(f=1, q=q)
        u = pde.getSolution()
        u = interpolate(u + dom.getX()[2], ReducedFunction(dom))
        print(u)
        handle, filename = tempfile.mkstemp(suffix='.vo', prefix='poisson')
        saveVoxet(filename, u=u)
        print("-------")
        dom = Brick(l0=1., l1=1., l2=4., n0=18, n1=18, n2=36)
        v = readVoxet(dom, filename, 'u', fillValue=0.5)
        print(v)
        os.remove(filename)
Example #18
0
 def setUp(self):
     Stations = [ (0.,0.,0.), (1.,0,0.), (0,1,0.), (1,1,0.) ]
     StationsTags = ["A1", "A2", "A3", "A4" ]
     self.domain=Brick(n0=5,n1=5,n2=5,diracPoints=Stations,diracTags=StationsTags)
Example #19
0
 def setUp(self):
     self.domain = Brick(10, 10, 10)
 def setUp(self):
     self.domain = Brick(n0=NE0*NXb-1, n1=NE1*NYb-1, n2=NE2*NZb-1, d0=NXb, d1=NYb, d2=NZb)
     self.package = SolverOptions.PASO
     self.method = SolverOptions.BICGSTAB
     self.preconditioner = SolverOptions.JACOBI
            rg.append((mid_point, receiver_line[iy]))
    #
    # create domain:
    #
    if DIM == 2:
        domain = Rectangle(ne_x,
                           ne_z,
                           l0=width_x,
                           l1=depth,
                           diracPoints=src_locations,
                           diracTags=src_tags)
    else:
        domain = Brick(ne_x,
                       ne_x,
                       ne_z,
                       l0=width_x,
                       l1=width_y,
                       l2=depth,
                       diracPoints=src_locations,
                       diracTags=src_tags)
    wl = Ricker(frq, tcenter)

    #======================================================================
    z = Function(domain).getX()[DIM - 1]
    z_bottom = 0
    v_p = 0
    delta = 0
    vareps = 0
    azmth = 0
    rho = 0
    for l in range(len(layers)):
        m = wherePositive(z -