Exemplo n.º 1
0
:var __licence__: licence agreement
:var __url__: url entry point on documentation
:var __version__: version
:var __date__: date of the version
"""

__author__="Lutz Gross, [email protected]"

from esys.pycad import *
from esys.pycad.gmsh import Design
from esys.finley import MakeDomain
p0=Point(0.,0.,0.,local_scale=0.01)
p1=Point(1.,0.,0.)
p2=Point(1.,1.,0.)
p3=Point(0.,1.,0.)
l01=Line(p0,p1)
l12=Line(p1,p2)
l23=Line(p2,p3)
l23.setElementDistribution(20)
l30=Line(p3,p0)
c=CurveLoop(l01,l12,l23,l30)
s=PlaneSurface(c)

d=Design(dim=2,element_size=0.3)
d.setScriptFileName("refine.geo")
d.setMeshFileName("refine.msh")
d.addItems(s)

dom=MakeDomain(d)
dom.write("refine.fly")
def getMesh(NE_X, NE_Y, t, d, o, fullOrder, r, l_X):
    if t == "Hex":
        if d == 2:
            dom = Rectangle(n0=NE_X,
                            n1=NE_Y,
                            l0=l_X,
                            order=o,
                            useFullElementOrder=fullOrder,
                            useElementsOnFace=r,
                            optimize=True)
        else:
            Brick()
            dom = Brick(n0=NE_X,
                        n1=NE_Y,
                        n2=NE_Y,
                        l0=l_X,
                        order=o,
                        useFullElementOrder=fullOrder,
                        useElementsOnFace=r,
                        optimize=True)
    else:
        des = Design(dim=d,
                     order=o,
                     element_size=min(l_X / max(3, NE_X), 1. / max(3, NE_Y)),
                     keep_files=True)
        des.setScriptFileName("tester.geo")
        if d == 2:
            p0 = Point(0., 0.)
            p1 = Point(l_X, 0.)
            p2 = Point(l_X, 1.)
            p3 = Point(0., 1.)
            l01 = Line(p0, p1)
            l12 = Line(p1, p2)
            l23 = Line(p2, p3)
            l30 = Line(p3, p0)
            s = PlaneSurface(CurveLoop(l01, l12, l23, l30))
            des.addItems(s, l01, l12, l23, l30)
        else:
            p000 = Point(0., 0., 0.)
            p100 = Point(l_X, 0., 0.)
            p010 = Point(0., 1., 0.)
            p110 = Point(l_X, 1., 0.)
            p001 = Point(0., 0., 1.)
            p101 = Point(l_X, 0., 1.)
            p011 = Point(0., 1., 1.)
            p111 = Point(l_X, 1., 1.)

            l10 = Line(p000, p100)
            l20 = Line(p100, p110)
            l30 = Line(p110, p010)
            l40 = Line(p010, p000)

            l11 = Line(p000, p001)
            l21 = Line(p100, p101)
            l31 = Line(p110, p111)
            l41 = Line(p010, p011)

            l12 = Line(p001, p101)
            l22 = Line(p101, p111)
            l32 = Line(p111, p011)
            l42 = Line(p011, p001)

            bottom = PlaneSurface(-CurveLoop(l10, l20, l30, l40))
            top = PlaneSurface(CurveLoop(l12, l22, l32, l42))

            front = PlaneSurface(CurveLoop(l10, l21, -l12, -l11))
            back = PlaneSurface(CurveLoop(l30, l41, -l32, -l31))

            left = PlaneSurface(CurveLoop(l11, -l42, -l41, l40))
            right = PlaneSurface(CurveLoop(-l21, l20, l31, -l22))

            vol = Volume(SurfaceLoop(bottom, top, front, back, left, right))
            des.addItems(vol)

        dom = MakeDomain(des)
    return dom
Exemplo n.º 3
0
    #Left and Right Blocks
    for i in range(0,nintf+1):
        lcurves.append(CurveLoop(lleft[i],lhleft[i+1],nlfleft[nintf-i],nlhleft[nintf+1-i]))
        rcurves.append(CurveLoop(lfright[i],lhright[i+1],nlright[nintf-i],nlhright[nintf+1-i]))
        
    #Build Surfaces
    fsurf=PlaneSurface(fcurves)
    lsurf=[]
    rsurf=[]
    for i in range(0,nintf+1):
        lsurf.append(PlaneSurface(lcurves[i]))
        rsurf.append(PlaneSurface(rcurves[i]))

    d=Design(dim=2, element_size=element_size, order=2)

    d.addItems(PropertySet('fault',fsurf))
    for i in range(0,nintf+1):
        d.addItems(PropertySet('lblock%d'%i,lsurf[i]))
        d.addItems(PropertySet('rblock%d'%i,rsurf[i]))

    d.addItems(PropertySet('top',lhright[0],lfhor[0],lhleft[0],lhright[4],lhleft[4],lfhor[1]))

    d.setScriptFileName(os.path.join(save_path,"example09n.geo"))
    d.setMeshFileName(os.path.join(save_path,"example09n.msh"))
    #
    #  make the domain:
    #
    domain=MakeDomain(d)
    # mesh=ReadMesh(fileName) this is how to read the fly file into escript
    domain.write(os.path.join(save_path,"example09n.fly"))
Exemplo n.º 4
0
l01=Line(p0,p1)
l13=Line(p1,p3)
l32=Line(p3,p2)
l20=Line(p2,p0)

l45=Line(p4,p5)
l57=Line(p5,p7)
l76=Line(p7,p6)
l64=Line(p6,p4)

l15=Line(p1,p5)
l40=Line(p4,p0)
l37=Line(p3,p7)
l62=Line(p6,p2)

bottom=PlaneSurface(CurveLoop(l01,l13,l32,l20))
top=PlaneSurface(CurveLoop(l45,l57,l76,l64))
front=PlaneSurface(CurveLoop(l01,l15,-l45,l40))
back=PlaneSurface(CurveLoop(l32,-l62,-l76,-l37))
left=PlaneSurface(CurveLoop(-l40,-l64,l62,l20))
right=PlaneSurface(CurveLoop(-l15,l13,l37,-l57))
v=Volume(SurfaceLoop(top,-bottom,front,back,left,right))

des=Design(dim=3, order=2, element_size = 0.1, keep_files=True)
des.setScriptFileName("brick.geo")
des.addItems(v, top, bottom, back, front, left , right)

des.setFileFormat(des.STL)
des.setMeshFileName("brick.stl")
des.generate()
Exemplo n.º 5
0
    # Create BOTTOM BLOCK
    # lines
    bbl1=Line(x1,p1)
    bbl3=Line(p2,x2)
    bbl4=-mysp
    l12=Line(p1, p2)
    # curve
    bblockloop = CurveLoop(bbl1,l12,bbl3,bbl4)
    # surface
    bblock = PlaneSurface(bblockloop)

    ################################################CREATE MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d=Design(dim=2, element_size=200)
    # Add the subdomains and flux boundaries.
    d.addItems(PropertySet("top",tblock),PropertySet("bottom",bblock),\
                                         PropertySet("linebottom",l12))
    # Create the geometry, mesh and Escript domain
    d.setScriptFileName(os.path.join(save_path,"example05.geo"))
    d.setMeshFileName(os.path.join(save_path,"example05.msh"))
    domain=MakeDomain(d, optimizeLabeling=True)
    print("Domain has been generated ...")
    ##############################################################SOLVE PDE
    mypde=LinearPDE(domain)
    mypde.getSolverOptions().setVerbosityOn()
    mypde.setSymmetryOn()
    kappa=Scalar(0,Function(domain))
    kappa.setTaggedValue("top",2.0*W/m/K)
    kappa.setTaggedValue("bottom",4.0*W/m/K)
    mypde.setValue(A=kappa*kronecker(domain))
    x=Solution(domain).getX()
    mypde.setValue(q=whereZero(x[1]-sup(x[1])),r=Ttop)
if DIM == 2:
    if (DEPTH * cos(DIP) > 0.9 * LX):
        raise ValueError("X edge to short (maybe DIP to large.)")

    p0 = Point(DEPTH * cos(DIP), -DEPTH)
    p1 = Point(LX, -DEPTH)
    p2 = Point(LX, 0.)
    p3 = Point(0., 0.)

    l01 = Line(p0, p1)
    l12 = Line(p1, p2)
    l23 = Line(p2, p3)
    l30 = Line(p3, p0)
    s = PlaneSurface(CurveLoop(l01, l12, l23, l30))
    des.addItems(s, PropertySet("subduction", l30))

else:

    if (DEPTH * cos(DIP) > 0.9 * LX):
        raise ValueError("X edge to short (maybe DIP to large.)")
    if (DEPTH * cos(DIP) + LY * sin(STRIKE) > 0.9 * LX):
        raise ValueError("X edge to short (maybe DIP to large.)")
    if (LY * sin(STRIKE) > 0.9 * LX):
        raise ValueError("X edge to short (maybe DIP to large.)")

    p0 = Point(DEPTH * cos(DIP), 0., -DEPTH)
    p1 = Point(LX, 0., -DEPTH)
    p2 = Point(DEPTH * cos(DIP) + LY * sin(STRIKE), LY, -DEPTH)
    p3 = Point(LX, LY, -DEPTH)
    p4 = Point(0., 0., 0.)
Exemplo n.º 7
0
    p3=Point(width,   0.0, 0.0)
    # Join corners in anti-clockwise manner.
    l01=Line(p0, p1)
    l12=Line(p1, p2)
    l23=Line(p2, p3)
    l30=Line(p3, p0)
    # Join line segments to create domain boundary.
    c=CurveLoop(l01, l12, l23, l30)
    # surface
    rec = PlaneSurface(c)

    #############################################EXPORTING MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d=Design(dim=2, element_size=200*m)
    # Add the subdomains and flux boundaries.
    d.addItems(rec, PropertySet("linebottom",l12) )
    d.addItems(l23, l30, l01) # just in case we need them.

    # this is the name of gmsh input file generated by pycad
    #
    # >> gmsh example04.geo
    #
    # to show the mesh.
    #
    d.setScriptFileName(os.path.join(save_path,"example04.geo"))

    # this is the name of mesh file generated gmsh. Use
    #
    # >> gmsh example04.msh
    #
    # to show the mesh.
    left_back_fault=getCutLine(Point(fault_mid_back-fault_w_back/2,length,0.), layers_left_at_back, offset=True)

    right_back_fault=getCutLine(Point(fault_mid_back+fault_w_back/2,length,0.), layers_right_at_back, offset=True)
    right_back_edge=getCutLine(Point(width,length,0.), layers_right_at_back, offset=False)

    PS={}
    FF=[]
    front_to_back_left_top, front_to_back_left_bot, PS, FF=addVolume(left_front_edge, left_back_edge, left_front_fault, left_back_fault, PS, FF, layers_left_at_front, filter_left=False)
    front_to_back_right_top, front_to_back_right_bot, PS, FF=addVolume(right_front_edge, right_back_edge, right_front_fault, right_back_fault, PS, FF, layers_right_at_front, filter_left=True)

    fault_line_top_front=Line(front_to_back_left_top.getStartPoint(), front_to_back_right_top.getStartPoint())
    fault_line_bot_front=Line(front_to_back_left_bot.getStartPoint(), front_to_back_right_bot.getStartPoint())
    fault_line_top_back=Line(front_to_back_left_top.getEndPoint(), front_to_back_right_top.getEndPoint())
    fault_line_bot_back=Line(front_to_back_left_bot.getEndPoint(), front_to_back_right_bot.getEndPoint())

    FF.append(PlaneSurface(CurveLoop(front_to_back_left_top,fault_line_top_back,-front_to_back_right_top,-fault_line_top_front)))
    FF.append(-PlaneSurface(CurveLoop(front_to_back_left_bot,fault_line_bot_back,-front_to_back_right_bot,-fault_line_bot_front)))

    FF.append(PlaneSurface(CurveLoop(*tuple([ -fault_line_top_front,fault_line_bot_front ]+left_front_fault+[ -l for l in right_front_fault ]))))
    FF.append(-PlaneSurface(CurveLoop(*tuple([ -fault_line_top_back,fault_line_bot_back ]+left_back_fault+[ -l for l in right_back_fault ]))))


    # war 120
    des=Design(dim=3, order=1, element_size = 400*m, keep_files=True)
    des.addItems(*tuple(PS.values()))
    des.addItems(PropertySet("fault",Volume(SurfaceLoop( *tuple(FF)))))
    des.setMeshFileName(os.path.join(save_path,"fault.msh"))
    dom=MakeDomain(des)
    dom.write(os.path.join(save_path,"fault.fly"))

Exemplo n.º 9
0
:var __date__: date of the version
"""

