Example #1
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")
Example #2
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")
Example #3
0
if getMPISizeWorld() > 1:
    import sys
    print("This example will not run in an MPI world.")
    sys.exit(0)

if HAVE_FINLEY:
    # make sure path exists 
    save_path= os.path.join("data","example11") 
    mkDir(save_path)

    ################################################ESTABLISHING PARAMETERS
    #Model Parameters
    xwidth=500.0   #x width of model
    ywidth=500.0   #y width of model
    depth=250.0   #depth of model
    element_size=5.0

    intfaces=[50,100,200,250]

    #Specify the domain.
    domaindes=Design(dim=3,element_size=element_size,order=1)
    cmplx_domain=layer_cake(domaindes,xwidth,ywidth,intfaces)
    cmplx_domain.setScriptFileName(os.path.join(save_path,"example11lc.geo"))
    cmplx_domain.setMeshFileName(os.path.join(save_path,"example11lc.msh"))
    dcmplx=MakeDomain(cmplx_domain)
    dcmplx.write(os.path.join(save_path,"example11lc.fly"))




    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)
    rho.setTaggedValue("bottom", rho2)

    ##########################################################ESTABLISH PDE
    mypde = LinearPDE(domain)  # create pde
Example #5
0
    #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"))





    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.addItems(v, PropertySet("subduction", left))

des.setScriptFileName("sub.geo")
des.setMeshFileName("sub.msh")

dom = MakeDomain(des, useMacroElements=True)
dom.write("sub.fly")
Example #7
0
    # 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"))

    if testing:
        intfaces=np.array([10,30,50,55,80,100,200,250,400])/100.
    else:
        intfaces=np.array([10,30,50,55,80,100,200,250,400])/10.

    # Specify the domain.
    domaindes=Design(dim=3,element_size=element_size,order=2)
    cmplx_domain=layer_cake(domaindes,xwidth,ywidth,intfaces)
    cmplx_domain.setScriptFileName(os.path.join(save_path,"example09lc.geo"))
    cmplx_domain.setMeshFileName(os.path.join(save_path,"example09lc.msh"))
    if testing:
    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"))

Example #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")
Example #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")
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
Example #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"))

    #############################################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.
    #
    d.setMeshFileName(os.path.join(save_path, "example04.msh"))
    #
    #  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, "example04.fly"))
    # 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"))

    if testing:
        intfaces=np.array([10,30,50,55,80,100,200,250,400])/100.
    else:
        intfaces=np.array([10,30,50,55,80,100,200,250,400])/10.

    # Specify the domain.
    domaindes=Design(dim=3,element_size=element_size,order=2)
    cmplx_domain=layer_cake(domaindes,xwidth,ywidth,intfaces)
    cmplx_domain.setScriptFileName(os.path.join(save_path,"example09lc.geo"))
    cmplx_domain.setMeshFileName(os.path.join(save_path,"example09lc.msh"))
    if testing:
except ImportError:
    print("Finley module not available")
    HAVE_FINLEY = False
########################################################MPI WORLD CHECK
if getMPISizeWorld() > 1:
    import sys
    print("This example will not run in an MPI world.")
    sys.exit(0)

if HAVE_FINLEY:
    # make sure path exists
    save_path = os.path.join("data", "example11")
    mkDir(save_path)

    ################################################ESTABLISHING PARAMETERS
    #Model Parameters
    xwidth = 500.0  #x width of model
    ywidth = 500.0  #y width of model
    depth = 250.0  #depth of model
    element_size = 5.0

    intfaces = [50, 100, 200, 250]

    #Specify the domain.
    domaindes = Design(dim=3, element_size=element_size, order=1)
    cmplx_domain = layer_cake(domaindes, xwidth, ywidth, intfaces)
    cmplx_domain.setScriptFileName(os.path.join(save_path, "example11lc.geo"))
    cmplx_domain.setMeshFileName(os.path.join(save_path, "example11lc.msh"))
    dcmplx = MakeDomain(cmplx_domain)
    dcmplx.write(os.path.join(save_path, "example11lc.fly"))
Example #16
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")
    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"),
            shell=True)
Example #18
0
: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")
    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
    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))
Example #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")
Example #21
0
    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 ...")
    ###########################################################GET SOLUTION
    T = mypde.getSolution()
    print("PDE has been solved  ...")
Example #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.addItems(v, PropertySet("subduction", left))

des.setScriptFileName("sub.geo")
des.setMeshFileName("sub.msh")

dom=MakeDomain(des, useMacroElements=True)
dom.write("sub.fly")
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")
Example #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")
Example #25
0
    # 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)
    rho.setTaggedValue("bottom", rho2)

    ##########################################################ESTABLISH PDE
    mypde = LinearPDE(domain)  # create pde
Example #26
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")