Beispiel #1
0
def sorted_nodes(nodeIDcoords):
    """create sorted nodes numpy array from nodes.dyn & elems.dyn

    :returns: sorted_nodes
    """
    from fem_mesh import SortNodeIDs
    [sorted_nodes, axes] = SortNodeIDs(nodeIDcoords, sort=False)

    return sorted_nodes
Beispiel #2
0
def test_assign_node_constraints(nodeIDcoords):
    from fem_mesh import SortNodeIDs
    from bc import assign_node_constraints
    [snic, axes] = SortNodeIDs(nodeIDcoords, sort=False)
    face_constraints = (('1,1,1,1,1,1', '2,2,2,2,2,2'),
                        ('3,3,3,3,3,3', '4,4,4,4,4,4'), ('5,5,5,5,5,5',
                                                         '6,6,6,6,6,6'))
    bcdict = assign_node_constraints(snic, axes, face_constraints)

    assert bcdict[1] == '5,5,5,5,5,5'
Beispiel #3
0
def axes(nodeIDcoords):
    """create axes numpy array from nodes.dyn & elems.dyn

    :returns: axes
    """
    from fem_mesh import SortNodeIDs
    elefile = '%s/elems.dyn' % myPath
    [sorted_nodes, axes] = SortNodeIDs(nodeIDcoords, sort=False)

    return axes
Beispiel #4
0
def test_sortnodeids(nodeIDcoords):
    """test node ID sorting by both order and coordinate locations
    """
    from fem_mesh import SortNodeIDs
    [snic, axes] = SortNodeIDs(nodeIDcoords, sort=False)

    assert axes[0][0] == -1.0
    assert axes[1][0] == 0.0
    assert axes[2][0] == -1.0
    assert axes[0][-1] == 0.0
    assert axes[1][-1] == 1.0
    assert axes[2][-1] == 0.0

    assert snic['id'][0][0][0] == 1
    assert snic['x'][0][0][0] == -1.0
    assert snic['y'][0][0][0] == 0.0
    assert snic['z'][0][0][0] == -1.0

    assert snic['id'][-1][-1][-1] == 1331
    assert snic['x'][-1][-1][-1] == 0.0
    assert snic['y'][-1][-1][-1] == 1.0
    assert snic['z'][-1][-1][-1] == 0.0

    [snic, axes] = SortNodeIDs(nodeIDcoords, sort=True)

    assert axes[0][0] == -1.0
    assert axes[1][0] == 0.0
    assert axes[2][0] == -1.0
    assert axes[0][-1] == 0.0
    assert axes[1][-1] == 1.0
    assert axes[2][-1] == 0.0

    assert snic['id'][0][0][0] == 1
    assert snic['x'][0][0][0] == -1.0
    assert snic['y'][0][0][0] == 0.0
    assert snic['z'][0][0][0] == -1.0

    assert snic['id'][-1][-1][-1] == 1331
    assert snic['x'][-1][-1][-1] == 0.0
    assert snic['y'][-1][-1][-1] == 1.0
    assert snic['z'][-1][-1][-1] == 0.0
Beispiel #5
0
def sorted_elems(nodeIDcoords):
    """create sorted elements numpy array from nodes.dyn & elems.dyn

    :returns: sorted_elems
    """
    from fem_mesh import load_elems
    from fem_mesh import SortElems
    from fem_mesh import SortNodeIDs
    elefile = '%s/elems.dyn' % myPath
    elems = load_elems(elefile)
    [snic, axes] = SortNodeIDs(nodeIDcoords, sort=False)
    sorted_elems = SortElems(elems, axes)

    return sorted_elems
