Example #1
0
def save_nodal_fields_from_structured(meshfilename, outputfilename, fieldnames,
                                      fielddata):
    if os.path.isfile(outputfilename): os.remove(outputfilename)

    with Suppressor():
        e = exodus.exodus(meshfilename, array_type='numpy', mode='r')
        x, y, z = e.get_coords()
        e.close()

    ux = np.unique(x.round(decimals=6))
    uy = np.unique(y.round(decimals=6))

    dx = ux[1] - ux[0]
    dy = uy[1] - uy[0]

    i = np.rint((x - min(x)) / dx)
    j = np.rint((y - min(y)) / dy)

    with Suppressor():
        e = exodus.copy_mesh(meshfilename, outputfilename)
        e.close()
        e = exodus.exodus(outputfilename, mode='a', array_type="numpy")
        exodus.add_variables(e, nodal_vars=fieldnames)
        for vidx, name in enumerate(fieldnames):
            for ts in range(fielddata.shape[0]):
                e.put_node_variable_values(
                    name, ts + 1, fielddata[ts, vidx,
                                            i.astype(int),
                                            j.astype(int)])
                e.put_time(ts + 1, ts)
        e.close()
Example #2
0
def copy_all_global_variables(filename_source, filename_dest):
    source = exodus.exodus(filename_source, array_type='numpy', mode='r')
    n = source.get_global_variable_number()

    if n > 0:
        names = source.get_global_variable_names()

        dest = exodus.exodus(filename_dest, array_type='numpy', mode='a')
        dest.set_global_variable_number(n)
        for i, name in enumerate(source.get_global_variable_names()):
            dest.put_global_variable_name(name, i + 1)
        for timestep in range(dest.num_times()):
            dest.put_all_global_variable_values(
                timestep + 1,
                source.get_all_global_variable_values(timestep + 1))
Example #3
0
 def test_put_assemblies(self):
     new = exo.assembly(name='Unit_test', type='EX_ASSEMBLY', id=444)
     new.entity_list = [100, 222]
     temp_exofile = exo.exodus(self.temp_exo_path, mode='a')
     temp_exofile.put_assemblies([new])
     temp_exofile.close()
     temp_exofile = exo.exodus(self.temp_exo_path)
     assembly_ids = temp_exofile.get_ids("EX_ASSEMBLY")
     assemblies = [
         temp_exofile.get_assembly(assembly) for assembly in assembly_ids
     ]
     self.assertEqual(new.name, assemblies[6].name)
     self.assertEqual(16, assemblies[6].type)
     self.assertEqual(new.id, assemblies[6].id)
     self.assertEqual(new.entity_list, assemblies[6].entity_list)
Example #4
0
def main():
    import exodus as exo
    import numpy as np
    import os
    import pymef90
    options = parse()
    
    if  os.path.exists(options.outputfile):
        if options.force:
            os.remove(options.outputfile)
        else:
            if pymef90.confirm("ExodusII file {0} already exists. Overwrite?".format(options.outputfile)):
                os.remove(options.outputfile)
            else:
                print ('\n\t{0} was NOT generated.\n'.format(options.outputfile))
                return -1
    exoin  = exo.exodus(options.inputfile,mode='r')
    exoout = exoin.copy(options.outputfile)
    exoin.close()
    exoformat(exoout)
    
    T = np.linspace(options.time_min,options.time_max,options.time_numstep)
    for step in range(options.time_numstep):
        exoout.put_time(step+1,T[step])
    for cs in options.cs:
        theta = beamProfile(exoout,options.Wabs,options.r0,options.initialPos,cs)
        step = 0
        for step in range(options.time_numstep):
            exoout.put_element_variable_values(cs,"Heat_Flux",step+1,theta)
            step += 1
    exoout.close()
Example #5
0
    def set_port_endogenous_values(self, pc_coeffs, germ, portid):
        """
        Sample polynomial chaos expansion for endogenous values at germ
        Assign those values to the nodes on the exodus mesh
        """

        endo_map = self.get_endogenous_data()

        with Suppressor():
            e = exodus.exodus(self.outfile, mode='a')
        ss_ids = e.get_side_set_ids()
        ss_names = e.get_side_set_names()
        dictionary = dict(zip(ss_names, ss_ids))

        # Get list of nodes
        ssname = self.endogenous_output_ports[portid].ssname
        varname = self.endogenous_output_ports[portid].varname
        side_set_node_ids = e.get_side_set_node_list(dictionary[ssname])[1]

        for timestep, node_map in enumerate(endo_map):
            nodal_values = e.get_node_variable_values(varname, timestep + 1)
            ssid = e.get_side_set_node_list(dictionary[ssname])[1]
            side_set_unique_node_ids = set(ssid)
            for nid in side_set_unique_node_ids:
                index = timestep * self.num_endogenous_nodes + node_map.keys(
                ).index(nid)
                endo_val = self.evaluate_pce(pc_coeffs[index, ...], germ)
                nodal_values[nid - 1] = endo_val
            e.put_node_variable_values(varname, timestep + 1, nodal_values)

        with Suppressor():
            e.close()
Example #6
0
def getElemsAndNodes(input_file):
    "Gets the number of elements and nodes per elements in `input_file`"
    exo_from = exodus.exodus(input_file,"r",array_type='ctype')
    BLOCK_ID = 1
    _, _, nNodeElm, _ = exo_from.elem_blk_info(BLOCK_ID)
    num_elems = exo_from.num_elems()
    return (num_elems,nNodeElm)
Example #7
0
    def save_nodal_pce(self, pc_coeffs, meshfilename, outputfilename):
        if os.path.isfile(outputfilename): os.remove(outputfilename)
        print("Save nodal PCE %s" % outputfilename)
        times = self.get_solution_times()

        varnames = []
        for coeff_idx in range(pc_coeffs.shape[1]):
            varnames.append('PCE_%d' % coeff_idx)

        e = exodus.copy_mesh(meshfilename, outputfilename)
        e.close()
        e = exodus.exodus(outputfilename, mode='a')
        exodus.add_variables(e, nodal_vars=varnames)

        numnodes = pc_coeffs.shape[0] / self.num_timesteps

        for timestep in range(self.num_timesteps):
            for coeff_idx in range(pc_coeffs.shape[1]):
                varname = varnames[coeff_idx]
                nodal_values = e.get_node_variable_values(varname, 1)
                for nidx in range(numnodes):
                    index = timestep * numnodes + nidx
                    nodal_values[nidx] = pc_coeffs[index, coeff_idx]
                e.put_node_variable_values(varname, timestep + 1, nodal_values)
                e.put_time(timestep + 1, times[timestep])

        e.close()
