Exemplo n.º 1
0
    def build_mesh(self):
        self.length = 100
        self.height = 100

        plate = mshr.Rectangle(fe.Point(0, 0),
                               fe.Point(self.length, self.height))
        notch = mshr.Polygon([
            fe.Point(0, self.height / 2 + 1),
            fe.Point(0, self.height / 2 - 1),
            fe.Point(6, self.height / 2)
        ])
        notch = mshr.Polygon([
            fe.Point(0, self.height / 2 + 1e-10),
            fe.Point(0, self.height / 2 - 1e-10),
            fe.Point(self.length / 2, self.height / 2)
        ])
        # notch = mshr.Polygon([fe.Point(self.length / 4, self.height / 2), fe.Point(self.length / 2, self.height / 2 - 1e-10), \
        #                       fe.Point(self.length * 3 / 4, self.height / 2), fe.Point(self.length / 2, self.height / 2 + 1e-10)])
        self.mesh = mshr.generate_mesh(plate - notch, 50)

        # self.mesh = da.RectangleMesh(fe.Point(0, 0), fe.Point(self.length, self.height), 40, 40, diagonal="crossed")

        length = self.length
        height = self.height

        class Lower(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[1], 0)

        class Upper(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[1], height)

        class Corner(fe.SubDomain):
            def inside(self, x, on_boundary):
                return fe.near(x[0], 0) and fe.near(x[1], 0)

        class Left(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[0], 0)

        class Right(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[0], length)

        class Notch(fe.SubDomain):
            def inside(self, x, on_boundary):
                return fe.near(x[1], height / 2) and x[0] < length / 20

        self.lower = Lower()
        self.upper = Upper()
        self.corner = Corner()

        self.left = Left()
        self.right = Right()
        self.notch = Notch()
Exemplo n.º 2
0
def mesh_Triangle(n=10):
    dom = mshr.Polygon(
        [Point(0., -1.),
         Point(sqrt(3) / 2, 1. / 2),
         Point(-sqrt(3) / 2, 1. / 2)])
    mesh = mshr.generate_mesh(dom, n, "cgal")
    return mesh
Exemplo n.º 3
0
    def create_coronal_section_mesh(self, model_z_n=0):

        brain_slice = self.image_manipulation_obj.\
                get_brain_slice_from_model_z_n(model_z_n)

        x_size = 65
        self.boundary_points = brain_slice.\
                generate_boundary_points_ccw(x_size)
        domain_vertices = []

        for x, y in zip(self.boundary_points[0], self.boundary_points[1]):
            domain_vertices.append(fe.Point(x, y))

        self.geometry = mesher.Polygon(domain_vertices)
        self.mesh = mesher.generate_mesh(self.geometry, 16)

        self.compute_mesh_volume()
        self.original_volume = self.mesh_volume
        print('Original volume', self.original_volume)
        self.generate_holes()
        #self.compute_hole_fractional_volume()
        self.puncture_mesh()
        self.compute_mesh_volume()
        domain_volume = self.mesh_volume
        print('New volume', domain_volume)
        self.hole_fractional_volume = 1 - domain_volume / self.original_volume
        print('Hole fractional volume:', self.hole_fractional_volume)
        print('# holes:', self.n_holes)
        print('Estimated hole fractional volume:',\
                self.compute_hole_fractional_volume())
Exemplo n.º 4
0
    def build_mesh(self):
        self.length = 100
        self.height = 100

        plate = mshr.Rectangle(fe.Point(0, 0),
                               fe.Point(self.length, self.height))
        notch = mshr.Polygon([
            fe.Point(0, self.height / 2 + 1),
            fe.Point(0, self.height / 2 - 1),
            fe.Point(6, self.height / 2)
        ])
        self.mesh = mshr.generate_mesh(plate - notch, 30)

        length = self.length
        height = self.height

        class Lower(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[1], 0)

        class Upper(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[1], height)

        class Corner(fe.SubDomain):
            def inside(self, x, on_boundary):
                return fe.near(x[0], 0) and fe.near(x[1], 0)

        self.lower = Lower()
        self.upper = Upper()
        self.corner = Corner()
