def list_print_BC(list_array,names,dim): """Print list_array in a format which can be copied directly into the c-code.""" if (dim == 2): if (names[1] == "FToP"): Pnames = ['IndF','IndFP','IndBC'] elif (names[1] == "EToP"): Pnames = ['IndE','IndEP','IndBC'] else: EXIT_TRACEBACK() NEntries = 3 Plists = ['' for i in range(NEntries)] count = 0 item_count = 0 for item in list_array: if item[0] != 'x': Plists[0] += Pnames[0]+'['+str(count)+'] = '+str(item_count)+'; ' Plists[1] += Pnames[1]+'['+str(count)+'] = '+str(item[0])+'; ' Plists[2] += Pnames[2]+'['+str(count)+'] = '+str(item[1])+'; ' count += 1 item_count += 1 for i in range(NEntries): print(Plists[i]) print("\n") elif (dim == 3): for i in range(len(list_array)): if (names[0] == "vh"): print(names[0],":",i+1) else: EXIT_TRACEBACK() list_print_BC(list_array[i],names,2) else: EXIT_TRACEBACK()
def find_MeshType(N,MeshTypes,MeshTypesPrefix,MeshName,MeshCurving): Found = 0 for i in range(0,N): if (MeshName.find(MeshCurving[i]+MeshTypes[i]) != -1): # Eliminate occurence of finding Curved in ToBeCurved ... if (MeshName.find('ToBeCurved') != -1 and MeshCurving[i].find('ToBeCurved') == -1): continue if (MeshName.find(MeshTypesPrefix[i][0:6]) == -1): continue Found = 1 MeshType = [MeshTypes[i]] MeshCurving = [MeshCurving[i]] if (len(MeshTypesPrefix) == 1): MeshTypesPrefix = [MeshTypesPrefix[0]] else: MeshTypesPrefix = [MeshTypesPrefix[i]] break; if (Found == 0): print("Did not find the MeshType.\n") print(MeshName,"\n",MeshCurving,"\n",MeshTypes,"\n",MeshTypesPrefix,"\n") EXIT_TRACEBACK() return [MeshType, MeshTypesPrefix, MeshCurving]
def get_ELEMENT_type(EType, ELEMENTs): for ELEMENT in ELEMENTs: if (EType.find(ELEMENT.EType) != -1): return ELEMENT print("Did not find the ELEMENT of type:", EType) EXIT_TRACEBACK()
def set_paths(self,Paths): if (self.name.find('update_h') != -1): self.name = 'Test_update_h_' self.Path = Paths.control_files+'test/update_h/' elif (self.name.find('L2_proj_p') != -1): self.name = 'Test_L2_proj_p_' self.Path = Paths.control_files+'test/L2_proj_p/' elif (self.name.find('L2_proj_h') != -1): self.name = 'Test_L2_proj_h_' self.Path = Paths.control_files+'test/L2_proj_h/' elif (self.name.find('linearization') != -1): self.name = 'Test_linearization_' self.Path = Paths.control_files+'test/linearization/' elif (self.name.find('Advection') != -1): if (self.name.find('test') != -1): self.name = 'Test_Advection_' self.Path = Paths.control_files+'test/Advection/' else: print("name: Advection") EXIT_TRACEBACK() elif (self.name.find('Poisson') != -1): if (self.name.find('test') != -1): self.name = 'Test_Poisson_' self.Path = Paths.control_files+'test/Poisson/' else: self.name = 'Poisson' print("name:",self.name) EXIT_TRACEBACK() elif (self.name.find('Euler') != -1): if (self.name.find('test') != -1): self.name = 'Test_Euler_' self.Path = Paths.control_files+'test/Euler/' else: print("name:",self.name) EXIT_TRACEBACK() elif (self.name.find('NavierStokes') != -1): if (self.name.find('test') != -1): self.name = 'Test_NavierStokes_' self.Path = Paths.control_files+'test/NavierStokes/' else: print("name:",self.name) EXIT_TRACEBACK() else: print("name:",self.name) EXIT_TRACEBACK()
def list_print(list_array, name, dim): if (dim == 2): for item in list_array: print('\t'.join(map(str, item))) print("\n") elif (dim == 3): for i in range(len(list_array)): print(name, ":", i) list_print(list_array[i], "", 2) else: EXIT_TRACEBACK()
def get_gmsh_number(gmsh_args,name,Paths): fName = Paths.meshes + 'Parameters.geo' Found = 0 with open(fName) as f: for line in f: if (name.upper() in line): Found = 1 return line.split()[2][:-1] print('Error: Did not find a value for '+name.upper()+' in '+fName+'\n') EXIT_TRACEBACK()
def add_TRIs_conn(self, row, neighbour_location): """ Add TRI element connectivity entries to the global connectivity array for the current row. """ conn = self.conn if (row % 2 == 0): NZCols = self.NZCols_evn else: NZCols = self.NZCols_odd base_c = row * self.NRows if (neighbour_location == 'above'): base_n = (row + 1) * self.NRows elif (neighbour_location == 'below'): base_n = (row - 1) * self.NRows else: EXIT_TRACEBACK() iterator = iter(range(0, self.NRows - 1)) for col in iterator: if (NZCols[col] == 0): continue if (row % 2 != 0): if (col == 0): conn_E = [base_c + col, base_c + col + 1, base_n + col] add_local_conn(self, neighbour_location, conn_E) continue elif (col == self.NRows - 2): conn_E = [ base_c + col, base_c + col + 1, base_n + col + 1 ] add_local_conn(self, neighbour_location, conn_E) continue if (NZCols[col + 1] == 0): conn_E = [base_c + col, base_c + col + 2, base_n + col + 1] add_local_conn(self, neighbour_location, conn_E) else: conn_E = [base_c + col, base_c + col + 1, base_n + col + 1] add_local_conn(self, neighbour_location, conn_E) conn_E = [ base_c + col + 1, base_c + col + 2, base_n + col + 1 ] add_local_conn(self, neighbour_location, conn_E) next(iterator, None)
def set_variables(self): if (self.name == 'Peterson'): self.VarName = 'ADVECTION_TEST_PETERSON' MESHES_SPECIFIC = 'n-Cube/Advection/Steady/Peterson/YL/' MeshOutputs = '' NML = 6 # Should match NML used in generate_peterson_meshes.py for ML in range(0, NML): MeshOutputs += MESHES_SPECIFIC + 'n-Cube2D_StraightTRI' + str( ML) + 'x.msh ' self.MeshOutputs = MeshOutputs else: EXIT_TRACEBACK()
def add_boundaries(self, line_index, BC_index): boundaries = self.boundaries NRows = self.NRows if (math.floor(line_index / 1000) == 1): # Horizontal boundaries (some entries skipped over depending on NZCols) NZCols = self.NZCols_evn base_c = 0 if (line_index == 1002): base_c = NRows * (NRows - 1) for col in range(0, NRows - 1): if (NZCols[col] == 0): continue if (NZCols[col + 1] == 0): conn_E = [base_c + col, base_c + col + 2] else: conn_E = [base_c + col, base_c + col + 1] boundaries.append([2, 10000 + BC_index, line_index] + conn_E) elif (math.floor(line_index / 1000) == 2): # Vertical boundaries base_c = 0 if (line_index == 2002): base_c = NRows - 1 NRows = self.NRows for row in range(0, NRows - 1): conn_E = [base_c + row * NRows, base_c + (row + 1) * NRows] boundaries.append([2, 10000 + BC_index, line_index] + conn_E) else: EXIT_TRACEBACK()
with open(fName) as f: for line in f: if (name.upper() in line): Found = 1 return line.split()[2][:-1] print('Error: Did not find a value for '+name.upper()+' in '+fName+'\n') EXIT_TRACEBACK() if __name__ == '__main__': """ Generate meshes based on the CaseList read from command line arguments. """ Paths = Paths_class() Paths.set_paths() CaseName = sys.argv[1] MeshName = sys.argv[2] if (len(sys.argv) > 3): print("Input arguments should be limitted to 'TestCase MeshFile'") EXIT_TRACEBACK() print('\n\n\nGenerating '+MeshName+'.\n\n') TestCase = TestCase_class(CaseName) TestCase.set_paths(Paths) TestCase.add_MeshTypes(Paths,MeshName) create_meshes(TestCase,Paths)
def add_MeshTypes(self,Paths,MeshName): MeshCurving = [] MeshTypes = [] MeshTypesPrefix = [] if (self.name.find('update_h') != -1 or self.name.find('L2_proj') != -1): if (self.name.find('update_h') != -1): self.VarName = 'UPDATE_H' elif (self.name.find('L2_proj_p') != -1): self.VarName = 'L2_PROJ_P' elif (self.name.find('L2_proj_h') != -1): self.VarName = 'L2_PROJ_H' NTotal = 6 MeshTypesPrefix = ['' for i in range(NTotal)] MeshCurving = ['' for i in range(NTotal)] MeshTypes = ['TRI','QUAD','TET','HEX','WEDGE','PYR'] if (MeshName.find('all') != -1): iRange = range(0,NTotal) else: iRange = range(0,1) [MeshTypes,MeshTypesPrefix,MeshCurving] = find_MeshType(NTotal,MeshTypes,MeshTypesPrefix,MeshName,MeshCurving) elif (self.name.find('linearization') != -1): self.VarName = 'LINEARIZATION' NTotal = 3 MeshTypesPrefix = ['' for i in range(NTotal)] MeshCurving = ['ToBeCurved' for i in range(NTotal)] MeshTypes = ['MIXED2D','MIXED3D_TP','MIXED3D_HW'] if (MeshName.find('all') != -1): iRange = range(0,NTotal) else: iRange = range(0,1) [MeshTypes,MeshTypesPrefix,MeshCurving] = find_MeshType(NTotal,MeshTypes,MeshTypesPrefix,MeshName,MeshCurving) elif (self.name.find('Advection') != -1): if (self.name.lower().find('test') != -1): self.VarName = 'ADVECTION_TEST' MeshCurving.extend(('Straight' for i in range (0,2))) MeshTypes.extend(('TRI','QUAD')) MeshTypesPrefix.extend(('Default_n-Cube_' for i in range(0,2))) NTotal = len(MeshTypes) if (MeshName.find('all') != -1): iRange = range(0,NTotal) else: iRange = range(0,1) [MeshTypes,MeshTypesPrefix,MeshCurving] = find_MeshType(NTotal,MeshTypes,MeshTypesPrefix,MeshName,MeshCurving) else: EXIT_TRACEBACK() elif (self.name.find('Poisson') != -1): if (self.name.lower().find('test') != -1): self.VarName = 'POISSON_TEST' MeshCurving.extend(('Curved' for i in range (0,4))) MeshCurving.extend(('ToBeCurved' for i in range (0,2))) MeshCurving.extend(('Straight' for i in range (0,1))) MeshTypes.extend(('MIXED2D','TRI','QUAD','MIXED2D')) MeshTypes.extend(('TRI','QUAD')) MeshTypes.extend(('LINE' for i in range(0,1))) MeshTypesPrefix.extend(('n-Ball_HollowSection_' for i in range(0,1))) MeshTypesPrefix.extend(('n-Ellipsoid_HollowSection_' for i in range(0,5))) MeshTypesPrefix.extend(('n-Cube_' for i in range(0,1))) NTotal = len(MeshTypes) if (MeshName.find('all') != -1): iRange = range(0,NTotal) else: iRange = range(0,1) [MeshTypes,MeshTypesPrefix,MeshCurving] = find_MeshType(NTotal,MeshTypes,MeshTypesPrefix,MeshName,MeshCurving) else: EXIT_TRACEBACK() elif (self.name.find('Euler') != -1): if (self.name.lower().find('test') != -1): self.VarName = 'EULER_TEST' MeshCurving.extend(('' for i in range (0,2))) MeshCurving.extend(('Curved' for i in range (0,1))) MeshCurving.extend(('ToBeCurved' for i in range (0,6))) MeshCurving.extend(('Curved' for i in range (0,1))) MeshCurving.extend(('ToBeCurved' for i in range (0,4))) MeshTypes.extend(('TRI','QUAD')) MeshTypes.append(('MIXED2D')) MeshTypes.extend(('MIXED2D','MIXED3D_TP','MIXED3D_HW','TET','HEX','WEDGE')) MeshTypes.append(('QUAD')) # Problem with not generating all meshes here (ToBeModified) MeshTypes.extend(('TRI','QUAD','TRI','TRI')) MeshTypesPrefix.extend(('PeriodicVortex_' for i in range(0,2))) MeshTypesPrefix.extend(('SupersonicVortex_' for i in range(0,7))) MeshTypesPrefix.extend(('GaussianBump_' for i in range(0,1))) MeshTypesPrefix.extend(('ParabolicPipe_' for i in range(0,1))) MeshTypesPrefix.extend(('EllipticPipe_' for i in range(0,2))) MeshTypesPrefix.extend(('SinusoidalPipe_' for i in range(0,1))) NTotal = len(MeshTypes) if (MeshName.find('all') != -1): iRange = range(0,NTotal) else: iRange = range(0,1) [MeshTypes,MeshTypesPrefix,MeshCurving] = find_MeshType(NTotal,MeshTypes,MeshTypesPrefix,MeshName,MeshCurving) else: print(self.name) EXIT_TRACEBACK() elif (self.name.find('NavierStokes') != -1): if (self.name.lower().find('test') != -1): self.VarName = 'NAVIERSTOKES_TEST' MeshCurving.extend(('' for i in range (0,1))) MeshCurving.extend(('ToBeCurved' for i in range (0,3))) MeshTypes.append(('QUAD')) MeshTypes.extend(('TRI','QUAD','MIXED2D')) MeshTypesPrefix.extend(('PlaneCouette_' for i in range(0,1))) MeshTypesPrefix.extend(('TaylorCouette_' for i in range(0,3))) NTotal = len(MeshTypes) if (MeshName.find('all') != -1): iRange = range(0,NTotal) else: iRange = range(0,1) [MeshTypes,MeshTypesPrefix,MeshCurving] = find_MeshType(NTotal,MeshTypes,MeshTypesPrefix,MeshName,MeshCurving) else: print(self.name) EXIT_TRACEBACK() else: EXIT_TRACEBACK() for i in iRange: TypeCurrent = MeshType_class(MeshTypes[i],MeshTypesPrefix[i]+MeshCurving[i]) TypeCurrent.set_parameters(self,Paths) self.MeshTypes.append(TypeCurrent)
def __init__(self, name): self.name = name Nv = 0 if (name.find('LINE') != -1): if (name == 'LINE2'): Nv = 2 VToVe = [[0, 1], [1, 2]] VTypes = ['LINE' for i in range(Nv)] elif (name.find('TRI') != -1): if (name == 'TRI4'): Nv = 4 VToVe = [[0, 1, 3], [1, 2, 4], [3, 4, 5], [4, 3, 1]] VTypes = ['TRI' for i in range(Nv)] elif (name.find('QUAD') != -1): if (name == 'QUAD4'): Nv = 4 VToVe = [[0, 1, 3, 4], [1, 2, 4, 5], [3, 4, 6, 7], [4, 5, 7, 8]] VTypes = ['QUAD' for i in range(Nv)] elif (name == 'QUAD2r'): Nv = 2 VToVe = [[0, 1, 6, 7], [1, 2, 7, 8]] VTypes = ['QUAD' for i in range(Nv)] elif (name == 'QUAD2s'): Nv = 2 VToVe = [[0, 2, 3, 5], [3, 5, 6, 8]] VTypes = ['QUAD' for i in range(Nv)] elif (name.find('TET') != -1): if (name == 'TET8'): Nv = 8 VToVe = [[0, 1, 3, 6], [1, 2, 4, 7], [3, 4, 5, 8], [6, 7, 8, 9], [1, 8, 7, 4], [8, 1, 6, 3], [7, 6, 8, 1], [4, 3, 1, 8]] VTypes = ['TET' for i in range(Nv)] elif (name == 'TET12'): Nv = 12 VToVe = [[0,1,3,6],[1,2,4,7],[3,4,5,8],[6,7,8,9],[10,8,7,4],[8,10,6,3],\ [7,6,10,1],[4,3,1,10],[10,1,6,3],[1,10,7,4],[4,3,10,8],[7,6,8,10]] VTypes = ['TET' for i in range(Nv)] elif (name == 'TET6'): Nv = 6 VToVe = [[0, 1, 3, 6], [1, 2, 4, 7], [3, 4, 5, 8], [6, 7, 8, 9], [7, 6, 4, 3, 1], [6, 7, 3, 4, 8]] VTypes = ['TET' for i in range(4)] for i in range(2): VTypes.append('PYR') elif (name.find('HEX') != -1): if (name == 'HEX8'): Nv = 8 VToVe = [[0,1, 3, 4, 9, 10,12,13],[1, 2, 4, 5, 10,11,13,14],[3, 4, 6, 7, 12,13,15,16],[4, 5, 7, 8, 13,14,16,17],\ [9,10,12,13,18,19,21,22],[10,11,13,14,19,20,22,23],[12,13,15,16,21,22,24,25],[13,14,16,17,22,23,25,26]] VTypes = ['HEX' for i in range(Nv)] elif (name.find('PYR') != -1): if (name == 'PYR10'): Nv = 10 VToVe = [[0,1,3,4,9],[1,2,4,5,10],[3,4,6,7,11],[4,5,7,8,12],\ [3,4,11,9],[4,5,12,10],[10,9,4,1],[12,11,7,4],[10,9,12,11,4],[9,10,11,12,13]] VTypes = ['PYR' for i in range(4)] for i in range(4): VTypes.append('TET') for i in range(2): VTypes.append('PYR') elif (name.find('WEDGE') != -1): if (name == 'WEDGE8'): Nv = 8 VToVe = [[0,1,3,6,7,9],[1,2,4,7,8,10],[3,4,5,9,10,11],[4,3,1,10,9,7],\ [6,7,9,12,13,15],[7,8,10,13,14,16],[9,10,11,15,16,17],[10,9,7,16,15,13]] VTypes = ['WEDGE' for i in range(Nv)] else: print(name) EXIT_TRACEBACK() if (Nv == 0): print("Did not find a refinement type for the given input.\n") EXIT_TRACEBACK() self.Nv = Nv self.VToVe = VToVe self.VTypes = VTypes
def __init__(self, EType): self.EType = EType Neve = 2 Nfve = [] if (EType == 'LINE'): d = 1 Nf = 2 Ne = 0 Nfve = [1 for i in range(0, Nf)] VToVe = [[0, 2]] RefTypes = ['LINE2'] FVertices = [set([0]), set([2])] EVertices = [] elif (EType == 'TRI'): d = 2 Nf = 3 Ne = 0 Nfve = [2 for i in range(0, Nf)] VToVe = [[0, 2, 5]] RefTypes = ['TRI4'] FVertices = [set([2, 4, 5]), set([0, 3, 5]), set([0, 1, 2])] EVertices = [] elif (EType == 'QUAD'): d = 2 Nf = 4 Ne = 0 Nfve = [2 for i in range(0, Nf)] VToVe = [[0, 2, 6, 8]] RefTypes = ['QUAD4', 'QUAD2r', 'QUAD2s'] FVertices = [ set([0, 3, 6]), set([2, 5, 8]), set([0, 1, 2]), set([6, 7, 8]) ] EVertices = [] elif (EType == 'TET'): d = 3 Nf = 4 Ne = 6 Nfve = [3 for i in range(0, Nf)] VToVe = [[0, 2, 5, 9]] RefTypes = ['TET8', 'TET12', 'TET6'] FVertices = [ set([2, 4, 5, 7, 8, 9]), set([0, 3, 5, 6, 8, 9]), set([0, 1, 2, 6, 7, 9]), set([0, 1, 2, 3, 4, 5]) ] EVertices = [ set([2, 4, 5]), set([0, 3, 5]), set([0, 1, 2]), set([0, 6, 9]), set([2, 7, 9]), set([5, 8, 9]) ] elif (EType == 'HEX'): d = 3 Nf = 6 Ne = 12 Nfve = [4 for i in range(0, Nf)] VToVe = [[0, 2, 6, 8, 18, 20, 24, 26]] RefTypes = ['HEX8'] FVertices = [set([0,3,6,9,12,15,18,21,24]), set([2,5,8,11,14,17,20,23,26]),set([0,1,2,9,10,11,18,19,20]),\ set([6,7,8,15,16,17,24,25,26]),set([0,1,2,3,4,5,6,7,8]), set([18,19,20,21,22,23,24,25,26])] EVertices = [set([0,1,2]), set([6,7,8]), set([18,19,20]),set([24,25,26]),set([0,3,6]), set([2,5,8]),\ set([18,21,24]),set([20,23,26]),set([0,9,18]), set([2,11,20]), set([6,15,24]),set([8,17,26])] elif (EType == 'PYR'): d = 3 Nf = 5 Ne = 8 Nfve = [3 for i in range(0, Nf - 1)] for i in range(1): Nfve.append(4) VToVe = [[0, 2, 6, 8, 13]] RefTypes = ['PYR10'] FVertices = [set([0,3,6,9,11,13]),set([2,5,8,10,12,13]),set([0,1,2,9,10,13]),set([6,7,8,11,12,13]),\ set([0,1,2,3,4,5,6,7,8])] EVertices = [set([0,3,6]),set([2,5,8]),set([0,1,2]),set([6,7,8]),\ set([0,9,13]),set([2,10,13]),set([6,11,13]),set([8,12,13])] elif (EType == 'WEDGE'): d = 3 Nf = 5 Ne = 9 Nfve.extend((4 for i in range(0, 3))) Nfve.extend((3 for i in range(0, 2))) VToVe = [[0, 2, 5, 12, 14, 17]] RefTypes = ['WEDGE8'] FVertices = [set([2,4,5,8,10,11,14,16,17]),set([0,3,5,6,9,11,12,15,17]),set([0,1,2,6,7,8,12,13,14]),\ set([0,1,2,3,4,5]),set([12,13,14,15,16,17])] EVertices = [set([2,4,5]),set([0,3,5]),set([0,1,2]),set([14,16,17]),set([12,15,17]),set([12,13,14]),\ set([0,6,12]),set([2,8,14]),set([5,11,17])] else: EXIT_TRACEBACK() self.d = d self.Nf = Nf self.Ne = Ne self.Nfve = Nfve self.Neve = Neve self.VToVe = VToVe self.FVertices = FVertices self.EVertices = EVertices self.set_FToVe() self.set_EToVe() self.initialize_RefTypes(RefTypes)
def compute_FE_correspondence(self, ELEMENTs): # Parent ELEMENT ELEMENT = get_ELEMENT_type(self.name, ELEMENTs) Nf = ELEMENT.Nf Ne = ELEMENT.Ne FVertices = ELEMENT.FVertices EVertices = ELEMENT.EVertices VToF = self.VToF VToE = self.VToE FToVe = self.FToVe EToVe = self.EToVe # FACE correspondence FToP = [] for v in range(self.Nv): FToP.append([]) for f in range(len(VToF[v])): FToP[v].append([]) if (VToF[v][f] != 'x'): # Internal FACEs FToP[v][f].append('x') continue # Find the parent FACE on which the child FACE lies for fP in range(Nf): Found = 1 for ve in range(len(FToVe[v][f])): if (not FToVe[v][f][ve] in FVertices[fP]): Found = 0 break if (Found): break if (not Found): list_print(self.VToV, "", 2) list_print(VToF, "", 2) print(FVertices) print(FToVe[v][f]) print("Error: Did not find the associated parent FACE.\n") EXIT_TRACEBACK() FToP[v][f].append(fP) FToP[v][f].append('F') self.FToP = FToP if (ELEMENT.d == 2): # EDGEs == FACEs return # EDGE correspondence EToP = [] for v in range(self.Nv): EToP.append([]) for e in range(len(VToE[v])): EToP[v].append([]) # If the EDGE lies on a parent EDGE, find the parent EDGE for eP in range(Ne): Found = 1 for ve in range(len(EToVe[v][e])): if (not EToVe[v][e][ve] in EVertices[eP]): Found = 0 break if (Found): EToP[v][e].append(eP) EToP[v][e].append('E') break # If the EDGE lies on a parent FACE, find the parent FACE if (not Found): for fP in range(Nf): Found = 1 for ve in range(len(EToVe[v][e])): if (not EToVe[v][e][ve] in FVertices[fP]): Found = 0 break if (Found): EToP[v][e].append(fP) EToP[v][e].append('F') break if (not Found): EToP[v][e].append('x') self.EToP = EToP
def get_IndOrd_Indices(Nve, vals): """Return IndOrd indices for RL and LR. The convention used here corresponds to the cases in d = 2, 3 expected outputs of DPG_ROOT/src/test_unit_get_face_ordering.c (P = 1). The notation may be different here as compared to the code (L == In, R == Out, e.g. LR == InOut). The concept behind the convention is: Given an index for each configuration of vals, find the index of the configuration as seen by the neighboring element. Examples: A TRI FACE on a 3D TET is oriented such that its vertices have indices [0,2,1] (RL = 3 below) with respect to the reference TET FACE (i.e. it has the same position of vertex 0, but is oriented in the opposite direction). From the point of view of the neighboring TET, to get from [0,2,1] to the reference [0,1,2] requires an ordering of [0,2,1] (LR = 3) Had the ordering of the FACE with respect to the reference been [1,2,0] (RL = 1), to get back to the reference [0,1,2] would required an ordering of [2,0,1] (LR = 2). Why this index is necessary is explained below. In a 2D code, elements from the mesh file are generally (this is necessary in the code) defined such that their orientations are all in the same direction (e.g. counter-clockwise for TRI elements). VOLUMEs with incorrect orientation are "flipped-over" and will be seen in the code as having negative volume. If this convention is maintained throughout the code, it would be known a priori that the FACEs of adjacent ELEMENTs are ALWAYS oriented in the opposite direction to each other (i.e. RL == LR == 1) and this information would be unnecessary. HOWEVER, the convention in the code changes this FACE orientation in the reference TRI and QUAD elements so that this is no longer true in the present case. Further, in 3D, special cases arise where the ordering cannot be simply defined as reversed (TRI: RL = 1,2; QUAD: RL = 5,6) and these indices become necessary to know the correct orientation of FACE data with respect to each of the neighboring VOLUMEs. Thus, in the interest of code generality, this information is used in 2D as well and we do not impose a restriction on the orientation of the FACEs of the reference ELEMENTs. """ data = collections.namedtuple('data', 'RL LR') if (Nve == 1): # POINT (d = 1) IndOrdInfo = data(RL=0, LR=0) elif (Nve == 2): # LINE (d == 2) if (vals == [0, 1]): IndOrdInfo = data(RL=0, LR=0) elif (vals == [1, 0]): IndOrdInfo = data(RL=1, LR=1) else: EXIT_TRACEBACK() elif (Nve == 3): # TRI (d == 3) if (vals == [0, 1, 2]): IndOrdInfo = data(RL=0, LR=0) elif (vals == [1, 2, 0]): IndOrdInfo = data(RL=1, LR=2) elif (vals == [2, 0, 1]): IndOrdInfo = data(RL=2, LR=1) elif (vals == [0, 2, 1]): IndOrdInfo = data(RL=3, LR=3) elif (vals == [2, 1, 0]): IndOrdInfo = data(RL=4, LR=4) elif (vals == [1, 0, 2]): IndOrdInfo = data(RL=5, LR=5) elif (Nve == 4): # QUAD (d == 3) if (vals == [0, 1, 2, 3]): IndOrdInfo = data(RL=0, LR=0) elif (vals == [1, 0, 3, 2]): IndOrdInfo = data(RL=1, LR=1) elif (vals == [2, 3, 0, 1]): IndOrdInfo = data(RL=2, LR=2) elif (vals == [3, 2, 1, 0]): IndOrdInfo = data(RL=3, LR=3) elif (vals == [0, 2, 1, 3]): IndOrdInfo = data(RL=4, LR=4) elif (vals == [2, 0, 3, 1]): IndOrdInfo = data(RL=5, LR=6) elif (vals == [1, 3, 0, 2]): IndOrdInfo = data(RL=6, LR=5) elif (vals == [3, 1, 2, 0]): IndOrdInfo = data(RL=7, LR=7) else: EXIT_TRACEBACK() return IndOrdInfo