Example #8
0
 def setUp(self):
     exofile = exo.exodus("test-assembly.exo", mode='r')
     self.tempdir = tempfile.TemporaryDirectory()
     self.temp_exo_path = os.path.join(self.tempdir.name,
                                       "temp-test-assembly.exo")
     self.temp_exofile = exofile.copy(self.temp_exo_path)
     exofile.close()
Example #9
0
def main():
    import exodus as exo
    import numpy as np
    import os
    import pymef90
    options = parse()
    
    if  os.path.exists(options.outputfile):
        if options.force:
            os.remove(options.outputfile)
        else:
            if pymef90.confirm("ExodusII file {0} already exists. Overwrite?".format(options.outputfile)):
                os.remove(options.outputfile)
            else:
                print ('\n\t{0} was NOT generated.\n'.format(options.outputfile))
                return -1
    exoin  = exo.exodus(options.inputfile,mode='r',array_type='numpy')
    exoout = exoin.copy(options.outputfile)
    exoin.close()
    exoformat(exoout)
    
    T = np.linspace(options.time_min,options.time_max,options.time_numstep)
    x0 = np.linspace(options.initialPos[0],options.finalPos[0],options.time_numstep)
    y0 = np.linspace(options.initialPos[1],options.finalPos[2],options.time_numstep)
    z0 = np.linspace(options.initialPos[2],options.finalPos[2],options.time_numstep)
    for step in range(options.time_numstep):
        print("Processing time step {0} (t={1:.2e}, x0=[{2},{3},{4})".format(step,T[step],x0[step],y0[step],z0[step]))
        exoout.put_time(step+1,T[step])
        for cs in options.cs:
            theta = beamProfile(exoout,options.Wabs,options.r0,[x0[step],y0[step],z0[step]],cs)
            exoout.put_element_variable_values(cs,"Heat_Flux",step+1,theta)
    exoout.close()
Example #10
0
    def set_all_endogenous_values(self, pc_coeffs, germ):
        """
        Sample polynomial chaos expansion for endogenous values at germ
        Assign those values to the nodes on the exodus mesh
        """
        endo_map = self.get_endogenous_data()

        with Suppressor():
            e = exodus.exodus(self.outfile, mode='a')
        ss_ids = e.get_side_set_ids()
        ss_names = e.get_side_set_names()
        dictionary = dict(zip(ss_names, ss_ids))

        index = 0
        for timestep in range(self.num_timesteps):
            for portid, port in enumerate(self.endogenous_output_ports):
                node_map = endo_map[timestep *
                                    len(self.endogenous_output_ports) + portid]
                nodal_values = e.get_node_variable_values(
                    port.varname, timestep + 1)

                ssid = e.get_side_set_node_list(dictionary[port.ssname])[1]
                side_set_unique_node_ids = set(ssid)
                for nid in side_set_unique_node_ids:
                    idx = index + node_map.keys().index(nid)
                    endo_val = self.evaluate_pce(pc_coeffs[idx, ...], germ)
                    nodal_values[nid - 1] = endo_val
                index += len(side_set_unique_node_ids)
                e.put_node_variable_values(port.varname, timestep + 1,
                                           nodal_values)

        with Suppressor():
            e.close()
Example #11
0
    def test_get_reduction_variable_assembly(self):

        temp_exofile = exo.exodus(self.temp_exo_path, mode='r')
        red_var = temp_exofile.get_reduction_variable_number("EX_ASSEMBLY")
        self.assertEqual(4, red_var)
        name = temp_exofile.get_reduction_variable_name("EX_ASSEMBLY", 1)
        self.assertIn("Momentum_X", name)
Example #12
0
 def test_get_reduction_variable_assembly_enum(self):
     temp_exofile = exo.exodus("test-assembly.exo", mode='r')
     red_var = temp_exofile.get_reduction_variable_number(
         exo.ex_entity_type.EX_ASSEMBLY)
     self.assertEqual(4, red_var)
     name = temp_exofile.get_reduction_variable_name(
         exo.ex_entity_type.EX_ASSEMBLY, 1)
     self.assertIn("Momentum_X", name)
Example #13
0
 def test_get_reduction_variable_assembly_enum(self):
     with exo.exodus(self.temp_exo_path) as temp_exofile:
         red_var = temp_exofile.get_reduction_variable_number(
             exo.ex_entity_type.EX_ASSEMBLY)
         name = temp_exofile.get_reduction_variable_name(
             exo.ex_entity_type.EX_ASSEMBLY, 1)
     self.assertEqual(4, red_var)
     self.assertIn("Momentum_X", name)
Example #14
0
def append_exodus(filenamelist,
                  outputfilename="joined-output.e",
                  skip_first=0,
                  skip_last=0):

    if os.path.isfile(outputfilename): os.remove(outputfilename)

    with Suppressor():
        # Copy Mesh
        e = exodus.copy_mesh(filenamelist[0], outputfilename)
        e.close()
        e = exodus.exodus(outputfilename, mode='a', array_type="numpy")

        # Add Variable Names
        var_names = []
        gvar_names = []
        for f in filenamelist:
            exo = exodus.exodus(f, mode='r', array_type="numpy")
            var_names.extend(exo.get_node_variable_names())
            gvar_names.extend(exo.get_global_variable_names())
            exo.close()
        var_names = list(set(var_names))
        gvar_names = list(set(gvar_names))
        exodus.add_variables(e, nodal_vars=var_names)
        e.set_global_variable_number(len(gvar_names))
        for i, gvar in enumerate(gvar_names):
            e.put_global_variable_name(gvar, i + 1)

    # Add Variable Data
    ts = 1
    for f in filenamelist:
        exo = exodus.exodus(f, mode='r', array_type="numpy")
        for step in range(skip_first, exo.num_times() - skip_last):
            for var in exo.get_node_variable_names():
                e.put_node_variable_values(
                    var, ts, exo.get_node_variable_values(var, step + 1))
            if len(gvar_names) > 0:
                gvar_vals = []
                for gvar in exo.get_global_variable_names():
                    gvar_vals.append(
                        exo.get_global_variable_values(gvar)[step])
                e.put_all_global_variable_values(ts, gvar_vals)
            e.put_time(ts, ts - 1)
            ts += 1
        exo.close()
    e.close()
Example #15
0
def read_element_type(name_file_exodus):

    file_exodus = exodus(name_file_exodus)
    ids_block = file_exodus.get_elem_blk_ids()
    element_block_info = file_exodus.elem_blk_info(ids_block[0])
    element_type = element_block_info[0]
    file_exodus.close()
    return element_type
Example #16
0
def read_element_type(name_file_exodus):

    file_exodus = exodus(name_file_exodus)
    ids_block = file_exodus.get_elem_blk_ids()
    element_block_info = file_exodus.elem_blk_info(ids_block[0])
    element_type = element_block_info[0]
    file_exodus.close() 
    return element_type