Exemplo n.º 5
0
    def build_mesh(self):
        self.length = 8.
        self.height = 2.
        self.notch_length = 0.2
        self.notch_height = 0.4

        domain = mshr.Polygon([fe.Point(0., 0.), 
                  fe.Point(self.length/2. - self.notch_length/2., 0.),
                  fe.Point(self.length/2., self.notch_height),
                  fe.Point(self.length/2. + self.notch_length/2., 0.),
                  fe.Point(self.length, 0.),
                  fe.Point(self.length, self.height),
                  fe.Point(self.length/2. + self.notch_length/2., self.height),
                  fe.Point(self.length/2., self.height),
                  fe.Point(self.length/2. - self.notch_length/2., self.height),
                  fe.Point(0., self.height)])

        # resolution = 100 if self.local_refinement_iteration == 0 else 200
        # self.mesh = mshr.generate_mesh(domain, resolution)

        self.mesh = mshr.generate_mesh(domain, 100)
        for i in range(self.local_refinement_iteration):
            cell_markers = fe.MeshFunction('bool', self.mesh, self.mesh.topology().dim())
            cell_markers.set_all(False)
            for cell in fe.cells(self.mesh):
                p = cell.midpoint()
                if  p[0] > 14./32.*self.length and p[0] < 18./32.*self.length and p[1] < self.height - self.notch_height:
                    cell_markers[cell] = True
            self.mesh = fe.refine(self.mesh, cell_markers)

        length = self.length
        height = self.height
        notch_length = self.notch_length

        class Upper(fe.SubDomain):
            def inside(self, x, on_boundary):
                # return on_boundary
                return on_boundary and fe.near(x[1], height) 


        class LeftCorner(fe.SubDomain):
            def inside(self, x, on_boundary):
                return fe.near(x[0], 0.) and fe.near(x[1], 0.)

        class RightCorner(fe.SubDomain):
            def inside(self, x, on_boundary):
                return fe.near(x[0], length) and fe.near(x[1], 0.)

        class MiddlePoint(fe.SubDomain):
            def inside(self, x, on_boundary):                    
                # return fe.near(x[0], length/2.) and fe.near(x[1], height)
                return x[0] > length/2. - notch_length/2.  and  x[0] < length/2. + notch_length/2. and fe.near(x[1], height)

        self.upper = Upper()
        self.left = LeftCorner()
        self.right = RightCorner()
        self.middle = MiddlePoint()
Exemplo n.º 6
0
def generate_blade_domain():
    path = os.path.abspath(os.path.dirname(__file__))
    data = io.loadmat(os.path.join(path, 'data', 'blade_geometry.mat'))
    bedge = data['bedge']
    xy = data['xy']
    points, bndry = [], []
    for ii in range(bedge.shape[1]):
        kn1 = bedge[0, ii] - 1
        kn2 = bedge[1, ii] - 1
        points.append(xy[:, kn1])
        points.append(xy[:, kn2])
        bndry.append(bedge[2, ii])
        bndry.append(bedge[2, ii])
    points = np.asarray(points).T
    bndry = np.asarray(bndry)

    coords = points[:, bndry == 0]
    sorted_coords, center = sort_points_in_anti_clockwise_order(coords)
    vertices = numpy_to_dolfin_points(sorted_coords)
    airfoil_domain = mshr.Polygon(vertices)
    cooling_domains = []
    domain = airfoil_domain
    for ii in range(1, 3):
        coords = points[:, bndry == ii]
        sorted_coords, center = sort_points_in_anti_clockwise_order(coords)
        vertices = numpy_to_dolfin_points(sorted_coords)
        cooling_domains.append(mshr.Polygon(vertices))
        domain -= cooling_domains[-1]
    # last cooling domain requires special treatment
    coords = points[:, bndry == 3]
    coords = coords[:, (coords[0] >= 0.45) & (coords[0] <= 0.7)]
    sorted_coords, center = sort_points_in_anti_clockwise_order(coords)
    vertices = numpy_to_dolfin_points(sorted_coords)
    cooling_domains.append(mshr.Polygon(vertices))
    domain -= cooling_domains[-1]

    coords = points[:, bndry == 3]
    coords = coords[:, (np.absolute(coords[1]) <= 0.01) & (coords[0] >= 0.7)]
    sorted_coords, center = sort_points_in_anti_clockwise_order(coords)
    vertices = numpy_to_dolfin_points(sorted_coords)
    cooling_domains.append(mshr.Polygon(vertices))
    domain -= cooling_domains[-1]

    return domain
Exemplo n.º 7
0
    def create_coronal_section_mesh(self, model_z_n = 0):

        brain_slice = self.image_manipulation_obj.\
                get_brain_slice_from_model_z_n(model_z_n)

        x_size = 65
        self.boundary_points = brain_slice.\
                generate_boundary_points_ccw(x_size)
        domain_vertices = []

        for x,y in zip(self.boundary_points[0], self.boundary_points[1]):
            domain_vertices.append(fe.Point(x,y))

        geo         = mesher.Polygon(domain_vertices)
        self.mesh   = mesher.generate_mesh(geo, self.mesh_density);
