diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_bladder1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_bladder1.py index 1ccca3fe..63b6d051 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_bladder1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_bladder1.py @@ -407,7 +407,6 @@ def generateBaseMesh(cls, region, options): fm = region.getFieldmodule() fm.beginChange() - cache = fm.createFieldcache() mesh = fm.findMeshByDimension(3) firstNodeIdentifier = 1 @@ -415,7 +414,7 @@ def generateBaseMesh(cls, region, options): # Geometric coordinates geometricCentralPath = BladderCentralPath(region, centralPath, elementsCountAlongDome, elementsCountAlongNeck) - xFinal, d1Final, d2Final, d3Final = findBladderNodes3D(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround, + xFinal, d1Final, d2Final, d3Final = getBladderCoordinates(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround, elementsCountThroughWall, wallThickness, geometricCentralPath) sx_dome_group = geometricCentralPath.sx_dome_group @@ -426,7 +425,7 @@ def generateBaseMesh(cls, region, options): # Material coordinates tmp_region = region.createRegion() materialCentralPath = BladderCentralPath(tmp_region, materialCentralPath, elementsCountAlongDome, elementsCountAlongNeck) - xOrgan, d1Organ, d2Organ, d3Organ = findBladderNodes3D(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround, + xOrgan, d1Organ, d2Organ, d3Organ = getBladderCoordinates(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround, elementsCountThroughWall, materialWallThickness, materialCentralPath) del tmp_region @@ -463,13 +462,16 @@ def generateBaseMesh(cls, region, options): xFinal, d1Final, d2Final, bladderCentralPathLength, urethraOpeningRadius, wallThickness) # Create nodes and elements + bladderCoordinatesFieldName = "bladder coordinates" nodeIdentifier, elementIdentifier, annotationGroups = tubemesh.createNodesAndElements( - region, xFinal, d1Final, d2Final, d3Final, xFlat, d1Flat, d2Flat, xOrgan, d1Organ, d2Organ, "bladder coordinates", - elementsCountAround, elementsCountAlongBladder, elementsCountThroughWall, + region, xFinal, d1Final, d2Final, d3Final, xFlat, d1Flat, d2Flat, xOrgan, d1Organ, d2Organ, + bladderCoordinatesFieldName, elementsCountAround, elementsCountAlongBladder, elementsCountThroughWall, annotationGroupsAround, annotationGroupsAlong, annotationGroupsThroughWall, firstNodeIdentifier, firstElementIdentifier, useCubicHermiteThroughWall, useCrossDerivatives, closedProximalEnd=True) + bladderCoordinates = fm.findFieldByName(bladderCoordinatesFieldName) + # Define trackSurface to put the ureter markers on xTrackSurface = [] d1TrackSurface = [] @@ -489,16 +491,9 @@ def generateBaseMesh(cls, region, options): ureter1Position = trackSurfaceBladder.createPositionProportion(ureterPositionAroundFactor, neckStartPositionAlongFactor) ureterElementPositionAround = ureter1Position.e1 - # Annotation fiducial point - markerGroup = findOrCreateFieldGroup(fm, "marker") - markerName = findOrCreateFieldStoredString(fm, name="marker_name") - markerLocation = findOrCreateFieldStoredMeshLocation(fm, mesh, name="marker_location") + # Annotation fiducial points nodes = fm.findNodesetByFieldDomainType(Field.DOMAIN_TYPE_NODES) - markerPoints = markerGroup.getOrCreateNodesetGroup(nodes) - markerTemplateInternal = nodes.createNodetemplate() - markerTemplateInternal.defineField(markerName) - markerTemplateInternal.defineField(markerLocation) # Define markers for apex and ureter junctions with bladder apexGroup = findOrCreateAnnotationGroupForTerm(annotationGroups, region, get_bladder_term("apex of urinary bladder")) @@ -519,12 +514,12 @@ def generateBaseMesh(cls, region, options): bladderNodesetGroup = bladderGroup.getNodesetGroup(nodes) for marker in markerList: annotationGroup = marker["group"] - markerPoint = markerPoints.createNode(nodeIdentifier, markerTemplateInternal) - cache.setNode(markerPoint) - markerLocation.assignMeshLocation(cache, mesh.findElementByIdentifier(marker["elementId"]), marker["xi"]) - markerName.assignString(cache, annotationGroup.getName()) - annotationGroup.getNodesetGroup(nodes).addNode(markerPoint) - bladderNodesetGroup.addNode(markerPoint) + element = mesh.findElementByIdentifier(marker["elementId"]) + # create marker points with element locations + markerNode = annotationGroup.createMarkerNode(nodeIdentifier, element=element, xi=marker["xi"]) + # calculate bladder coordinates automatically from element:xi + annotationGroup.setMarkerMaterialCoordinates(bladderCoordinates) + bladderNodesetGroup.addNode(markerNode) nodeIdentifier += 1 fm.endChange() @@ -1149,8 +1144,8 @@ def __init__(self, region, centralPath, elementsCountAlongDome, elementsCountAlo self.bladderCentralPathLength = bladderCentralPathLength self.domeLength = domeLength -def findBladderNodes3D(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround, elementsCountThroughWall, - wallThickness, centralPath): +def getBladderCoordinates(elementsCountAlongDome, elementsCountAlongNeck, elementsCountAround, elementsCountThroughWall, + wallThickness, centralPath): sx_dome_group = centralPath.sx_dome_group sx_neck_group = centralPath.sx_neck_group