From bd6a1d7886ba19d1f115c3dd58f783bf2e87471d Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Thu, 31 Mar 2016 18:13:14 +0100 Subject: [PATCH] Experimental functionality to include geometry from externally stored NumPy array. --- gprMax/input_cmds_geometry.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/gprMax/input_cmds_geometry.py b/gprMax/input_cmds_geometry.py index f2070170..84fa4eac 100644 --- a/gprMax/input_cmds_geometry.py +++ b/gprMax/input_cmds_geometry.py @@ -40,7 +40,40 @@ def process_geometrycmds(geometry, G): for object in geometry: tmp = object.split() - if tmp[0] == '#edge:': + if tmp[0] == '#geometry_objects_file:': + if len(tmp) != 2: + raise CmdInputError("'" + ' '.join(tmp) + "'" + ' requires exactly one parameter') + geofile = tmp[1] + + # See if file exists at specified path and if not try input file directory + if not os.path.isfile(geofile): + geofile = os.path.join(G.inputdirectory, geofile) + + data = np.load(geofile) + nx = data.shape[0] + ny = data.shape[1] + nz = data.shape[2] + + if nx > G.nx or ny > G.ny or nz > G.nz: + raise CmdInputError("'" + ' '.join(tmp) + "'" + ' the requested geometry objects do not fit within the model domain') + + for i in range(nx): + for j in range(ny): + for k in range(nz): + numIDlocal = data[i, j, k] + for material in G.materials: + try: + material.ID.split('_')[1] + if int(material.ID.split('_')[1]) == numIDlocal: + numID = numIDx = numIDy = numIDz = material.numID + build_voxel(i, j, k, numID, numIDx, numIDy, numIDz, False, G.solid, G.rigidE, G.rigidH, G.ID) + else: + raise CmdInputError("'" + ' '.join(tmp) + "'" + ' cannot find material ID {}'.format(numIDlocal)) + except: + pass + + + elif tmp[0] == '#edge:': if len(tmp) != 8: raise CmdInputError("'" + ' '.join(tmp) + "'" + ' requires exactly seven parameters')