From e1320020ecd253df95062de33a2f3e2b4cf25aff Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Thu, 10 Mar 2022 20:43:57 +1300 Subject: [PATCH 1/4] Adjust range of elements according to updated number of elements. Update annotation terms for stomach in whole-body according to new terms. --- .../meshtypes/meshtype_3d_solidsphere2.py | 7 +++++++ src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py | 11 ++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py index c8ccb322..b1736b9b 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py @@ -42,6 +42,7 @@ def getDefaultOptions(cls, parameterSetName='Default'): 'Use cross derivatives': False, 'Refine': False, 'Refine number of elements': 1, + 'Current number of elements': [4, 4, 4] } return options @@ -140,6 +141,12 @@ def checkOptions(cls, options): if options['Shell element thickness proportion'] < 0.15: options['Shell element thickness proportion'] = 1.0 + for i in range(1, nm): + if options['Number of elements across axis {}'.format(i)] != options['Current number of elements'][i - 1]: + dependentChanges = True + options['Range of elements required in direction {}'.format(i)][1] = \ + options['Number of elements across axis {}'.format(i)] + options['Current number of elements'][i - 1] = options['Number of elements across axis {}'.format(i)] return dependentChanges @staticmethod diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py index 5c860c48..fc8342d9 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_wholebody1.py @@ -405,11 +405,10 @@ def generateBaseMesh(region, options): rightUreterJunctionWithBladder = bladder_terms.get_bladder_term('right ureter junction with bladder') urethraJunctionWithBladderDorsal = bladder_terms.get_bladder_term('urethra junction of dorsal bladder neck') urethraJunctionWithBladderVentral = bladder_terms.get_bladder_term('urethra junction of ventral bladder neck') - gastroesophagalJunctionOnLesserCurvature = stomach_terms.get_stomach_term('gastro-esophagal junction on lesser curvature') - limitingRidgeOnGreaterCurvature = stomach_terms.get_stomach_term('limiting ridge on greater curvature') - pylorusOnGreaterCurvature = stomach_terms.get_stomach_term('pylorus on greater curvature') - duodenumOnGreaterCurvature = stomach_terms.get_stomach_term('duodenum on greater curvature') - junctionBetweenFundusAndBodyOnGreaterCurvature = stomach_terms.get_stomach_term("junction between fundus and body on greater curvature") + gastroesophagalJunctionOnLesserCurvature = stomach_terms.get_stomach_term('esophagogastric junction along the lesser curvature on serosa') + limitingRidgeOnGreaterCurvature = stomach_terms.get_stomach_term('limiting ridge along the greater curvature on serosa') + pylorusOnGreaterCurvature = stomach_terms.get_stomach_term('gastroduodenal junction along the greater curvature on serosa') + junctionBetweenFundusAndBodyOnGreaterCurvature = stomach_terms.get_stomach_term("fundus-body junction along the greater curvature on serosa") apexOfLeftLung = lung_terms.get_lung_term('apex of left lung') ventralBaseOfLeftLung = lung_terms.get_lung_term('ventral base of left lung') dorsalBaseOfLeftLung = lung_terms.get_lung_term('dorsal base of left lung') @@ -463,7 +462,6 @@ def generateBaseMesh(region, options): {"group": gastroesophagalJunctionOnLesserCurvature, "x": [0.12, 0.009, 1.446]}, {"group": limitingRidgeOnGreaterCurvature, "x": [0.318, 0.097, 1.406]}, {"group": pylorusOnGreaterCurvature, "x": [0.08, -0.111, 1.443]}, - {"group": duodenumOnGreaterCurvature, "x": [0.029, -0.138, 1.481]}, ] elif isHuman: bodyMarkerPoints = [ @@ -490,7 +488,6 @@ def generateBaseMesh(region, options): {"group": dorsalBaseOfRightLung, "x": [0.0369, -0.2524, 0.912]}, {"group": gastroesophagalJunctionOnLesserCurvature, "x": [-0.0062, -0.3259, 0.8586]}, {"group": pylorusOnGreaterCurvature, "x": [-0.0761, -0.3189, 0.8663]}, - {"group": duodenumOnGreaterCurvature, "x": [-0.1599, 0.1601, 1.1939]}, {"group": junctionBetweenFundusAndBodyOnGreaterCurvature, "x": [0.1884, -0.1839, 0.9639]}, ] From 57c557b29773049daf58f9e0b668212d3c78c51b Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 7 Jun 2022 17:05:59 +1200 Subject: [PATCH 2/4] Change Range of required elements to Crop number of elements --- .../meshtypes/meshtype_3d_solidsphere2.py | 69 +++++++------------ 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py index b1736b9b..05e0d3b6 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py @@ -35,14 +35,13 @@ def getDefaultOptions(cls, parameterSetName='Default'): 'Radius1': 1.0, 'Radius2': 1.0, 'Radius3': 1.0, - 'Range of elements required in direction 1': [0, 4], - 'Range of elements required in direction 2': [0, 4], - 'Range of elements required in direction 3': [0, 4], + 'Crop number of elements in direction 1': [0, 0], + 'Crop number of elements in direction 2': [0, 0], + 'Crop number of elements in direction 3': [0, 0], 'Box derivatives': [1, 2, 3], 'Use cross derivatives': False, 'Refine': False, 'Refine number of elements': 1, - 'Current number of elements': [4, 4, 4] } return options @@ -58,9 +57,9 @@ def getOrderedOptionNames(): 'Radius1', 'Radius2', 'Radius3', - 'Range of elements required in direction 1', - 'Range of elements required in direction 2', - 'Range of elements required in direction 3', + 'Crop number of elements in direction 1', + 'Crop number of elements in direction 2', + 'Crop number of elements in direction 3', 'Box derivatives', 'Refine', 'Refine number of elements' @@ -96,37 +95,20 @@ def checkOptions(cls, options): if len(options['Box derivatives']) > len(set(options['Box derivatives'])): options['Box derivatives'] = [1, 2, 3] - for i in range(1, 4): - if options['Range of elements required in direction {}'.format(i)][1] >= \ - options['Number of elements across axis {}'.format(i)] - 1\ - - options['Number of elements across shell']: - options['Range of elements required in direction {}'.format(i)][1] = \ - options['Number of elements across axis {}'.format(i)] - - nm = 4 - for i in range(1, nm): - if options['Range of elements required in direction {}'.format(i)][0] <= 1 + \ - options['Number of elements across shell']: - options['Range of elements required in direction {}'.format(i)][0] = 0 - maxelems = [options['Number of elements across axis 1'], options['Number of elements across axis 2'], options['Number of elements across axis 3']] - ranges = [options['Range of elements required in direction 1'], - options['Range of elements required in direction 2'], - options['Range of elements required in direction 3']] - for i in range(3): - if ranges[i][1] > maxelems[i] or ranges[i][1] <= max(1, ranges[i][0]): - dependentChanges = True - ranges[i][1] = maxelems[i] - for i in range(3): - if ranges[i][0] >= min(maxelems[i] - 1, ranges[i][1]) or ranges[i][0] < 1: - dependentChanges = True - ranges[i][0] = 0 - options['Range of elements required in direction 1'] = ranges[0] - options['Range of elements required in direction 2'] = ranges[1] - options['Range of elements required in direction 3'] = ranges[2] + cropElements = [ + options['Crop number of elements in direction 1'], + options['Crop number of elements in direction 2'], + options['Crop number of elements in direction 3'], + ] + + for i in range(3): + for j in [0, 1]: + if not (1 + options['Number of elements across shell'] < cropElements[i][j] < maxelems[i]): + options['Crop number of elements in direction {}'.format(i + 1)][j] = 0 elementsCount_min = min(options['Number of elements across axis 1'], options['Number of elements across axis 2'], @@ -141,12 +123,6 @@ def checkOptions(cls, options): if options['Shell element thickness proportion'] < 0.15: options['Shell element thickness proportion'] = 1.0 - for i in range(1, nm): - if options['Number of elements across axis {}'.format(i)] != options['Current number of elements'][i - 1]: - dependentChanges = True - options['Range of elements required in direction {}'.format(i)][1] = \ - options['Number of elements across axis {}'.format(i)] - options['Current number of elements'][i - 1] = options['Number of elements across axis {}'.format(i)] return dependentChanges @staticmethod @@ -167,9 +143,16 @@ def generateBaseMesh(region, options): shellProportion = options['Shell element thickness proportion'] radius = [options['Radius1'], options['Radius2'], options['Radius3']] useCrossDerivatives = options['Use cross derivatives'] - rangeOfRequiredElements = [options['Range of elements required in direction 1'], - options['Range of elements required in direction 2'], - options['Range of elements required in direction 3']] + cropElements = [ + options['Crop number of elements in direction 1'], + options['Crop number of elements in direction 2'], + options['Crop number of elements in direction 3'], + ] + rangeOfRequiredElements = [ + [cropElements[0][0], elementsCountAcrossAxis1 - cropElements[0][1]], + [cropElements[1][0], elementsCountAcrossAxis1 - cropElements[1][1]], + [cropElements[2][0], elementsCountAcrossAxis1 - cropElements[2][1]], + ] sphereBoxDerivatives = [-options['Box derivatives'][0], options['Box derivatives'][1], options['Box derivatives'][2]] # To make the values more intuitive for the user but # consistent with [back, right, up] From 99ea255001215e4b3e5a2a7082e0c0e7d10a8477 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 7 Jun 2022 18:20:38 +1200 Subject: [PATCH 3/4] Change range to crop number of elements for cylinder --- .../meshtypes/meshtype_3d_solidcylinder1.py | 44 ++++++++++++++++--- .../meshtypes/meshtype_3d_solidsphere2.py | 1 + src/scaffoldmaker/utils/cylindermesh.py | 10 ++++- src/scaffoldmaker/utils/shieldmesh.py | 15 ++++++- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidcylinder1.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidcylinder1.py index 93bc1268..ebf459b9 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidcylinder1.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidcylinder1.py @@ -57,7 +57,9 @@ def getDefaultOptions(cls, parameterSetName='Default'): 'Number of elements across transition': 1, 'Number of elements along': 1, 'Shell element thickness proportion': 1.0, - 'Lower half': False, + 'Crop number of elements across major': [0, 0], + 'Crop number of elements across minor': [0, 0], + 'Crop number of elements along': [0, 0], 'Use cross derivatives': False, 'Refine': False, 'Refine number of elements across major': 1, @@ -75,7 +77,9 @@ def getOrderedOptionNames(): 'Number of elements across transition', 'Number of elements along', 'Shell element thickness proportion', - 'Lower half', + 'Crop number of elements across major', + 'Crop number of elements across minor', + 'Crop number of elements along', 'Refine', 'Refine number of elements across major', 'Refine number of elements along' @@ -140,6 +144,24 @@ def checkOptions(cls, options): if options['Shell element thickness proportion'] < 0.15: options['Shell element thickness proportion'] = 1.0 + maxelems = [options['Number of elements across major'], + options['Number of elements across minor'], + options['Number of elements along']] + + cropElements = [ + options['Crop number of elements across major'], + options['Crop number of elements across minor'], + options['Crop number of elements along'], + ] + + for j in [0, 1]: + if not (1 + options['Number of elements across shell'] < cropElements[0][j] < maxelems[0]): + options['Crop number of elements across major'][j] = 0 + if not (1 + options['Number of elements across shell'] < cropElements[1][j] < maxelems[1] - 1): + options['Crop number of elements across minor'][j] = 0 + if not (0 <= options['Crop number of elements along'][j] < options['Number of elements along']): + options['Crop number of elements along'][j] = 0 + return dependentChanges @staticmethod @@ -152,10 +174,7 @@ def generateBaseMesh(region, options): """ centralPath = options['Central path'] - full = not options['Lower half'] elementsCountAcrossMajor = options['Number of elements across major'] - if not full: - elementsCountAcrossMajor //= 2 elementsCountAcrossMinor = options['Number of elements across minor'] elementsCountAcrossShell = options['Number of elements across shell'] elementsCountAcrossTransition = options['Number of elements across transition'] @@ -163,12 +182,23 @@ def generateBaseMesh(region, options): shellProportion = options['Shell element thickness proportion'] useCrossDerivatives = options['Use cross derivatives'] + cropElements = [ + options['Crop number of elements across major'], + options['Crop number of elements across minor'], + options['Crop number of elements along'], + ] + rangeOfRequiredElements = [ + [cropElements[0][0], elementsCountAcrossMajor - cropElements[0][1]], + [cropElements[1][0], elementsCountAcrossMinor - cropElements[1][1]], + [cropElements[2][0], elementsCountAlong - cropElements[2][1]], + ] + fm = region.getFieldmodule() coordinates = findOrCreateFieldCoordinates(fm) cylinderCentralPath = CylinderCentralPath(region, centralPath, elementsCountAlong) - cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL if full else CylinderShape.CYLINDER_SHAPE_LOWER_HALF + cylinderShape = CylinderShape.CYLINDER_SHAPE_FULL base = CylinderEnds(elementsCountAcrossMajor, elementsCountAcrossMinor, elementsCountAcrossShell, elementsCountAcrossTransition, @@ -176,7 +206,7 @@ def generateBaseMesh(region, options): [0.0, 0.0, 0.0], cylinderCentralPath.alongAxis[0], cylinderCentralPath.majorAxis[0], cylinderCentralPath.minorRadii[0]) cylinder1 = CylinderMesh(fm, coordinates, elementsCountAlong, base, - cylinderShape=cylinderShape, + cylinderShape=cylinderShape, rangeOfRequiredElements=rangeOfRequiredElements, cylinderCentralPath=cylinderCentralPath, useCrossDerivatives=False) annotationGroup = [] diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py index 05e0d3b6..f16d9823 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py @@ -143,6 +143,7 @@ def generateBaseMesh(region, options): shellProportion = options['Shell element thickness proportion'] radius = [options['Radius1'], options['Radius2'], options['Radius3']] useCrossDerivatives = options['Use cross derivatives'] + cropElements = [ options['Crop number of elements in direction 1'], options['Crop number of elements in direction 2'], diff --git a/src/scaffoldmaker/utils/cylindermesh.py b/src/scaffoldmaker/utils/cylindermesh.py index a9fb6e5e..fac13e1b 100644 --- a/src/scaffoldmaker/utils/cylindermesh.py +++ b/src/scaffoldmaker/utils/cylindermesh.py @@ -135,7 +135,7 @@ class CylinderMesh: """ def __init__(self, fieldModule, coordinates, elementsCountAlong, base=None, end=None, - cylinderShape=CylinderShape.CYLINDER_SHAPE_FULL, + cylinderShape=CylinderShape.CYLINDER_SHAPE_FULL, rangeOfRequiredElements=None, tapered=None, cylinderCentralPath=None, useCrossDerivatives=False , meshGroupsElementsAlong=[], meshGroups=[]): """ :param fieldModule: Zinc fieldModule to create elements in. @@ -144,6 +144,8 @@ def __init__(self, fieldModule, coordinates, elementsCountAlong, base=None, end= :param end: Cylinder end ellipse. It is an instance of class CylinderEnds. :param elementsCountAlong: Number of elements along the cylinder axis. :param cylinderShape: A value from enum CylinderMode specifying. + :param rangeOfRequiredElements: Specifies the range of elements required to be created. It can be used to + create the part of cylinder required. If None or same as elementsCountAcross the whole part will be created. """ self._centres = None @@ -177,6 +179,8 @@ def __init__(self, fieldModule, coordinates, elementsCountAlong, base=None, end= self._cylinderType = CylinderType.CYLINDER_TAPERED self._tapered = tapered self._useCrossDerivatives = useCrossDerivatives + self._rangeOfRequiredElements = rangeOfRequiredElements + self._meshGroups = meshGroups self._meshGroupsElementsAlong = meshGroupsElementsAlong self._cylinderCentralPath = cylinderCentralPath @@ -380,7 +384,8 @@ def generateNodes(self, nodes, fieldModule, coordinates): """ nodeIdentifier = max(1, getMaximumNodeIdentifier(nodes) + 1) self._startNodeIdentifier = nodeIdentifier - nodeIdentifier = self._shield.generateNodes(fieldModule, coordinates, nodeIdentifier) + nodeIdentifier = self._shield.generateNodes(fieldModule, coordinates, nodeIdentifier, + self._rangeOfRequiredElements) self._endNodeIdentifier = nodeIdentifier def generateElements(self, mesh, fieldModule, coordinates): @@ -393,6 +398,7 @@ def generateElements(self, mesh, fieldModule, coordinates): elementIdentifier = max(1, getMaximumElementIdentifier(mesh) + 1) self._startElementIdentifier = elementIdentifier elementIdentifier = self._shield.generateElements(fieldModule, coordinates, elementIdentifier, + self._rangeOfRequiredElements, self._meshGroupsElementsAlong, self._meshGroups) self._endElementIdentifier = elementIdentifier diff --git a/src/scaffoldmaker/utils/shieldmesh.py b/src/scaffoldmaker/utils/shieldmesh.py index 868f806a..415994ce 100644 --- a/src/scaffoldmaker/utils/shieldmesh.py +++ b/src/scaffoldmaker/utils/shieldmesh.py @@ -434,12 +434,13 @@ def generateNodesForOtherHalf(self, mirrorPlane): self.pd2[n3][2*self.elementsCountUp-n2][n1] = mirror.mirrorVector(self.pd2[n3][n2][n1]) self.pd3[n3][2*self.elementsCountUp-n2][n1] = mirror.mirrorVector(self.pd3[n3][n2][n1]) - def generateNodes(self, fieldmodule, coordinates, startNodeIdentifier, mirrorPlane=None): + def generateNodes(self, fieldmodule, coordinates, startNodeIdentifier, rangeOfRequiredElements, mirrorPlane=None): """ Create shield nodes from coordinates. :param fieldmodule: Zinc fieldmodule to create nodes in. Uses DOMAIN_TYPE_NODES. :param coordinates: Coordinate field to define. :param startNodeIdentifier: First node identifier to use. + :param rangeOfRequiredElements: Only the elements and nodes for the given range is generated. :param mirrorPlane: mirror plane ax+by+cz=d in form of [a,b,c,d] :return: next nodeIdentifier. """ @@ -465,6 +466,10 @@ def generateNodes(self, fieldmodule, coordinates, startNodeIdentifier, mirrorPla for n2 in range(self.elementsCountUpFull + 1): for n3 in range(self.elementsCountAlong+1): for n1 in range(self.elementsCountAcross + 1): + if n3 > rangeOfRequiredElements[2][1] or n3 < rangeOfRequiredElements[2][0]\ + or n2 > rangeOfRequiredElements[0][1] or n2 < rangeOfRequiredElements[0][0]\ + or n1 > rangeOfRequiredElements[1][1] or n1 < rangeOfRequiredElements[1][0]: + continue if self.px[n3][n2][n1]: node = nodes.createNode(nodeIdentifier, nodetemplate) self.nodeId[n3][n2][n1] = nodeIdentifier @@ -477,12 +482,14 @@ def generateNodes(self, fieldmodule, coordinates, startNodeIdentifier, mirrorPla return nodeIdentifier - def generateElements(self, fieldmodule, coordinates, startElementIdentifier, meshGroupsElementsAlong=[], meshGroups=[]): + def generateElements(self, fieldmodule, coordinates, startElementIdentifier, rangeOfRequiredElements, + meshGroupsElementsAlong=[], meshGroups=[]): """ Create shield elements from nodes. :param fieldmodule: Zinc fieldmodule to create elements in. :param coordinates: Coordinate field to define. :param startElementIdentifier: First element identifier to use. + :param rangeOfRequiredElements: Only the elements and nodes for the given range is generated. :param meshGroups, meshGroupsElementsAlong: Zinc mesh groups to add elements to. meshGroupsElementsAlong is a list that specifies number of elements along the cylinder to be added to the same meshGroup. :return: next elementIdentifier. @@ -522,6 +529,10 @@ def generateElements(self, fieldmodule, coordinates, startElementIdentifier, mes for e3 in range(self.elementsCountAlong): for e2 in range(self.elementsCountUpFull): for e1 in range(self.elementsCountAcross): + if e3 >= rangeOfRequiredElements[2][1] or e3 < rangeOfRequiredElements[2][0] or\ + e2 >= rangeOfRequiredElements[0][1] or e2 < rangeOfRequiredElements[0][0]\ + or e1 >= rangeOfRequiredElements[1][1] or e1 < rangeOfRequiredElements[1][0]: + continue eft1 = eft scalefactors = None if self._type == ShieldRimDerivativeMode.SHIELD_RIM_DERIVATIVE_MODE_AROUND: From 9f3ddd141f494a6d09cf8b5fa55f073bd3db7769 Mon Sep 17 00:00:00 2001 From: elias-soltani Date: Tue, 7 Jun 2022 18:35:57 +1200 Subject: [PATCH 4/4] Fix test functions --- .../meshtypes/meshtype_3d_solidsphere2.py | 4 ++-- src/scaffoldmaker/utils/cylindermesh.py | 9 ++++++++- tests/test_cylinder.py | 2 +- tests/test_sphere.py | 12 ++++++------ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py b/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py index f16d9823..682859c9 100644 --- a/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py +++ b/src/scaffoldmaker/meshtypes/meshtype_3d_solidsphere2.py @@ -151,8 +151,8 @@ def generateBaseMesh(region, options): ] rangeOfRequiredElements = [ [cropElements[0][0], elementsCountAcrossAxis1 - cropElements[0][1]], - [cropElements[1][0], elementsCountAcrossAxis1 - cropElements[1][1]], - [cropElements[2][0], elementsCountAcrossAxis1 - cropElements[2][1]], + [cropElements[1][0], elementsCountAcrossAxis2 - cropElements[1][1]], + [cropElements[2][0], elementsCountAcrossAxis3 - cropElements[2][1]], ] sphereBoxDerivatives = [-options['Box derivatives'][0], options['Box derivatives'][1], options['Box derivatives'][2]] # To make the values more intuitive for the user but diff --git a/src/scaffoldmaker/utils/cylindermesh.py b/src/scaffoldmaker/utils/cylindermesh.py index fac13e1b..b960b6f0 100644 --- a/src/scaffoldmaker/utils/cylindermesh.py +++ b/src/scaffoldmaker/utils/cylindermesh.py @@ -179,7 +179,14 @@ def __init__(self, fieldModule, coordinates, elementsCountAlong, base=None, end= self._cylinderType = CylinderType.CYLINDER_TAPERED self._tapered = tapered self._useCrossDerivatives = useCrossDerivatives - self._rangeOfRequiredElements = rangeOfRequiredElements + if rangeOfRequiredElements: + self._rangeOfRequiredElements = rangeOfRequiredElements + else: + self._rangeOfRequiredElements = [ + [0, self._elementsCountAcrossMajor], + [0, self._elementsCountAcrossMinor], + [0, self._elementsCountAlong], + ] self._meshGroups = meshGroups self._meshGroupsElementsAlong = meshGroupsElementsAlong diff --git a/tests/test_cylinder.py b/tests/test_cylinder.py index d32a77d8..01b64fca 100644 --- a/tests/test_cylinder.py +++ b/tests/test_cylinder.py @@ -20,7 +20,7 @@ def test_cylinder1(self): parameterSetNames = scaffold.getParameterSetNames() self.assertEqual(parameterSetNames, ["Default"]) options = scaffold.getDefaultOptions("Default") - self.assertEqual(12, len(options)) + self.assertEqual(14, len(options)) self.assertEqual(4, options.get("Number of elements across major")) self.assertEqual(4, options.get("Number of elements across minor")) self.assertEqual(0, options.get("Number of elements across shell")) diff --git a/tests/test_sphere.py b/tests/test_sphere.py index 7609026f..9881ad63 100644 --- a/tests/test_sphere.py +++ b/tests/test_sphere.py @@ -31,9 +31,9 @@ def test_sphere1(self): self.assertEqual(1.0, options.get("Radius2")) self.assertEqual(1.0, options.get("Radius3")) self.assertEqual(1.0, options.get("Shell element thickness proportion")) - self.assertEqual([0, 4], options.get("Range of elements required in direction 1")) - self.assertEqual([0, 4], options.get("Range of elements required in direction 2")) - self.assertEqual([0, 4], options.get("Range of elements required in direction 3")) + self.assertEqual([0, 0], options.get("Crop number of elements in direction 1")) + self.assertEqual([0, 0], options.get("Crop number of elements in direction 2")) + self.assertEqual([0, 0], options.get("Crop number of elements in direction 3")) self.assertEqual([1, 2, 3], options.get("Box derivatives")) context = Context("Test") @@ -140,9 +140,9 @@ def test_sphere1(self): options['Number of elements across axis 1'] = 4 options['Number of elements across axis 2'] = 6 options['Number of elements across axis 3'] = 8 - options['Range of elements required in direction 1'] = [0, 4] - options['Range of elements required in direction 2'] = [0, 6] - options['Range of elements required in direction 3'] = [0, 8] + options['Crop number of elements in direction 1'] = [0, 0] + options['Crop number of elements in direction 2'] = [0, 0] + options['Crop number of elements in direction 3'] = [0, 0] options['Radius1'] = 0.5 options['Radius2'] = 0.8