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")   
예제 #2
0
    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")   
 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")   
예제 #4
0
 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")   
예제 #5
0
        elif (NY+1)%(d1*f) == 0:
            d1 = d1 * f
            d2 = d2 / f
    else:
        if (NY+1)%(d1*f) == 0:
            d1 = d1 * f
            d2 = d2 / f
        elif (NX+1)%(d0*f) == 0:
            d0 = d0 * f
            d2 = d2 / f

# create domain
print("Domain subdivisions: %d x %d x %d"%(d0,d1,d2))
dom = Brick(NX, NY, n_cells_v, l0, l1, l2, d0, d1, d2)

dom_len = [sup(dom.getX()[i])-inf(dom.getX()[i]) for i in range(dom.getDim())]

# report domain setup
print("Domain size: "+str([NX, NY, n_cells_v]))
print("     length: "+str(dom_len))
print("     origin: "+str(dom_origin))

DIM = dom.getDim() # = 3

datacoords = ReducedFunction(dom).getX()

# create the output directory if not existing already
try:
    os.mkdir(OUTPUTDIR)
except:
    pass