Exemplo n.º 8
0
def irregular_channel():
    radius = 0.35
    resolution = 25
    point_A = fa.Point(0, 0)
    point_B = fa.Point(2, -1)
    point_C = fa.Point(2, 2)
    point_D = fa.Point(0, 1)
    point_E = fa.Point(0.5, 0.5)
    point_F = fa.Point(1.5, 1)
    point_G = fa.Point(1.5, 0)
    outline = mshr.Polygon([point_A, point_B, point_C, point_D])
    circle_1 = mshr.Circle(point_E, radius)
    circle_2 = mshr.Circle(point_F, radius)
    circle_3 = mshr.Circle(point_G, radius)
    mesh = mshr.generate_mesh(outline - circle_1 - circle_2 - circle_3,
                              resolution)
    return mesh
Exemplo n.º 9
0
    def create_coronal_section_mesh(self, experimental_z_n=0):


        brain_slice = self.image_manipulation_obj.\
                get_brain_slice_from_experimental_z_n(experimental_z_n)

        #get_brain_slice_from_experimental_z_mm(0)

        x_size = 65
        points = brain_slice.\
                generate_boundary_points_ccw(x_size)
        domain_vertices = []

        for x, y in zip(points[0], points[1]):
            domain_vertices.append(fe.Point(x, y))

        geo = mesher.Polygon(domain_vertices)
        self.mesh = mesher.generate_mesh(geo, 64)
Exemplo n.º 10
0
def create_toy_mesh():

    box = mshr.Box(dolfin.Point(-3, -1, -0.5), dolfin.Point(3, 1, 0.5))

    c1 = mshr.Cylinder(dolfin.Point(0, 0, -2), dolfin.Point(0, 0, 2), 0.6, 0.6)
    b1 = mshr.Box(dolfin.Point(-2.5, -0.5, -2), dolfin.Point(-1.5, 0.5, 2))

    # "triangle"
    t1 = mshr.Polygon([
        dolfin.Point(2.5, -0.5, 0),
        dolfin.Point(2.5, 0.5, 0),
        dolfin.Point(1.5, -0.5, 0),
    ])
    g3d = mshr.Extrude2D(t1, -2)
    g3d = mshr.CSGTranslation(g3d, dolfin.Point(0, 0, 1))

    m = mshr.generate_mesh(box - c1 - b1 - g3d, 40, "cgal")

    return m.coordinates(), m.cells()
Exemplo n.º 11
0
    def build_mesh(self):
        self.length = 1.
        self.height = 1.

        plate = mshr.Rectangle(fe.Point(0, 0),
                               fe.Point(self.length, self.height))
        notch = mshr.Polygon([
            fe.Point(0, self.height / 2 + 1e-10),
            fe.Point(0, self.height / 2 - 1e-10),
            fe.Point(self.length / 2, self.height / 2)
        ])

        resolution = 50 * np.power(2, self.local_refinement_iteration)
        self.mesh = mshr.generate_mesh(plate - notch, resolution)

        length = self.length
        height = self.height

        class Lower(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[1], 0)

        class Upper(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[1], height)

        class Left(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[0], 0)

        class Right(fe.SubDomain):
            def inside(self, x, on_boundary):
                return on_boundary and fe.near(x[0], length)

        class Corner(fe.SubDomain):
            def inside(self, x, on_boundary):
                return fe.near(x[0], 0) and fe.near(x[1], 0)

        self.lower = Lower()
        self.upper = Upper()
        self.corner = Corner()
        self.left = Left()
        self.right = Right()
