コード例 #1
0
ファイル: create_res_sim_mat.py プロジェクト: Guokr1991/fem-1
def run(dynadeck,
        disp_comp=2,
        disp_scale=-1e4,
        ressim="res_sim.mat",
        nodedyn="nodes.dyn",
        dispout="disp.dat.xz",
        legacynodes=False):
    """

    :param dynadeck: main dyna input deck
    :param disp_comp=2: component of displacement to extract
    :param disp_scale=-1e4: displacement scaling
    :param ressim: default = "res_sim.mat"
    :param nodedyn: default = "nodes.dyn"
    :param dispout: default = "disp.dat.xz"
    :return: 0
    """
    from fem.mesh import fem_mesh

    node_id_coords = fem_mesh.load_nodeIDs_coords(nodedyn)
    [snic, axes] = fem_mesh.SortNodeIDs(node_id_coords)

    image_plane = extract_image_plane(snic, axes, ele_pos=0.0)

    header = read_header(dispout)
    dt = extract_dt(dynadeck)
    t = [float(x) * dt for x in range(0, header['num_timesteps'])]

    arfidata = extract_arfi_data(dispout, header, image_plane, disp_comp,
                                 disp_scale, legacynodes)

    save_res_mat(ressim, arfidata, axes, t)

    return 0
コード例 #2
0
def extract_top_plane_nodes(nodefile, top_face):
    """

    Args:
        nodefile: param top_face:
        top_face:

    Returns:
        planeNodeIDs

    """
    import numpy as np
    from fem.mesh import fem_mesh

    top_face = np.array(top_face)

    nodeIDcoords = fem_mesh.load_nodeIDs_coords(nodefile)
    [snic, axes] = fem_mesh.SortNodeIDs(nodeIDcoords)

    # extract spatially-sorted node IDs on a the top z plane
    axis = int(np.floor(np.divide(top_face.nonzero(), 2)))
    if np.mod(top_face.nonzero(), 2) == 1:
        plane = (axis, axes[axis].max())
    else:
        plane = (axis, axes[axis].min())

    planeNodeIDs = fem_mesh.extractPlane(snic, axes, plane)

    return planeNodeIDs
コード例 #3
0
def extract3Darfidata(dynadeck, disp_comp=2, disp_scale=-1e4, ressim="res_sim.h5", nodedyn="nodes.dyn", dispout="disp.dat.xz"):

    from fem.mesh import fem_mesh
    import fem.post.create_res_sim_mat as crsm
    import numpy as np

    node_id_coords = fem_mesh.load_nodeIDs_coords(nodedyn)
    [snic, axes] = fem_mesh.SortNodeIDs(node_id_coords)

    header = crsm.read_header(dispout)
    dt = crsm.extract_dt(dynadeck)
    t = [float(x) * dt for x in range(0, header['num_timesteps'])]

    arfidata = crsm.extract_arfi_data(dispout, header, snic['id'], disp_comp,
                                      disp_scale, legacynodes=False)

    crsm.save_res_mat(ressim, arfidata, axes, t)
コード例 #4
0
def apply_nonreflect(face_constraints,
                     edge_constraints,
                     nodefile="nodes.dyn",
                     bcfile="bc.dyn",
                     segfile="nonreflect_segs.dyn"):
    """driver function to generate non-reflecting boundaries

    Args:
      face_constraints (str): vector of face constraints, ordered xmin to zmax
      edge_constraints (str): vector of edge constraints, ordered xmin to zmax
      nodefile (str): default - 'nodes.dyn'
      bcfile (str): default - 'bc.dyn'
      segfile (str): default - 'nonreflect_segs.dyn'

    Returns:
      0 on success

    """
    import fem.mesh.fem_mesh as fem_mesh

    nodeIDcoords = fem_mesh.load_nodeIDs_coords(nodefile)
    [snic, axes] = fem_mesh.SortNodeIDs(nodeIDcoords)

    segID = 1
    seg_names = [['XMIN', 'XMAX'], ['YMIN', 'YMAX'], ['ZMIN', 'ZMAX']]
    SEGBCFILE = open(segfile, 'w')
    for a in range(0, 3):
        for m in range(0, 2):
            if face_constraints[a][m] == '1,1,1,1,1,1':
                if m == 0:
                    axis_limit = axes[a][0]
                else:
                    axis_limit = axes[a][-1]
                planeNodeIDs = fem_mesh.extractPlane(snic, axes,
                                                     (a, axis_limit))
                segID = writeSeg(SEGBCFILE, seg_names[a][m], segID,
                                 planeNodeIDs)
    write_nonreflecting(SEGBCFILE, segID)
    SEGBCFILE.close()

    bcdict = assign_node_constraints(snic, axes, face_constraints)
    bcdict = assign_edge_sym_constraints(bcdict, snic, axes, edge_constraints)
    write_bc(bcdict, bcfile)

    return 0