Example #17
0
 def test_get_reduction_variables_assembly(self):
     temp_exofile = exo.exodus("test-assembly.exo", mode='r')
     red_var = temp_exofile.get_reduction_variable_number("EX_ASSEMBLY")
     self.assertEqual(4, red_var)
     names = temp_exofile.get_reduction_variable_names("EX_ASSEMBLY")
     self.assertIn("Momentum_X", names)
     self.assertIn("Momentum_Y", names)
     self.assertIn("Momentum_Z", names)
     self.assertIn("Kinetic_Energy", names)
Example #18
0
	def initFromExodus(self, fName):
		
		self.fNameIn = fName
		self.template = exodus.exodus(fName, array_type='numpy')
		self.nNode = self.template.numNodes.value
		self.nElem = self.template.numElem.value
		self.x, self.y, _ = np.array(self.template.get_coords())
		self.xMax, self.xMin = np.amax(self.x), np.amin(self.x)
		self.yMax, self.yMin = np.amax(self.y), np.amin(self.y)
Example #19
0
 def test_get_reduction_variables_assembly(self):
     with exo.exodus(self.temp_exo_path) as temp_exofile:
         red_var = temp_exofile.get_reduction_variable_number("EX_ASSEMBLY")
         names = temp_exofile.get_reduction_variable_names("EX_ASSEMBLY")
     self.assertEqual(4, red_var)
     self.assertIn("Momentum_X", names)
     self.assertIn("Momentum_Y", names)
     self.assertIn("Momentum_Z", names)
     self.assertIn("Kinetic_Energy", names)
Example #20
0
 def test_get_reduction_variable_values_assembly_no_values(self):
     temp_exofile = exo.exodus("test-assembly.exo", mode='r')
     assembly_ids = temp_exofile.get_ids("EX_ASSEMBLY")
     assemblies = [
         temp_exofile.get_assembly(assembly) for assembly in assembly_ids
     ]
     values = temp_exofile.get_reduction_variable_values(
         'EX_ASSEMBLY', assemblies[5].id, 1)
     self.assertListEqual([0.00, 0.00, 0.00, 0.00], list(values))
Example #21
0
def get_nodal_variable_values(filename, varname, step=1):
    """
    Extracts nodal field data from exodus file and returns a numpy array of nodal values
    """
    with Suppressor():
        e = exodus.exodus(filename, array_type='numpy', mode='r')
        vals = e.get_node_variable_values(varname, step)
        e.close()
    return vals
Example #22
0
def get_coords(filename):
    """
    Returns the spatial coordinates of nodes in all blocks
    """
    with Suppressor():
        e = exodus.exodus(filename, array_type='numpy', mode='r')
        x, y, z = e.get_coords()
        e.close()
    return x, y, z
Example #23
0
def get_nodal_variable_names(filename):
    """
    Returns list of nodal variables present in exodus file
    """
    with Suppressor():
        e = exodus.exodus(filename, array_type='numpy', mode='r')
        names = e.get_node_variable_names()
        e.close()
    return names
Example #24
0
def get_num_globals(filename):
    """
    Returns number of global variables in the exodus file
    """
    with Suppressor():
        e = exodus.exodus(filename, array_type='numpy', mode='r')
        n = e.get_global_variable_number()
        e.close()
    return n
Example #25
0
def get_node_id_map(filename):
    """
    Returns mapping between node index and node id from exodus file
    """
    with Suppressor():
        e = exodus.exodus(filename, array_type='numpy', mode='r')
        nid = e.get_node_id_map()
        e.close()
    return nid
Example #26
0
 def get_QoI_data(self):
     with Suppressor():
         e = exodus.exodus(self.outfile, mode='r')
     QoI_vals = {}
     for QoI in self.QoIs:
         QoI_vals[QoI] = e.get_global_variable_values(QoI)
     with Suppressor():
         e.close()
     return QoI_vals
Example #27
0
def get_num_nodes(filename):
    """
    Returns the total number of nodes in all blocks
    """
    with Suppressor():
        e = exodus.exodus(filename, array_type='numpy', mode='r')
        n = e.num_nodes()
        e.close()
    return n
Example #28
0
def get_times(filename):
    """
    Returns list of times corresponding to time planes in the exodus file
    """
    with Suppressor():
        e = exodus.exodus(filename, array_type='numpy', mode='r')
        t = e.get_times()
        e.close()
    return t
Example #29
0
 def test_get_block_id_map(self):
     with exo.exodus(self.temp_exo_path) as temp_exofile:
         elem_ids = temp_exofile.get_ids("EX_ELEM_BLOCK")
         expected = [1, 2, 3, 4, 5, 6, 7]
         outputs = []
         for val in elem_ids:
             outputs.extend(
                 temp_exofile.get_block_id_map("EX_ELEM_BLOCK", val))
     self.assertListEqual(expected, outputs)
Example #30
0
 def test_get_assembly(self):
     temp_exofile = exo.exodus(self.temp_exo_path)
     assembly_ids = temp_exofile.get_ids("EX_ASSEMBLY")
     assemblies = [
         temp_exofile.get_assembly(assembly) for assembly in assembly_ids
     ]
     root = exo.assembly(name='Root', type='EX_ASSEMBLY', id=100)
     root.entity_list = [100, 200, 300, 400]
     self.assertEqual(str(root), str(assemblies[0]))
Example #31
0
def normalize_data(filename, outputfilename="normalized-output.e"):
    if os.path.isfile(outputfilename): os.remove(outputfilename)

    # Copy Mesh
    e = exodus.copy_mesh(filename, outputfilename)
    e.close()
    exo_out = exodus.exodus(outputfilename, mode='a', array_type="numpy")
    exo_in = exodus.exodus(filename, mode='r', array_type="numpy")

    # Add Variable Names
    var_names = exo_in.get_node_variable_names()
    gvar_names = exo_in.get_global_variable_names()
    exodus.add_variables(exo_out, nodal_vars=var_names)
    exo_out.set_global_variable_number(len(gvar_names))
    for i, gvar in enumerate(gvar_names):
        exo_out.put_global_variable_name(gvar, i + 1)

    # Compute Var Min/Max
    minmax = []
    for var in var_names:
        print(var)
        vmin = float("inf")
        vmax = -vmin
        for step in range(exo_in.num_times()):
            data = exo_in.get_node_variable_values(var, step + 1)
            vmin = min(vmin, min(data))
            vmax = max(vmax, max(data))

        print((vmin, vmax))
        minmax.append((vmin, vmax))

    # Add Data
    for step in range(exo_in.num_times()):
        for i, var in enumerate(var_names):
            data = exo_in.get_node_variable_values(var, step + 1)
            vmin, vmax = minmax[i]
            exo_out.put_node_variable_values(var, step + 1,
                                             (data - vmin) / (vmax - vmin))
        exo_out.put_time(step + 1, step)

    # Add Global Data

    exo_in.close()
    exo_out.close()