Exemplo n.º 12
0
def generate_polygonal_mesh(resolution,
                            ampothem,
                            nedges,
                            radius,
                            plot_mesh=False):
    """
    Sometimes segault is thrown when mshr.generate_mesh() is 
    called. This is because resolution is to low to resolve
    smaller inner-most circle.
    """
    import mshr
    vertices = get_vertices_of_polygon(ampothem, nedges)

    domain_vertices = []
    for vertex in vertices.T:
        domain_vertices.append(dl.Point(vertex[0], vertex[1]))

    domain = mshr.Polygon(domain_vertices)

    cx1, cy1 = 0.0, 0.0
    circle1 = mshr.Circle(dl.Point(cx1, cy1), radius)
    domain.set_subdomain(1, circle1)
    cx2, cy2 = cx1 - radius / np.sqrt(8), cy1 - radius / np.sqrt(8)
    circle2 = mshr.Circle(dl.Point(cx2, cy2), radius / 2)
    domain.set_subdomain(2, circle2)
    mesh = mshr.generate_mesh(domain, resolution)

    if plot_mesh:
        subdomains = dl.MeshFunction('size_t', mesh, mesh.topology().dim(), 2)
        subdomains.set_all(0)
        subdomain1 = dl.AutoSubDomain(lambda x: np.sqrt(
            (x[0] - cx1)**2 + (x[1] - cy1)**2) < radius + 1e-8)
        subdomain1.mark(subdomains, 1)
        subdomain2 = dl.AutoSubDomain(lambda x: np.sqrt(
            (x[0] - cx2)**2 + (x[1] - cy2)**2) < radius / 2 + 1e-8)
        subdomain2.mark(subdomains, 2)
        dl.plot(mesh)
        dl.plot(subdomains)
        plt.show()

    return mesh
Exemplo n.º 13
0
    def __init__(self, mesh_resolution, polynomial_degree, adjust, L1, L2, h1,
                 h2, b):

        self.L1 = L1
        self.L2 = L2
        self.h1 = h1
        self.h2 = h2
        self.b = b

        p1 = Point(0., 0.)
        p2 = Point(L1, h1)
        p3 = Point(L1 + b, h1)
        p4 = Point(L1, 0.)

        domain1 = mshr.Rectangle(p1, p2) + mshr.Polygon([p4, p3, p2])

        p5 = Point(L1, -(h2 - h1))
        p6 = Point(L1 + L2, h1)

        domain2 = mshr.Rectangle(p5, p6)
        domain = domain1 + domain2

        self.insides = LShapedOverlap(self.L1, self.h1, self.b)
        self.outsides = OnBoundary()
        self.left_dirichlet = LShapedLeftDirichlet(self.h1)
        self.left_robin = LShapedLeftRobin(self.L1, self.h1, self.b)
        self.right_dirichlet = LShapedRightDirichlet(self.L1, self.L2, self.h1,
                                                     self.h2)
        self.right_robin = LShapedRightRobin(self.L1, self.h1, self.b)
        boundaries = list([
            self.insides, self.outsides, self.left_dirichlet, self.left_robin,
            self.right_dirichlet, self.right_robin
        ])

        Membrane.__init__(self, domain, domain1, domain2, mesh_resolution,
                          boundaries, polynomial_degree, adjust)