__author__="Lutz Gross, [email protected]"

from esys.pycad import *
from esys.pycad.gmsh import Design
from esys.finley import MakeDomain
p0=Point(0.,0.,0.)
p1=Point(1.,0.,0.)
p2=Point(1.,1.,0.)
p3=Point(0.,1.,0.)
l01=Line(p0,p1)
l12=Line(p1,p2)
l23=Line(p2,p3)
l30=Line(p3,p0)
c=CurveLoop(l01,l12,l23,l30)
s=PlaneSurface(c)

d=Design(dim=2,element_size=0.05)
d.setScriptFileName("quad.geo")
d.setMeshFileName("quad.msh")
d.addItems(s)

pl1=PropertySet("sides",l01,l23)
pl2=PropertySet("top_and_bottom",l12,l30)
d.addItems(pl1,pl2)

dom=MakeDomain(d)
dom.write("quad.fly")
Exemplo n.º 10
0
:var __date__: date of the version
"""

__author__="Lutz Gross, [email protected]"

from esys.pycad import *
from esys.pycad.gmsh import Design
from esys.finley import MakeDomain
p0=Point(0.,0.,0.)
p1=Point(1.,0.,0.)
p2=Point(1.,1.,0.)
p3=Point(0.,1.,0.)
l01=Line(p0,p1)
l12=Line(p1,p2)
l23=Line(p2,p3)
l30=Line(p3,p0)
c=CurveLoop(l01,l12,l23,l30)
s=PlaneSurface(c)

d=Design(dim=2,element_size=0.05)
d.setScriptFileName("quad.geo")
d.setMeshFileName("quad.msh")
d.addItems(s)

pl1=PropertySet("sides",l01,l23)
pl2=PropertySet("top_and_bottom",l12,l30)
d.addItems(pl1,pl2)

dom=MakeDomain(d)
dom.write("quad.fly")
Exemplo n.º 11
0
    p7=Point(xshift,    zdepth+zshift)
    # Join corners in anti-clockwise manner.
    l45=Line(p4, p5)
    l56=Line(p5, p6)
    l67=Line(p6, p7)
    l74=Line(p7, p4)

    csmall=CurveLoop(l45,l56,l67,l74)

    ssmall=PlaneSurface(csmall)
    sbig=PlaneSurface(cbig,holes=[csmall])

    #############################################EXPORTING MESH FOR ESCRIPT
    # Design the geometry for the big mesh.
    d1=Design(dim=2, element_size=bele_size, order=1)
    d1.addItems(sbig)
    d1.addItems(PropertySet(l01,l12,l23,l30))
    d1.setScriptFileName(os.path.join(save_path,"example10m_big.geo"))
    MakeDomain(d1)

    # Design the geometry for the small mesh.
    d2=Design(dim=2, element_size=sele_size, order=1)
    d2.addItems(ssmall)
    d2.setScriptFileName(os.path.join(save_path,"example10m_small.geo"))
    MakeDomain(d2)

    # Join the two meshes using Gmsh and then apply a 2D meshing algorithm.
    # The small mesh must come before the big mesh in the merging call!!@!!@!
    sp.call("gmsh -2 "+
            os.path.join(save_path,"example10m_small.geo")+" "+
            os.path.join(save_path,"example10m_big.geo")+" -o "+
Exemplo n.º 12
0
    left_back_fault=getCutLine(Point(fault_mid_back-fault_w_back/2,length,0.), layers_left_at_back, offset=True)

    right_back_fault=getCutLine(Point(fault_mid_back+fault_w_back/2,length,0.), layers_right_at_back, offset=True)
    right_back_edge=getCutLine(Point(width,length,0.), layers_right_at_back, offset=False)

    PS={}
    FF=[]
    front_to_back_left_top, front_to_back_left_bot, PS, FF=addVolume(left_front_edge, left_back_edge, left_front_fault, left_back_fault, PS, FF, layers_left_at_front, filter_left=False)
    front_to_back_right_top, front_to_back_right_bot, PS, FF=addVolume(right_front_edge, right_back_edge, right_front_fault, right_back_fault, PS, FF, layers_right_at_front, filter_left=True)

    fault_line_top_front=Line(front_to_back_left_top.getStartPoint(), front_to_back_right_top.getStartPoint())
    fault_line_bot_front=Line(front_to_back_left_bot.getStartPoint(), front_to_back_right_bot.getStartPoint())
    fault_line_top_back=Line(front_to_back_left_top.getEndPoint(), front_to_back_right_top.getEndPoint())
    fault_line_bot_back=Line(front_to_back_left_bot.getEndPoint(), front_to_back_right_bot.getEndPoint())

    FF.append(PlaneSurface(CurveLoop(front_to_back_left_top,fault_line_top_back,-front_to_back_right_top,-fault_line_top_front)))
    FF.append(-PlaneSurface(CurveLoop(front_to_back_left_bot,fault_line_bot_back,-front_to_back_right_bot,-fault_line_bot_front)))

    FF.append(PlaneSurface(CurveLoop(*tuple([ -fault_line_top_front,fault_line_bot_front ]+left_front_fault+[ -l for l in right_front_fault ]))))
    FF.append(-PlaneSurface(CurveLoop(*tuple([ -fault_line_top_back,fault_line_bot_back ]+left_back_fault+[ -l for l in right_back_fault ]))))


    # war 120
    des=Design(dim=3, order=1, element_size = 400*m, keep_files=True)
    des.addItems(*tuple(PS.values()))
    des.addItems(PropertySet("fault",Volume(SurfaceLoop( *tuple(FF)))))
    des.setMeshFileName(os.path.join(save_path,"fault.msh"))
    dom=MakeDomain(des)
    dom.write(os.path.join(save_path,"fault.fly"))

Exemplo n.º 13
0
    #Left and Right Blocks
    for i in range(0,nintf+1):
        lcurves.append(CurveLoop(lleft[i],lhleft[i+1],nlfleft[nintf-i],nlhleft[nintf+1-i]))
        rcurves.append(CurveLoop(lfright[i],lhright[i+1],nlright[nintf-i],nlhright[nintf+1-i]))
        
    #Build Surfaces
    fsurf=PlaneSurface(fcurves)
    lsurf=[]
    rsurf=[]
    for i in range(0,nintf+1):
        lsurf.append(PlaneSurface(lcurves[i]))
        rsurf.append(PlaneSurface(rcurves[i]))

    d=Design(dim=2, element_size=element_size, order=2)

    d.addItems(PropertySet('fault',fsurf))
    for i in range(0,nintf+1):
        d.addItems(PropertySet('lblock%d'%i,lsurf[i]))
        d.addItems(PropertySet('rblock%d'%i,rsurf[i]))

    d.addItems(PropertySet('top',lhright[0],lfhor[0],lhleft[0],lhright[4],lhleft[4],lfhor[1]))

    d.setScriptFileName(os.path.join(save_path,"example09n.geo"))
    d.setMeshFileName(os.path.join(save_path,"example09n.msh"))
    #
    #  make the domain:
    #
    domain=MakeDomain(d)
    # mesh=ReadMesh(fileName) this is how to read the fly file into escript
    domain.write(os.path.join(save_path,"example09n.fly"))
Exemplo n.º 14
0
    cintfb_ar.append(CurveLoop(linte_ar[5],l74,-linte_ar[7],-linhe_ar[2]))
    cintfb_ar.append(CurveLoop(linte_ar[7],l45,-linte_ar[1],-linhe_ar[3]))

    sintfa_ar=[PlaneSurface(cintfa_ar[i]) for i in range(0,4)]
    sintfb_ar=[PlaneSurface(cintfb_ar[i]) for i in range(0,4)]

    sintf=PlaneSurface(CurveLoop(*tuple(linhe_ar)))

    vintfa=Volume(SurfaceLoop(stop,-sintf,*tuple(sintfa_ar)))
    vintfb=Volume(SurfaceLoop(sbot,sintf,*tuple(sintfb_ar)))

    #############################################EXPORTING MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d=Design(dim=3, element_size=element_size, order=2)

    d.addItems(PropertySet('vintfa',vintfa))
    d.addItems(PropertySet('vintfb',vintfb))
    d.addItems(PropertySet('stop',stop))
    d.addItems(PropertySet('sbot',sbot))

    d.setScriptFileName(os.path.join(save_path,"example09m.geo"))
    d.setMeshFileName(os.path.join(save_path,"example09m.msh"))
    if testing:
        d.setOptions(optimize_quality=0)
    #
    #  make the domain:
    #
    domain=MakeDomain(d)
    # Create a file that can be read back in to python with
    # mesh=ReadMesh(fileName)
    domain.write(os.path.join(save_path,"example09m.fly"))
Exemplo n.º 15
0
    bblockl = PlaneSurface(bblockloopl)

    # Create BOTTOM BLOCK RIGHT
    bbrl1 = Line(p6, p2)
    bbrl2 = Line(p2, p7)
    bbrl3 = -tbl3
    bbrl4 = -bbll3
    bblockloopr = CurveLoop(bbrl1, bbrl2, bbrl3, bbrl4)
    bblockr = PlaneSurface(bblockloopr)

    #############################################EXPORTING MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d = Design(dim=2, element_size=200)
    # Add the subdomains and flux boundaries.
    d.addItems(PropertySet("top",tblock),\
                           PropertySet("bottomleft",bblockl),\
                           PropertySet("bottomright",bblockr),\
                           PropertySet("linebottom",bbll2, bbrl1))

    # Create the geometry, mesh and Escript domain
    d.setScriptFileName(os.path.join(save_path, "example06.geo"))

    d.setMeshFileName(os.path.join(save_path, "example06.msh"))
    domain = MakeDomain(d)
    print("Domain has been generated ...")

    # set up kappa (thermal conductivity across domain) using tags
    kappa = Scalar(0, Function(domain))
    kappa.setTaggedValue("top", 2.0)
    kappa.setTaggedValue("bottomleft", 10.0)
    kappa.setTaggedValue("bottomright", 6.0)
    ##############################################################SOLVE PDE
Exemplo n.º 16
0
    bblockl = PlaneSurface(bblockloopl)

    # Create BOTTOM BLOCK RIGHT
    bbrl1=Line(p6,p2)
    bbrl2=Line(p2,p7)
    bbrl3=-tbl3
    bbrl4=-bbll3
    bblockloopr = CurveLoop(bbrl1,bbrl2,bbrl3,bbrl4)
    bblockr = PlaneSurface(bblockloopr)

    #############################################EXPORTING MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d=Design(dim=2, element_size=200)
    # Add the subdomains and flux boundaries.
    d.addItems(PropertySet("top",tblock),\
                           PropertySet("bottomleft",bblockl),\
                           PropertySet("bottomright",bblockr),\
                           PropertySet("linebottom",bbll2, bbrl1))

    # Create the geometry, mesh and Escript domain
    d.setScriptFileName(os.path.join(save_path,"example06.geo"))

    d.setMeshFileName(os.path.join(save_path,"example06.msh"))
    domain=MakeDomain(d)
    print("Domain has been generated ...")

    # set up kappa (thermal conductivity across domain) using tags
    kappa=Scalar(0,Function(domain))
    kappa.setTaggedValue("top",2.0)
    kappa.setTaggedValue("bottomleft",10.0)
    kappa.setTaggedValue("bottomright",6.0)
    ##############################################################SOLVE PDE
Exemplo n.º 17
0
    cintfb_ar.append(CurveLoop(linte_ar[5],l74,-linte_ar[7],-linhe_ar[2]))
    cintfb_ar.append(CurveLoop(linte_ar[7],l45,-linte_ar[1],-linhe_ar[3]))

    sintfa_ar=[PlaneSurface(cintfa_ar[i]) for i in range(0,4)]
    sintfb_ar=[PlaneSurface(cintfb_ar[i]) for i in range(0,4)]

    sintf=PlaneSurface(CurveLoop(*tuple(linhe_ar)))

    vintfa=Volume(SurfaceLoop(stop,-sintf,*tuple(sintfa_ar)))
    vintfb=Volume(SurfaceLoop(sbot,sintf,*tuple(sintfb_ar)))

    #############################################EXPORTING MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d=Design(dim=3, element_size=element_size, order=2)

    d.addItems(PropertySet('vintfa',vintfa))
    d.addItems(PropertySet('vintfb',vintfb))
    d.addItems(PropertySet('stop',stop))
    d.addItems(PropertySet('sbot',sbot))

    d.setScriptFileName(os.path.join(save_path,"example09m.geo"))
    d.setMeshFileName(os.path.join(save_path,"example09m.msh"))
    if testing:
        d.setOptions(optimize_quality=0)
    #
    #  make the domain:
    #
    domain=MakeDomain(d)
    # Create a file that can be read back in to python with
    # mesh=ReadMesh(fileName)
    domain.write(os.path.join(save_path,"example09m.fly"))
Exemplo n.º 18
0
l01 = Line(p0, p1)
l13 = Line(p1, p3)
l32 = Line(p3, p2)
l20 = Line(p2, p0)

l45 = Line(p4, p5)
l57 = Line(p5, p7)
l76 = Line(p7, p6)
l64 = Line(p6, p4)

l15 = Line(p1, p5)
l40 = Line(p4, p0)
l37 = Line(p3, p7)
l62 = Line(p6, p2)

bottom = PlaneSurface(-CurveLoop(l01, l13, l32, l20))
top = PlaneSurface(CurveLoop(l45, l57, l76, l64))
front = PlaneSurface(CurveLoop(l01, l15, -l45, l40))
back = PlaneSurface(CurveLoop(l32, -l62, -l76, -l37))
left = PlaneSurface(CurveLoop(-l40, -l64, l62, l20))
right = PlaneSurface(CurveLoop(-l15, l13, l37, -l57))
v = Volume(SurfaceLoop(top, bottom, front, back, left, right))
des = Design(dim=3, order=2, element_size=1, keep_files=True)
des.addItems(PropertySet("V", v), PropertySet("bottom", bottom))
des.setScriptFileName("dom.geo")
des.setMeshFileName("dom.msh")

dom = MakeDomain(des)
dom.write("brick.fly")
Exemplo n.º 19
0
p6 = Point(0., 1., 1.)
p7 = Point(1., 1., 1.)

l01 = Line(p0, p1)
l13 = Line(p1, p3)
l32 = Line(p3, p2)
l20 = Line(p2, p0)

l45 = Line(p4, p5)
l57 = Line(p5, p7)
l76 = Line(p7, p6)
l64 = Line(p6, p4)

l15 = Line(p1, p5)
l40 = Line(p4, p0)
l37 = Line(p3, p7)
l62 = Line(p6, p2)

bottom = PlaneSurface(-CurveLoop(l01, l13, l32, l20))
top = PlaneSurface(CurveLoop(l45, l57, l76, l64))
front = PlaneSurface(CurveLoop(l01, l15, -l45, l40))
back = PlaneSurface(CurveLoop(l32, -l62, -l76, -l37))
left = PlaneSurface(CurveLoop(-l40, -l64, l62, l20))
right = PlaneSurface(CurveLoop(-l15, l13, l37, -l57))
v = Volume(SurfaceLoop(top, bottom, front, back, left, right))
des = Design(dim=3, order=2, element_size=1, keep_files=True)
des.addItems(v)

dom = MakeDomain(des)
dom.write("brick.fly")
Exemplo n.º 20
0
__copyright__ = """Copyright (c) 2003-2018 by The University of Queensland
http://www.uq.edu.au
Primary Business: Queensland, Australia"""
__license__ = """Licensed under the Apache License, version 2.0
http://www.apache.org/licenses/LICENSE-2.0"""
__url__ = "https://launchpad.net/escript-finley"

