From 796be57be270047810ad6fa36f9c8c51ecf091d0 Mon Sep 17 00:00:00 2001 From: Mathieu Deiber Date: Tue, 19 Nov 2019 16:53:57 +1100 Subject: [PATCH] correct mid side node and layer number bug --- RMA2SERAPHIN_3DRMA11_20191118.py | 29 +++++++++++++++++++++-------- py_rmatools_v03.py | 1 + 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/RMA2SERAPHIN_3DRMA11_20191118.py b/RMA2SERAPHIN_3DRMA11_20191118.py index 36d61be..9dbf1a4 100644 --- a/RMA2SERAPHIN_3DRMA11_20191118.py +++ b/RMA2SERAPHIN_3DRMA11_20191118.py @@ -13,12 +13,11 @@ import pandas as pd import numpy as np plt.rcParams.update({'figure.max_open_warning': 0}) - # In[65]: -meshFilename = 'pok005.rm1' +meshFilename = 'KMA003.rm1' channelWidth = 100 -RMAfilenames = ['POA034'] +RMAfilenames = ['KMA008'] #If RMA11 constNum = [1] @@ -26,10 +25,10 @@ constNum = [1] #If RMA11 3D #Options = [4,8,1,'Max'] #Option available 'Max' , an integer correspond to the layer number to extract the results, if 2D use options = [1] - 'Percentile' (percentile only work for RMA11 FOR now) -Options = [8] +Options = [9] #if we specified 8 layers in RMA10 then the bed layer is layer #9 percentiles = [0.5,0.8,0.9,0.95,1] -NodeLayersFile = 'NodeLayers005.txt' #the node layer file was created by getting the nodes number from the RMA Outfile (just run RMA11 for a few steps) -Nnodes = 6674 #Number of nodes (including mid side node) - thisn umber also correspond to the last node number in the nodelayers file +NodeLayersFile = 'NodeLayers003.txt' #the node layer file was created by getting the nodes number from the RMA Outfile (just run RMA11 for a few steps) +Nnodes = 6127 #Number of nodes (including mid side node) - thisn umber also correspond to the last node number in the nodelayers file # In[66]: def isElementOneD(nodelist1): @@ -480,7 +479,10 @@ def writeConst(param,key): tempArr.append(tempR[n]) tempVal1 = max(tempArr) elif isinstance(option, int): - temppos = (option - 1 ) * 2 + if key in cornerNodes: + temppos = (option - 1 ) * 2 + else: + temppos = option temppos2 = min([temppos,len(nodelayer[key])-1]) tempVal1 = tempR[nodelayer[key][temppos2]] else: @@ -626,6 +628,8 @@ def readNodeLayers(fname,Nnodes): #Read mesh file and extract node (except mid node) and elements - plus convert 1D element to 2D for vizualisation nodelayer = {} +midSideNodes = [] +cornerNodes = [] NodeList = [] ElementList = [] ElementDict = {} @@ -649,6 +653,13 @@ with open(meshFilename) as f: temp = re.findall('.....',line) ElementDict[int(temp[0])] = [int(temp[i]) for i in range(1,9) if int(temp[i]) != 0 and int(temp[9]) < 100] + + for idx, n in enumerate(ElementDict[int(temp[0])]): + if idx%2 == 0: + cornerNodes.append(n) + else: + midSideNodes.append(n) + ElementList.append(int(temp[0])) line = f.readline() @@ -656,6 +667,8 @@ with open(meshFilename) as f: NodeList.extend(value) NodeList = list(set(NodeList)) + cornerNodes = list(set(cornerNodes)) + midSideNodes = list(set(midSideNodes)) line = f.readline() while line and line != ' 9999\n': @@ -699,7 +712,7 @@ for key, value in nodeDict.items(): # In[72]: for run in RMAfilenames: for option in Options: - RMAfilename = '{}'.format(run) + RMAfilename = '{}/{}'.format(run,run) R=rma() R.open(RMAfilename) R.next() diff --git a/py_rmatools_v03.py b/py_rmatools_v03.py index 7e2af6e..4f136b0 100644 --- a/py_rmatools_v03.py +++ b/py_rmatools_v03.py @@ -4,6 +4,7 @@ import sys from array import array + # Updated 10/11/15 BMM : Added mesh. # Updated 10/11/15 MD : Added dictionnary initialisation in mesh. # Update 8/11/2019 MD : Improve performance (used array instead of unpack)