コード例 #5
0
def apply_face_bc_only(face_constraints,
                       nodefile="nodes.dyn",
                       bcfile="bc.dyn"):
    """driver function to apply node BCs just to faces

    :param face_constraints: 3x2 array of strings, specifying the BCs on each face (3), min/max (2)
    :param nodefile: default - 'nodes.dyn'
    :param bcfile: 'defauly - 'bc.dyn'
    :return:
    """

    from fem.mesh import fem_mesh

    nodeIDcoords = fem_mesh.load_nodeIDs_coords(nodefile)
    [snic, axes] = fem_mesh.SortNodeIDs(nodeIDcoords)

    bcdict = assign_node_constraints(snic, axes, face_constraints)

    write_bc(bcdict, bcfile)

    return 0
コード例 #6
0
def apply_pml(pml_elems,
              face_constraints,
              edge_constraints,
              nodefile="nodes.dyn",
              elefile="elems.dyn",
              pmlfile="elems_pml.dyn",
              bcfile="bc.dyn",
              pml_partID=2):
    """
    driver function to apply PML boundary conditions

    :param pml_elems: 3x2 array of ints specifying thickness of PML elements (5--10) on each PML layer
    :param face_constraints: 3x2 array of strings, specifying the BCs on each face (3), min/max (2)
    :param edge_constraints: 1x6 vector of BCs on each edge
    :param nodefile: default - 'nodes.dyn'
    :param elefile: default - 'elems.dyn'
    :param pmlfile: default - 'elems_pml.dyn'
    :param bcfile: 'defauly - 'bc.dyn'
    :param pml_partID: default - 2
    :return:
    """
    from fem.mesh import fem_mesh

    nodeIDcoords = fem_mesh.load_nodeIDs_coords(nodefile)
    [snic, axes] = fem_mesh.SortNodeIDs(nodeIDcoords)
    elems = fem_mesh.load_elems(elefile)
    sorted_elems = fem_mesh.SortElems(elems, axes)

    sorted_pml_elems = assign_pml_elems(sorted_elems, pml_elems, pml_partID)
    write_pml_elems(sorted_pml_elems, pmlfile)

    bcdict = assign_node_constraints(snic, axes, face_constraints)
    bcdict = constrain_sym_pml_nodes(bcdict, snic, axes, pml_elems,
                                     edge_constraints)
    bcdict = assign_edge_sym_constraints(bcdict, snic, axes, edge_constraints)
    write_bc(bcdict, bcfile)

    return 0
コード例 #7
0
def apply_pml(pml_elems,
              face_constraints,
              edge_constraints,
              nodefile="nodes.dyn",
              elefile="elems.dyn",
              pmlfile="elems_pml.dyn",
              bcfile="bc.dyn",
              pml_partID=2):
    """driver function to apply PML boundary conditions

    Args:
      pml_elems (str): 3x2 array of ints specifying thickness of
        PML elements (5--10) on each PML layer
        face_constraints: 3x2 array of strings, specifying the BCs on each
        face (3), min/max (2)
      edge_constraints (str): 1x6 vector of BCs on each edge
      nodefile (str): default - input file for the node definitions
      elefile (str): default - input file for the element definitions
      pmlfile (str): output file for the elements w/ PMLs
      bcfile (str): output file for the boundary conditions
      pml_partID (int): PID for the PML elements

    """
    import fem.mesh.fem_mesh as fem_mesh

    nodeIDcoords = fem_mesh.load_nodeIDs_coords(nodefile)
    [snic, axes] = fem_mesh.SortNodeIDs(nodeIDcoords)
    elems = fem_mesh.load_elems(elefile)
    sorted_elems = fem_mesh.SortElems(elems, axes)

    sorted_pml_elems = assign_pml_elems(sorted_elems, pml_elems, pml_partID)
    write_pml_elems(sorted_pml_elems, pmlfile)

    bcdict = assign_node_constraints(snic, axes, face_constraints)
    bcdict = constrain_sym_pml_nodes(bcdict, snic, axes, pml_elems,
                                     edge_constraints)
    bcdict = assign_edge_sym_constraints(bcdict, snic, axes, edge_constraints)
    write_bc(bcdict, bcfile)
コード例 #8
0
def apply_face_bc_only(face_constraints,
                       nodefile="nodes.dyn",
                       bcfile="bc.dyn"):
    """Driver function to apply node BCs just to faces.

    Args:
      face_constraints (tuple): 3x2 tuple of strings
        (('0,0,0,0,0,0'), ('0,0,0,0,0,0'),
         ('0,0,0,0,0,0'), ('0,0,0,0,0,0'),
         ('0,0,0,0,0,0'), ('0,0,0,0,0,0'))
        Specify face BCs as ((xmin, xmax), (ymin, ymax), (zmin, zmax))
      nodefile (str): input file for node definitions (*NODE)
      bcfile (str): output file for boundary conditions (*BOUNDARY_SPC_NODE)
    """

    import fem.mesh.fem_mesh as fem_mesh

    nodeIDcoords = fem_mesh.load_nodeIDs_coords(nodefile)
    [snic, axes] = fem_mesh.SortNodeIDs(nodeIDcoords)

    bcdict = assign_node_constraints(snic, axes, face_constraints)

    write_bc(bcdict, bcfile)
コード例 #9
0
    def load_sorted_nodes(self):
        """ """
        from fem.mesh import fem_mesh

        nic = fem_mesh.load_nodeIDs_coords(nodefile=self.nodefile)
        [self.snic, self.axes] = fem_mesh.SortNodeIDs(nic)