from esys.escript import *
from esys.pycad import *
from esys.pycad.gmsh import Design
from esys.finley import MakeDomain

p0 = Point(0., 0.)
p1 = Point(1., 0.)
p2 = Point(1., 1.)
p3 = Point(0., 1.)

l01 = Line(p0, p1)
l12 = Line(p1, p2)
l23 = Line(p2, p3)
l30 = Line(p3, p0)

s = PlaneSurface(CurveLoop(l01, l12, l23, l30))
des = Design(dim=2, order=1, element_size=1, keep_files=True)
des.setMeshFileName("rec.geo")
des.addItems(s)

dom = MakeDomain(des)
dom.write("rec.fly")
Exemplo n.º 21
0
    p3 = Point(width, 0.0, 0.0)
    # Join corners in anti-clockwise manner.
    l01 = Line(p0, p1)
    l12 = Line(p1, p2)
    l23 = Line(p2, p3)
    l30 = Line(p3, p0)
    # Join line segments to create domain boundary.
    c = CurveLoop(l01, l12, l23, l30)
    # surface
    rec = PlaneSurface(c)

    #############################################EXPORTING MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d = Design(dim=2, element_size=200 * m)
    # Add the subdomains and flux boundaries.
    d.addItems(rec, PropertySet("linebottom", l12))
    d.addItems(l01, l23, l30)  # just in case we need them
    #############################################MAKE THE DOMAIN
    domain = MakeDomain(d, optimizeLabeling=True)
    print("Domain has been generated ...")
    ##############################################################SOLVE PDE
    mypde = LinearPDE(domain)
    mypde.getSolverOptions().setVerbosityOn()
    mypde.setSymmetryOn()
    mypde.setValue(A=kappa * kronecker(domain))
    x = Solution(domain).getX()
    mypde.setValue(q=whereZero(x[1] - sup(x[1])), r=Ttop)
    qS = Scalar(0, FunctionOnBoundary(domain))
    qS.setTaggedValue("linebottom", qin)
    mypde.setValue(y=-qS)
    print("PDE has been generated ...")
