From 9c7c88efa11427080b304e1111c808052de64901 Mon Sep 17 00:00:00 2001 From: Richard Christie Date: Mon, 22 Mar 2021 17:11:25 +1300 Subject: [PATCH 1/2] Fix unused scale factor bugs Fix lung apex annotation. --- .../meshtypes/meshtype_3d_heart1.py | 2 -- .../meshtypes/meshtype_3d_heartatria2.py | 2 +- .../meshtypes/meshtype_3d_heartventricles1.py | 4 +-- .../meshtypes/meshtype_3d_heartventricles3.py | 15 ++++++-- .../meshtype_3d_heartventriclesbase2.py | 5 ++- .../meshtypes/meshtype_3d_lung1.py | 8 ++--- .../meshtypes/meshtype_3d_stellate1.py | 20 +++++++++-- src/scaffoldmaker/utils/annulusmesh.py | 34 +++++++++++-------- .../utils/eftfactory_tricubichermite.py | 14 +++++--- src/scaffoldmaker/utils/shieldmesh.py | 17 +++++++--- 10 files changed, 80 insertions(+), 41 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_heart1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_heart1.py index c01dcaaa..2d6dce10 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_heart1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_heart1.py @@ -275,8 +275,6 @@ def generateBaseMesh(cls, region, options): elif e == (elementsCountAroundLeftAtriumFreeWall - 1): # general linear map d3 adjacent to collapsed sulcus eft1 = bicubichermitelinear.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [ 6, 8 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, []) ]) result = elementtemplate1.defineField(coordinates, -1, eft1) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_heartatria2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_heartatria2.py index 4b5366c2..fb216b50 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_heartatria2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_heartatria2.py @@ -1014,8 +1014,8 @@ def generateBaseMesh(cls, region, options): meshGroups = [ laMeshGroup if (i == 0) else raMeshGroup ] if (e2 == 0) and (((i == 0) and (e1 == e1FreeWallStart)) or ((i == 1) and (e1 == elementsCountAroundAtria + 1))): eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) if i == 0: + setEftScaleFactorIds(eft1, [1], []) remapEftNodeValueLabel(eft1, [ 5 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [1] ), ( Node.VALUE_LABEL_D_DS3, []) ]) else: remapEftNodeValueLabel(eft1, [ 6 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, []) ]) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles1.py index 4554a6bc..9c9344f3 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles1.py @@ -910,10 +910,10 @@ def generateBaseMesh(cls, region, options): elif e1 == (elementsCountAroundRVFreeWall - 1): # general linear map d3 adjacent to collapsed anterior interventricular sulcus eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] if e2 == elementsCountUpLVApex: # collapsed RV corner uses outside d/dxi2 = d1 + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [ 2 ], Node.VALUE_LABEL_D_DS2, [ ( Node.VALUE_LABEL_D_DS1, [] ) ]) remapEftNodeValueLabel(eft1, [ 5 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS2, [1] ), ( Node.VALUE_LABEL_D_DS3, []) ]) remapEftNodeValueLabel(eft1, [ 6 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS2, [1] ), ( Node.VALUE_LABEL_D_DS3, []) ]) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles3.py b/src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles3.py index ab490fb3..0a22b329 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles3.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_heartventricles3.py @@ -944,7 +944,6 @@ def generateBaseMesh(cls, region, options): rvNodeId = rvShield.nodeId n1ln, n2ln = lvShield.convertRimIndex(0) n1rn, n2rn = rvShield.convertRimIndex(elementsCountAroundFull) - scalefactors = [ -1.0 ] for ix in range(elementsCountAroundFull): n1lp, n2lp = n1ln, n2ln n1ln, n2ln = lvShield.convertRimIndex(ix + 1) @@ -954,10 +953,12 @@ def generateBaseMesh(cls, region, options): nids = [ rvNodeId[0][n2rp][n1rp], rvNodeId[0][n2rn][n1rn], lvNodeId[0][n2lp][n1lp], lvNodeId[0][n2ln][n1ln], rvNodeId[1][n2rp][n1rp], rvNodeId[1][n2rn][n1rn], lvNodeId[1][n2lp][n1lp], lvNodeId[1][n2ln][n1ln] ] eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) + scalefactors = None if ix <= lvShield.elementsCountUpRegular: nids = [ nids[1], nids[3], nids[0], nids[2], nids[5], nids[7], nids[4], nids[6] ] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] if ix == lvShield.elementsCountUpRegular: remapEftNodeValueLabel(eft1, [ 2, 6 ], Node.VALUE_LABEL_D_DS2, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) remapEftNodeValueLabel(eft1, [ 2 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [] ), ( Node.VALUE_LABEL_D_DS3, [1] ) ]) @@ -974,6 +975,8 @@ def generateBaseMesh(cls, region, options): elif ix >= (elementsCountAroundFull - 1 - lvShield.elementsCountUpRegular): nids = [ nids[2], nids[0], nids[3], nids[1], nids[6], nids[4], nids[7], nids[5] ] if ix == (elementsCountAroundFull - 1 - lvShield.elementsCountUpRegular): + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [ 1 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [1] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) remapEftNodeValueLabel(eft1, [ 5 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [1] ) ]) remapEftNodeValueLabel(eft1, [ 1, 5 ], Node.VALUE_LABEL_D_DS2, [ ( Node.VALUE_LABEL_D_DS1, [] ) ]) @@ -981,12 +984,18 @@ def generateBaseMesh(cls, region, options): else: remapEftNodeValueLabel(eft1, [ 1, 3 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) if ix == (elementsCountAroundFull - 1 - rvShield.elementsCountUpRegular): + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [ 2, 6 ], Node.VALUE_LABEL_D_DS2, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) remapEftNodeValueLabel(eft1, [ 2, 6 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [] ) ]) elif ix < (elementsCountAroundFull - 1 - rvShield.elementsCountUpRegular): + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [ 2, 4, 6, 8 ], Node.VALUE_LABEL_D_DS2, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) remapEftNodeValueLabel(eft1, [ 2, 4, 6, 8 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [] ) ]) else: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] if ix == rvShield.elementsCountUpRegular: scaleEftNodeValueLabels(eft1, [ 2, 6 ], [ Node.VALUE_LABEL_D_DS1 , Node.VALUE_LABEL_D_DS2 ], [ 1 ]) remapEftNodeValueLabel(eft1, [ 1, 5 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [1] ) ]) @@ -1008,7 +1017,7 @@ def generateBaseMesh(cls, region, options): elementtemplate1.defineField(coordinates, -1, eft1) element = mesh.createElement(elementIdentifier, elementtemplate1) result2 = element.setNodesByIdentifier(eft1, nids) - result3 = element.setScaleFactors(eft1, scalefactors) + result3 = element.setScaleFactors(eft1, scalefactors) if scalefactors else None #print('create element sulcus', elementIdentifier, result2, result3, nids) #self.elementId[e2][e1] = elementIdentifier elementIdentifier += 1 diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_heartventriclesbase2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_heartventriclesbase2.py index 1d4f076b..00e1473d 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_heartventriclesbase2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_heartventriclesbase2.py @@ -1009,7 +1009,6 @@ def generateBaseMesh(cls, region, options): # 7-node collapsed LV free wall element 1, by lv crest and la nids = [ nsdl, nsdl + 1, laNodeId[0][3], nsdl + nowl, nsdl + nowl + 1, lv_crest_nid1, laNodeId[1][3] ] eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) remapEftNodeValueLabel(eft1, [ 1, 3 ], Node.VALUE_LABEL_D_DS2, []) remapEftNodeValueLabel(eft1, [ 3 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [] ) ]) remapEftNodeValueLabel(eft1, [ 3 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS2, [] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) @@ -1151,7 +1150,7 @@ def generateBaseMesh(cls, region, options): # supraventricular crest outer 2, outer infundibulum 1 nids = [ nidr + 4, nidr + 5, rv_crest_nid1, rvOutletNodeId[0][2], nidr + nowr + 4, nidr + nowr + 5, rv_crest_nid2, rvOutletNodeId[1][2] ] eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1, 102, 104, 108, 304], []) + setEftScaleFactorIds(eft1, [1], []) tricubichermite.setEftLinearDerivative(eft1, [ 4, 8 ], Node.VALUE_LABEL_D_DS3, 4, 8, 1) remapEftNodeValueLabel(eft1, [ 4, 8 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [] ), ( Node.VALUE_LABEL_D_DS2, [] ) ]) meshGroups += [ conusArteriosusMeshGroup ] @@ -1159,7 +1158,7 @@ def generateBaseMesh(cls, region, options): # outer infundibulum 2 nids = [ nidr + 5, nidr + 6, rvOutletNodeId[0][2], rvOutletNodeId[0][3], nidr + nowr + 5, nidr + nowr + 6, rvOutletNodeId[1][2], rvOutletNodeId[1][3] ] eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1, 102, 104, 108, 304], []) + setEftScaleFactorIds(eft1, [1], []) tricubichermite.setEftLinearDerivative(eft1, [ 3, 7 ], Node.VALUE_LABEL_D_DS3, 3, 7, 1) tricubichermite.setEftLinearDerivative(eft1, [ 4, 8 ], Node.VALUE_LABEL_D_DS3, 4, 8, 1) meshGroups += [ conusArteriosusMeshGroup ] diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py index a669c5dc..9a7f4482 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_lung1.py @@ -577,7 +577,7 @@ def generateBaseMesh(cls, region, options): lowerRightNodeIds, upperRightNodeIds, nodeIndex, nodeIdentifier) # Diaphragm lung nodes - getDiaphragmaticLungNodes(cache, coordinates, generateParameters, + diaNodeIndex, nodeIdentifier = getDiaphragmaticLungNodes(cache, coordinates, generateParameters, nodes, nodetemplate, nodeFieldParameters, diaphragmaticElementsCount1, diaphragmaticElementsCount2, diaphragmaticElementsCount3, diaphragmaticNodeIds, nodeIndex, nodeIdentifier) @@ -875,7 +875,6 @@ def getLungElements(coordinates, eftfactory, eftRegular, elementtemplateRegular, nodeIdentifiers.pop(6) nodeIdentifiers.pop(2) eft = eftfactory.createEftBasic() - setEftScaleFactorIds(eft, [1], []) nodes = [3, 4, 7, 8] collapseNodes = [3, 7] remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS1, []) @@ -985,7 +984,6 @@ def getLungElements(coordinates, eftfactory, eftRegular, elementtemplateRegular, elif (e3 == (uElementsCount3 - 2)) and (e2 == (uElementsCount2 - 2)): # Remapped cube element 2 eft = eftfactory.createEftBasic() - setEftScaleFactorIds(eft, [1], []) remapEftNodeValueLabel(eft, [1, 2], Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS3, [])]) elif None in nodeIdentifiers: @@ -1082,17 +1080,17 @@ def getDiaphragmaticLungElements(coordinates, eftfactory, eftRegular, elementtem NodeIds[e3 + 1][e2 + 1][e1], NodeIds[e3 + 1][e2 + 1][e1 + 1]] if (e1 == 1) and (e3 == (elementsCount3 - 1)): + # wedge elements along crest nodeIdentifiers.pop(6) nodeIdentifiers.pop(4) eft = eftfactory.createEftBasic() - setEftScaleFactorIds(eft, [1], []) nodes = [5, 6, 7, 8] collapseNodes = [5, 7] remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS1, []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS3, [])]) if e2 == 0: - # Remapping the element + setEftScaleFactorIds(eft, [1], []) remapEftNodeValueLabel(eft, [3], Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, []), (Node.VALUE_LABEL_D_DS1, [1])]) ln_map = [1, 2, 3, 4, 5, 5, 6, 6] diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py index 347a3264..f53b560e 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_stellate1.py @@ -403,10 +403,10 @@ def generateBaseMesh(cls, region, options): if e1 == 0: # wheel eft1 = bicubichermitelinear.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] if armCount == 3: if e2 == 0: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] scaleEftNodeValueLabels(eft1, [1, 5], [Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2], [1]) ns = [3, 7] @@ -417,9 +417,13 @@ def generateBaseMesh(cls, region, options): [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) if e2 == 0: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) elif na == 1: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1])]) if e2 == 0: @@ -430,6 +434,8 @@ def generateBaseMesh(cls, region, options): [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) elif na == 2: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS2, [1])]) if e2 == 0: @@ -441,6 +447,8 @@ def generateBaseMesh(cls, region, options): [(Node.VALUE_LABEL_D_DS1, [])]) elif armCount == 4: if e2 == 0: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] scaleEftNodeValueLabels(eft1, [1, 5], [Node.VALUE_LABEL_D_DS1, Node.VALUE_LABEL_D_DS2], [1]) ns = [3, 7] @@ -451,9 +459,13 @@ def generateBaseMesh(cls, region, options): [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [])]) if e2 == 0: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) elif na == 1: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [])]) @@ -464,6 +476,8 @@ def generateBaseMesh(cls, region, options): remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) elif na == 2: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, [1]), (Node.VALUE_LABEL_D_DS2, [1])]) @@ -474,6 +488,8 @@ def generateBaseMesh(cls, region, options): remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS2, [1])]) elif na == 3: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, ns, Node.VALUE_LABEL_D_DS1, [(Node.VALUE_LABEL_D_DS1, []), (Node.VALUE_LABEL_D_DS2, [1])]) diff --git a/src/scaffoldmaker/utils/annulusmesh.py b/src/scaffoldmaker/utils/annulusmesh.py index f06814c2..bd0f2368 100644 --- a/src/scaffoldmaker/utils/annulusmesh.py +++ b/src/scaffoldmaker/utils/annulusmesh.py @@ -410,22 +410,28 @@ def createAnnulusMesh3d(nodes, mesh, nextNodeIdentifier, nextElementIdentifier, eft1 = eftFactory.createEftNoCrossDerivatives() # work out if scaling by global -1 scaleMinus1 = mapStartLinearDerivativeXi3 or mapEndLinearDerivativeXi3 - if (not scaleMinus1) and startDerivativesMap: + if (not scaleMinus1) and mapStartDerivatives: for n3 in range(2): - for i in range(2): - derivativesMap = startDerivativesMap[n3][e1] if (i == 0) else startDerivativesMap[n3][en] - for map in derivativesMap: - if map and (-1 in map): - scaleMinus1 = True - break - if (not scaleMinus1) and endDerivativesMap: + # need to handle 3 or 4 maps (e1 uses first 3, en uses last 3) + for map in startDerivativesMap[n3][e1][-3:]: + if map and (-1 in map): + scaleMinus1 = True + break + for map in startDerivativesMap[n3][en][:3]: + if map and (-1 in map): + scaleMinus1 = True + break + if (not scaleMinus1) and mapEndDerivatives: for n3 in range(2): - for i in range(2): - derivativesMap = endDerivativesMap[n3][e1] if (i == 0) else endDerivativesMap[n3][en] - for map in derivativesMap: - if map and (-1 in map): - scaleMinus1 = True - break + # need to handle 3 or 4 maps (e1 uses last 3, en uses first 3) + for map in endDerivativesMap[n3][e1][-3:]: + if map and (-1 in map): + scaleMinus1 = True + break + for map in endDerivativesMap[n3][en][:3]: + if map and (-1 in map): + scaleMinus1 = True + break # make node scale factors vary fastest by local node varying across lower xi nodeScaleFactorIds = [] for n3 in range(2): diff --git a/src/scaffoldmaker/utils/eftfactory_tricubichermite.py b/src/scaffoldmaker/utils/eftfactory_tricubichermite.py index f225f3de..36515fce 100644 --- a/src/scaffoldmaker/utils/eftfactory_tricubichermite.py +++ b/src/scaffoldmaker/utils/eftfactory_tricubichermite.py @@ -825,13 +825,13 @@ def createEftWedgeCollapseXi1Quadrant(self, collapseNodes): :return: Element field template ''' eft = self.createEftBasic() - setEftScaleFactorIds(eft, [1], []) valid = True if collapseNodes in [[1, 3], [2, 4]]: nodes = [1, 2, 3, 4] # remap parameters on xi3 = 0 before collapsing nodes if collapseNodes == [1, 3]: + setEftScaleFactorIds(eft, [1], []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS1, []) elif collapseNodes == [2, 4]: @@ -847,6 +847,7 @@ def createEftWedgeCollapseXi1Quadrant(self, collapseNodes): remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS1, []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [])]) elif collapseNodes == [6, 8]: + setEftScaleFactorIds(eft, [1], []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS1, []) else: @@ -856,6 +857,7 @@ def createEftWedgeCollapseXi1Quadrant(self, collapseNodes): nodes = [1, 2, 5, 6] # remap parameters on xi2 = 0 before collapsing nodes if collapseNodes == [1, 5]: + setEftScaleFactorIds(eft, [1], []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS1, []) elif collapseNodes == [2, 6]: @@ -871,6 +873,7 @@ def createEftWedgeCollapseXi1Quadrant(self, collapseNodes): remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS1, []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [])]) elif collapseNodes == [4, 8]: + setEftScaleFactorIds(eft, [1], []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS2, [(Node.VALUE_LABEL_D_DS1, [1])]) remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS1, []) else: @@ -888,7 +891,8 @@ def createEftWedgeCollapseXi1Quadrant(self, collapseNodes): remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D3_DS1DS2DS3, []) remapEftLocalNodes(eft, 6, ln_map) - assert eft.validate(), 'eftfactory_tricubichermite.createEftWedgeCollapseXi1Quadrant: Failed to validate eft' + if not eft.validate(): + print('eftfactory_tricubichermite.createEftWedgeCollapseXi1Quadrant: Failed to validate eft for collapseNodes', collapseNodes) return eft def createEftWedgeCollapseXi2Quadrant(self, collapseNodes): @@ -897,13 +901,13 @@ def createEftWedgeCollapseXi2Quadrant(self, collapseNodes): :return: Element field template ''' eft = self.createEftBasic() - setEftScaleFactorIds(eft, [1], []) valid = True if collapseNodes in [[1, 2], [3, 4]]: nodes = [1, 2, 3, 4] # remap parameters on xi3 = 0 before collapsing nodes if collapseNodes == [1, 2]: + setEftScaleFactorIds(eft, [1], []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS2, []) elif collapseNodes == [3, 4]: @@ -919,6 +923,7 @@ def createEftWedgeCollapseXi2Quadrant(self, collapseNodes): remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS2, []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [])]) elif collapseNodes == [7, 8]: + setEftScaleFactorIds(eft, [1], []) remapEftNodeValueLabel(eft, collapseNodes, Node.VALUE_LABEL_D_DS3, [(Node.VALUE_LABEL_D_DS2, [1])]) remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D_DS2, []) else: @@ -941,7 +946,8 @@ def createEftWedgeCollapseXi2Quadrant(self, collapseNodes): remapEftNodeValueLabel(eft, nodes, Node.VALUE_LABEL_D3_DS1DS2DS3, []) remapEftLocalNodes(eft, 6, ln_map) - assert eft.validate(), 'eftfactory_tricubichermite.createEftWedgeCollapseXi2Quadrant: Failed to validate eft' + if not eft.validate(): + print('eftfactory_tricubichermite.createEftWedgeCollapseXi2Quadrant: Failed to validate eft for collapseNodes', collapseNodes) return eft def createEftTetrahedronCollapseXi1Xi2Quadrant(self, peakNode, sideNode): diff --git a/src/scaffoldmaker/utils/shieldmesh.py b/src/scaffoldmaker/utils/shieldmesh.py index 2e5cc334..d20e4672 100644 --- a/src/scaffoldmaker/utils/shieldmesh.py +++ b/src/scaffoldmaker/utils/shieldmesh.py @@ -412,7 +412,6 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes e2z = 2*self.elementsCountUp-1-self.elementsCountRim e2y = e2z - 1 e2x = e2z - 2 - for e3 in range(self.elementsCountAlong): for e2 in range(self.elementsCountUpFull): for e1 in range(self.elementsCountAcross): @@ -466,19 +465,17 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes if (e1 == e1b) or (e1 == e1y): # map bottom triple point element eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [-1.0] if e1 == e1b: remapEftNodeValueLabel(eft1, [3, 7], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS1, []),(Node.VALUE_LABEL_D_DS2, [])]) else: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [-1.0] remapEftNodeValueLabel(eft1, [4, 8], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS1, [1]),(Node.VALUE_LABEL_D_DS2, [])]) elif (e2 == e2b) or (e2 == e2y): if (e1 <= e1a) or (e1 >= e1z): # map top 2 triple point elements eft1 = tricubichermite.createEftNoCrossDerivatives() - setEftScaleFactorIds(eft1, [1], []) - scalefactors = [ -1.0 ] if e1 < e1a: e2r = e1 if self._type == ShieldRimDerivativeMode.SHIELD_RIM_DERIVATIVE_MODE_AROUND: @@ -494,10 +491,14 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes nids[1] = self.nodeId[0][e2r + 1][e1b] nids[4] = self.nodeId[1][e2r ][e1b] nids[5] = self.nodeId[1][e2r + 1][e1b] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [ 1, 2, 5, 6 ], Node.VALUE_LABEL_D_DS2, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) remapEftNodeValueLabel(eft1, [ 1, 2, 5, 6 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [] ) ]) elif e1 == e1a: if self._type == ShieldRimDerivativeMode.SHIELD_RIM_DERIVATIVE_MODE_AROUND: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] if e2 == e2b: nids[0] = self.nodeId[e3][e2a][e1b] nids[2] = self.nodeId[e3+1][e2a][e1b] @@ -511,6 +512,8 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes remapEftNodeValueLabel(eft1, [ 1, 2, 3, 4 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS1, [1] ) ]) remapEftNodeValueLabel(eft1, [ 1, 2, 3, 4 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS3, [1] ) ]) elif self._type == ShieldRimDerivativeMode.SHIELD_RIM_DERIVATIVE_MODE_REGULAR: + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] nids[0] = self.nodeId[0][e2a][e1b] nids[4] = self.nodeId[1][e2a][e1b] remapEftNodeValueLabel(eft1, [1, 5], Node.VALUE_LABEL_D_DS2,[(Node.VALUE_LABEL_D_DS1, [1])]) @@ -521,6 +524,8 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes if e2 == e2b: nids[4] = self.nodeId[e3][e2a][e1z] nids[6] = self.nodeId[e3+1][e2a][e1z] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [ 1, 3 ], Node.VALUE_LABEL_D_DS3, [ ( Node.VALUE_LABEL_D_DS1, [1] ), ( Node.VALUE_LABEL_D_DS3, [] ) ]) elif e2 == e2y: nids[5] = self.nodeId[e3][e2z+1][e1z] @@ -549,6 +554,8 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes nids[1] = self.nodeId[0][e2r - 1][e1z] nids[4] = self.nodeId[1][e2r ][e1z] nids[5] = self.nodeId[1][e2r - 1][e1z] + setEftScaleFactorIds(eft1, [1], []) + scalefactors = [ -1.0 ] remapEftNodeValueLabel(eft1, [ 1, 2, 5, 6 ], Node.VALUE_LABEL_D_DS1, [ ( Node.VALUE_LABEL_D_DS2, [1] ) ]) remapEftNodeValueLabel(eft1, [ 1, 2, 5, 6 ], Node.VALUE_LABEL_D_DS2, [ ( Node.VALUE_LABEL_D_DS1, [] ) ]) else: From 7cd65bd6ca29d7da44564bb023f8a92d504a317c Mon Sep 17 00:00:00 2001 From: Richard Christie Date: Tue, 23 Mar 2021 11:06:04 +1300 Subject: [PATCH 2/2] Fix incorrect comment, from review --- src/scaffoldmaker/utils/annulusmesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scaffoldmaker/utils/annulusmesh.py b/src/scaffoldmaker/utils/annulusmesh.py index bd0f2368..69f4a192 100644 --- a/src/scaffoldmaker/utils/annulusmesh.py +++ b/src/scaffoldmaker/utils/annulusmesh.py @@ -412,7 +412,7 @@ def createAnnulusMesh3d(nodes, mesh, nextNodeIdentifier, nextElementIdentifier, scaleMinus1 = mapStartLinearDerivativeXi3 or mapEndLinearDerivativeXi3 if (not scaleMinus1) and mapStartDerivatives: for n3 in range(2): - # need to handle 3 or 4 maps (e1 uses first 3, en uses last 3) + # need to handle 3 or 4 maps (e1 uses last 3, en uses first 3) for map in startDerivativesMap[n3][e1][-3:]: if map and (-1 in map): scaleMinus1 = True