Beispiel #6
0
def test_assign_edge_sym_constraints(nodeIDcoords):
    from fem_mesh import SortNodeIDs
    from bc import assign_edge_sym_constraints
    [snic, axes] = SortNodeIDs(nodeIDcoords, sort=False)
    bcdict = {}
    edge_constraints = (((0, 1), (1, 0), (0, 0)), '1,1,0,1,1,1')
    bcdict = assign_edge_sym_constraints(bcdict, snic, axes, edge_constraints)

    for nodeID in (737, 616, 495, 374):
        assert bcdict[nodeID] == "1,1,0,1,1,1"

    # test for node IDs excluded based on zmin/zmax PML elems
    for nodeID in (1221, 11):
        assert nodeID not in bcdict.keys()
Beispiel #7
0
def test_extractPlane(nodeIDcoords):
    """test all that all 6 planes are extracted as expected
    """
    from fem_mesh import SortNodeIDs
    from fem_mesh import extractPlane

    [snic, axes] = SortNodeIDs(nodeIDcoords)

    planeNodeIDs = extractPlane(snic, axes, [0, -1.0])
    assert planeNodeIDs.shape == (11, 11)
    assert planeNodeIDs[0, 0] == 1
    assert planeNodeIDs[0, 10] == 1211
    assert planeNodeIDs[10, 0] == 111
    assert planeNodeIDs[10, 10] == 1321

    planeNodeIDs = extractPlane(snic, axes, [0, 0.0])
    assert planeNodeIDs.shape == (11, 11)
    assert planeNodeIDs[0, 0] == 11
    assert planeNodeIDs[0, 10] == 1221
    assert planeNodeIDs[10, 0] == 121
    assert planeNodeIDs[10, 10] == 1331

    planeNodeIDs = extractPlane(snic, axes, [1, 0.0])
    assert planeNodeIDs.shape == (11, 11)
    assert planeNodeIDs[0, 0] == 1
    assert planeNodeIDs[0, 10] == 1211
    assert planeNodeIDs[10, 0] == 11
    assert planeNodeIDs[10, 10] == 1221

    planeNodeIDs = extractPlane(snic, axes, [1, 1.0])
    assert planeNodeIDs.shape == (11, 11)
    assert planeNodeIDs[0, 0] == 111
    assert planeNodeIDs[0, 10] == 1321
    assert planeNodeIDs[10, 0] == 121
    assert planeNodeIDs[10, 10] == 1331

    planeNodeIDs = extractPlane(snic, axes, [2, -1.0])
    assert planeNodeIDs.shape == (11, 11)
    assert planeNodeIDs[0, 0] == 1
    assert planeNodeIDs[0, 10] == 111
    assert planeNodeIDs[10, 0] == 11
    assert planeNodeIDs[10, 10] == 121

    planeNodeIDs = extractPlane(snic, axes, [2, 0.0])
    assert planeNodeIDs.shape == (11, 11)
    assert planeNodeIDs[0, 0] == 1211
    assert planeNodeIDs[0, 10] == 1321
    assert planeNodeIDs[10, 0] == 1221
    assert planeNodeIDs[10, 10] == 1331
Beispiel #8
0
def test_constrain_sym_pml_nodes(nodeIDcoords):
    """THIS FUNCTION IS NOT NEEDED!!
    """
    from fem_mesh import SortNodeIDs
    from bc import constrain_sym_pml_nodes
    [snic, axes] = SortNodeIDs(nodeIDcoords, sort=False)
    bcdict = {}
    edge_constraints = (((0, 1), (1, 0), (0, 0)), '1,1,0,1,1,1')
    pml_elems = ((3, 0), (0, 1), (2, 3))
    bcdict = constrain_sym_pml_nodes(bcdict, snic, axes, pml_elems,
                                     edge_constraints)
    # check x sym face
    for start_node in (11, 132, 253, 858, 979, 1100, 1221):
        for nodeID in range(start_node, start_node + 111, 11):
            assert bcdict[nodeID] == '1,1,1,1,1,1'
    for not_in_bc in (374, 495, 616, 737):
        assert not_in_bc not in bcdict.keys()
    # check y sym face
    for start_node in (1, 122, 243, 848, 969, 1090, 1211):
        for nodeID in range(start_node, start_node + 11):
            assert bcdict[nodeID] == '1,1,1,1,1,1'