Example #1
0
def add_constant_material_parameter(input_file, name, value, output_file):
    '''
    Adds single parameter with a constant value for entire mesh.
    > python pysalvus.py model_handling add_constant_material_parameter --input_file mesh-in.e --name VP --value 4 --output_file mesh-out.e
    '''    
    (num_elems,nNodeElm) = model.getElemsAndNodes(input_file)
    parameter_values = []
    parameter_names = []
    for (this_name,this_value) in zip(name,value):        
        for i in range(0,nNodeElm):
            parameter_names.append("{}_{}".format(this_name,i))
            parameter_values.append(np.ones(num_elems) * this_value)
                    
    exo = model.getExodusCopy(input_file,output_file,parameter_names)
    model.setMaterialParameter(exo,parameter_names,parameter_values)
    exo.close()
Example #2
0
def add_fluid_flag(input_file, fluid_type, output_file):
    '''
    Just a quick function to mark everything as fluid.
    :param input_file:
    :param output_file:
    :return:
    '''
    (num_elems,nNodeElm) = model.getElemsAndNodes(input_file)    
    
    if fluid_type == "fluid":
        values = np.ones(num_elems)
    elif fluid_type == "elastic":
        values = np.zeros(num_elems)

    exo = model.getExodusCopy(input_file,output_file,["fluid"])
    model.setMaterialParameter(exo,["fluid"],[values])
    exo.close()