Exemplo n.º 22
0
l01=Line(p0,p1)
l13=Line(p1,p3)
l32=Line(p3,p2)
l20=Line(p2,p0)

l45=Line(p4,p5)
l57=Line(p5,p7)
l76=Line(p7,p6)
l64=Line(p6,p4)

l15=Line(p1,p5)
l40=Line(p4,p0)
l37=Line(p3,p7)
l62=Line(p6,p2)

bottom=PlaneSurface(-CurveLoop(l01,l13,l32,l20))
top=PlaneSurface(CurveLoop(l45,l57,l76,l64))
front=PlaneSurface(CurveLoop(l01,l15,-l45,l40))
back=PlaneSurface(CurveLoop(l32,-l62,-l76,-l37))
left=PlaneSurface(CurveLoop(-l40,-l64,l62,l20))
right=PlaneSurface(CurveLoop(-l15,l13,l37,-l57))
v=Volume(SurfaceLoop(top,bottom,front,back,left,right))
des=Design(dim=3, order=2, element_size = 1, keep_files=True)
des.addItems(v)

dom=MakeDomain(des)
dom.write("brick.fly")



Exemplo n.º 23
0
    l12 = Line(p1, p2)
    # curve
    bblockloop = CurveLoop(bbl1, l12, bbl3, bbl4)

    # surface
    bblock = PlaneSurface(bblockloop)

    #clockwise check as splines must be set as polygons in the point order
    #they were created. Otherwise get a line across plot.
    bblockloop2 = CurveLoop(mysp, Line(x2, p2), Line(p2, p1), Line(p1, x1))

    ################################################CREATE MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d = Design(dim=2, element_size=dx, order=2)
    # Add the subdomains and flux boundaries.
    d.addItems(PropertySet("top",tblock),PropertySet("bottom",bblock),\
                                         PropertySet("linetop",l30))
    # Create the geometry, mesh and Escript domain
    d.setScriptFileName(os.path.join(save_path, "example08c.geo"))
    d.setMeshFileName(os.path.join(save_path, "example08c.msh"))
    domain = MakeDomain(d, optimizeLabeling=True)
    x = domain.getX()
    print("Domain has been generated ...")

    lam = Scalar(0, Function(domain))
    lam.setTaggedValue("top", lam1)
    lam.setTaggedValue("bottom", lam2)
    mu = Scalar(0, Function(domain))
    mu.setTaggedValue("top", mu1)
    mu.setTaggedValue("bottom", mu2)
    rho = Scalar(0, Function(domain))
    rho.setTaggedValue("top", rho1)