Example #32
0
    def initialize_PCE(self):
        if os.path.isfile(self.pce_file):
            # Read initial PCE values from exodus file
            my_endo_pce_coeffs = np.zeros(
                (self.get_num_endogenous_ports(), self.get_num_pc_terms()))

            varnames = []
            for coeff_idx in range(self.get_num_pc_terms()):
                varnames.append('PCE_%d' % coeff_idx)

            e = exodus.exodus(self.pce_file, mode='r')
            ss_ids = e.get_side_set_ids()
            ss_names = e.get_side_set_names()
            dictionary = dict(zip(ss_names, ss_ids))

            # Get list of nodes for which to provide data
            #TODO: This likely broken from port change
            all_side_set_node_ids = []
            for port in self.endogenous_output_ports:
                side_set_node_ids = e.get_side_set_node_list(
                    dictionary[port.ssname])[1]
                all_side_set_node_ids.append(side_set_node_ids)

            endo_map = self.get_endogenous_data()
            for timestep, node_map in enumerate(endo_map):
                print("timestep: %d" % timestep)
                for coeff_idx in range(self.get_num_pc_terms()):
                    varname = varnames[coeff_idx]
                    nodal_values = e.get_node_variable_values(varname, 1)
                    for ssid in all_side_set_node_ids:
                        side_set_unique_node_ids = set(ssid)
                        for nid in side_set_unique_node_ids:
                            index = timestep * self.num_endogenous_nodes + node_map.keys(
                            ).index(nid)
                            my_endo_pce_coeffs[index,
                                               coeff_idx] = nodal_values[nid -
                                                                         1]

            e.close()

        else:
            endo_init = self.get_endogenous_data()
            my_endo_pce_coeffs = np.zeros(
                (self.get_num_endogenous_ports(), self.get_num_pc_terms()))

            index = 0
            for timestep in range(self.num_timesteps):
                for portid, port in enumerate(self.endogenous_output_ports):
                    nodal_data = endo_init[timestep *
                                           len(self.endogenous_output_ports) +
                                           portid]
                    for nid in nodal_data:
                        my_endo_pce_coeffs[index, 0] = nodal_data[nid]
                        index += 1

        return my_endo_pce_coeffs
Example #33
0
    def read_mesh(self, filename):
        """
		Reads the model and saves some generic information.
		"""

        self.filename = filename
        self.mesh = exodus.exodus(filename, array_type="numpy")
        self.nNode = self.mesh.numNodes.value
        self.nElem = self.mesh.numElem.value
        self.x, self.y, _ = np.array(self.mesh.get_coords())
        self.xMax, self.xMin = np.amax(self.x), np.amin(self.x)
        self.yMax, self.yMin = np.amax(self.y), np.amin(self.y)
Example #34
0
def read_names_block(name_file_exodus):

    file_exodus = exodus(name_file_exodus)
    ids_block = file_exodus.get_elem_blk_ids()
    names_block = file_exodus.get_elem_blk_names()
    file_exodus.close()

    for idx in range(len(ids_block)):
        if (names_block[idx] == ""):
            names_block[idx] = "block_" + str(ids_block[idx])

    return names_block
Example #35
0
	def initFromExodus(self, fName):
		'''
		Initialize generic information (co-ordinates, etc.) from an exodus
		file.
		'''
		
		self.fNameIn = fName
		self.template = exodus.exodus(fName, array_type='numpy')
		self.nNode = self.template.numNodes.value
		self.nElem = self.template.numElem.value
		self.x, self.y, _ = np.array(self.template.get_coords())
		self.xMax, self.xMin = np.amax(self.x), np.amin(self.x)
		self.yMax, self.yMin = np.amax(self.y), np.amin(self.y)
Example #36
0
def open_file_exodus(name_file_exodus, mode = 'r', output = os.devnull, verbosity = 0):

    with stdout_redirected(to = output):
        file_exodus = exodus.exodus(name_file_exodus, mode)

    if verbosity > 0:

        # Print database parameters from file_exodus
        print " "
        print "Database version:         " + str(round(file_exodus.version.value,2))
        print "Database title:           " + file_exodus.title()
        print "Database dimensions:      " + str(file_exodus.num_dimensions())
        print "Number of nodes:          " + str(file_exodus.num_nodes())
        print "Number of elements:       " + str(file_exodus.num_elems())
        print "Number of element blocks: " + str(file_exodus.num_blks())
        print "Number of node sets:      " + str(file_exodus.num_node_sets())
        print "Number of side sets:      " + str(file_exodus.num_side_sets())
        print " "

    return file_exodus
def initialize_genesis(genesis_input=None, genesis_output_name=None):
    if os.path.exists(genesis_output_name):
        os.remove(genesis_output_name)
    num_blocks_input = genesis_input.num_blks()
    if args.combine_blocks == True:
        num_blocks_output = 1
    else:
        num_blocks_output = num_blocks_input
    genesis_output = exodus.exodus(
        genesis_output_name,
       'w',
       'numpy',
       genesis_input.title(),
       genesis_input.num_dimensions(),
       genesis_input.num_nodes(),
       genesis_input.num_elems(),
       num_blocks_output,
       genesis_input.num_node_sets(),
       genesis_input.num_side_sets())
    return genesis_output
