def test_hex_contact_3D_order2_onFace(self):
     file = "hex_contact_3D_order2_onFace.msh"
     ms1 = Brick(1, 1, 1, 2, l2=0.5, useElementsOnFace=True)
     ms2 = Brick(1, 1, 1, 2, l2=0.5, useElementsOnFace=True)
     ms2.setX(ms2.getX() + [0, 0, 0.5])
     my_dom = JoinFaces([ms1, ms2], optimize=False)
     self.checker(my_dom, file)
Exemplo n.º 2
0
 def test_hex_contact_3D_order2_onFace(self):
    file="hex_contact_3D_order2_onFace.msh"
    ms1=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)
    ms2=Brick(1,1,1,2,l2=0.5,useElementsOnFace=True)
    ms2.setX(ms2.getX()+[0,0,0.5])
    my_dom=JoinFaces([ms1,ms2],optimize=False)
    self.checker(my_dom,file)
Exemplo n.º 3
0
 def setUp(self):
     self.order = 2
     d1 = Brick(n0=NE // 2, n1=NE, n2=NE, l0=0.5, order=2, useElementsOnFace=True)
     d2 = Brick(n0=NE // 2 + 1, n1=NE, n2=NE, l0=0.5, order=2, useElementsOnFace=True)
     d2.setX(d2.getX() + [0.5, 0.0, 0.0])
     if getMPISizeWorld() > 1:
         with self.assertRaises(NotImplementedError) as pkg:
             self.domain = JoinFaces([d1, d2], optimize=False)
         e = pkg.exception
         if FINLEY_MERGE_ERROR not in str(e):
             raise e
         raise unittest.SkipTest(FINLEY_MERGE_ERROR)
     else:
         self.domain = JoinFaces([d1, d2], optimize=False)
Exemplo n.º 4
0
 def setUp(self):
     self.order = 2
     d1 = Brick(n0=NE // 2,
                n1=NE,
                n2=NE,
                l0=0.5,
                order=2,
                useElementsOnFace=True)
     d2 = Brick(n0=NE // 2 + 1,
                n1=NE,
                n2=NE,
                l0=0.5,
                order=2,
                useElementsOnFace=True)
     d2.setX(d2.getX() + [0.5, 0., 0.])
     if getMPISizeWorld() > 1:
         with self.assertRaises(NotImplementedError) as pkg:
             self.domain = JoinFaces([d1, d2], optimize=False)
         e = pkg.exception
         if FINLEY_MERGE_ERROR not in str(e):
             raise e
         raise unittest.SkipTest(FINLEY_MERGE_ERROR)
     else:
         self.domain = JoinFaces([d1, d2], optimize=False)
Exemplo n.º 5
0
    #PDE related
    rho=100.0
    rholoc=[0,0,-0]
    G=6.67300*10E-11

    ################################################ESTABLISHING PARAMETERS
    #the folder to put our outputs in, leave blank "" for script path 
    save_path= os.path.join("data","example10")
    #ensure the dir exists
    mkDir(save_path)

    ####################################################DOMAIN CONSTRUCTION
    domain = Brick(l0=mx,l1=my,n0=ndx, n1=ndy,l2=mz,n2=ndz)
    x=Solution(domain).getX()
    x=x-[mx/2,my/2,mz/2]
    domain.setX(interpolate(x, ContinuousFunction(domain)))
    mask=wherePositive(100-length(x-rholoc))
    rho=rho*mask
    kro=kronecker(domain)

    mass=rho*vol(domain)
    ipot=FunctionOnBoundary(domain)
    xb=ipot.getX()

    q=whereZero(x[2]-inf(x[2]))
    ###############################################ESCRIPT PDE CONSTRUCTION

    mypde=LinearPDE(domain)
    mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)
    mypde.setSymmetryOn()
    sol=mypde.getSolution()
def getDomain():
    """
    this defines a dom as a brick of length and width l and hight h

      
    """
    global netotal

    v_p = {}
    for tag in sorted(rho_tab.keys()):
        v_p[tag] = sqrt((2 * mu_tab[tag] + lmbd_tab[tag]) / rho_tab[tag])
    v_p_ref = min(v_p.values())
    print(
        "velocities: bedrock = %s, sand = %s, water =%s, absorber =%s, reference =%s"
        % (v_p[bedrock], v_p[sand], v_p[water], v_p[absorber], v_p_ref))

    sections = {}
    sections["x"] = [
        d_absorber, x_sand, l_sand, l_x_water, l_sand,
        l - x_sand - 2 * l_sand - l_x_water, d_absorber
    ]
    sections["y"] = [
        d_absorber, y_sand, l_sand, l_y_water, l_sand,
        l - y_sand - 2 * l_sand - l_y_water, d_absorber
    ]
    sections["z"] = [d_absorber, h - h_water - h_sand, h_sand, h_water]
    if output:
        print("sections x = ", sections["x"])
        print("sections y = ", sections["y"])
        print("sections z = ", sections["z"])

    mats = [[
        [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
        [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
        [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
        [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
        [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
        [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
        [absorber, absorber, absorber, absorber, absorber, absorber, absorber]
    ],
            [[
                absorber, absorber, absorber, absorber, absorber, absorber,
                absorber
            ],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [
                 absorber, absorber, absorber, absorber, absorber, absorber,
                 absorber
             ]],
            [[
                absorber, absorber, absorber, absorber, absorber, absorber,
                absorber
            ],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [absorber, bedrock, sand, sand, sand, bedrock, absorber],
             [absorber, bedrock, sand, sand, sand, bedrock, absorber],
             [absorber, bedrock, sand, sand, sand, bedrock, absorber],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [
                 absorber, absorber, absorber, absorber, absorber, absorber,
                 absorber
             ]],
            [[
                absorber, absorber, absorber, absorber, absorber, absorber,
                absorber
            ],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [absorber, bedrock, sand, sand, sand, bedrock, absorber],
             [absorber, bedrock, sand, water, sand, bedrock, absorber],
             [absorber, bedrock, sand, sand, sand, bedrock, absorber],
             [absorber, bedrock, bedrock, bedrock, bedrock, bedrock, absorber],
             [
                 absorber, absorber, absorber, absorber, absorber, absorber,
                 absorber
             ]]]

    num_elem = {}
    for d in sections:
        num_elem[d] = []
        for i in range(len(sections[d])):
            if d == "x":
                v_p_min = v_p[mats[0][0][i]]
                for q in range(len(sections["y"])):
                    for r in range(len(sections["z"])):
                        v_p_min = min(v_p[mats[r][q][i]], v_p_min)
            elif d == "y":
                v_p_min = v_p[mats[0][i][0]]
                for q in range(len(sections["x"])):
                    for r in range(len(sections["z"])):
                        v_p_min = min(v_p[mats[r][i][q]], v_p_min)
            elif d == "z":
                v_p_min = v_p[mats[i][0][0]]
                for q in range(len(sections["x"])):
                    for r in range(len(sections["y"])):
                        v_p_min = min(v_p[mats[i][r][q]], v_p_min)
            num_elem[d].append(
                max(1,
                    int(sections[d][i] * v_p_ref / v_p_min / resolution +
                        0.5)))

    ne_x = sum(num_elem["x"])
    ne_y = sum(num_elem["y"])
    ne_z = sum(num_elem["z"])
    netotal = ne_x * ne_y * ne_z
    if output:
        print("grid : %s x %s x %s (%s elements)" %
              (ne_x, ne_y, ne_z, netotal))
    dom = Brick(ne_x,
                ne_y,
                ne_z,
                l0=o * ne_x,
                l1=o * ne_y,
                l2=o * ne_z,
                order=o)
    x_old = dom.getX()
    x_new = 0

    for d in sections:
        if d == "x":
            i = 0
            f = [1, 0, 0]
        if d == "y":
            i = 1
            f = [0, 1, 0]
        if d == "z":
            i = 2
            f = [0, 0, 1]
        x = x_old[i]

        p = origin[d]
        ne = 0
        s = 0.

        for i in range(len(sections[d]) - 1):
            msk = whereNonPositive(x - o * ne + 0.5)
            s = s * msk + (sections[d][i] / (o * num_elem[d][i]) *
                           (x - o * ne) + p) * (1. - msk)
            ne += num_elem[d][i]
            p += sections[d][i]
        x_new = x_new + s * f
    dom.setX(x_new)

    fs = Function(dom)
    x = Function(dom).getX()
    x0 = x[0]
    x1 = x[1]
    x2 = x[2]
    p_z = origin["z"]
    for i in range(len(mats)):
        f_z = wherePositive(x2 - p_z) * wherePositive(x2 - p_z +
                                                      sections["z"][i])
        p_y = origin["y"]
        for j in range(len(mats[i])):
            f_y = wherePositive(x1 - p_y) * wherePositive(x1 - p_z +
                                                          sections["y"][j])
            p_x = origin["x"]
            for k in range(len(mats[i][j])):
                f_x = wherePositive(x0 - p_x) * wherePositive(x0 - p_x +
                                                              sections["x"][k])
                fs.setTags(mats[i][j][k], f_x * f_y * f_z)
                p_x += sections["x"][k]
            p_y += sections["y"][j]
        p_z += sections["z"][i]
    return dom
Exemplo n.º 7
0
    #PDE related
    rho=100.0
    rholoc=[0,0,-0]
    G=6.67300*10E-11

    ################################################ESTABLISHING PARAMETERS
    #the folder to put our outputs in, leave blank "" for script path 
    save_path= os.path.join("data","example10")
    #ensure the dir exists
    mkDir(save_path)

    ####################################################DOMAIN CONSTRUCTION
    domain = Brick(l0=mx,l1=my,n0=ndx, n1=ndy,l2=mz,n2=ndz)
    x=Solution(domain).getX()
    x=x-[mx/2,my/2,mz/2]
    domain.setX(interpolate(x, ContinuousFunction(domain)))
    mask=wherePositive(100-length(x-rholoc))
    rho=rho*mask
    kro=kronecker(domain)

    mass=rho*vol(domain)
    ipot=FunctionOnBoundary(domain)
    xb=ipot.getX()

    q=whereZero(x[2]-inf(x[2]))
    ###############################################ESCRIPT PDE CONSTRUCTION

    mypde=LinearPDE(domain)
    mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)
    mypde.setSymmetryOn()
    sol=mypde.getSolution()
Exemplo n.º 8
0
def getDomain():
    """
    this defines a dom as a brick of length and width l and hight h

      
    """
    global netotal
    
    v_p={}
    for tag in sorted(rho_tab.keys()):
       v_p[tag]=sqrt((2*mu_tab[tag]+lmbd_tab[tag])/rho_tab[tag])
    v_p_ref=min(v_p.values())
    print("velocities: bedrock = %s, sand = %s, water =%s, absorber =%s, reference =%s"%(v_p[bedrock],v_p[sand],v_p[water],v_p[absorber],v_p_ref))

    sections={}
    sections["x"]=[d_absorber, x_sand, l_sand, l_x_water, l_sand, l-x_sand-2*l_sand-l_x_water, d_absorber]
    sections["y"]=[d_absorber, y_sand, l_sand, l_y_water, l_sand, l-y_sand-2*l_sand-l_y_water, d_absorber]
    sections["z"]=[d_absorber,h-h_water-h_sand,h_sand,h_water]
    if output:
      print("sections x = ",sections["x"])
      print("sections y = ",sections["y"])
      print("sections z = ",sections["z"])

    mats= [ 
            [ [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber] ],

            [ [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber] ],

            [ [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, bedrock , sand    , sand    , sand    , bedrock , absorber],
              [absorber, bedrock , sand    , sand    , sand    , bedrock , absorber],
              [absorber, bedrock , sand    , sand    , sand    , bedrock , absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber] ],

            [ [absorber, absorber, absorber, absorber, absorber, absorber, absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, bedrock , sand    , sand    , sand    , bedrock , absorber],
              [absorber, bedrock , sand    , water   , sand    , bedrock , absorber],
              [absorber, bedrock , sand    , sand    , sand    , bedrock , absorber],
              [absorber, bedrock , bedrock , bedrock , bedrock , bedrock , absorber],
              [absorber, absorber, absorber, absorber, absorber, absorber, absorber] ] ]
    
    num_elem={}
    for d in sections:
       num_elem[d]=[]
       for i in range(len(sections[d])):
           if d=="x":
              v_p_min=v_p[mats[0][0][i]]
              for q in range(len(sections["y"])):
                 for r in range(len(sections["z"])):
                    v_p_min=min(v_p[mats[r][q][i]],v_p_min)
           elif d=="y":
              v_p_min=v_p[mats[0][i][0]]
              for q in range(len(sections["x"])):
                 for r in range(len(sections["z"])):
                    v_p_min=min(v_p[mats[r][i][q]],v_p_min)
           elif d=="z":
              v_p_min=v_p[mats[i][0][0]]
              for q in range(len(sections["x"])):
                 for r in range(len(sections["y"])):
                    v_p_min=min(v_p[mats[i][r][q]],v_p_min)
           num_elem[d].append(max(1,int(sections[d][i] * v_p_ref/v_p_min /resolution+0.5)))
       
    ne_x=sum(num_elem["x"])
    ne_y=sum(num_elem["y"])
    ne_z=sum(num_elem["z"])
    netotal=ne_x*ne_y*ne_z
    if output: print("grid : %s x %s x %s (%s elements)"%(ne_x,ne_y,ne_z,netotal))
    dom=Brick(ne_x,ne_y,ne_z,l0=o*ne_x,l1=o*ne_y,l2=o*ne_z,order=o)
    x_old=dom.getX()
    x_new=0

    for d in sections:
        if d=="x": 
            i=0
            f=[1,0,0]
        if d=="y": 
            i=1
            f=[0,1,0]
        if d=="z": 
            i=2
            f=[0,0,1]
        x=x_old[i]

        p=origin[d]
        ne=0
        s=0.
 
        for i in range(len(sections[d])-1):
            msk=whereNonPositive(x-o*ne+0.5)
            s=s*msk + (sections[d][i]/(o*num_elem[d][i])*(x-o*ne)+p)*(1.-msk)
            ne+=num_elem[d][i]
            p+=sections[d][i]
        x_new=x_new + s * f
    dom.setX(x_new)

    fs=Function(dom)
    x=Function(dom).getX()
    x0=x[0]
    x1=x[1]
    x2=x[2]
    p_z=origin["z"]
    for i in range(len(mats)):
       f_z=wherePositive(x2-p_z)*wherePositive(x2-p_z+sections["z"][i])
       p_y=origin["y"]
       for j in range(len(mats[i])):
         f_y=wherePositive(x1-p_y)*wherePositive(x1-p_z+sections["y"][j])
         p_x=origin["x"]
         for k in range(len(mats[i][j])):
             f_x=wherePositive(x0-p_x)*wherePositive(x0-p_x+sections["x"][k]) 
             fs.setTags(mats[i][j][k],f_x*f_y*f_z)
             p_x+=sections["x"][k]
         p_y+=sections["y"][j]
       p_z+=sections["z"][i]
    return dom