Exemplo n.º 24
0
__copyright__="""Copyright (c) 2003-2016 by The University of Queensland
http://www.uq.edu.au
Primary Business: Queensland, Australia"""
__license__="""Licensed under the Apache License, version 2.0
http://www.apache.org/licenses/LICENSE-2.0"""
__url__="https://launchpad.net/escript-finley"

from esys.escript import *
from esys.pycad import *
from esys.pycad.gmsh import Design
from esys.finley import MakeDomain


p0=Point(0.,0.)
p1=Point(1.,0.)
p2=Point(1.,1.)
p3=Point(0.,1.)

l01=Line(p0,p1)
l12=Line(p1,p2)
l23=Line(p2,p3)
l30=Line(p3,p0)

s=PlaneSurface(CurveLoop(l01,l12,l23,l30))
des=Design(dim=2, order=1, element_size = 1, keep_files=True)
des.setMeshFileName("rec.geo")
des.addItems(s)

dom=MakeDomain(des)
dom.write("rec.fly")
Exemplo n.º 25
0
if DIM ==2 :
  if (DEPTH*cos(DIP) > 0.9 * LX):
      raise ValueError("X edge to short (maybe DIP to large.)")

  p0=Point(DEPTH*cos(DIP),-DEPTH)
  p1=Point(LX,-DEPTH)
  p2=Point(LX,0.)
  p3=Point(0.,0.)

  l01=Line(p0,p1)
  l12=Line(p1,p2)
  l23=Line(p2,p3)
  l30=Line(p3,p0)
  s=PlaneSurface(CurveLoop(l01,l12,l23,l30))
  des.addItems(s, PropertySet("subduction",l30))

