예제 #1
0
def test_volmesh_data():

    # if not os.path.exists("temp"):
    #     os.mkdir("temp")

    vmesh1 = VolMesh.from_obj(compas.get('boxes.obj'))

    data1 = vmesh1.to_data()

    # vmesh1.to_json('temp/vmesh1.json')
    # vmesh1.from_json('temp/vmesh1.json')

    # vmesh1.validate_data()
    # vmesh1.validate_json()

    data1_ = vmesh1.to_data()

    assert data1 == data1_

    vmesh2 = VolMesh.from_data(data1_)

    # vmesh2.validate_data()
    # vmesh2.validate_json()

    data2 = vmesh2.to_data()

    # vmesh2.to_json('temp/vmesh2.json')
    # vmesh2.from_json('temp/vmesh2.json')

    data2_ = vmesh2.to_data()

    assert data2 == data2_

    assert data1 == data2
예제 #2
0
def test_json_volmesh():
    before = VolMesh.from_vertices_and_cells(
        [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 1], [1, 0, 1],
         [1, 1, 1], [0, 1, 1]], [[[0, 1, 5, 4], [1, 2, 5, 6], [2, 3, 7, 6],
                                  [3, 0, 4, 7], [4, 5, 6, 7], [0, 3, 2, 1]]])
    after = compas.json_loads(compas.json_dumps(before))
    assert before.dtype == after.dtype
    assert before.attributes == after.attributes
    assert all(before.has_vertex(vertex) for vertex in after.vertices())
    assert all(after.has_vertex(vertex) for vertex in before.vertices())
예제 #3
0
def volmesh_from_ansys_results(output_path, name):
    output_path = os.path.join(output_path, name + '_output')
    nodes, elements = get_nodes_elements_from_result_files(output_path)
    nkeys = sorted(nodes.keys(), key=int)
    vertices = [[nodes[k]['x'], nodes[k]['y'], nodes[k]['z']] for k in nkeys]
    ckeys = sorted(elements.keys(), key=int)
    cells = []
    for ck in ckeys:
        i, j, k, l, m, n, o, p = elements[ck]['nodes']
        if k == l:
            cells.append([[i, j, k], [i, j, m], [j, k, m], [k, i, m]])
        else:
            cells.append([[i, j, k, l], [i, j, n, m], [j, k, o, n],
                          [k, l, p, o], [l, i, m, p], [m, n, o, p]])

    mesh = VolMesh.from_vertices_and_cells(vertices, cells)
    return mesh
예제 #4
0
#    from compas.geometry import centroid_points
#    rs.AddPoint(centroid_points([a, b, c, d]))
#    # sphere centre
#rs.EnableRedraw(True)

cells = []
for a, b, c, d in simplices:
    #print a, b, c, d
    halffaces = [[a, b, c], [a, b, d], [a, c, d], [b, c, d]]
    cells.append(halffaces)
    #halffaces.append([a, b, c])
    #halffaces.append([c, b, a])
    #halffaces.append([a, b, d])
    #halffaces.append([d, b, a])
    #halffaces.append([a, c, d])
    #halffaces.append([d, c, a])
    #halffaces.append([b, c, d])
    #halffaces.append([d, c, d])

from compas.datastructures import VolMesh

volmesh = VolMesh.from_vertices_and_cells(points, cells)

print volmesh.cells()

#rs.EnableRedraw(False)
#for u, v in volmesh.edges():
#    u = volmesh.vertex_coordinates(u)
#    v = volmesh.vertex_coordinates(v)
#    rs.AddLine(u, v)
#rs.EnableRedraw(True)
예제 #5
0
    def clear(self):

        self.clear_vertices()
        self.clear_faces()
        self.clear_edges()


# ==============================================================================
# Main
# ==============================================================================

if __name__ == "__main__":

    import compas

    from compas.datastructures import VolMesh

    volmesh = VolMesh.from_obj(compas.get('boxes.obj'))

    artist = VolMeshArtist(volmesh, layer='VolMeshArtist')

    # artist.clear_layer()

    artist.draw_vertices()
    artist.draw_vertexlabels()
    # artist.clear_vertexlabels()

    artist.draw_edges()
    artist.draw_edgelabels()
    # artist.clear_edgelabels()
from compas.datastructures import VolMesh

from compas_fea.structure import Structure
from compas_fea.structure import FixedDisplacement
from compas_fea.structure import SolidSection
from compas_fea.structure import ElasticIsotropic
from compas_fea.structure import ElementProperties
from compas_fea.structure import GravityLoad
from compas_fea.structure import GeneralStep

# Author(s): Tomás Méndez Echenagucia (github.com/tmsmendez)

# get mesh from json file ------------------------------------------------------

filepath = compas_fea.get('volmesh_torus.json')
volmesh = VolMesh.from_json(filepath)

# add shell elements from mesh -------------------------------------------------
s = Structure(path=compas_fea.TEMP, name='torus')
s.add_nodes_elements_from_volmesh(volmesh, elset='solids')

# add supports --------------------------------------------------------------

nkeys = list(volmesh.vertices_where({'z': 0}))
s.add_set(name='support_nodes', type='NODE', selection=nkeys)
supppots = FixedDisplacement(name='supports', nodes='support_nodes')
s.add_displacement(supppots)

# add materials and sections -----------------------------------------------
E = 35 * 10**9
v = .02