Example #38
0
'''

import sys
import os
from exodus import exodus
from exodus import copy_mesh
import numpy
import matplotlib.pyplot as plt

inFileName = sys.argv[1]
outFileName = sys.argv[2]


# set i/o units ------------------------------------------------------------------------------------

inFile = exodus(inFileName,"r")
if os.path.isfile(outFileName):
  cmdLine = "rm %s" % outFileName
  os.system(cmdLine)
outFile = copy_mesh(inFileName, outFileName)


# get number of dimensions -------------------------------------------------------------------------
num_dims = inFile.num_dimensions()

print "Dimensions"
print num_dims


# get times ----------------------------------------------------------------------------------------
times = inFile.get_times()
Example #39
0
def write_file_exodus(domain = None, name_file_input = None, name_file_output = None):

    times = domain.times
    num_dims = domain.num_dims

    if os.path.isfile(name_file_output):
        cmd_line = "rm %s" % name_file_output
        os.system(cmd_line)

    with stdout_redirected():
        file_input = exodus(name_file_input)
        file_output = file_input.copy(name_file_output)

    # write times to file_output
    for step in range(len(times)):
       file_output.put_time(step + 1, times[step])

    #
    # write out displacement vector
    #
    file_output.set_node_variable_number(file_input.get_node_variable_number())

    count = 0
    for key, value in domain.names_variable_node.items():
        
        for suffix in value:

            count += 1
            name_variable = key + '_' + suffix
            file_output.put_node_variable_name(name_variable, count)

            for step in range(len(times)):

                file_output.put_node_variable_values(
                    name_variable,
                    step + 1,
                    file_input.get_node_variable_values(name_variable, step + 1))

    #
    # create variables in output file
    #

    names_var_output_tensor = ['Cauchy_Stress', 'F', 'Log_Strain']
    names_var_output_scalar = ['Mises_Stress', 'eqps', 'Misorientation', 'Strain_Energy']

    names_var_avail_tensor = [name for name in names_var_output_tensor if name in domain.variables]
    names_var_avail_scalar = [name for name in names_var_output_scalar if name in domain.variables]

    num_vars_tensor = len(names_var_avail_tensor)
    num_vars_scalar = len(names_var_avail_scalar)

    file_output.set_element_variable_number(num_dims**2 * len(names_var_avail_tensor) + len(names_var_avail_scalar))

    for index, name in enumerate(names_var_avail_tensor):

        for dim_i in range(num_dims):

            for dim_j in range(num_dims):

                name_indexed = name + '_' + str(dim_i + 1) + str(dim_j + 1)

                file_output.put_element_variable_name(
                    name_indexed, 
                    index * num_dims**2 + dim_i * num_dims + dim_j + 1)

                for key_block in domain.blocks:

                    block = domain.blocks[key_block]

                    for step in range(len(times)):

                        file_output.put_element_variable_values(
                            key_block,
                            name_indexed,
                            step + 1,
                            [block.elements[key_element].variables[name][times[step]][dim_i][dim_j] for key_element in block.elements])

    for index, name in enumerate(names_var_avail_scalar):

        file_output.put_element_variable_name(
            name, 
            num_vars_tensor + index + 2)

        for key_block in domain.blocks:

            block = domain.blocks[key_block]

            for step in range(len(times)):

                file_output.put_element_variable_values(
                    key_block,
                    name,
                    step + 1,
                    [block.elements[key_element].variables[name][times[step]] for key_element in block.elements])

    with stdout_redirected():
        file_output.close()
Example #40
0
## Here, the stresses of the current and gold files are compared and plotted.

import sys
import exodus
import numpy
import matplotlib.pyplot as plt

file_name_old_gold = "MultiSlipPlaneHard_Implicit_Active_Sets.gold.exo"
exo_file_old_gold = exodus.exodus(file_name_old_gold,"r")

file_name_new_gold = "MultiSlipPlaneHard_Implicit_Active_Sets.exo"
exo_file_new_gold = exodus.exodus(file_name_new_gold,"r")

dep_var_name = "Cauchy_Stress_01"
inp_var_name = "gamma_1_1"

int_pt = 1
block_id = 2

output_file_name = "SingleSlipHard_" + dep_var_name + ".pdf"

output_file_name_png = "SingleSlipHard_" + dep_var_name + ".png"


############### old gold
n_steps_old_gold = exo_file_old_gold.num_times()
time_vals_old_gold = exo_file_old_gold.get_times()

inp_var_old_gold = numpy.zeros(shape=(n_steps_old_gold,1))
dep_var_old_gold = numpy.zeros(shape=(n_steps_old_gold,1))
for i in range(n_steps_old_gold):
    if len(sys.argv) < 3:
        print "\nUsage:  imprint_dirichlet_field_on_mesh.py <input.g> <output.g>\n"
        sys.exit(1)

    input_file_name = sys.argv[1]
    output_file_name = sys.argv[2]

    print "\n-- imprint_dirichlet_field_on_mesh.py --\n"
    print "Genesis input file:", input_file_name
    print "Genesis output file:", output_file_name

    if os.path.exists(output_file_name):
        os.remove(output_file_name)

    old_database = exodus.exodus(input_file_name, 'r')
    x, y, z = old_database.get_coords()
    new_database = old_database.copy(output_file_name)
    old_database.close()

    g_var_names = []
    n_var_names = ["dirichlet_field"]
    e_var_names = []
    exodus.add_variables(new_database, g_var_names, n_var_names, e_var_names)

    dirichlet_field_values = []
    for i in range(len(x)):
        val = DirichletField(x[i], y[i], z[i])
        dirichlet_field_values.append(val)

    new_database.put_node_variable_values("dirichlet_field", 1, dirichlet_field_values)
            basename = args.rotfile.replace('_Rotations.txt','')
            args.meshfile = basename + '.g'
        else:
            names_file = os.walk('.').next()[2]
            names_potential = [n for n in names_file if n.endswith('_Rotations.txt')]
            if len(names_potential) is 1:
                basename = names_potential[0].replace('_Rotations.txt','')
                args.rotfile = basename + '_Rotations.txt'
                args.meshfile = basename + '.g'
            else:
                raise InputError('Non-unique or missing assumed base file name')

    assert(os.path.isfile(args.meshfile))
    assert(os.path.isfile(args.rotfile))

    genesis_input = exodus.exodus(args.meshfile, mode='r', array_type='numpy')

    # Read the orientation data
    orientations = np.loadtxt(args.rotfile, ndmin=2)
    num_orientations = orientations.shape[0]
    num_dims = int(np.sqrt(orientations.shape[1]))
    assert(num_dims**2 == orientations.shape[1])

    # Print database parameters from genesis_input
    print_info(genesis_input=genesis_input)

    genesis_output_name = os.path.splitext(
        genesis_input_name)[0] + '_orientation.g'

    genesis_output = transfer_genesis(
        genesis_input=genesis_input, genesis_output_name=genesis_output_name)
    if len(sys.argv) < 3:
        print "\nUsage:  imprint_orientation_on_mesh.py <mesh.g> <orientations.txt> [options]\n"
        print "Options:\n  --combine_blocks\n"
        sys.exit(1)

    # "rotation matrix" or "euler angles"
    orientation_format = "rotation matrix"

    num_orientation_attributes = 0
    if orientation_format == "rotation matrix":
        num_orientation_attributes = 9
    elif orientation_format == "euler angles":
        num_orientation_attributes = 3

    genesis_input_name = sys.argv[1]
    genesis_input = exodus.exodus(genesis_input_name, mode='r')
    combine_blocks = False
    if len(sys.argv) > 3:
        option = sys.argv[3]
        if option == "--combine_blocks":
            combine_blocks = True

    # Read the orientation data

    orientations_input_name = sys.argv[2]
    orientations_file = open(orientations_input_name, 'r')
    orientations_lines = orientations_file.readlines()
    orientations_file.close()
    orientations = []
    for line in orientations_lines:
        vals = string.splitfields(line)
Example #44
0
 def __reload_from_tmp(self):
     self.exodus_template = exodus.exodus(TEMP_EXODUS_FILENAME, array_type='numpy')
#    The file exodus.py is in this directory.
# 2) Edit exodus.py as follows (approximately line 71):
#    accessPth = "/projects/seacas/linux_rhel6/current"
#    The path above is valid on the CEE LAN.  On other systems, you need to provide a path to a SEACAS build
#    that includes shared libraries.
import sys

sys.path.append("/ascldap/users/djlittl/Albany_TPL/trilinos/trilinos-votd/GCC_4.7.2_OPT/bin")
import exodus

import string

if __name__ == "__main__":

    inFileName = "OBC_PatchTest.e"
    inFile = exodus.exodus(inFileName, mode="r")

    outFileLabel = string.splitfields(inFileName, ".")[0]

    # Print database parameters from inFile
    print " "
    print "Database version:         " + str(round(inFile.version.value, 2))
    print "Database title:           " + inFile.title()
    print "Database dimensions:      " + str(inFile.num_dimensions())
    print "Number of nodes:          " + str(inFile.num_nodes())
    print "Number of elements:       " + str(inFile.num_elems())
    print "Number of element blocks: " + str(inFile.num_blks())
    print "Number of node sets:      " + str(inFile.num_node_sets())
    print "Number of side sets:      " + str(inFile.num_side_sets())
    print " "
def write_file_exodus(domain = None, name_file_input = None, name_file_output = None):

    times = domain.times
    num_dims = domain.num_dims

    if os.path.isfile(name_file_output):
        cmd_line = "rm %s" % name_file_output
        os.system(cmd_line)

    with stdout_redirected():
        file_input = exodus(name_file_input)
        file_output = file_input.copy(name_file_output)

    # write times to file_output
    for step in range(len(times)):
       file_output.put_time(step + 1, times[step])

    #
    # write out displacement vector
    #
    file_output.set_node_variable_number(file_input.get_node_variable_number())

    count = 0
    for key, value in domain.names_variable_node.items():
        
        for suffix in value:

            count += 1
            name_variable = key + '_' + suffix
            file_output.put_node_variable_name(name_variable, count)

            for step in range(len(times)):

                file_output.put_node_variable_values(
                    name_variable,
                    step + 1,
                    file_input.get_node_variable_values(name_variable, step + 1))

    #
    # create variables in output file
    #
    file_output.set_element_variable_number(3 * num_dims**2 + 3)

    for dim_i in range(num_dims):

        for dim_j in range(num_dims):

            name_stress = 'Cauchy_Stress_' + str(dim_i + 1) + str(dim_j + 1)

            file_output.put_element_variable_name(
                name_stress, 
                dim_i * num_dims + dim_j + 1)

            name_def_grad = 'F_' + str(dim_i + 1) + str(dim_j + 1)

            file_output.put_element_variable_name(
                name_def_grad, 
                num_dims**2 + dim_i * num_dims + dim_j + 1)

            name_strain = 'Log_Strain_' + str(dim_i + 1) + str(dim_j + 1)

            file_output.put_element_variable_name(
                name_strain, 
                2 * num_dims**2 + dim_i * num_dims + dim_j + 1)

            for key_block in domain.blocks:

                block = domain.blocks[key_block]

                for step in range(len(times)):

                    file_output.put_element_variable_values(
                        key_block,
                        name_stress,
                        step + 1,
                        [block.elements[key_element].variables['Cauchy_Stress'][times[step]][dim_i][dim_j] for key_element in block.elements])

                    file_output.put_element_variable_values(
                        key_block,
                        name_def_grad,
                        step + 1,
                        [block.elements[key_element].variables['F'][times[step]][dim_i][dim_j] for key_element in block.elements])

                    file_output.put_element_variable_values(
                        key_block,
                        name_strain,
                        step + 1,
                        [block.elements[key_element].variables['Log_Strain'][times[step]][dim_i][dim_j] for key_element in block.elements])

    file_output.put_element_variable_name(
        'Mises_Stress', 
        3 * num_dims**2 + 1)

    for key_block in domain.blocks:

        block = domain.blocks[key_block]

        for step in range(len(times)):

            file_output.put_element_variable_values(
                key_block,
                'Mises_Stress',
                step + 1,
                [block.elements[key_element].variables['Mises_Stress'][times[step]] for key_element in block.elements])

    file_output.put_element_variable_name(
        'eqps', 
        3 * num_dims**2 + 2)

    for key_block in domain.blocks:

        block = domain.blocks[key_block]

        for step in range(len(times)):

            file_output.put_element_variable_values(
                key_block,
                'eqps',
                step + 1,
                [block.elements[key_element].variables['eqps'][times[step]] for key_element in block.elements])

    file_output.put_element_variable_name(
        'Misorientation', 
        3 * num_dims**2 + 3)

    for key_block in domain.blocks:

        block = domain.blocks[key_block]

        for step in range(len(times)):

            file_output.put_element_variable_values(
                key_block,
                'Misorientation',
                step + 1,
                [block.elements[key_element].variables['Misorientation'][times[step]] for key_element in block.elements])

            
    with stdout_redirected():
        file_output.close()
Example #47
0
#!/usr/bin/env python
from optparse import OptionParser
import sys
import os
module_dir = os.path.dirname(os.path.realpath(__file__))
module_dir += '/modules'
sys.path.append(module_dir)
import exodus

database_path = "baseline.g"

#Test outputing c-type arrays and numpy arrays
array_types = ['ctype', 'numpy']
for array_type in array_types:
    e = exodus.exodus(database_path, array_type = array_type)
    print "Exodus file has title:", e.title()
    print "Exodus file has", e.num_dimensions(), "dimensions"
    print "Exodus file has", e.num_nodes(), "nodes"
    print "Exodus file has", e.num_elems(), "elements"
    print "Exodus file has", e.num_blks(), "blocks"
    print "Exodus file has", e.num_node_sets(), "node sets"
    print "Exodus file has", e.num_side_sets(), "side sets"
    print "Exodus file has", e.num_times(), "time steps"
    if e.num_times() > 0:
      times = e.get_times()
      for time in times:
        print "time = ", time
        
    blocks = e.get_elem_blk_ids()
    for block in blocks:
      print "block id = ", block
    mat_file.close()

    print "\nMaterials file written to", file_name

    return

if __name__ == "__main__":

    if len(sys.argv) != 4:
        print "\nUsage: python -m lcm_preprocess.write_file_material <mat_props.txt> <rotation_matrices.txt> <mesh_filename>\n"
        sys.exit(1)

    mat_params_file_name = sys.argv[1]
    rotations_file_name = sys.argv[2]
    name_file_exodus = sys.argv[3]
    file_exodus = exodus(name_file_exodus)
    ids_block = file_exodus.get_elem_blk_ids()
    names_block = file_exodus.get_elem_blk_names()

    for idx in range(len(ids_block)):
        if (names_block[idx] == ""):
            names_block[idx] = "block_" + str(ids_block[idx])

    # List of material parameters that are expected to be in the input file
    # If it's set to None, then it is a required parameter
    mat_params = {}

    mat_params["crystal_structure"] = "fcc"
    mat_params["slip_families"] = "unspecified"
    mat_params["ratio_c_a"] = "unspecified"
Example #49
0
    # Remove old version of the exodus file, if it exists
    if os.path.exists(exodusFileName):
        os.remove(exodusFileName)

    # Open the output Exodus file
    exodusNumberOfDimensions = 3
    exodusNumberOfNodes = len(X)
    exodusNumberOfElements = len(X)
    exodusNumberOfBlocks = len(blocks)
    exodusNumberOfNodeSets = len(nodeSets)
    exodusNumberOfSideSets = 0
    exodusFile = exodus.exodus( exodusFileName,
                                'w',
                                'ctype',
                                exodusTitle,
                                exodusNumberOfDimensions,
                                exodusNumberOfNodes,
                                exodusNumberOfElements,
                                exodusNumberOfBlocks,
                                exodusNumberOfNodeSets,
                                exodusNumberOfSideSets )

    # Write the nodal coordinates
    coordNames = ["X", "Y", "Z"]
    exodusFile.put_coord_names(coordNames)
    exodusFile.put_coords(X, Y, Z)

    exodusBlockIds = []
    for key in blocks.keys():
        exodusBlockIds.append(key)

    # Write the element block information
def read_file_output_exodus(
    filename = None,
    names_variable_read = [
        'Cauchy_Stress',
        'F'],
    build_domain = True):

    with lcm_postprocess.stdout_redirected():
        file_input = exodus(filename,'r')

    # get number of dimensions
    num_dims = file_input.num_dimensions()

    # Get number of elements
    num_elements = dict([(id,file_input.num_elems_in_blk(id)) for id in file_input.get_elem_blk_ids()])
    element_ids = file_input.get_elem_id_map()
    lookup_index_id = dict([(element_ids[index],index) for index in range(len(element_ids))])

    # Get number of nodes
    num_nodes = file_input.num_nodes()
    node_ids = file_input.get_node_id_map()

    # Get output times
    times = file_input.get_times()

    # Get list of nodal variables
    node_var_names = file_input.get_node_variable_names()

    # Get the unique nodal variable names
    names_variable_node = dict()

    for name_node_variable in file_input.get_node_variable_names():

        match = re.search('(.+)_([x-z]+)', name_node_variable)
        
        if match != None:

            name_base = match.group(1)

            name_index = match.group(2)
        
            if name_base not in names_variable_node:

                names_variable_node[name_base] = [name_index]

            else:

                names_variable_node[name_base].append(name_index)

    # Get the unique variable names (deal with integration points and arrays)
    names_variable_element = dict()

    for name_element_variable in file_input.get_element_variable_names():

        match = re.search('(.+)_([0-9]+)', name_element_variable)
        
        if match != None:

            name_base = match.group(1)

            name_index = match.group(2)
        
        if name_base not in names_variable_element:

            names_variable_element[name_base] = [name_index]

        else:

            names_variable_element[name_base].append(name_index)

    # Get number of element blocks and block ids
    block_ids = file_input.get_elem_blk_ids()

    num_blocks = file_input.num_blks()

    # Calculate number of integration points
    num_points = len(names_variable_element['Weights'])

    # Check that "Weights" exist as an element variable
    if (num_points == 0):
      raise Exception("The weights field is not available...try again.")

    #
    # Create and populate the domain object
    #
    if build_domain is True:
        domain = lcm_postprocess.ObjDomain(
            num_dims = num_dims,
            num_elements = np.sum(num_elements.values()),
            num_nodes = num_nodes,
            times = [x for x in times],
            names_variable_node = names_variable_node,
            names_variable_element = names_variable_element)

    coords = file_input.get_coords()

    for index_node, node_id in enumerate(node_ids):

        domain.nodes[node_id] = lcm_postprocess.ObjNode(
            coords = np.array([coords[x][index_node] for x in range(num_dims)]))

        node = domain.nodes[node_id]

        for name_variable_node in names_variable_node:

            indices_variable = names_variable_node[name_variable_node]

            if len(indices_variable) == num_dims: #TODO: write code to store nodal scalars, etc.

                node.variables[name_variable_node] = \
                    dict([(step, np.zeros(num_dims)) for step in times])

    for name_variable_node in names_variable_node:

        for step in range(len(times)):

            time = times[step]

            for dim_i in range(num_dims):

                name_variable = name_variable_node + '_' + names_variable_node[name_variable_node][dim_i]

                values = file_input.get_node_variable_values(
                    name_variable,
                    step + 1)

                for index_node, key_node in enumerate(domain.nodes):

                    node = domain.nodes[key_node]

                    try:
                        node.variables[name_variable_node][time][dim_i] = values[index_node]
                    except:
                        print key_node

#-------------------------------------------------------------------------------
# Store the element variable values
#-------------------------------------------------------------------------------

    element_start_id = 0

    names_variable_exodus = get_names_variable(file_input)

    for block_id in block_ids:

        num_elements_block = get_num_elements_block(file_input, block_id)

        domain.blocks[block_id] = lcm_postprocess.ObjBlock(
            num_elements = num_elements[block_id],
            num_points = num_points,
            num_nodes_per_elem = file_input.num_nodes_per_elem(block_id),
            name = file_input.get_elem_blk_name(block_id))
        # TODO: change line above to line below
        # num_points =  = num_points[block_id]

        block = domain.blocks[block_id]

        block.map_element_ids = dict()

        for index_element in range(num_elements[block_id]):

            # Get the global element number
            key_element = element_ids[index_element + element_start_id]

            # Map global element id to blockwise index
            block.map_element_ids[key_element] = index_element

            block.elements[key_element] = lcm_postprocess.ObjElement()

            element = block.elements[key_element]

            connectivity, num_elements_block, num_nodes_element = file_input.get_elem_connectivity(block_id)

            connectivity_array = np.reshape([x - 1 for x in connectivity], (num_elements_block, num_nodes_element))

            for index_node in range(block.num_nodes_per_elem):

                node_id = node_ids[connectivity_array[index_element, index_node]]

                element.nodes[node_id] = domain.nodes[node_id]

            for index_point in range(num_points):

                element.points[index_point] = lcm_postprocess.ObjPoint()

        for index_point in range(block.num_points):

            key_weight = 'Weights_' + str(index_point + 1)

            index_weight = names_variable_exodus.index(key_weight) + 1

            values_weights = get_element_variable_values(
                file_input, block_id, num_elements_block, index_weight, 1)

            for key_element in block.elements:

                block.elements[key_element].points[index_point].weight = \
                    values_weights[block.map_element_ids[key_element]]

        for key_element in block.elements:

            element = block.elements[key_element]

            element.volume = np.sum([element.points[x].weight for x in element.points])

        block.volume = np.sum([block.elements[x].volume for x in block.elements])

        element_start_id += block.num_elements

    domain.volume = np.sum([domain.blocks[x].volume for x in domain.blocks])

    #
    # Set the values of the variables in the domain object
    #
    for key_variable in names_variable_element:

        # print 'Reading variable:'
        # print '  ', key_variable

        indices_variable = names_variable_element[key_variable]

        if len(indices_variable) == num_points * num_dims**2:

            _set_values_tensor(
                file_input,
                key_variable,
                indices_variable,
                domain)

        # elif len(indices_variable) == num_slip_systems:

        #     _set_values_vector(
        #         file_input,
        #         key_variable,
        #         indices_variable,
        #         domain)

        elif len(indices_variable) == num_points:

            _set_values_scalar(
                file_input,
                key_variable,
                indices_variable,
                domain)

    with lcm_postprocess.stdout_redirected():
        file_input.close()

    return domain
Example #51
0
#!/usr/bin/python
# Usage:
#      chqa.py <filename>
#
# Simple python script that retrieves and prints to stdout
# the qa records of exodus file <filename>
#
# Note: This requires the exodus python module to be in a
# directory listed in $PYTHONPATH and a dynamic exodus
# library (exodus.so) to be named in exodus.py.

import exodus
import sys

ef = exodus.exodus(sys.argv[1], 'r')
print(ef.get_qa_records())
ef.close()
Example #52
0
import sys

sys.path.append('/opt/moose/seacas/lib')

from exodus import exodus

e = exodus('xyz.e', mode='r', array_type='numpy')

print e.num_elems()
Example #53
0
import sys
import exodus
import numpy
import matplotlib.pyplot as plt

file_name_exp = "SingleSlipPlaneHard_Explicit.exo"
exo_file_exp = exodus.exodus(file_name_exp,"r")

file_name_imp = "SingleSlipPlaneHard_Implicit.exo"
exo_file_imp = exodus.exodus(file_name_imp,"r")

inp_var_name = "gamma_1_1"
dep_var_name = "tau_hard_1_1"
dep_var_name_2 = "tau_1_1"
dep_var_name_3 =  "CP_Residual_1"

int_pt = 1
block_id = 2

output_file_name = "SingleSlipPlaneHard_" + dep_var_name + ".pdf"
output_file_name_2 = "SingleSlipPlaneHard_" + dep_var_name_2 + ".pdf"
output_file_name_3 = "SingleSlipPlaneHard_" + dep_var_name_3 + ".pdf"

output_file_name_png = "SingleSlipPlaneHard_" + dep_var_name + ".png"
output_file_name_2_png = "SingleSlipPlaneHard_" + dep_var_name_2 + ".png"
output_file_name_3_png = "SingleSlipPlaneHard_" + dep_var_name_3 + ".png"


############### explicit
n_steps_exp = exo_file_exp.num_times()
time_vals_exp = exo_file_exp.get_times()
Example #54
0
#    The path above is valid on the CEE LAN.  On other systems, you need to provide a path to a SEACAS build
#    that includes shared libraries.
import sys
sys.path.append('/ascldap/users/djlittl/Albany_TPL/trilinos/trilinos-votd/GCC_4.7.2_OPT/bin')
sys.path.append('/home/glbergel/LCM/trilinos-install-serial-gcc-release/bin')
import exodus
import string

if __name__ == "__main__":

    if len(sys.argv) != 2:
        print "\nUsage:  PostProcess.py <exodus_file_name>\n"
        sys.exit(1)

    inFileName = sys.argv[1]
    inFile = exodus.exodus(inFileName, mode='r')

    outFileLabel = string.splitfields(inFileName, '.')[0] + "_"

    # Print database parameters from inFile
    print " "
    print "Database version:         " + str(round(inFile.version.value,2))
    print "Database title:           " + inFile.title()
    print "Database dimensions:      " + str(inFile.num_dimensions())
    print "Number of nodes:          " + str(inFile.num_nodes())
    print "Number of elements:       " + str(inFile.num_elems())
    print "Number of element blocks: " + str(inFile.num_blks())
    print "Number of node sets:      " + str(inFile.num_node_sets())
    print "Number of side sets:      " + str(inFile.num_side_sets())
    print " "
Example #55
0
else:
        print 'creating new mesh file'

#------Define geometry of Mesh------#
titleIn = 'Generic Title'
numDimIn = dimension 
print 'tot nodes', totNodes
numNodesIn = totNodes  
numElemsIn = 2
numBlocksIn = 2
numNodeSetsIn = 2
numSideSetsIn = 2

#------Construct Mesh Object------#
e = exodus(fileName, mode='w', array_type='numpy',title=titleIn,
           numDims=numDimIn,numNodes=numNodesIn,numElems=numElemsIn,
           numBlocks=numBlocksIn,numNodeSets=numNodeSetsIn,numSideSets=numSideSetsIn,io_size=0)
#------Put QA Records------#
rec1 = ('Python Writer','1.0','date','time')
rec2 = ('Python Writer','1.0','date','time')
rec3 = ('Python Writer','1.0','date','time')
qaRecords = (rec1,rec2,rec3)
e.put_qa_records(qaRecords)

#------Function to create a list of evenly spaced coordinates------#
def create_coord(cmin,cmax,cnum):
        absDiff = abs(cmax)+abs(cmin)
        cmin    = float(cmin)
        cmax    = float(cmax)
        absDiff = float(absDiff)
        cnum    = float(cnum)
Example #56
0
import sys
import exodus
import numpy
import matplotlib.pyplot as plt

file_name = "out.e"
exo_file = exodus.exodus(file_name,"r")
inp_var_name = "Normal_Jump_1"
dep_var_name = "Normal_Traction_1"
int_pt = 1
block_id = 3

output_file_name = file_name + ".pdf"

###############
n_steps = exo_file.num_times()
time_vals = exo_file.get_times()

inp_var = numpy.zeros(shape=(n_steps,1))
for i in range(n_steps):
    inp_var[i]=exo_file.get_element_variable_values(block_id,inp_var_name,i+1)

dep_var = numpy.zeros(shape=(n_steps,1))
for i in range(n_steps):
    dep_var[i]=exo_file.get_element_variable_values(block_id,dep_var_name,i+1)

###############
fig, ax = plt.subplots()
ax.plot(inp_var,dep_var,color='blue',label=file_name)
plt.xlabel(inp_var_name)
plt.ylabel(dep_var_name)
Example #57
0
 def __read(self):
     self.exodus_template = exodus.exodus(self.exodus_file, array_type='numpy')