else: 

  if (DEPTH*cos(DIP) > 0.9 * LX):
      raise ValueError("X edge to short (maybe DIP to large.)")
  if (DEPTH*cos(DIP)+LY*sin(STRIKE) > 0.9 * LX):
      raise ValueError("X edge to short (maybe DIP to large.)")
  if (LY*sin(STRIKE) > 0.9 * LX):
      raise ValueError("X edge to short (maybe DIP to large.)")

 
  p0=Point(DEPTH*cos(DIP),0.,-DEPTH)
  p1=Point(LX,0.,-DEPTH)
  p2=Point(DEPTH*cos(DIP)+LY*sin(STRIKE),LY,-DEPTH)
  p3=Point(LX,LY,-DEPTH)
Exemplo n.º 26
0
l01 = Line(p0, p1)
l13 = Line(p1, p3)
l32 = Line(p3, p2)
l20 = Line(p2, p0)

l45 = Line(p4, p5)
l57 = Line(p5, p7)
l76 = Line(p7, p6)
l64 = Line(p6, p4)

l15 = Line(p1, p5)
l40 = Line(p4, p0)
l37 = Line(p3, p7)
l62 = Line(p6, p2)

bottom = PlaneSurface(-CurveLoop(l01, l13, l32, l20))
top = PlaneSurface(CurveLoop(l45, l57, l76, l64))
front = PlaneSurface(CurveLoop(l01, l15, -l45, l40))
back = PlaneSurface(CurveLoop(l32, -l62, -l76, -l37))
left = PlaneSurface(CurveLoop(-l40, -l64, l62, l20))
right = PlaneSurface(CurveLoop(-l15, l13, l37, -l57))
v = Volume(SurfaceLoop(top, bottom, front, back, left, right))

