def extrude_base_net(self): net = self.create_base_net() square_jump = 1/self.n_squares r = square_jump * self.square_fraction n_levels = 3 delta = self.L/(n_levels + 1) z_jump = np.array([0,0,delta]) p = np.zeros(3) geo = None p += z_jump for k in range(n_levels): if geo is None: geo = mesher.CSGTranslation(net, fe.Point(p)) else: geo += mesher.CSGTranslation(net, fe.Point(p)) p += z_jump print('Finished creating extruded mesh') return geo
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()