コード例 #1
0
def test_padded_bbox(padding):
    """
    Test collision between two meshes separated by a distance of epsilon,
    and check if padding the mesh creates a possible collision
    """
    eps = 1e-12
    x0 = numpy.array([0, 0, 0])
    x1 = numpy.array([1, 1, 1 - eps])
    mesh_0 = BoxMesh(MPI.COMM_WORLD, [x0, x1], [1, 1, 2], cpp.mesh.CellType.hexahedron)
    x2 = numpy.array([0, 0, 1 + eps])
    x3 = numpy.array([1, 1, 2])
    mesh_1 = BoxMesh(MPI.COMM_WORLD, [x2, x3], [1, 1, 2], cpp.mesh.CellType.hexahedron)
    if padding:
        pad = eps
    else:
        pad = 0
    bbox_0 = BoundingBoxTree(mesh_0, mesh_0.topology.dim, padding=pad)
    bbox_1 = BoundingBoxTree(mesh_1, mesh_1.topology.dim, padding=pad)
    collisions = compute_collisions(bbox_0, bbox_1)
    if padding:
        assert(len(collisions) == 1)
        # Check that the colliding elements are separated by a distance 2*epsilon
        element_0 = extract_geometricial_data(mesh_0, mesh_0.topology.dim, [collisions[0][0]])[0]
        element_1 = extract_geometricial_data(mesh_1, mesh_1.topology.dim, [collisions[0][1]])[0]
        distance = numpy.linalg.norm(cpp.geometry.compute_distance_gjk(element_0, element_1))
        assert(numpy.isclose(distance, 2 * eps))
    else:
        assert(len(collisions) == 0)
コード例 #2
0
    basis = VectorSpaceBasis(nullspace_basis)
    basis.orthonormalize()

    _x = [basis[i] for i in range(6)]
    nsp = PETSc.NullSpace()
    nsp.create(_x)
    return nsp


# Load mesh from file
# mesh = Mesh(MPI.comm_world)
# XDMFFile(MPI.comm_world, "../pulley.xdmf").read(mesh)

# mesh = UnitCubeMesh(2, 2, 2)
mesh = BoxMesh(MPI.comm_world,
               [np.array([0.0, 0.0, 0.0]),
                np.array([2.0, 1.0, 1.0])], [12, 12, 12], CellType.tetrahedron,
               dolfinx.cpp.mesh.GhostMode.none)
cmap = dolfinx.fem.create_coordinate_map(mesh.ufl_domain())
mesh.geometry.coord_mapping = cmap

# Function to mark inner surface of pulley
# def inner_surface(x, on_boundary):
#    r = 3.75 - x[2]*0.17
#    return (x[0]*x[0] + x[1]*x[1]) < r*r and on_boundary


def boundary(x):
    return np.logical_or(x[0] < 10.0 * np.finfo(float).eps,
                         x[0] > 1.0 - 10.0 * np.finfo(float).eps)

コード例 #3
0
def box():
    return BoxMesh(
        MPI.COMM_WORLD,
        [np.array([0, 0, 0]), np.array([2, 2, 2])], [2, 2, 5],
        CellType.tetrahedron, cpp.mesh.GhostMode.none)
コード例 #4
0
ファイル: demo_elasticity.py プロジェクト: chenminacm/dolfinx
    # Create vector space basis and orthogonalize
    basis = VectorSpaceBasis(nullspace_basis)
    basis.orthonormalize()

    _x = [basis[i] for i in range(6)]
    nsp = PETSc.NullSpace().create(vectors=_x)
    return nsp


# Load mesh from file
# mesh = Mesh(MPI.COMM_WORLD)
# XDMFFile(MPI.COMM_WORLD, "../pulley.xdmf").read(mesh)

# mesh = UnitCubeMesh(2, 2, 2)
mesh = BoxMesh(MPI.COMM_WORLD,
               [np.array([0.0, 0.0, 0.0]),
                np.array([2.0, 1.0, 1.0])], [12, 12, 12], CellType.tetrahedron,
               dolfinx.cpp.mesh.GhostMode.none)

# Function to mark inner surface of pulley
# def inner_surface(x, on_boundary):
#    r = 3.75 - x[2]*0.17
#    return (x[0]*x[0] + x[1]*x[1]) < r*r and on_boundary


def boundary(x):
    return np.logical_or(x[0] < 10.0 * np.finfo(float).eps,
                         x[0] > 1.0 - 10.0 * np.finfo(float).eps)


# Rotation rate and mass density
omega = 300.0