Exemplo n.º 14
0
def method(L=6., H=2., R=0.3, n_segments=40, res=120, **kwargs):
    """
    Generates barbell capilar with rounded edges.
    """
    info("Generating mesh of rounded barbell capilar")
    
    pt_1 = df.Point(0., 0.)
    pt_1star = df.Point(1., 0.)
    pt_1starstar = df.Point(L/(2*res), 0.)
    pt_2 = df.Point(L, H)
    pt_2star = df.Point(L-1., H)
    pt_2starstar = df.Point(L-L/(2*res), H)
    pt_3 = df.Point(1., H)
    pt_3star = df.Point(0, H)
    pt_3starstar = df.Point(L/(2*res), H)
    pt_4 = df.Point(L-1., 0)
    pt_4star = df.Point(L, 0)
    pt_4starstar = df.Point(L-L/(2*res), 0)
    pt_5 = df.Point(1., R)
    pt_6 = df.Point(1., H-R)
    pt_7 = df.Point(L-1., R)
    pt_8 = df.Point(L-1., H-R)
    pt_9 = df.Point(1.+2*R, R)
    pt_10 = df.Point(1.+2*R, H-R)
    pt_11 = df.Point(L-2*R-1, R)
    pt_12 = df.Point(L-2*R-1, H-R)
    pt_13 = df.Point(1.+2*R, H-2*R)
    pt_14 = df.Point(L-2*R-1, 2*R)

    inlet_polygon = [pt_1]
    inlet_polygon.append(pt_1starstar)
    add_vertical_boundary_vertices(inlet_polygon, L/res, H, res, 1)
    inlet_polygon.append(pt_3starstar)
    inlet_polygon.append(pt_3star)
    add_vertical_boundary_vertices(inlet_polygon, 0.0, H, res, -1)
    inlet_polygon.append(pt_1)

    outlet_polygon = [pt_4starstar]
    outlet_polygon.append(pt_4star)
    add_vertical_boundary_vertices(outlet_polygon, L, H, res, 1)
    outlet_polygon.append(pt_2)
    outlet_polygon.append(pt_2starstar)
    add_vertical_boundary_vertices(outlet_polygon, L-L/res, H, res, -1)
    outlet_polygon.append(pt_4starstar)

    inlet1 = mshr.Polygon(inlet_polygon)
    inlet2 = mshr.Rectangle(pt_1starstar, pt_3)
    outlet1 = mshr.Polygon(outlet_polygon)
    outlet2 = mshr.Rectangle(pt_4, pt_2starstar)
    channel = mshr.Rectangle(pt_5, pt_8)
    pos_cir_1 = mshr.Circle(pt_5, R, segments=n_segments)
    pos_cir_2 = mshr.Circle(pt_6, R, segments=n_segments)
    pos_cir_3 = mshr.Circle(pt_7, R, segments=n_segments)
    pos_cir_4 = mshr.Circle(pt_8, R, segments=n_segments)
    neg_cir_1 = mshr.Circle(pt_9, R, segments=n_segments)
    neg_cir_2 = mshr.Circle(pt_10, R, segments=n_segments)
    neg_cir_3 = mshr.Circle(pt_11, R, segments=n_segments)
    neg_cir_4 = mshr.Circle(pt_12, R, segments=n_segments)
    neg_reg_1 = mshr.Rectangle(pt_13, pt_12)
    neg_reg_2 = mshr.Rectangle(pt_9, pt_14)

    domain = inlet1 + inlet2 + outlet1 + outlet2 + \
        channel + pos_cir_1 + pos_cir_2 + pos_cir_3 + \
        pos_cir_4 - neg_cir_1 - neg_cir_2 - neg_cir_3 - \
        neg_cir_4 - neg_reg_1 - neg_reg_2

    mesh = mshr.generate_mesh(domain, res)

    mesh_path = os.path.join(MESHES_DIR,
                             "roundet_barbell_res" + str(res))
    store_mesh_HDF5(mesh, mesh_path)
    df.plot(mesh)
    df.interactive()
Exemplo n.º 15
0
def method(L=6., H=2., R=0.3, n_segments=40, res=180, show=False, **kwargs):
    """
    Generates hourglass.
    """
    info("Generating mesh of an hourglass")

    pt_1 = df.Point(0., 0.)
    pt_1star = df.Point(2., 0.)
    pt_1starstar = df.Point(L/(2*res), 0.)
    pt_2 = df.Point(L, H)
    pt_2star = df.Point(L-2., H)
    pt_2starstar = df.Point(L-L/(2*res), H)
    pt_3 = df.Point(2., H)
    pt_3star = df.Point(0, H)
    pt_3starstar = df.Point(L/(2*res), H)
    pt_4 = df.Point(L-2., 0)
    pt_4star = df.Point(L, 0)
    pt_4starstar = df.Point(L-L/(2*res), 0)
    pt_5 = df.Point(2., R)
    pt_6 = df.Point(2., H-R)
    pt_7 = df.Point(L-2., R)
    pt_8 = df.Point(L-2., H-R)
    pt_9 = df.Point(2.+2*R, R)
    pt_10 = df.Point(2.+2*R, H-R)
    pt_11 = df.Point(L-2*R-2, R)
    pt_12 = df.Point(L-2*R-2, H-R)
    pt_13 = df.Point(2.+2*R, H-2*R)
    pt_14 = df.Point(L-2*R-2, 2*R)

    inlet_polygon = [pt_1]
    inlet_polygon.append(pt_1starstar)
    add_vertical_boundary_vertices(inlet_polygon, L/res, H, res, 1)
    inlet_polygon.append(pt_3starstar)
    inlet_polygon.append(pt_3star)
    add_vertical_boundary_vertices(inlet_polygon, 0.0, H, res, -1)
    inlet_polygon.append(pt_1)

    outlet_polygon = [pt_4starstar]
    outlet_polygon.append(pt_4star)
    add_vertical_boundary_vertices(outlet_polygon, L, H, res, 1)
    outlet_polygon.append(pt_2)
    outlet_polygon.append(pt_2starstar)
    add_vertical_boundary_vertices(outlet_polygon, L-L/res, H, res, -1)
    outlet_polygon.append(pt_4starstar)

    inlet1 = mshr.Polygon(inlet_polygon)
    inlet2 = mshr.Rectangle(pt_1starstar, pt_3)
    outlet1 = mshr.Polygon(outlet_polygon)
    outlet2 = mshr.Rectangle(pt_4, pt_2starstar)
    channel = mshr.Rectangle(pt_5, pt_8)
    pos_cir_1 = mshr.Circle(pt_5, R, segments=n_segments)
    pos_cir_2 = mshr.Circle(pt_6, R, segments=n_segments)
    pos_cir_3 = mshr.Circle(pt_7, R, segments=n_segments)
    pos_cir_4 = mshr.Circle(pt_8, R, segments=n_segments)
    neg_cir_1 = mshr.Circle(pt_9, R, segments=n_segments)
    neg_cir_2 = mshr.Circle(pt_10, R, segments=n_segments)
    neg_cir_3 = mshr.Circle(pt_11, R, segments=n_segments)
    neg_cir_4 = mshr.Circle(pt_12, R, segments=n_segments)
    neg_reg_1 = mshr.Rectangle(pt_13, pt_12)
    neg_reg_2 = mshr.Rectangle(pt_9, pt_14)

    domain = inlet1 + inlet2 + outlet1 + outlet2 + channel + \
        pos_cir_1 + pos_cir_2 + pos_cir_3 + pos_cir_4 - neg_cir_1 - \
        neg_cir_2 - neg_cir_3 - neg_cir_4 - neg_reg_1 - neg_reg_2

    mesh = mshr.generate_mesh(domain, res)

    mesh_path = os.path.join(MESHES_DIR,
                             "hourglass_res" + str(res))
    store_mesh_HDF5(mesh, mesh_path)
    if show:
        df.plot(mesh)
        plt.show()
