2 from numpy
import genfromtxt, zeros, savetxt
11 Creates a node based file for variables
17 variable_file : string
18 name of file containing variable files. Must be a single column where each line corresponds to that fracture number.
20 name of materialid file produced by large. Normally produced by run_meshing. Can
23 variable_file_by_node : string
24 name of file containing node based values of the variable
28 print(f
"--> Making {variable} by node file")
29 values = genfromtxt(variable_file, skip_header=1)[:, -1]
30 if not os.path.isfile(matid_file):
31 error = f
"ERROR!!! Cannot locate the file '{matid_file}'\nExiting\n"
32 sys.stderr.write(error)
34 nodes = genfromtxt(matid_file, skip_header=3).astype(int)
35 value_by_node = zeros(len(nodes))
36 for i, n
in enumerate(nodes):
37 value_by_node[i] = values[n - 1]
38 variable_file_by_node = f
"{variable}_by_node.dat"
39 savetxt(variable_file_by_node, value_by_node)
41 return variable_file_by_node
47 Creates a LaGriT script to append the attribute to the mesh
53 variable_file : string
54 name of file containing variable files. Must be a single column where each line corresponds to that node number in the mesh
56 Name of source mesh file
57 mesh_file_out : string
58 Name of Target mesh file
62 Name of LaGriT output file
64 print(
"Making LaGriT script")
66 read / {mesh_file_in} / mo1
67 cmo / addatt / mo1 / {variable} / vdouble / scalar / nnodes
68 cmo / setatt / mo1 / {variable} / 1 0 0 / 1
69 cmo / readatt / mo1 / {variable} / 1, 0, 0 / {variable_file}
70 dump / {mesh_file_out} / mo1
74 lagrit_file = f
"add_{variable}_to_mesh.lgi"
75 fp = open(lagrit_file,
"w")
76 fp.write(lagrit_script)
90 Adds a variable to the nodes of a mesh. Can be either fracture (material) based
99 variable_file : string
100 name of file containing variable files. Must be a single column where each line corresponds to that node number in the mesh
101 mesh_file_in : string
102 Name of source mesh file
103 mesh_file_out : string
104 Name of Target mesh file. If no name if provide, mesh_file_in will be used
106 Set to True if variable_file contains cell-based values, Set to False
107 if variable_file provide fracture based values
112 Name of LaGriT output file
115 if mesh_file_out
is None:
116 mesh_file_out = mesh_file_in
120 mesh_file_in, mesh_file_out)
124 variable_file_by_node,
125 mesh_file_in, mesh_file_out)
126 run_lagrit_script(lagrit_file)
def add_variable_to_mesh(self, variable, variable_file, mesh_file_in, mesh_file_out=None, cell_based=None)
def create_variable_file(variable, variable_file, matid_file="materialid.dat")
def create_lagrit_append_script(variable, variable_file, mesh_file_in, mesh_file_out)