des = Design(dim=3, order=2, element_size=0.1, keep_files=True)
des.setScriptFileName("brick.geo")
des.addItems(v, top, bottom, back, front, left, right)

dom = MakeDomain(des)
dom.write("brick.fly")
Exemplo n.º 27
0
l12=Line(p1, p2)
l23=Line(p2, p3)
l30=Line(p3, p0)
c=CurveLoop(l01, l12, l23, l30)

# A small triangular cutout
x0=Point(0.1, 0.1, 0.0)
x1=Point(0.5, 0.1, 0.0)
x2=Point(0.5, 0.2, 0.0)
x01=Line(x0, x1)
x12=Line(x1, x2)
x20=Line(x2, x0)
cutout=CurveLoop(x01, x12, x20)

# Create the surface with cutout
s=PlaneSurface(c, holes=[cutout])

# Create a Design which can make the mesh
d=Design(dim=2, element_size=0.05)

# Add the trapezoid with cutout
d.addItems(s)

# Create the geometry, mesh and Escript domain
d.setScriptFileName("trapezoid.geo")
d.setMeshFileName("trapezoid.msh")
domain=MakeDomain(d, integrationOrder=-1, reducedIntegrationOrder=-1, optimizeLabeling=True)

# Create a file that can be read back in to python with 
domain.write("trapezoid.fly")
Exemplo n.º 28
0
    p7 = Point(xshift, zdepth + zshift)
    # Join corners in anti-clockwise manner.
    l45 = Line(p4, p5)
    l56 = Line(p5, p6)
    l67 = Line(p6, p7)
    l74 = Line(p7, p4)

    csmall = CurveLoop(l45, l56, l67, l74)

    ssmall = PlaneSurface(csmall)
    sbig = PlaneSurface(cbig, holes=[csmall])

    #############################################EXPORTING MESH FOR ESCRIPT
    # Design the geometry for the big mesh.
    d1 = Design(dim=2, element_size=bele_size, order=1)
    d1.addItems(sbig)
    d1.addItems(PropertySet(l01, l12, l23, l30))
    d1.setScriptFileName(os.path.join(save_path, "example10m_big.geo"))
    MakeDomain(d1)

    # Design the geometry for the small mesh.
    d2 = Design(dim=2, element_size=sele_size, order=1)
    d2.addItems(ssmall)
    d2.setScriptFileName(os.path.join(save_path, "example10m_small.geo"))
    MakeDomain(d2)

    # Join the two meshes using Gmsh and then apply a 2D meshing algorithm.
    # The small mesh must come before the big mesh in the merging call!!@!!@!
    sp.call("gmsh -2 " + os.path.join(save_path, "example10m_small.geo") +
            " " + os.path.join(save_path, "example10m_big.geo") + " -o " +
            os.path.join(save_path, "example10m.msh"),
Exemplo n.º 29
0
    l12 = Line(p1, p2)
    # curve
    bblockloop = CurveLoop(bbl1, l12, bbl3, bbl4)

    # surface
    bblock = PlaneSurface(bblockloop)

    # clockwise check as splines must be set as polygons in the point order
    # they were created. Otherwise get a line across plot.
    bblockloop2 = CurveLoop(mysp, Line(x2, p2), Line(p2, p1), Line(p1, x1))

    ################################################CREATE MESH FOR ESCRIPT
    # Create a Design which can make the mesh
    d = Design(dim=2, element_size=dx, order=2)
    # Add the subdomains and flux boundaries.
    d.addItems(PropertySet("top", tblock), PropertySet("bottom", bblock), PropertySet("linetop", l30))
    # Create the geometry, mesh and Escript domain
    d.setScriptFileName(os.path.join(save_path, "example08c.geo"))
    d.setMeshFileName(os.path.join(save_path, "example08c.msh"))
    domain = MakeDomain(d, optimizeLabeling=True)
    x = domain.getX()
    print("Domain has been generated ...")

    lam = Scalar(0, Function(domain))
    lam.setTaggedValue("top", lam1)
    lam.setTaggedValue("bottom", lam2)
    mu = Scalar(0, Function(domain))
    mu.setTaggedValue("top", mu1)
    mu.setTaggedValue("bottom", mu2)
    rho = Scalar(0, Function(domain))
    rho.setTaggedValue("top", rho1)
Exemplo n.º 30
0
l32=Line(p3,p2)
l20=Line(p2,p0)

l45=Line(p4,p5)
l57=Line(p5,p7)
l76=Line(p7,p6)
l64=Line(p6,p4)

l15=Line(p1,p5)
l40=Line(p4,p0)
l37=Line(p3,p7)
l62=Line(p6,p2)

bottom=PlaneSurface(-CurveLoop(l01,l13,l32,l20))
top=PlaneSurface(CurveLoop(l45,l57,l76,l64))
front=PlaneSurface(CurveLoop(l01,l15,-l45,l40))
back=PlaneSurface(CurveLoop(l32,-l62,-l76,-l37))
left=PlaneSurface(CurveLoop(-l40,-l64,l62,l20))
right=PlaneSurface(CurveLoop(-l15,l13,l37,-l57))
v=Volume(SurfaceLoop(top,bottom,front,back,left,right))
des=Design(dim=3, order=2, element_size = 1, keep_files=True)
des.addItems(PropertySet("V",v), PropertySet("bottom",bottom))
des.setScriptFileName("dom.geo")
des.setMeshFileName("dom.msh")

dom=MakeDomain(des)
dom.write("brick.fly")