Exemplo n.º 16
0
def generate_tower_mesh(quality=20):
    otri = mshr.Polygon([Point(0, 0), Point(1, 0), Point(0.5, 1)])
    itri = mshr.Polygon([Point(0.2, 0.0), Point(0.8, 0.0), Point(0.5, 0.75)])
    domain = otri - itri
    return mshr.generate_mesh(domain, quality)
Exemplo n.º 17
0
#Geometric Dimensions
t_sleeve = 0.188
t_wall = t_sleeve
t_gap = 0.02
L_sleeve = 10.0 * t_wall
L_wall = 1.5 * L_sleeve

#Build Geometry
domain_vertices = [
    Point(0, 0),
    Point(L_wall, 0),
    Point(L_wall, t_wall),
    Point(0, t_wall)
]
domain = mshr.Polygon(domain_vertices)
domain_vertices = [
    Point(L_wall - L_sleeve, t_wall),
    Point(L_wall - L_sleeve, t_wall + t_gap),
    Point(L_wall, t_wall + t_gap),
    Point(L_wall, t_wall + t_gap + t_sleeve),
    Point(L_wall - L_sleeve, t_wall + t_gap + t_sleeve),
    Point(L_wall - L_sleeve - t_gap - t_sleeve, t_wall)
]
domain = domain + mshr.Polygon(domain_vertices)

# Build Mesh, mesh resolution=higher numbers give more elements
mesh_resolution = 60
mesh = mshr.generate_mesh(domain, mesh_resolution)

#Build Function Space (FEM Space)
def build_pore_polygon(base_pore_points, offset):
    points = [
        fa.Point(p[0] + offset[0], p[1] + offset[1]) for p in base_pore_points
    ]
    pore = mshr.Polygon(points)
    return pore
Exemplo n.º 19
0
        width, height, tol = self.width, self.height, self.tol

        class PointLoad(SubDomain):
            """ Add a point load to the top center. """
            def inside(self, x, on_boundary):
                return near(x[0], width, tol) and near(x[1], height / 3., tol)

        return [PointLoad()], [Constant((0.0, -3e-1))]


if __name__ == "__main__":
    bc = LBracketBoundaryConditions(1, 1, 5e-2)

    # Create the mesh to solve linear elasticity on.
    large_quad = mshr.Polygon(
        [Point(0, 0), Point(1, 0),
         Point(1, 1), Point(0, 1)])
    small_quad = mshr.Polygon([
        Point(1 / 3., 1 / 3.),
        Point(1, 1 / 3.),
        Point(1, 1),
        Point(1 / 3., 1)
    ])
    domain = large_quad - small_quad
    mesh = mshr.generate_mesh(domain, 30)
    run_simulation(mesh, bc, "L-bracket/v100-")

    mesh = Mesh("meshes/L-bracket-v20.xml")
    scale_mesh(mesh, 1, 1)
    run_simulation(mesh, bc, "L-bracket/v20-")