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")
    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))
    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
    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)
    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")
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"))
Esempio n. 7
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")
Esempio n. 8
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")
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
    # 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: